/* Gallery + Arcade */
#screen-gallery { flex-direction: column; }
#gal-toolbar {
  display: flex; gap: 8px; padding: 12px 16px;
  background: #10131d; border-bottom: 1px solid var(--line);
}
#gal-search { flex: 1; min-width: 120px; }
#gal-wrap { flex: 1; position: relative; min-height: 0; }
#gal-scroll { position: absolute; inset: 0; overflow-y: auto; padding: 10px 18px 60px; }
#gal-canvas { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.gal-sec h2 {
  font-size: 15px; letter-spacing: 2px; text-transform: uppercase; color: var(--tx1);
  margin: 22px 4px 10px; font-weight: 600;
}
.gal-sec h2 .count { color: var(--tx2); font-weight: 400; font-size: 13px; margin-left: 8px; }
.gal-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.card {
  background: linear-gradient(180deg, #161b29, #11141f);
  border: 1px solid var(--line); border-radius: 14px; padding: 10px;
  cursor: pointer; transition: border-color .15s, transform .15s, box-shadow .15s;
}
.card:hover { border-color: var(--acc); transform: translateY(-2px); box-shadow: 0 10px 24px #0007; }
.card.scrub { border-color: var(--acc); box-shadow: 0 0 0 2px #62b6f066, 0 10px 24px #0007; transform: translateY(-2px); }
.card-view { height: 128px; }
.card-name { font-size: 13px; line-height: 1.25; margin-top: 6px; min-height: 32px; }
.card-sub { font-size: 11.5px; color: var(--tx2); margin-top: 2px; }
.gal-empty { color: var(--tx2); text-align: center; padding: 60px; }

/* Arcade */
#screen-arcade { align-items: center; justify-content: center; overflow-y: auto; }
#ar-home { text-align: center; max-width: 560px; margin: auto; padding: 30px; }
#ar-home h1 { letter-spacing: 3px; margin-bottom: 8px; }
#ar-stats { color: var(--tx1); font-size: 14px; margin-bottom: 26px; min-height: 22px; }
#ar-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ar-mode { padding: 20px 14px; font-size: 15.5px; border-radius: 14px; }
#ar-round { max-width: 720px; margin: auto; padding: 30px; text-align: center; width: 100%; }
#ar-question { font-size: 19px; margin-bottom: 18px; min-height: 30px; }
#ar-visual { min-height: 200px; display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
#ar-visual img { width: 200px; height: 200px; border-radius: 14px; background: #ffffff10; border: 1px solid var(--line); }
#ar-visual img.pick { cursor: pointer; transition: border-color .15s, transform .15s; }
#ar-visual img.pick:hover { border-color: var(--acc); transform: scale(1.04); }
#ar-answers { display: flex; flex-direction: column; gap: 8px; max-width: 460px; margin: 0 auto 16px; }
#ar-answers button { padding: 11px; font-size: 15px; }
#ar-answers button.right { border-color: var(--good); background: #21351f; }
#ar-answers button.wrong { border-color: var(--bad); background: #351f24; }
#ar-feedback { min-height: 54px; font-size: 15px; color: var(--tx1); }
#ar-feedback .big { font-size: 19px; color: var(--tx0); }

/* Tessellation Station */
#screen-tess { display: none; }
#screen-tess.active { display: flex; }
#ts-tools {
  width: 250px; min-width: 250px; padding: 14px; overflow-y: auto;
  background: linear-gradient(180deg, #121624, #0e1119);
  border-right: 1px solid var(--line);
}
#ts-stage { flex: 1; position: relative; min-width: 0; background: radial-gradient(900px 600px at 50% 30%, #141a29, #0b0e14); }
#ts-side { width: 300px; min-width: 300px; overflow-y: auto; padding: 16px; background: #10131d; border-left: 1px solid var(--line); }
#ts-status { font-size: 13.5px; color: var(--tx1); line-height: 1.55; }
#ts-status .good { color: var(--good); }
#ts-status .bad { color: var(--bad); }
#ts-status .dim { color: var(--tx2); }
.ts-shape-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.ts-shape-grid button { padding: 7px 0; font-size: 14px; }
#ts-tools select { width: 100%; margin-top: 6px; }

/* Math Wonders */
#screen-wonders { display: none; overflow-y: auto; }
#screen-wonders.active { display: block; }
#wx-gallery { max-width: 1100px; margin: 0 auto; padding: 28px; }
#wx-gallery h1 { letter-spacing: 3px; }
#wx-gallery h2 { margin: 26px 0 12px; color: var(--tx1); letter-spacing: 2px; text-transform: uppercase; font-size: 14px; }
.wx-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.wx-card {
  background: linear-gradient(180deg, #161b29, #11141f); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px; cursor: pointer; transition: all .15s;
}
.wx-card:hover { border-color: var(--acc); transform: translateY(-2px); }
.wx-card .wx-icon { font-size: 30px; margin-bottom: 6px; }
.wx-card { position: relative; }
/* ---- naV Studios branding ---- */
#nv-ident {
  position: fixed; inset: 0; z-index: 200; background: #070a16;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  opacity: 1; transition: opacity .45s;
}
#nv-ident.nv-out { opacity: 0; pointer-events: none; }
#nv-ident svg { width: min(52vw, 460px); }
#nv-ident .nv-e { stroke-dasharray: 400; stroke-dashoffset: 400; animation: nv-draw .7s ease-out forwards; }
#nv-ident .nv-e1 { animation-delay: .05s; } #nv-ident .nv-e2 { animation-delay: .2s; }
#nv-ident .nv-e3 { animation-delay: .3s; } #nv-ident .nv-e4 { animation-delay: .45s; }
#nv-ident .nv-e5 { animation-delay: .6s; }
#nv-ident .nv-d { opacity: 0; transform-origin: center; transform-box: fill-box; animation: nv-bloom .45s ease-out forwards; }
#nv-ident .nv-d1 { animation-delay: .9s; } #nv-ident .nv-d2 { animation-delay: 1.1s; }
#nv-ident .nv-d3 { animation-delay: 1.3s; } #nv-ident .nv-d4 { animation-delay: 1.5s; }
#nv-ident .nv-word { opacity: 0; animation: nv-fade .5s ease-out 1.65s forwards; }
#nv-ident.nv-short .nv-e { animation-duration: .35s; }
#nv-ident.nv-short .nv-e1 { animation-delay: 0s; } #nv-ident.nv-short .nv-e2 { animation-delay: .06s; }
#nv-ident.nv-short .nv-e3 { animation-delay: .12s; } #nv-ident.nv-short .nv-e4 { animation-delay: .2s; }
#nv-ident.nv-short .nv-e5 { animation-delay: .28s; }
#nv-ident.nv-short .nv-d { animation-duration: .25s; }
#nv-ident.nv-short .nv-d1 { animation-delay: .4s; } #nv-ident.nv-short .nv-d2 { animation-delay: .5s; }
#nv-ident.nv-short .nv-d3 { animation-delay: .6s; } #nv-ident.nv-short .nv-d4 { animation-delay: .7s; }
#nv-ident.nv-short .nv-word { animation-delay: .8s; }
@keyframes nv-draw { to { stroke-dashoffset: 0; } }
@keyframes nv-bloom { 0% { opacity: 0; transform: scale(0.2); } 60% { opacity: 1; transform: scale(1.5); } 100% { opacity: 1; transform: scale(1); } }
@keyframes nv-fade { to { opacity: 1; } }
#nv-byline {
  position: absolute; right: 18px; bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  font-size: 11.5px; letter-spacing: 1px; color: var(--tx2); opacity: .55;
  cursor: pointer; z-index: 5; user-select: none;
}
#nv-byline:hover { opacity: .95; }
#nv-credits {
  position: fixed; inset: 0; z-index: 210; background: #070a16d8;
  display: flex; align-items: center; justify-content: center;
}
#nv-credits-card {
  background: linear-gradient(180deg, #141b33, #0c1122); border: 1px solid var(--line);
  border-radius: 18px; padding: 26px 40px 22px; text-align: center; max-width: min(92vw, 440px);
}
#nv-credits-card svg { width: min(60vw, 300px); }
#nv-credits h2 { letter-spacing: 3px; margin-top: 6px; }
#nv-credits .nv-ver { color: var(--tx2); font-size: 12.5px; margin-top: 2px; }
#nv-credits .nv-line { color: var(--tx1); margin-top: 10px; letter-spacing: 1px; }
#nv-credits .nv-story { color: var(--gold); font-style: italic; margin-top: 6px; }
#nv-credits .nv-hint { font-size: 11.5px; margin-top: 10px; }
#nv-credits #nv-close { margin-top: 14px; }
#nv-credits .nv-tappable { cursor: pointer; pointer-events: all; }
#nv-credits .nv-ping { animation: nv-bloom .4s ease-out; }
#nv-credits .nv-chordglow svg { filter: drop-shadow(0 0 26px #ffd24a88); transition: filter .3s; }

/* ---- the secret of five (5 taps on the ◇ logo) ---- */
#nv-fifth {
  position: fixed; inset: 0; z-index: 210; background: #070a16d8;
  display: flex; align-items: center; justify-content: center;
}
#nv-fifth-card {
  background: linear-gradient(180deg, #141b33, #0c1122); border: 1px solid var(--gold);
  border-radius: 18px; padding: 24px 30px 20px; max-width: min(94vw, 560px);
  max-height: 88vh; overflow-y: auto; box-shadow: 0 0 60px #e8d47722;
}
#nv-fifth-mark svg { width: 84px; display: block; margin: 0 auto 6px; }
#nv-fifth h2 { letter-spacing: 3px; text-align: center; color: var(--gold); }
#nv-fifth-note {
  margin: 12px auto 16px; max-width: 44ch; text-align: center;
  color: var(--tx0); font-style: italic; line-height: 1.65;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 12px 0;
}
#nv-fifth-list { display: flex; flex-direction: column; gap: 9px; }
.nv-five { display: flex; gap: 10px; align-items: center; font-size: 13.5px; color: var(--tx1); }
.nv-five b { color: var(--gold); }
.nv-five-n {
  flex: 0 0 24px; height: 24px; text-align: center; line-height: 22px;
  border: 1px solid var(--gold); border-radius: 50%; color: var(--gold); font-weight: 700;
}
.nv-five-go { flex: 0 0 auto; margin-left: auto; font-size: 12px; white-space: nowrap; }
#nv-fifth-close { display: block; margin: 16px auto 0; }
#splash-presents { font-size: 12px; letter-spacing: 4px; color: var(--tx2); margin-bottom: 10px; text-transform: uppercase; }
#splash-presents b { color: #8fa3d9; }

