/* ===== Space Math Academy v2 - Decoupled Lane Studio ===== */
:root{
  --space-0:#05060f;
  --space-1:#0b1027;
  --space-2:#141a3d;
  --space-3:#1d2555;
  --ink:#f2f5ff;
  --ink-dim:#b9c2e8;
  --line:rgba(255,255,255,.14);
  --panel:rgba(20,26,61,.82);
  --panel-solid:#161d47;
  --numbers:#ff8a3d;
  --algebra:#8b5cf6;
  --measurement:#22c9a6;
  --geometry:#ff5d8f;
  --mixed:#ffd23f;
  --good:#3ddc84;
  --bad:#ff7a7a;
  --gold:#ffd23f;
  --r-lg:22px;
  --r-md:16px;
  --shadow:0 10px 30px rgba(0,0,0,.45);
  --font: "Trebuchet MS", "Segoe UI", Verdana, system-ui, sans-serif;
}

*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{height:100%}
body{
  margin:0;font-family:var(--font);color:var(--ink);
  background:radial-gradient(1200px 800px at 20% -10%, #22265e 0%, transparent 60%),
             radial-gradient(900px 700px at 100% 10%, #3a1a5c 0%, transparent 55%),
             linear-gradient(180deg,#070a1c 0%, #05060f 100%);
  background-attachment:fixed;
  font-size:18px;line-height:1.45;overflow-x:hidden;
}
#starfield{position:fixed;inset:0;pointer-events:none;z-index:0;overflow:hidden}
.star{position:absolute;background:#fff;border-radius:50%;opacity:.7;animation:tw 4s ease-in-out infinite}
@keyframes tw{0%,100%{opacity:.25}50%{opacity:.95}}
#app{position:relative;z-index:1;max-width:1120px;margin:0 auto;padding:16px 16px 60px}

h1,h2,h3{margin:0 0 .4em;line-height:1.15}
h1{font-size:2.1rem;letter-spacing:.5px}
h2{font-size:1.5rem}
p{margin:.3em 0 .7em}
button{font-family:inherit}

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:.5em;
  min-height:56px;padding:12px 22px;border-radius:var(--r-md);
  border:2px solid rgba(255,255,255,.18);
  background:linear-gradient(180deg,#2a3273,#1b2150);
  color:var(--ink);font-size:1.05rem;font-weight:700;cursor:pointer;
  box-shadow:0 4px 0 rgba(0,0,0,.35), var(--shadow);
  transition:transform .08s ease, filter .15s ease;
}
.btn:hover{filter:brightness(1.12)}
.btn:active{transform:translateY(3px);box-shadow:0 1px 0 rgba(0,0,0,.35)}
.btn:focus-visible{outline:3px solid var(--gold);outline-offset:3px}
.btn.primary{background:linear-gradient(180deg,#3ddc84,#1fa25e);color:#052014;border-color:rgba(255,255,255,.35)}
.btn.gold{background:linear-gradient(180deg,#ffd85c,#e5a51b);color:#2b1c00}
.btn.ghost{background:rgba(255,255,255,.07)}
.btn.danger{background:linear-gradient(180deg,#ff7a7a,#c93b3b);color:#2a0505}
.btn.small{min-height:42px;padding:8px 14px;font-size:.92rem;border-radius:12px}
.btn.big{min-height:70px;font-size:1.25rem;padding:14px 30px}
.btn[disabled]{opacity:.45;cursor:not-allowed;transform:none}
.btn-row{display:flex;gap:12px;flex-wrap:wrap;align-items:center}

/* ---------- Panels ---------- */
.panel{
  background:var(--panel);border:2px solid var(--line);border-radius:var(--r-lg);
  padding:18px 20px;box-shadow:var(--shadow);backdrop-filter:blur(6px);margin-bottom:18px;
}
.panel.tight{padding:14px}
.card-grid{display:grid;gap:14px;grid-template-columns:repeat(auto-fill,minmax(220px,1fr))}
.muted{color:var(--ink-dim)}
.center{text-align:center}
.pill{display:inline-block;padding:4px 12px;border-radius:999px;background:rgba(255,255,255,.12);font-size:.85rem;font-weight:700}

/* ---------- Top bar ---------- */
.topbar{
  display:flex;align-items:center;gap:12px;flex-wrap:wrap;
  background:var(--panel);border:2px solid var(--line);border-radius:var(--r-lg);
  padding:10px 14px;margin-bottom:16px;box-shadow:var(--shadow);
}
.topbar .grow{flex:1 1 auto}
.hud{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
.hud .chip{display:inline-flex;align-items:center;gap:6px;background:rgba(255,255,255,.1);
  padding:6px 12px;border-radius:999px;font-weight:800;font-size:.95rem;white-space:nowrap}
.chip .lbl{font-weight:600;color:var(--ink-dim);font-size:.8rem}
.avatar-badge{width:46px;height:46px;border-radius:50%;display:grid;place-items:center;font-size:26px;
  background:rgba(255,255,255,.12);border:2px solid var(--line)}

/* ---------- Galaxy map ---------- */
.galaxy{display:grid;gap:18px;grid-template-columns:repeat(auto-fit,minmax(240px,1fr))}
.planet-card{
  position:relative;border-radius:26px;padding:18px;cursor:pointer;text-align:center;
  border:3px solid var(--line);background:rgba(10,14,38,.7);
  transition:transform .15s ease, box-shadow .2s ease;overflow:hidden;
  color:var(--ink);font-family:inherit;
}
.planet-card:hover{transform:translateY(-4px)}
.planet-card:focus-visible{outline:3px solid var(--gold);outline-offset:3px}
.planet-card .glow{position:absolute;left:-10%;right:-10%;top:-40%;height:220px;filter:blur(45px);opacity:.35;border-radius:50%}
.planet-card h3{position:relative;font-size:1.25rem;margin-top:8px}
.planet-svg{width:150px;height:150px;display:block;margin:0 auto;position:relative}
.progressbar{height:14px;border-radius:999px;background:rgba(255,255,255,.14);overflow:hidden;margin-top:8px;position:relative}
.progressbar > div{height:100%;border-radius:999px;transition:width .5s ease}
.planet-card .sub{font-size:.9rem;color:var(--ink-dim);margin-top:6px;position:relative}

/* ---------- Level select ---------- */
.level-grid{display:grid;gap:14px;grid-template-columns:repeat(auto-fill,minmax(150px,1fr))}
.level-btn{
  position:relative;border-radius:18px;border:3px solid var(--line);padding:14px 10px;
  background:rgba(255,255,255,.06);cursor:pointer;color:var(--ink);text-align:center;min-height:120px;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;font-family:inherit;
}
.level-btn .num{font-size:1.6rem;font-weight:900}
.level-btn .nm{font-size:.85rem;line-height:1.2;color:var(--ink-dim)}
.level-btn.locked{opacity:.5;cursor:not-allowed}
.level-btn.done{background:rgba(61,220,132,.16);border-color:rgba(61,220,132,.6)}
.level-btn.boss{background:linear-gradient(180deg,rgba(255,93,143,.25),rgba(255,93,143,.08));border-color:rgba(255,93,143,.7)}
.level-btn .stars{font-size:.9rem;letter-spacing:2px;color:var(--gold)}
.level-btn:hover:not(.locked){transform:translateY(-3px)}

/* ---------- Question card ---------- */
.qwrap{max-width:860px;margin:0 auto}
.qprogress{display:flex;gap:6px;margin-bottom:12px;flex-wrap:wrap}
.qdot{width:26px;height:10px;border-radius:999px;background:rgba(255,255,255,.18)}
.qdot.ok{background:var(--good)}
.qdot.no{background:var(--bad)}
.qdot.cur{background:var(--gold)}
.qtext{font-size:1.45rem;font-weight:700;margin:6px 0 16px;line-height:1.35}
.qtext .big-eq{font-family:"Consolas","Courier New",monospace;font-size:1.9rem;letter-spacing:1px;display:inline-block}
.qstory{color:var(--ink-dim);font-size:1rem;font-style:italic;margin-bottom:6px}
.choices{display:grid;gap:12px;grid-template-columns:repeat(auto-fit,minmax(160px,1fr))}
.choice{
  min-height:66px;border-radius:16px;border:3px solid var(--line);background:rgba(255,255,255,.07);
  color:var(--ink);font-size:1.25rem;font-weight:800;cursor:pointer;padding:10px 14px;font-family:inherit;
  display:flex;align-items:center;justify-content:center;gap:8px;transition:transform .08s,background .15s
}
.choice:hover{background:rgba(255,255,255,.15)}
.choice:active{transform:translateY(2px)}
.choice.sel{border-color:var(--gold);background:rgba(255,210,63,.2)}
.choice.correct{border-color:var(--good);background:rgba(61,220,132,.28)}
.choice.wrong{border-color:var(--bad);background:rgba(255,122,122,.25)}
.choice[disabled]{cursor:default}
.answer-input{
  font-size:2rem;font-weight:800;text-align:center;width:220px;max-width:100%;padding:12px;border-radius:16px;
  border:3px solid var(--line);background:rgba(0,0,0,.35);color:var(--ink);font-family:inherit;
}
.answer-input:focus{outline:none;border-color:var(--gold)}
.answer-input.correct{border-color:var(--good)}
.answer-input.wrong{border-color:var(--bad)}
.unit-label{font-size:1.2rem;font-weight:700;margin-left:8px;color:var(--ink-dim)}

/* ---------- Feedback ---------- */
.feedback{margin-top:16px;border-radius:18px;padding:16px 18px;border:3px solid var(--line);background:rgba(255,255,255,.06)}
.feedback.good{border-color:rgba(61,220,132,.7);background:rgba(61,220,132,.12)}
.feedback.bad{border-color:rgba(255,180,80,.7);background:rgba(255,180,80,.1)}
.feedback h3{margin:0 0 6px;font-size:1.2rem}
.steps{margin:8px 0 0;padding-left:0;list-style:none;counter-reset:s}
.steps li{counter-increment:s;position:relative;padding:8px 0 8px 44px;border-top:1px solid rgba(255,255,255,.1)}
.steps li:first-child{border-top:none}
.steps li::before{
  content:counter(s);position:absolute;left:0;top:7px;width:30px;height:30px;border-radius:50%;
  background:rgba(255,255,255,.16);display:grid;place-items:center;font-weight:900;font-size:.95rem
}
.streak-badge{
  display:inline-block;background:linear-gradient(180deg,#ffd85c,#e5a51b);color:#2b1c00;
  padding:6px 16px;border-radius:999px;font-weight:900;margin-top:10px;animation:pop .4s ease
}
@keyframes pop{0%{transform:scale(.4);opacity:0}70%{transform:scale(1.12)}100%{transform:scale(1);opacity:1}}
.mentor{display:flex;gap:14px;align-items:flex-start}
.mentor .face{font-size:44px;line-height:1;flex:0 0 auto}

/* ---------- Toasts / achievements ---------- */
#toast-root{position:fixed;right:14px;bottom:14px;z-index:60;display:flex;flex-direction:column;gap:10px;align-items:flex-end}
.toast{
  display:flex;gap:12px;align-items:center;min-width:270px;max-width:360px;
  background:linear-gradient(180deg,#2b3480,#151a45);border:3px solid var(--gold);
  border-radius:18px;padding:12px 16px;box-shadow:var(--shadow);animation:slidein .35s ease
}
.toast .ic{font-size:34px}
.toast .t{font-weight:900;color:var(--gold)}
.toast .d{font-size:.88rem;color:var(--ink-dim)}
@keyframes slidein{from{transform:translateX(40px);opacity:0}to{transform:none;opacity:1}}

/* ---------- Overlays ---------- */
.overlay{position:fixed;inset:0;background:rgba(3,5,16,.8);z-index:50;display:grid;place-items:center;padding:16px;backdrop-filter:blur(3px)}
.modal{background:var(--panel-solid);border:3px solid var(--line);border-radius:var(--r-lg);padding:22px;max-width:660px;width:100%;max-height:92vh;overflow:auto;box-shadow:var(--shadow)}
.modal h2{margin-top:0}

/* ---------- Scratchpad ---------- */
.scratch-panel{
  position:fixed;right:12px;bottom:12px;width:min(520px,94vw);background:var(--panel-solid);
  border:3px solid var(--line);border-radius:var(--r-lg);padding:10px;box-shadow:var(--shadow);z-index:41
}
.scratch-panel canvas{width:100%;height:300px;background:#fdfdf5;border-radius:12px;touch-action:none;display:block;cursor:crosshair}
.scratch-tools{display:flex;gap:8px;align-items:center;margin-top:8px;flex-wrap:wrap}
.swatch{width:34px;height:34px;border-radius:50%;border:3px solid rgba(255,255,255,.4);cursor:pointer}
.swatch.on{border-color:var(--gold);transform:scale(1.1)}

/* ---------- Shop / collections ---------- */
.shop-grid{display:grid;gap:12px;grid-template-columns:repeat(auto-fill,minmax(140px,1fr))}
.shop-item{border:3px solid var(--line);border-radius:18px;padding:12px;text-align:center;background:rgba(255,255,255,.06);cursor:pointer;color:var(--ink);font-family:inherit}
.shop-item.owned{border-color:rgba(61,220,132,.6)}
.shop-item.equipped{border-color:var(--gold);background:rgba(255,210,63,.16)}
.shop-item.cant{opacity:.55}
/* A prize, not a purchase: visibly locked, and it says how to earn it. */
.shop-item.prize{border-color:rgba(139,92,246,.55);background:rgba(139,92,246,.1)}
.shop-item.prize .pr{color:#b79bff}
.shop-item .how{font-size:.72rem;color:var(--ink-dim);line-height:1.25;margin-top:4px}
.shop-item .em{font-size:34px;display:block}
.shop-item .nm{font-weight:800;font-size:.92rem;margin-top:4px}
.shop-item .pr{font-size:.85rem;color:var(--gold);font-weight:800}
.sticker{border:3px solid var(--line);border-radius:16px;padding:10px;text-align:center;background:rgba(255,255,255,.05)}
.sticker.locked{opacity:.35}
.sticker .em{font-size:38px}
.sticker .nm{font-size:.78rem;color:var(--ink-dim)}
.ach{display:flex;gap:12px;align-items:center;border:3px solid var(--line);border-radius:16px;padding:12px;background:rgba(255,255,255,.05)}
.ach.locked{opacity:.45}
.ach.got{border-color:rgba(255,210,63,.6);background:rgba(255,210,63,.1)}
.ach .ic{font-size:32px}
.ach .t{font-weight:900}
.ach .d{font-size:.85rem;color:var(--ink-dim)}

/* ---------- Tables / parent view ---------- */
table.data{width:100%;border-collapse:collapse;margin:10px 0}
table.data th,table.data td{padding:8px 10px;border-bottom:1px solid var(--line);text-align:left;font-size:.95rem}
table.data th{color:var(--ink-dim);font-size:.85rem;text-transform:uppercase;letter-spacing:.5px}
.bar-row{display:flex;align-items:center;gap:10px;margin:8px 0}
.bar-row .nm{width:160px;font-weight:700;font-size:.95rem}
.bar-row .track{flex:1;height:20px;background:rgba(255,255,255,.12);border-radius:999px;overflow:hidden}
.bar-row .fill{height:100%;border-radius:999px}
.bar-row .val{width:86px;text-align:right;font-weight:800;font-size:.9rem}
.pin-input{font-size:2rem;letter-spacing:14px;text-align:center;width:200px;padding:10px;border-radius:14px;border:3px solid var(--line);background:rgba(0,0,0,.35);color:var(--ink);font-family:inherit}

/* ---------- Manipulatives ---------- */
.manip{margin:10px 0;display:flex;flex-direction:column;align-items:center;gap:8px}
.manip svg{max-width:100%;height:auto;touch-action:none;user-select:none}
/* Question diagrams are authored at a fixed width with a viewBox, so they
   scale cleanly. Without this they overflow on a narrow screen and .svgwrap
   scrolls sideways instead - which on a tablet means she cannot see the whole
   picture at once. */
.svgwrap svg{max-width:100%;height:auto}
.hint{font-size:.9rem;color:var(--ink-dim);text-align:center}
.tool-toggle{display:flex;gap:8px;justify-content:center;flex-wrap:wrap;margin:6px 0}
.svgwrap{background:rgba(255,255,255,.05);border-radius:18px;padding:10px;border:2px solid var(--line);max-width:100%;overflow-x:auto}

/* ---------- Base station ---------- */
.module-list{display:grid;gap:10px;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));margin-top:12px}
.module{border:2px dashed var(--line);border-radius:14px;padding:10px;text-align:center;font-size:.9rem}
.module.on{border-style:solid;border-color:rgba(61,220,132,.6);background:rgba(61,220,132,.1)}

/* ---------- Misc ---------- */
.kbd{display:inline-block;background:rgba(255,255,255,.14);border-radius:6px;padding:1px 7px;font-size:.85em;font-weight:700}
.flex{display:flex;gap:12px;flex-wrap:wrap;align-items:center}
.spread{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap}
.grow{flex:1 1 auto}
.hide{display:none !important}
.result-big{font-size:3.4rem;font-weight:900;line-height:1}
.emoji-pick{display:grid;grid-template-columns:repeat(auto-fill,minmax(56px,1fr));gap:8px}
.emoji-pick button{font-size:28px;min-height:56px;border-radius:14px;border:3px solid var(--line);background:rgba(255,255,255,.07);cursor:pointer}
.emoji-pick button.on{border-color:var(--gold);background:rgba(255,210,63,.2)}
.numpad{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;max-width:280px;margin:12px auto 0}
.numpad button{min-height:54px;font-size:1.3rem;font-weight:800;border-radius:14px;border:2px solid var(--line);background:rgba(255,255,255,.08);color:var(--ink);cursor:pointer;font-family:inherit}
@media (max-width:640px){
  body{font-size:17px}
  h1{font-size:1.6rem}
  #app{padding:10px 10px 70px}
  .qtext{font-size:1.25rem}
  .answer-input{width:180px;font-size:1.7rem}
  .bar-row .nm{width:110px;font-size:.85rem}
}

/* ============================================================
   v02 additions
   ============================================================ */

/* ---------- studio splash ---------- */
.splash{
  position:fixed;inset:0;z-index:200;display:grid;place-items:center;
  background:radial-gradient(900px 700px at 50% 40%, #141a3d 0%, #05060f 70%);
  animation:splashIn .5s ease;cursor:pointer;
}
.splash-out{opacity:0;transition:opacity .4s ease}
@keyframes splashIn{from{opacity:0}to{opacity:1}}
.splash-inner{text-align:center;padding:20px;max-width:min(520px,88vw)}
.splash-pre{color:var(--ink-dim);letter-spacing:3px;text-transform:uppercase;font-size:.78rem;margin-bottom:18px}
.splash-logo img{width:min(420px,80vw);height:auto;margin:0 auto}
.splash-title{margin-top:20px;font-size:1.5rem;font-weight:900;letter-spacing:.5px}
.splash-skip{margin-top:22px;color:var(--ink-dim);font-size:.78rem;opacity:.75}

/* ---------- studio marks ---------- */
.dls-img{display:block;max-width:100%}
.dls-textmark{
  display:inline-grid;place-items:center;width:1.9em;height:1.9em;border-radius:7px;
  background:linear-gradient(180deg,#2a3273,#151a45);border:1px solid var(--line);
  font-weight:900;font-size:.72em;letter-spacing:.5px;color:var(--ink-dim)
}
.dls-footer{
  display:flex;align-items:center;justify-content:center;gap:10px;flex-wrap:wrap;
  padding:16px 10px 6px;color:var(--ink-dim);font-size:.82rem
}
.dls-footer-icon img{width:22px;height:22px;border-radius:6px}
.dls-footer-link{
  background:none;border:none;color:var(--ink-dim);text-decoration:underline;
  cursor:pointer;font:inherit;padding:4px 6px;min-height:32px
}
.dls-footer-link:hover{color:var(--ink)}

/* ---------- credits ---------- */
.credits{max-width:760px;margin:0 auto}
.credits-hero{border-radius:18px;overflow:hidden;border:2px solid var(--line);line-height:0}
.credits-thumb img{width:100%;height:auto}
.credits-logo{display:inline-block;max-width:100%}
.credits-logo img{height:auto}
.credits-contact{margin-top:4px;font-size:.9rem;overflow-wrap:anywhere}
.credits-blurb{max-width:560px;margin:14px auto;color:var(--ink-dim);font-size:1.02rem}
.credits-divider{height:1px;background:var(--line);margin:22px 0}
.credits-dev{font-weight:900;font-size:1.1rem;margin-top:12px}
.credits-facts{display:grid;gap:8px;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));margin-top:18px;text-align:left}
.credits-fact{background:rgba(255,255,255,.05);border:1px solid var(--line);border-radius:12px;padding:10px 12px}
.credits-fact-k{font-size:.74rem;text-transform:uppercase;letter-spacing:.6px;color:var(--ink-dim)}
.credits-fact-v{font-weight:800;font-size:.95rem;margin-top:2px}

/* ---------- grade badges ---------- */
.grade-badge{
  position:relative;display:inline-block;margin-top:8px;padding:4px 14px;border-radius:999px;
  border:2px solid var(--line);font-weight:900;font-size:.9rem
}
.grade-strip{font-family:"Consolas","Courier New",monospace;letter-spacing:.5px;margin-top:6px;font-size:.82rem}
.planet-card.locked{opacity:.5;cursor:not-allowed}
/* A galaxy she has already finished in this track: still playable for revision,
   but visibly not where she is supposed to be. */
.planet-card.revisit{opacity:.78;border-style:dashed}
.planet-card.revisit .grade-badge{filter:saturate(.5)}
.planet-card.locked:hover{transform:none}
.planet-card.wormhole{border-color:rgba(255,210,63,.6)}
.galaxy-dark{background:rgba(8,10,26,.9);border-color:rgba(140,160,255,.25)}

/* ---------- Overdrive ---------- */
.pill.overdrive{
  background:linear-gradient(180deg,#ffd85c,#ff8a3d);color:#2b1c00;font-weight:900;
  box-shadow:0 0 14px rgba(255,160,60,.5);animation:odPulse 1.4s ease-in-out infinite
}
@keyframes odPulse{0%,100%{box-shadow:0 0 10px rgba(255,160,60,.4)}50%{box-shadow:0 0 22px rgba(255,160,60,.85)}}

/* ---------- math keypad ---------- */
.kp-wrap{margin-top:6px}
.kp-field{display:flex;align-items:center;justify-content:center;gap:4px;flex-wrap:wrap}
.numpad{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;max-width:300px;margin:12px auto 0}
.numpad.wide{grid-template-columns:repeat(4,1fr);max-width:400px}
.kp-key{
  min-height:52px;font-size:1.25rem;font-weight:800;border-radius:14px;
  border:2px solid var(--line);background:rgba(255,255,255,.08);color:var(--ink);
  cursor:pointer;font-family:inherit;touch-action:manipulation
}
.kp-key:active{transform:translateY(2px);background:rgba(255,255,255,.16)}
.kp-key[disabled]{opacity:.4}

/* ---------- gate test ---------- */
.gate-card{border-color:rgba(140,160,255,.35)}
.gate-card.gate-ready{border-color:rgba(255,210,63,.7);background:rgba(255,210,63,.08)}
.gate-card.gate-passed{border-color:rgba(61,220,132,.6);background:rgba(61,220,132,.08)}
.panel.gate-ready{border-color:rgba(255,210,63,.7);background:rgba(255,210,63,.1);text-align:center}

/* ---------- collapsible detail blocks ---------- */
.miss-item,.std-group{
  border-top:1px solid var(--line);padding:10px 0
}
.miss-item summary,.std-group summary{
  cursor:pointer;font-weight:700;padding:4px 0;min-height:34px;list-style:none
}
.miss-item summary::-webkit-details-marker,.std-group summary::-webkit-details-marker{display:none}
.miss-item summary::before,.std-group summary::before{content:'\25B8 ';color:var(--gold)}
.miss-item[open] summary::before,.std-group[open] summary::before{content:'\25BE '}

/* ---------- misc v2 ---------- */
.hc-badge{font-size:.68rem;font-weight:900;color:#ffb3b3;margin-top:4px}
.reward-pop{
  background:rgba(255,210,63,.12);border-color:rgba(255,210,63,.6);text-align:center;
  animation:pop .45s ease
}
.panel.alert{border-color:rgba(255,180,80,.6);background:rgba(255,180,80,.08)}
.celebrate{animation:celebrate .6s ease}
@keyframes celebrate{0%{transform:scale(.94)}60%{transform:scale(1.03)}100%{transform:scale(1)}}
.streak-day{
  width:38px;height:46px;border-radius:10px;display:grid;place-items:center;
  background:rgba(255,255,255,.06);border:2px solid var(--line);
  font-size:.72rem;font-weight:800;text-align:center;line-height:1.1
}
.streak-day.on{background:rgba(255,210,63,.28);border-color:rgba(255,210,63,.7)}
.cert-card{
  border:3px solid var(--line);border-radius:18px;padding:14px;text-align:center;
  background:rgba(255,255,255,.06);cursor:pointer;color:var(--ink);font-family:inherit
}
.cert-card:hover{border-color:var(--gold)}
input[type=range]{min-height:34px}
/* A checkbox is a real tap target, so give it a real size and make the whole
   label row tappable - 22px was fine with a mouse and fiddly with a finger. */
label.flex{min-height:44px;align-items:center;cursor:pointer}
label.flex input[type=checkbox]{width:28px;height:28px;flex:0 0 auto;accent-color:#ffd23f}

/* ---------- printable certificate ---------- */
.certificate{
  background:#fffdf7;color:#1a1a2e;border-radius:10px;padding:14px;
  max-width:900px;margin:0 auto 18px;box-shadow:var(--shadow)
}
.cert-border{
  border:6px double #b89333;border-radius:6px;padding:34px 30px;
  background:
    radial-gradient(520px 260px at 50% 0%, rgba(184,147,51,.09), transparent 70%),
    #fffdf7;
  text-align:center
}
.cert-kicker{letter-spacing:6px;font-size:.72rem;font-weight:700;color:#8a6d2b;text-transform:uppercase}
.cert-title{font-size:2.3rem;margin:8px 0 0;color:#1a1a2e;font-weight:900;letter-spacing:.5px}
.cert-body{margin:26px 0}
.cert-label{font-size:.78rem;letter-spacing:2px;text-transform:uppercase;color:#6b6b80;margin-top:16px}
.cert-name{
  font-size:2.5rem;font-weight:900;color:#0b1027;margin:6px 0 2px;
  border-bottom:2px solid #b89333;display:inline-block;padding:0 26px 6px
}
.cert-subject{font-size:1.5rem;font-weight:800;margin-top:6px;color:#1a1a2e}
.cert-sub{color:#6b6b80;font-size:.92rem;margin-top:4px}
.cert-score{margin-top:20px;font-size:1.05rem;color:#1a1a2e}
.cert-dot{margin:0 10px;color:#b89333}
.cert-foot{display:flex;justify-content:space-between;align-items:flex-end;gap:20px;margin-top:30px}
.cert-sig{text-align:left;min-width:190px}
.cert-sig-line{border-bottom:1.5px solid #1a1a2e;height:26px}
.cert-sig-label{font-size:.74rem;color:#6b6b80;margin-top:4px}
.cert-dls{display:flex;align-items:center;gap:8px}
.cert-logo img{width:46px;height:46px;border-radius:8px}
.cert-dls-text{font-size:.8rem;font-weight:700;color:#6b6b80}

@media print{
  @page{size:letter;margin:0.5in}
  body{background:#fff !important;color:#000}
  #starfield,#toast-root,#overlay-root,#splash-root,.no-print,.topbar,.dls-footer{display:none !important}
  #app{padding:0;max-width:none}
  .certificate{box-shadow:none;margin:0;padding:0;border-radius:0}
  .cert-border{border-color:#8a6d2b}
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{animation-duration:.001s !important;animation-iteration-count:1 !important;transition-duration:.001s !important}
  .star{animation:none;opacity:.6}
}

/* ---------- iPad / small screens ---------- */
@media (max-width:900px){
  .cert-title{font-size:1.9rem}
  .cert-name{font-size:2rem}
  .cert-border{padding:24px 18px}
}
@media (max-width:640px){
  .numpad{max-width:260px}
  .numpad.wide{grid-template-columns:repeat(3,1fr);max-width:260px}
  .credits-facts{grid-template-columns:1fr}
  .cert-foot{flex-direction:column;align-items:stretch}
}

/* ---------- placement / Starship Assessment ---------- */
.assess-facts{list-style:none;padding:0;margin:14px 0 0}
.assess-facts li{padding:5px 0;color:var(--ink-dim);font-size:.95rem}
.placement-card{
  border:3px solid var(--line);border-radius:18px;padding:14px 18px;min-width:140px;
  background:rgba(255,255,255,.05)
}
.placement-grade{font-size:1.5rem;font-weight:900;margin-top:4px}
.panel.nudge{border-color:rgba(140,160,255,.45);background:rgba(140,160,255,.08)}

/* ============================================================
   Phase 5: risk HUD, wagers, Hardcore
   ============================================================ */
.riskbar{
  display:flex;gap:14px;align-items:center;flex-wrap:wrap;justify-content:space-between;
  background:var(--panel);border:2px solid var(--line);border-radius:var(--r-md);
  padding:8px 14px;margin-bottom:12px
}
.riskbar.hardcore{border-color:rgba(255,93,143,.6);background:rgba(60,10,25,.7)}

/* ---- shields ---- */
.shields{display:flex;align-items:center;gap:6px}
.shields-label{font-size:.72rem;text-transform:uppercase;letter-spacing:1px;color:var(--ink-dim);margin-right:4px}
.shield{font-size:22px;transition:transform .2s, filter .2s}
.shield.gone{filter:grayscale(1) brightness(.6);transform:scale(.85)}
.shield-hit{
  display:flex;align-items:center;gap:10px;margin:10px 0;padding:10px 14px;
  border-radius:14px;background:rgba(255,93,143,.16);border:2px solid rgba(255,93,143,.5);
  font-weight:800;animation:shake .4s ease
}
.shield-hit-icon{font-size:24px}
@keyframes shake{
  0%,100%{transform:translateX(0)}
  20%{transform:translateX(-7px)}40%{transform:translateX(7px)}
  60%{transform:translateX(-4px)}80%{transform:translateX(4px)}
}

/* ---- combo meter ---- */
.combo{display:flex;align-items:center;gap:8px;min-width:190px}
.combo-mult{font-weight:900;font-size:1.2rem;min-width:34px;text-align:right}
.combo-track{flex:1;height:10px;border-radius:999px;background:rgba(255,255,255,.14);overflow:hidden}
.combo-fill{height:100%;border-radius:999px;transition:width .3s ease}
.combo-label{font-size:.72rem;font-weight:900;letter-spacing:.5px;white-space:nowrap}
.combo.live .combo-mult{animation:comboPulse 1s ease-in-out infinite}
@keyframes comboPulse{0%,100%{transform:scale(1)}50%{transform:scale(1.15)}}
.combo-pop{
  font-weight:900;font-size:1.3rem;letter-spacing:1px;margin-top:8px;
  animation:pop .45s ease
}

/* ---- boss health ---- */
.bosshp{display:flex;align-items:center;gap:8px;min-width:230px}
.boss-name{font-weight:900;font-size:.85rem;white-space:nowrap}
.boss-track{flex:1;height:16px;border-radius:999px;background:rgba(255,255,255,.12);
  overflow:hidden;border:1px solid rgba(255,93,143,.4)}
.boss-fill{height:100%;border-radius:999px;
  background:linear-gradient(90deg,#ff5d8f,#ff8a3d);transition:width .45s ease}
.boss-num{font-size:.74rem;color:var(--ink-dim);min-width:62px;text-align:right}
.boss-hit{
  margin-top:10px;padding:8px 12px;border-radius:12px;font-weight:800;
  background:rgba(255,138,61,.18);border:2px solid rgba(255,138,61,.5);animation:pop .35s ease
}

/* ---- wager ---- */
.wager-card{border-color:rgba(255,93,143,.5)}
.wager-readout{margin-top:14px}
.wager-amount{font-size:2rem;font-weight:900;color:var(--gold)}
.wager-opt{min-width:110px}

/* ---- Hardcore ---- */
.hardcore-btn{
  background:linear-gradient(180deg,#5a1026,#2a0610);border-color:rgba(255,93,143,.6);
  color:#ffd0dc
}
.hardcore-btn:hover{filter:brightness(1.3)}
.pill.hardcore-pill{background:rgba(255,93,143,.3);color:#ffd0dc;font-weight:900}
.hardcore-badge-card{background:rgba(90,16,38,.5) !important;border-color:rgba(255,93,143,.7) !important}

/* ============================================================
   PHASE 5 (part 2): Gauntlet ladder, Lightning Round,
   Cadet vs. Commander, Trick Shot Lab.

   Every tappable thing here is at least 44px on its shortest side, and
   nothing depends on hover - iPad Safari in both orientations is the
   target, so hover is a bonus and never a requirement.
   ============================================================ */

.huge { font-size: 2.6rem; font-weight: 900; line-height: 1.1; }

/* ---------------- Gauntlet ---------------- */
.gauntlet-hero {
  text-align: center;
  padding: 18px 14px 20px;
  border-radius: var(--r);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 210, 63, .22), transparent 62%),
    linear-gradient(180deg, rgba(139, 92, 246, .22), rgba(10, 14, 36, .5));
  border: 1px solid rgba(255, 210, 63, .3);
}
.gauntlet-title {
  font-size: clamp(1.6rem, 6vw, 2.6rem);
  font-weight: 900;
  letter-spacing: .04em;
  background: linear-gradient(90deg, #ffd23f, #ff8a3d, #ffd23f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
}
/* Fallback for engines that will not do gradient text. */
@supports not (background-clip: text) {
  .gauntlet-title { color: #ffd23f; -webkit-text-fill-color: #ffd23f; }
}

/* the full ladder, bottom rung first visually */
.ladder {
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  margin-top: 10px;
}
.rung {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 6px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .09);
}
.rung.reached {
  background: rgba(61, 220, 132, .14);
  border-color: rgba(61, 220, 132, .4);
}
.rung.current {
  background: rgba(255, 210, 63, .2);
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(255, 210, 63, .25);
}
.rung.checkpoint { border-left: 5px solid #4da3ff; }
.rung-n {
  flex: 0 0 34px;
  text-align: center;
  font-weight: 900;
  font-size: 1.05rem;
  color: var(--gold);
}
.rung-coins { flex: 1; font-weight: 800; }
.rung-d { font-size: .78rem; opacity: .75; }
.rung-cp {
  font-size: .72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(77, 163, 255, .28);
  white-space: nowrap;
}
.rung-extra { font-size: .9rem; white-space: nowrap; }

/* compact ladder shown beside a live run */
.ladder-strip {
  display: flex;
  flex-direction: column-reverse;
  gap: 3px;
  flex: 0 0 92px;
}
.strip-rung {
  min-height: 18px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .06);
  font-size: .68rem;
  text-align: center;
  line-height: 18px;
  color: #b9c2e8;
}
.strip-rung.reached { background: rgba(61, 220, 132, .3); color: #eafff2; }
.strip-rung.current {
  background: var(--gold);
  color: #141414;
  font-weight: 900;
  box-shadow: 0 0 10px rgba(255, 210, 63, .6);
}
.strip-rung.cp { outline: 1px solid rgba(77, 163, 255, .7); }

/* the money she is playing for, front and centre */
.money-stack {
  text-align: center;
  padding: 10px 14px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 210, 63, .2), rgba(255, 138, 61, .1));
  border: 1px solid rgba(255, 210, 63, .36);
}
.money-amount {
  font-size: clamp(1.5rem, 5.5vw, 2.4rem);
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .35);
}
.gauntlet-rung-pill {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  font-weight: 900;
  background: rgba(139, 92, 246, .3);
  border: 1px solid rgba(139, 92, 246, .55);
}

/* ---------------- Lightning Round ---------------- */
.lightning-timer {
  position: relative;
  height: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .09);
  overflow: hidden;
}
.lightning-bar {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3ddc84, #ffd23f 55%, #ff5d8f);
  /* width is set inline each tick; the transition keeps it from stuttering */
  transition: width .25s linear;
}
.lightning-bar.low { background: linear-gradient(90deg, #ff8a3d, #ff5d8f); }
.lightning-score { display: flex; gap: 16px; align-items: baseline; justify-content: center; }
.lightning-num {
  font-size: clamp(2.2rem, 9vw, 3.4rem);
  font-weight: 900;
  color: var(--gold);
  min-width: 2.2em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.lightning-card {
  text-align: center;
  padding: 18px 14px;
  border-radius: var(--r);
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .1);
  transition: background .12s ease;
}
.lightning-card.flash-good { background: rgba(61, 220, 132, .25); border-color: #3ddc84; }
.lightning-card.flash-bad { background: rgba(255, 93, 143, .22); border-color: #ff5d8f; }
.lightning-answer {
  font-size: clamp(1.6rem, 7vw, 2.4rem);
  font-weight: 900;
  letter-spacing: .02em;
}
.flash-good { animation: flashGood .3s ease; }
.flash-bad { animation: flashBad .3s ease; }
@keyframes flashGood { 0% { background: rgba(61, 220, 132, .45); } 100% { background: transparent; } }
@keyframes flashBad { 0% { background: rgba(255, 93, 143, .4); } 100% { background: transparent; } }

/* family leaderboard */
.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .04);
}
.lb-row.me { background: rgba(255, 210, 63, .18); border: 1px solid rgba(255, 210, 63, .4); }
.lb-rank {
  flex: 0 0 30px;
  text-align: center;
  font-weight: 900;
  color: var(--gold);
}
.lb-name { flex: 1; font-weight: 700; }
.lb-score { font-weight: 900; font-variant-numeric: tabular-nums; }

/* ---------------- Cadet vs. Commander ---------------- */
.scoreboard {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 10px;
  border-radius: var(--r);
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .09);
}
.sb-side {
  flex: 1;
  text-align: center;
  padding: 8px 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .04);
}
.sb-side.active {
  background: rgba(255, 210, 63, .2);
  box-shadow: inset 0 0 0 2px rgba(255, 210, 63, .5);
}
.sb-mid {
  flex: 0 0 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  opacity: .6;
}
.sb-name {
  font-weight: 800;
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-score {
  font-size: clamp(1.6rem, 7vw, 2.3rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.banter {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--r);
  background: rgba(139, 92, 246, .14);
  border: 1px solid rgba(139, 92, 246, .3);
}
.banter-face { font-size: 30px; flex: 0 0 auto; }

/* The hand-off card. It covers the screen between turns so neither player
   sees a question that is not theirs. */
.handoff {
  text-align: center;
  padding: 30px 18px;
  border-radius: var(--r);
  background: linear-gradient(180deg, rgba(10, 14, 36, .92), rgba(10, 14, 36, .98));
  border: 2px dashed rgba(255, 255, 255, .22);
}
.handoff .huge { margin: 8px 0 14px; }
.parent-turn {
  border-color: rgba(255, 93, 143, .45);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 93, 143, .18), transparent 60%),
    rgba(10, 14, 36, .9);
}
.final-score {
  font-size: clamp(2.4rem, 11vw, 4rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}

/* ---------------- Trick Shot Lab ---------------- */
.ts-level {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 96px;
  padding: 12px 14px;
  text-align: left;
  border-radius: var(--r);
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .1);
  color: var(--fg);
  font: inherit;
  cursor: pointer;
}
.ts-level.done { background: rgba(61, 220, 132, .14); border-color: rgba(61, 220, 132, .4); }
.ts-level.locked { opacity: .5; cursor: default; }
.ts-level:active:not(.locked) { transform: scale(.98); }
.ts-num {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--gold);
  line-height: 1;
}

.ts-stage { padding: 8px; overflow: hidden; }
.ts-canvas {
  display: block;
  width: 100%;
  height: auto;
  /* the canvas is authored at 960x520 and scaled down to fit */
  aspect-ratio: 960 / 520;
  border-radius: 12px;
  background: #05060f;
  touch-action: manipulation;
}
/* aspect-ratio is well supported, but keep a floor for older engines */
@supports not (aspect-ratio: 1) {
  .ts-canvas { max-height: 60vh; }
}

.ts-controls { padding: 14px; }
.ts-dial {
  width: 150px;
  height: 100px;
  touch-action: none;
  cursor: grab;
}
.ts-readout {
  font-weight: 900;
  font-size: 1.15rem;
  text-align: center;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  min-height: 1.4em;
}
.ts-controls input[type="range"] {
  width: 100%;
  height: 44px;              /* a comfortable touch target, not a hairline */
  accent-color: #ffd23f;
  background: transparent;
}

.predict-box {
  border: 1px solid rgba(139, 92, 246, .45);
  background:
    radial-gradient(circle at 50% 0%, rgba(139, 92, 246, .18), transparent 60%),
    rgba(255, 255, 255, .04);
}

/* ---------------- motion preferences ---------------- */
@media (prefers-reduced-motion: reduce) {
  .flash-good, .flash-bad { animation: none; }
  .lightning-bar { transition: none; }
  .ts-level:active:not(.locked) { transform: none; }
}

/* ---------------- narrow screens (iPad portrait, phones) ---------------- */
@media (max-width: 560px) {
  .rung-d { display: none; }
  .ladder-strip { flex: 0 0 68px; }
  .sb-mid { flex: 0 0 30px; }
  .ts-dial { width: 128px; height: 86px; }
}

/* Lightning HUD: a draining bar, a countdown and the live score. */
.lightning-hud { display: flex; align-items: center; gap: 14px; }
.lightning-count { display: flex; align-items: baseline; gap: 2px; margin-top: 4px; }
.lightning-count.urgent .lightning-num { color: #ff5d8f; }
@media (max-width: 560px) {
  .lightning-hud { flex-wrap: wrap; }
  .lightning-num { font-size: 1.8rem; }
}

/* ============================================================
   PHASE 4a: the grade 6-8 manipulatives.

   By Galaxy 2 the widget usually has a readout under it, because at this
   level she needs to see what she has built stated in symbols - "x >= -3",
   "y = 2x + 1", "3x + 4" - not just as a picture.
   ============================================================ */

/* a shared readout strip, used by several widgets */
.ineq-readout,
.fit-readout,
.tiles-readout,
.spin-status {
  margin: 8px auto 0;
  padding: 7px 14px;
  max-width: 520px;
  border-radius: 12px;
  text-align: center;
  font-weight: 800;
  font-size: 1.05rem;
  background: rgba(255, 210, 63, .14);
  border: 1px solid rgba(255, 210, 63, .3);
  font-variant-numeric: tabular-nums;
}

/* ---------------- inequality builder ---------------- */
.ineq-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 10px;
}
.ineq-controls .btn { min-height: 44px; }

/* ---------------- scientific notation ---------------- */
.sci-display {
  text-align: center;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .12);
}
.sci-main { display: block; font-size: 2rem; font-weight: 900; }
.sci-main sup { font-size: .62em; }
.sci-plain {
  display: block;
  margin-top: 4px;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  min-height: 1.3em;
}
.sci-answer { margin-top: 6px; font-size: .9rem; color: #3ddc84; font-weight: 700; }
.sci-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.sci-row input[type="range"] {
  width: 100%;
  height: 44px;
  accent-color: #ffd23f;
  background: transparent;
}

/* ---------------- algebra tiles ---------------- */
.tiles-board { min-height: 72px; }
.tiles-expr { font-size: 1.25rem; }
.tiles-answer { color: #3ddc84; }
.tiles-controls {
  display: flex;
  gap: 18px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}
.tile-stepper { text-align: center; }
.tile-stepper .flex { gap: 8px; align-items: center; justify-content: center; margin-top: 4px; }
.tile-stepper .btn {
  min-width: 46px;
  min-height: 44px;
  font-size: 1.3rem;
  font-weight: 900;
  line-height: 1;
}
.tile-count {
  min-width: 2.2em;
  font-size: 1.4rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

/* ---------------- spinner trials ---------------- */
.spin-host { text-align: center; }
.spin-tally {
  max-width: 420px;
  margin: 10px auto 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.tally-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}
.tally-name {
  flex: 0 0 76px;
  text-align: right;
  font-weight: 700;
  font-size: .9rem;
}
.tally-bar {
  height: 18px;
  min-width: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, #22c9a6, #4da3ff);
  transition: width .2s ease;
}
.tally-n {
  margin-left: auto;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  flex: 0 0 2.2em;
  text-align: right;
}
.spin-status { font-size: .95rem; }

@media (prefers-reduced-motion: reduce) {
  .tally-bar { transition: none; }
}
@media (max-width: 560px) {
  .tiles-controls { gap: 10px; }
  .tally-name { flex-basis: 60px; font-size: .82rem; }
  .sci-main { font-size: 1.6rem; }
}

/* ============================================================
   PHASE 4: Deep Reach (Galaxy 2).

   The Home Galaxy is round, bright and friendly. Deep Reach is older and
   colder: squarer corners, thinner rules, less glow, a blue-steel palette.
   It is the same game, but it has stopped talking to her like she is eight.

   Only visual treatment lives here - every control keeps its size and its
   contrast, and nothing becomes harder to see or to hit.
   ============================================================ */
.deep-reach {
  --dr-line: rgba(140, 170, 255, .26);
  --dr-panel: rgba(8, 11, 28, .92);
}

/* panels: flatter, squarer, cooler */
.deep-reach .panel {
  background: var(--dr-panel);
  border-color: var(--dr-line);
  border-radius: 14px;
}

/* planet cards lose the soft glow and gain an edge */
.deep-reach .planet-card {
  border-radius: 14px;
  border-width: 2px;
  border-color: var(--dr-line);
  background:
    linear-gradient(180deg, rgba(18, 24, 54, .85), rgba(6, 9, 22, .95));
}
.deep-reach .planet-card .glow { opacity: .16; filter: blur(60px); }
.deep-reach .planet-card h3 { letter-spacing: .01em; }
.deep-reach .planet-card:hover { transform: translateY(-2px); }

/* the planet drawings are cooled rather than redrawn */
.deep-reach .planet-svg { filter: saturate(.72) brightness(.92) hue-rotate(-8deg); }

/* mission buttons: a straighter, more technical list */
.deep-reach .level-btn {
  border-radius: 10px;
  border-color: var(--dr-line);
}
.deep-reach .grade-badge { border-radius: 6px; }

/* a thin rule under the header, instead of the Home Galaxy's rounded card */
.deep-reach .galaxy-dark {
  border-radius: 14px;
  border-left: 3px solid #8fb4ff;
}

/* pills and chips squared off to match */
.deep-reach .pill { border-radius: 8px; }

/* the Arcade Deck keeps its gold, because the stakes are the same everywhere */
.deep-reach .money-amount,
.deep-reach .gauntlet-title { filter: none; }

@media (prefers-reduced-motion: reduce) {
  .deep-reach .planet-card:hover { transform: none; }
}

/* ============================================================
   PHASE 6: the Workbench, Build Mode, the companion, and the
   Bonus Planet of the Day.

   Same rules as everywhere else: nothing smaller than 44px to tap, no
   hover-only information, and a reduced-motion fallback for anything
   that moves.
   ============================================================ */

/* ---------------- materials ---------------- */
.mat-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 12px;
}
.mat-cell {
  min-width: 78px;
  min-height: 78px;
  padding: 8px 6px;
  border-radius: 12px;
  text-align: center;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .12);
}
.mat-cell.tier2 { border-color: rgba(255, 210, 63, .4); }
.mat-cell.tier3 { border-color: rgba(139, 92, 246, .55); background: rgba(139, 92, 246, .12); }
.mat-cell.empty { opacity: .45; }
.mat-cell.wanted {
  border-color: #ff5d8f;
  box-shadow: 0 0 0 2px rgba(255, 93, 143, .3);
  opacity: 1;
}
.mat-em { font-size: 24px; line-height: 1.1; }
.mat-n {
  font-size: 1.15rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.mat-name { font-size: .68rem; color: var(--ink-dim); line-height: 1.15; }
.mat-need { font-size: .64rem; color: #ff5d8f; font-weight: 700; }
.mat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

/* ---------------- recipes ---------------- */
.recipe {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border-radius: var(--r);
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .1);
}
.recipe.ready { border-color: rgba(61, 220, 132, .5); background: rgba(61, 220, 132, .1); }
.recipe.made { opacity: .6; }
.recipe-em { font-size: 34px; line-height: 1; }
.recipe-name { font-weight: 900; font-size: 1.05rem; }
.recipe-cost { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.cost-chip {
  font-size: .8rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .07);
  font-variant-numeric: tabular-nums;
}
.cost-chip.ok { background: rgba(61, 220, 132, .22); }
.cost-chip.short { background: rgba(255, 93, 143, .2); }
.recipe-state { font-size: .85rem; font-weight: 700; margin-top: 2px; }
.recipe-hint { font-size: .78rem; color: var(--ink-dim); }
.recipe .btn { margin-top: 4px; }

/* ---------------- build mode ---------------- */
.tray {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.tray-tile {
  min-width: 76px;
  min-height: 84px;
  padding: 8px 6px;
  border-radius: 12px;
  text-align: center;
  background: rgba(255, 255, 255, .06);
  border: 2px solid rgba(255, 255, 255, .14);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.tray-tile.picked {
  border-color: var(--gold);
  background: rgba(255, 210, 63, .2);
  box-shadow: 0 0 0 2px rgba(255, 210, 63, .3);
}
.tray-tile.eraser { border-style: dashed; }
.tray-tile.out, .tray-tile:disabled { opacity: .4; cursor: default; }
.tray-em { font-size: 26px; line-height: 1.1; }
.tray-n { font-weight: 900; font-variant-numeric: tabular-nums; }
.tray-name { font-size: .7rem; color: var(--ink-dim); }
.build-hint {
  margin-top: 10px;
  font-size: .9rem;
  font-weight: 700;
  min-height: 1.3em;
  color: var(--gold);
}

.deck {
  display: grid;
  gap: 3px;
  max-width: 560px;
  margin: 0 auto;
}
.deck .cell {
  aspect-ratio: 1;
  min-width: 30px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .035);
  border: 1px solid rgba(255, 255, 255, .09);
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  color: var(--ink);
}
.deck .cell.filled { border-color: rgba(255, 255, 255, .22); }
.deck .cell:active { transform: scale(.94); }
.cell-em { font-size: clamp(14px, 3.4vw, 26px); line-height: 1; pointer-events: none; }
@supports not (aspect-ratio: 1) {
  .deck .cell { height: 44px; }
}

/* ---------------- the companion ---------------- */
.pet-bubble {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(139, 92, 246, .16);
  border: 1px solid rgba(139, 92, 246, .32);
  text-align: left;
}
.pet-face { font-size: 26px; line-height: 1; flex: 0 0 auto; }
.pet-says { font-size: .95rem; }
.pet-big { font-size: 78px; line-height: 1.05; }
.pet-face.collared, .pet-big.collared {
  filter: drop-shadow(0 0 10px rgba(139, 92, 246, .9));
}
.pet-card { padding-bottom: 20px; }

.pet-stages {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}
.pet-stage {
  min-width: 76px;
  padding: 8px 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .1);
  opacity: .6;
}
.pet-stage.done { opacity: 1; }
.pet-stage.now {
  opacity: 1;
  border-color: var(--gold);
  background: rgba(255, 210, 63, .16);
}
.pet-stage-em { font-size: 30px; line-height: 1.1; }

.pet-pick {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 14px;
  border-radius: var(--r);
  text-align: left;
  background: rgba(255, 255, 255, .05);
  border: 2px solid rgba(255, 255, 255, .12);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.pet-pick.chosen {
  border-color: var(--gold);
  background: rgba(255, 210, 63, .14);
  box-shadow: 0 0 0 2px rgba(255, 210, 63, .25);
}
.pet-pick-em { font-size: 42px; line-height: 1; }
.pet-pick-stages { font-size: 1.05rem; margin-top: 4px; letter-spacing: .02em; }

/* ---------------- bonus planet of the day ---------------- */
.bonus-card { border-color: rgba(255, 210, 63, .5); }
.bonus-flag {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .06em;
  background: var(--gold);
  color: #141414;
  position: relative;
}
.bonus-flag.big { font-size: .95rem; padding: 5px 16px; }
.bonus-pill { background: rgba(255, 210, 63, .3) !important; }

@media (prefers-reduced-motion: reduce) {
  .deck .cell:active { transform: none; }
}
@media (max-width: 560px) {
  .mat-cell { min-width: 64px; min-height: 70px; }
  .mat-em { font-size: 20px; }
  .pet-big { font-size: 58px; }
  .tray-tile { min-width: 66px; }
}

/* ============================================================
   PHASE 7: the printable weekly report.

   This is the only screen in the game designed for paper. On screen it
   stays legible against the dark theme; on paper it goes black-on-white,
   because a teacher is not printing a dark background.
   ============================================================ */
.report-sheet {
  max-width: 820px;
  margin: 0 auto;
  padding: 26px 30px 34px;
  border-radius: var(--r);
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line);
}
.report-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--line);
}
.report-title { font-size: 1.6rem; margin: 0; }
.report-sub { font-size: 1rem; color: var(--ink-dim); margin-top: 2px; }
.report-brand { text-align: right; font-size: .9rem; }
.report-h2 {
  font-size: 1.15rem;
  margin: 24px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.report-h3 { font-size: 1rem; margin: 14px 0 6px; color: var(--ink-dim); }
.report-body { font-size: .98rem; line-height: 1.5; margin: 6px 0; }
.report-fine { font-size: .8rem; color: var(--ink-dim); line-height: 1.45; }
.report-list { font-size: .9rem; line-height: 1.55; padding-left: 20px; }
.report-list li { margin-bottom: 6px; }

.report-kpis {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 16px;
}
.report-kpi {
  flex: 1 1 110px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  text-align: center;
}
.report-kpi-n {
  font-size: 1.3rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

/* the day-by-day strip */
.report-days {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 8px;
  height: 128px;
  padding: 8px 4px 0;
  margin: 10px 0;
  border-bottom: 1px solid var(--line);
}
.report-day { text-align: center; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; }
.report-day-val { font-size: .78rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.report-day-bar {
  width: 70%;
  margin: 3px auto 4px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, #ffd23f, #ff8a3d);
  min-height: 3px;
}
.report-day-bar.none { background: rgba(255, 255, 255, .16); }
.report-foot {
  margin-top: 26px;
  padding-top: 12px;
  border-top: 2px solid var(--line);
  display: flex;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--ink-dim);
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------------- on paper ---------------- */
@media print {
  .report-sheet {
    max-width: none;
    margin: 0;
    padding: 0;
    background: #fff !important;
    border: none;
    color: #000 !important;
  }
  .report-sheet * { color: #000 !important; }
  .report-head, .report-h2, .report-foot { border-color: #000 !important; }
  .report-h3, .report-fine, .report-sub, .report-brand .report-fine { color: #333 !important; }
  .report-kpi { background: #fff !important; border: 1px solid #000 !important; }
  .report-days { border-bottom: 1px solid #000 !important; }
  .report-day-bar { background: #555 !important; }
  .report-day-bar.none { background: #ddd !important; }
  .report-sheet table.data {
    background: #fff !important;
    width: 100%;
    border-collapse: collapse;
  }
  .report-sheet table.data th,
  .report-sheet table.data td {
    border: 1px solid #999 !important;
    padding: 4px 6px !important;
    font-size: 10pt !important;
    text-align: left !important;
    font-weight: normal !important;
  }
  .report-sheet table.data th { font-weight: bold !important; background: #eee !important; }
  /* keep a section and its table together where the printer allows it */
  .report-h2, .report-h3 { page-break-after: avoid; }
  .report-sheet table.data { page-break-inside: avoid; }
}

@media (max-width: 560px) {
  .report-sheet { padding: 18px 14px 24px; }
  .report-head { flex-direction: column; }
  .report-brand { text-align: left; }
  .report-days { height: 108px; }
}