#ts-del {
  position: absolute; z-index: 30; min-width: 44px; min-height: 44px;
  border-radius: 50%; background: #2a1218ee; border-color: var(--bad); color: #ef9fa8; font-size: 16px;
}
#ts-del.hidden { display: none; }
#ar-backup .ar-backup-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
#ar-backup .ar-backup-row .dim { font-size: 12px; flex-basis: 100%; }
#ar-reset.danger { border-color: #6b2a35; color: #ef9fa8; }
#ar-reset.danger:hover { background: #2a1218; border-color: var(--bad); }

#wx-wings { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.wx-wingtab {
  background: #151a26; color: var(--tx2); border: 1px solid #2a3046; border-radius: 999px;
  padding: 7px 16px; font-size: 13px; cursor: pointer; letter-spacing: 0.3px;
}
.wx-wingtab:hover { color: var(--tx1); border-color: var(--gold); }
.wx-wingtab.on { background: var(--gold); color: #0b0e14; border-color: var(--gold); font-weight: 700; }
.wx-new {
  position: absolute; top: 10px; right: 12px; font-size: 10px; letter-spacing: 1.5px;
  color: #0b0e14; background: var(--gold); border-radius: 6px; padding: 2px 7px; font-weight: 700;
}
.wx-card p { color: var(--tx2); font-size: 13px; margin-top: 6px; }
.wx-head { display: flex; gap: 16px; align-items: center; padding: 14px 22px; border-bottom: 1px solid var(--line); }
#wx-body { position: absolute; top: 62px; bottom: 0; left: 0; right: 0; display: flex; flex-direction: column; padding: 12px 22px 20px; }
#screen-wonders { position: absolute; }
/* flex-shrink:0 is load-bearing: #wx-body is a fixed-height column with NO
   scroll container, so when these controls wrap to two or three 44px rows on an
   iPad the column used to compress them under the opaque canvases — which is
   how the Mandelbrot's Reset became unreachable and the exhibit "bricked" */
.wx-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 8px 0 12px; font-size: 13.5px; color: var(--tx1); flex-shrink: 0; }
.wx-controls label { display: flex; gap: 6px; align-items: center; }
.wx-controls .big-num { font-size: 19px; color: var(--gold); min-width: 84px; }
.wx-canvas { flex: 1; width: 100%; min-height: 0; border-radius: 12px; background: #0d1019; border: 1px solid var(--line); }
.wx-split { flex: 1; display: flex; gap: 12px; min-height: 0; position: relative; }
.wx-canvas.half { flex: 2; height: 100%; min-width: 0; }
.wx-canvas.half.small { flex: 1; }
/* stack when the stage is narrow (iPad portrait, split view) */
@media (max-width: 1120px) {
  .wx-split { flex-direction: column; }
  .wx-canvas.half { height: auto; flex: 2; min-height: 0; }
  .wx-canvas.half.small { flex: 1.2; }
}
#wx-jmark {
  position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border: 2px solid #ffe66d; border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 10px #ffe66daa, inset 0 0 6px #ffe66d55;
}
/* the escape hatch that can never scroll away: a reset pinned to the fractal
   stage itself, tappable at ANY zoom state */
#wx-mreset-overlay {
  position: absolute; top: 10px; left: 10px; z-index: 5;
  min-width: 44px; min-height: 44px; font-size: 18px;
  background: #0b0e14cc; opacity: 0.8;
}
#wx-mreset-overlay:hover { opacity: 1; }
.wx-stage { flex: 1; position: relative; min-height: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.wx-table { border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.wx-table td, .wx-table th { padding: 3px 12px; border-bottom: 1px solid var(--line); text-align: right; }
.wx-table tr.prim td { color: var(--gold); }
.wx-triples { overflow-y: auto; flex: 1; }
#wx-read { color: var(--tx1); }
#wx-read .good, .wx-controls .good { color: var(--good); }

/* trophies */
#ar-trophies { margin-top: 18px; }
.trophy { display: inline-block; width: 34px; height: 34px; line-height: 34px; text-align: center;
  font-size: 19px; background: #161b29; border: 1px solid var(--line); border-radius: 9px; margin: 3px; }
.trophy.locked { color: #2a3046; }
.trophy.won { border-color: var(--gold); box-shadow: 0 0 8px #e8d47733; }

/* Net builder canvas */
#nb-canvas { background: #0d1019; border-top: 1px solid var(--line); cursor: grab; touch-action: none; }
.nb-palette { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 0; }
.nb-palette button { flex: 0 0 auto; width: 44px; height: 38px; font-size: 15px; }
