@import url("design/tokens.css");
@import url("design/home-stage.css");
@import url("design/ui-refine.css");
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Noto+Sans+KR:wght@400;500;700&display=swap');

:root{
  --font:var(--jq-font);
  --font-display:var(--jq-font-display);
  --fs-logo:calc(30px * var(--jq-type-scale));
  --fs-title:calc(22px * var(--jq-type-scale));
  --fs-body:calc(16px * var(--jq-type-scale));
  --fs-mode:calc(17px * var(--jq-type-scale));
  --fs-desc:calc(14px * var(--jq-type-scale));
  --fs-btn:calc(16px * var(--jq-type-scale));
  --fs-label:calc(12px * var(--jq-type-scale));
  --lh-body:1.6;
  --lh-tight:1.35;
  --space-section:24px;
  --space-card:20px;
  --space-title:8px;
  --space-btn:12px;
  --bg:var(--jq-bg);
  --bg-2:var(--jq-bg-2);
  --surface:var(--jq-surface);
  --surface-2:var(--jq-surface-2);
  --line:var(--jq-line);
  --text:var(--jq-text);
  --muted:var(--jq-muted);
  --faint:var(--jq-faint);
  --accent:var(--jq-accent);
  --accent-ink:var(--jq-accent-ink);
  --sand:var(--jq-sand);
  --s:var(--jq-s);
  --t:var(--jq-t);
  --a:var(--jq-a);
  --r:var(--jq-r);
  --shadow:var(--jq-shadow);
  --neon-pink:var(--s);
  --neon-cyan:var(--t);
  --neon-yellow:var(--a);
  --neon-green:var(--r);
  --neon-purple:var(--jq-purple);
  --neon-orange:var(--jq-orange);
}
@media (min-width:700px){
  :root{ --fs-logo:calc(34px * var(--jq-type-scale)); }
}
@media (min-width:900px){
  :root{ --fs-logo:calc(36px * var(--jq-type-scale)); --fs-title:calc(22px * var(--jq-type-scale)); --space-section:24px; }
}
@media (min-width:1280px){
  :root{ --fs-logo:calc(38px * var(--jq-type-scale)); }
}

#starquest, #starquest *{ box-sizing:border-box; }
#starquest [hidden]{ display:none !important; }
html, body{ height:100%; }
body{
  margin:0;
  font-family:var(--font);
  font-size:var(--fs-body);
  line-height:var(--lh-body);
  background:var(--bg);
  color:var(--text);
  min-height:100vh;
}
button, input{ font-family:inherit; }
#starquest{ position:relative; min-height:100vh; word-break:keep-all; overflow-wrap:break-word; }
#starquest :focus-visible{ outline:2px solid var(--sand); outline-offset:3px; }

#app{
  position:relative;
  z-index:1;
  width:min(920px, 100%);
  margin:0 auto;
  padding:24px 16px 48px;
}
.screen{ display:none; }
.screen.active{ display:block; }

.s{ color:var(--s); } .t{ color:var(--t); } .a{ color:var(--a); } .r{ color:var(--r); }
.cyan{ color:var(--t); } .yellow{ color:var(--a); }
.dim{ color:var(--muted); font-size:var(--fs-desc); }

/* ---------- HOME ---------- */
.home-wrap{
  display:flex;
  flex-direction:column;
  align-items:stretch;
  gap:var(--space-section);
  width:min(840px, 100%);
  margin:0 auto;
  padding:0 0 32px;
  text-align:center;
}
.home-hero, .home-block, .home-start, .home-links{ min-width:0; }
.eyebrow{
  margin:0 0 12px;
  font-size:var(--fs-label);
  font-weight:700;
  letter-spacing:.12em;
  color:var(--sand);
}
.title{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  align-items:baseline;
  gap:4px 12px;
  margin:0;
  font-family:var(--font);
  font-size:var(--fs-logo);
  font-weight:700;
  line-height:1.15;
  letter-spacing:.04em;
}
.title span{ display:inline-block; max-width:100%; line-height:1.15; }
.title .q{ color:var(--sand); }
.subtitle{
  margin:12px 0 0;
  font-size:var(--fs-body);
  line-height:var(--lh-body);
  color:var(--muted);
}
.intro-box{
  text-align:left;
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:18px;
  padding:var(--space-card);
  box-shadow:var(--shadow);
}
.intro-box p{ margin:0 0 8px; }
.intro-box p:last-child{ margin:0; }
.intro-kicker{
  font-size:var(--fs-label);
  font-weight:700;
  letter-spacing:.08em;
  color:var(--sand);
}
.legend{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:12px;
}
.chip{
  font-size:var(--fs-desc);
  font-weight:700;
  line-height:1.3;
  padding:10px 14px;
  border-radius:999px;
  border:1px solid var(--line);
  background:var(--bg-2);
}
.chip.s{ color:var(--s); border-color:color-mix(in srgb, var(--s) 55%, var(--line)); }
.chip.t{ color:var(--t); border-color:color-mix(in srgb, var(--t) 55%, var(--line)); }
.chip.a{ color:var(--a); border-color:color-mix(in srgb, var(--a) 55%, var(--line)); }
.chip.r{ color:var(--r); border-color:color-mix(in srgb, var(--r) 55%, var(--line)); }

.mode-label{
  margin:0 0 12px;
  font-size:var(--fs-label);
  font-weight:700;
  letter-spacing:.08em;
  color:var(--muted);
}
.mode-label span{ display:block; margin-top:4px; font-weight:500; letter-spacing:0; color:var(--faint); }
.mode-grid{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:16px;
}
.mode-btn{
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  gap:8px;
  width:100%;
  margin:0;
  padding:20px;
  text-align:left;
  color:var(--text);
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:18px;
  cursor:pointer;
}
.mode-btn .m-icon{
  width:36px;
  height:36px;
  border-radius:10px;
  background:var(--surface-2) center / 18px 18px no-repeat;
}
.mode-btn[data-mode="classic"] .m-icon{
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'><rect x='1' y='3' width='3' height='12' rx='1' fill='%23e6d3b3'/><rect x='6' y='6' width='3' height='9' rx='1' fill='%23e6d3b3'/><rect x='11' y='1' width='3' height='14' rx='1' fill='%23e07a5f'/></svg>");
}
.mode-btn[data-mode="time"] .m-icon{
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'><circle cx='9' cy='9' r='6.5' fill='none' stroke='%237eb8c4' stroke-width='1.6'/><path d='M9 5.5V9l2.4 1.6' fill='none' stroke='%237eb8c4' stroke-width='1.6' stroke-linecap='round'/></svg>");
}
.mode-btn[data-mode="survival"] .m-icon{
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'><path d='M9 14s-5-3.1-5-6.2A2.8 2.8 0 0 1 9 6a2.8 2.8 0 0 1 5 1.8C14 10.9 9 14 9 14z' fill='none' stroke='%23e08b96' stroke-width='1.5'/></svg>");
}
.mode-btn .m-name{
  font-size:var(--fs-mode);
  font-weight:700;
  line-height:var(--lh-tight);
}
.mode-btn .m-desc{
  font-size:var(--fs-desc);
  line-height:1.5;
  color:var(--muted);
}
.mode-btn:hover{ border-color:#d5cbbd; background:var(--surface-2); }
.mode-btn.sel{
  border-color:var(--sand);
  background:#f7f1e6;
}

.lvl-btns{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:12px;
}
#classicLens{ grid-template-columns:repeat(2, minmax(0, 1fr)); }
.lvl-pick, .len-pick{
  min-height:48px;
  margin:0;
  padding:12px 8px;
  border-radius:12px;
  border:1px solid var(--line);
  background:transparent;
  color:var(--muted);
  font-size:var(--fs-desc);
  font-weight:700;
  line-height:1.35;
  cursor:pointer;
}
.lvl-pick:hover, .len-pick:hover{ border-color:#d5cbbd; color:var(--text); }
.lvl-pick.active, .len-pick.active{
  border-color:var(--sand);
  color:var(--text);
  background:#f7f1e6;
}

.home-start, .quick-entry{ display:flex; flex-direction:column; align-items:center; gap:8px; }
.btn.sand{ border-color:#d9cbb8; background:#fff; color:var(--text); }
.simple-start{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:14px;
  margin-top:12px;
}
.jq-home-cta .btn.big.sand{
  border:0;
  background:var(--sand);
  color:#fff;
  border-radius:14px;
  box-shadow:0 10px 22px rgba(138, 104, 68, .22);
}
.jq-home-cta .btn.big.sand:hover{
  background:#7a5c3c;
  color:#fff;
}
.home-wrap.jq-home-stage{
  width:min(560px, 100%);
  gap:16px;
  min-height:min(70vh, 640px);
  justify-content:center;
}
.more-link{
  min-height:44px;
  padding:8px 4px;
  border:0;
  background:none;
  color:var(--muted);
  font:inherit;
  font-size:var(--fs-desc);
  text-decoration:underline;
  text-underline-offset:3px;
  cursor:pointer;
}
#moreWaysPanel{ margin-top:40px; }
.press-start{ margin:0; font-size:var(--fs-desc); color:var(--faint); }
.best-line{ min-height:1.4em; margin:0; font-size:var(--fs-desc); font-weight:700; color:var(--r); }
.quick-entry .link-btn{ margin-top:4px; }
.home-links{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:8px 16px;
}
.link-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:48px;
  margin:0;
  padding:10px 8px;
  border:0;
  background:none;
  color:var(--muted);
  font-size:var(--fs-desc);
  line-height:1.4;
  text-decoration:underline;
  text-underline-offset:3px;
  cursor:pointer;
}
.link-btn:hover{ color:var(--text); }

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:48px;
  margin:0;
  padding:12px 22px;
  border:1px solid var(--line);
  border-radius:999px;
  background:#fff;
  color:var(--text);
  font-size:var(--fs-btn);
  font-weight:700;
  line-height:1.3;
  letter-spacing:0;
  cursor:pointer;
}
.btn:hover{ filter:brightness(1.06); }
.btn:active{ transform:translateY(1px); }
.btn.big{ min-width:min(100%, 240px); min-height:56px; padding:14px 32px; }
.btn.small{ min-height:44px; padding:10px 16px; font-size:calc(15px * var(--jq-type-scale)); }
.btn.cyan{ background:var(--t); color:#102226; }
.btn.yellow{ background:var(--a); color:#2a220c; }
.btn:disabled{ opacity:.45; cursor:not-allowed; filter:none; }

/* ---------- GAME ---------- */
.hud{
  display:grid;
  grid-template-columns:repeat(4, minmax(0, 1fr));
  gap:8px;
  margin:0 0 16px;
  padding:12px;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--surface);
}
.hud .item{ display:flex; flex-direction:column; align-items:center; gap:4px; min-width:0; }
.hud .label{ font-size:var(--fs-label); font-weight:700; letter-spacing:.06em; color:var(--faint); }
.hud .val{
  max-width:100%;
  font-size:calc(18px * var(--jq-type-scale));
  font-weight:700;
  line-height:1.3;
  font-variant-numeric:tabular-nums;
  overflow-wrap:anywhere;
}
.hud .time{ color:var(--a); }
.hud .time.warn{ color:var(--s); }
.hud .score{ color:var(--r); }
.hud .mode{ color:var(--sand); font-size:calc(15px * var(--jq-type-scale)); }

.sub-hud{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  min-height:44px;
  margin:0 0 16px;
  flex-wrap:wrap;
}
.lives{ display:flex; gap:6px; font-size:calc(18px * var(--jq-type-scale)); line-height:1; }
.lives .heart{ color:var(--s); }
.lives .heart.lost{ opacity:.28; }
.combo-box{ font-size:calc(14px * var(--jq-type-scale)); font-weight:700; color:var(--neon-orange); opacity:0; }
.combo-box.show{ opacity:1; }
.combo-box.pump{ animation:comboPump .3s; }
@keyframes comboPump{ from{ transform:scale(1.12); } to{ transform:scale(1); } }

.scenario-head{ text-align:center; margin:0 0 12px; }
.scenario-head .tag{
  font-size:var(--fs-label);
  font-weight:700;
  letter-spacing:.06em;
  color:var(--sand);
}
.scenario-head .theme{
  margin-top:8px;
  font-size:calc(20px * var(--jq-type-scale));
  font-weight:700;
  line-height:1.45;
}
.hint{
  margin:0 0 16px;
  min-height:1.5em;
  text-align:center;
  font-size:calc(15px * var(--jq-type-scale));
  line-height:1.5;
  color:var(--muted);
}
.hint.reveal{ color:var(--sand); }

.slots{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
  margin:0 0 16px;
}
.slot{
  position:relative;
  display:flex;
  flex-direction:column;
  min-height:92px;
  min-width:0;
  padding:12px;
  border:1px dashed var(--line);
  border-radius:16px;
  background:rgba(255,255,255,.02);
  cursor:pointer;
  overflow-wrap:anywhere;
  word-break:keep-all;
}
.slot .slot-title{ margin:0 0 4px; font-size:calc(14px * var(--jq-type-scale)); font-weight:700; line-height:1.3; }
.slot .slot-sub{ font-size:calc(13px * var(--jq-type-scale)); line-height:1.4; color:var(--faint); }
.slot[data-type="S"]{ border-color:color-mix(in srgb, var(--s) 70%, var(--line)); }
.slot[data-type="T"]{ border-color:color-mix(in srgb, var(--t) 70%, var(--line)); }
.slot[data-type="A"]{ border-color:color-mix(in srgb, var(--a) 70%, var(--line)); }
.slot[data-type="R"]{ border-color:color-mix(in srgb, var(--r) 70%, var(--line)); }
.slot[data-type="S"] .slot-title{ color:var(--s); }
.slot[data-type="T"] .slot-title{ color:var(--t); }
.slot[data-type="A"] .slot-title{ color:var(--a); }
.slot[data-type="R"] .slot-title{ color:var(--r); }
.slot.over{ background:rgba(44,41,38,.05); }
.slot.filled{ border-style:solid; }
.slot.hintglow{ background:rgba(230,211,179,.12); }
.slot.shake{ animation:shake .4s; }
@keyframes shake{
  0%,100%{ transform:translateX(0); }
  25%{ transform:translateX(-6px); }
  75%{ transform:translateX(6px); }
}
.wrong-mark{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:calc(28px * var(--jq-type-scale));
  font-weight:700;
  color:var(--s);
  pointer-events:none;
  animation:popX .45s ease;
}
@keyframes popX{ from{ opacity:0; } to{ opacity:0; } 40%{ opacity:1; } }

.card-pool{ display:flex; flex-direction:column; gap:12px; margin:0 0 16px; min-height:8px; }
.card{
  display:block;
  position:relative;
  width:100%;
  margin:0;
  padding:14px 16px;
  border:1px solid var(--line);
  border-radius:12px;
  background:var(--surface);
  color:var(--text);
  font-family:inherit;
  font-size:calc(16px * var(--jq-type-scale));
  line-height:1.55;
  text-align:left;
  overflow-wrap:anywhere;
  word-break:keep-all;
  cursor:pointer;
  touch-action:none;
  user-select:none;
  box-shadow:none;
}
/* 왼쪽 세로 장식선(::before) 제거 — 선택·채점에 불필요 */
.card:hover{ border-color:#6a7286; }
.card.dragging{ opacity:.45; }
.card.ghost{
  position:fixed;
  z-index:9999;
  width:auto;
  max-width:min(520px, 92vw);
  pointer-events:none;
  border-color:var(--sand);
}
.card.placed{ margin-top:8px; padding:10px 12px; font-size:calc(14px * var(--jq-type-scale)); line-height:1.5; cursor:default; }
.card.correct-flash{ animation:correctFlash .45s; }
@keyframes correctFlash{ from{ border-color:var(--r); } to{ border-color:var(--line); } }
#starquest .card.is-selected{
  border-color:var(--sand);
  box-shadow:inset 0 0 0 1px var(--sand);
  background:color-mix(in srgb, var(--sand) 10%, #fff);
}
.q-choice:active{ transform:translateY(1px); }
.q-choice.good{ background:color-mix(in srgb, var(--r) 10%, #fff); }
.q-choice.bad{ background:color-mix(in srgb, var(--s) 8%, #fff); }
@media (prefers-reduced-motion: reduce){
  .q-choice:active{ transform:none; }
}
#starquest .card.hinted{ border-color:var(--a); box-shadow:inset 0 0 0 1px var(--a); }
#starquest .slots.armed .slot:not(.filled){ background:rgba(230,211,179,.06); }

.q-prompt{ margin:8px 0 12px; font-size:calc(20px * var(--jq-type-scale)); font-weight:700; line-height:1.4; }
.q-text{ margin:0 0 16px; padding:16px; text-align:left; font-size:calc(16px * var(--jq-type-scale)); line-height:1.6; background:var(--surface); border:1px solid var(--line); border-radius:16px; }
.q-choices{ display:flex; flex-direction:column; gap:12px; margin:0 0 12px; }
.q-choice{
  width:100%; min-height:52px; margin:0; padding:14px 16px;
  text-align:left; font:inherit; font-size:calc(16px * var(--jq-type-scale)); font-weight:500; line-height:1.45;
  color:var(--text); background:var(--surface); border:1px solid var(--line); border-radius:12px; cursor:pointer;
  box-shadow:none;
}
.q-choice:hover{ border-color:#6a7286; }
.q-choice.good{ border-color:var(--r); border-width:2px; }
.q-choice.bad{ border-color:var(--s); border-width:2px; }
.q-choice:disabled{ cursor:default; }
.q-choice:focus-visible{
  outline:2px solid var(--sand);
  outline-offset:2px;
}
.boss-banner{ margin:0 0 8px; font-size:calc(14px * var(--jq-type-scale)); font-weight:700; letter-spacing:.08em; color:var(--sand); }
.game-footer{ display:flex; justify-content:center; flex-wrap:wrap; gap:12px; }
.game-footer .btn{ min-height:44px; }

.stage-review{
  margin:0 0 16px;
  padding:20px;
  text-align:left;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--surface);
}
.review-kicker{ margin:0 0 8px; font-size:var(--fs-label); font-weight:700; letter-spacing:.08em; color:var(--sand); }
.review-theme{ margin:0 0 12px; font-size:calc(18px * var(--jq-type-scale)); font-weight:700; line-height:1.4; }
.story-line{ margin:10px 0; font-size:calc(15px * var(--jq-type-scale)); line-height:1.6; }
.story-line b{ display:inline-block; min-width:4.6em; margin-right:6px; font-size:calc(13px * var(--jq-type-scale)); }
.review-actions{ display:flex; justify-content:flex-end; margin-top:12px; }

/* ---------- RESULT / TUTORIAL ---------- */
.result-wrap{
  width:min(640px, 100%);
  margin:0 auto;
  padding:32px 0 16px;
  text-align:center;
}
.result-title{
  margin:0 0 8px;
  font-size:clamp(calc(22px * var(--jq-type-scale)), 4vw, calc(32px * var(--jq-type-scale)));
  font-weight:700;
  line-height:1.35;
  color:var(--sand);
}
.result-grade-label{
  margin:8px 0 0;
  color:var(--faint);
  font-size:calc(12px * var(--jq-type-scale));
  font-weight:700;
  letter-spacing:.06em;
}
.grade{
  margin:4px 0 0;
  font-family:var(--font);
  font-size:calc(36px * var(--jq-type-scale));
  font-weight:700;
  line-height:1.2;
  color:var(--text);
  text-shadow:none !important;
}
.final-score{
  margin:4px 0 8px;
  font-size:calc(26px * var(--jq-type-scale));
  font-weight:700;
  line-height:1.3;
  font-variant-numeric:tabular-nums;
  color:var(--sand);
}
.newbest{ display:none; margin:0 0 8px; font-size:calc(14px * var(--jq-type-scale)); font-weight:700; color:var(--r); }
.newbest.show{ display:block; }
.solved-fold{
  width:min(560px, 100%);
  margin:20px auto 8px;
  text-align:left;
}
.solved-fold > summary{
  cursor:pointer;
  min-height:44px;
  padding:8px 0;
  color:var(--muted);
  font-size:calc(14px * var(--jq-type-scale));
  font-weight:700;
  text-decoration:underline;
  text-underline-offset:3px;
  list-style:none;
}
.solved-fold > summary::-webkit-details-marker{ display:none; }
.review-clear{
  margin:0 0 10px;
  padding:8px 12px;
  border:1px solid color-mix(in srgb, var(--r) 35%, var(--line));
  border-radius:10px;
  background:color-mix(in srgb, var(--r) 8%, #fff);
  color:var(--r);
  font-size:calc(14px * var(--jq-type-scale));
  font-weight:700;
  line-height:1.4;
}
.result-actions{
  margin-top:20px;
}
.stat-grid{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:12px;
  margin:24px 0;
}
.stat{
  padding:16px 8px;
  border:1px solid var(--line);
  border-radius:14px;
  background:var(--surface);
}
.stat .n{ font-size:calc(22px * var(--jq-type-scale)); font-weight:700; line-height:1.2; font-variant-numeric:tabular-nums; }
.stat .l{ margin-top:8px; font-size:calc(13px * var(--jq-type-scale)); line-height:1.4; color:var(--muted); }
.comment{
  margin:0 auto 20px;
  padding:14px 16px;
  max-width:560px;
  text-align:left;
  font-size:calc(15px * var(--jq-type-scale));
  line-height:1.7;
  color:var(--text);
  background:var(--surface);
  border-radius:12px;
}
.solved-log{ max-width:560px; margin:0 auto 20px; text-align:left; }
.solved-block{
  margin:0 0 12px;
  padding:14px 16px;
  border:1px solid var(--line);
  border-radius:14px;
  background:var(--bg-2);
}
.solved-block h3{ margin:0 0 8px; font-size:calc(16px * var(--jq-type-scale)); line-height:1.4; }
.result-btns{ display:flex; justify-content:center; flex-wrap:wrap; gap:12px; }

.tutor-wrap{ text-align:left; }
.tutor-title{ margin:0; font-size:var(--fs-title); font-weight:700; line-height:1.35; text-align:center; }
.tutor-lead{ margin:0; font-size:var(--fs-body); line-height:var(--lh-body); color:var(--muted); text-align:center; }
.tutor-slots{ margin-top:4px; }
.tutor-slot, .tutor-card{
  width:100%;
  margin:0;
  padding:14px 16px;
  text-align:left;
  color:var(--text);
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:14px;
  font:inherit;
  font-size:calc(15px * var(--jq-type-scale));
  line-height:1.5;
  cursor:pointer;
}
.tutor-card.is-selected, .tutor-slot.ready{ border-color:var(--sand); box-shadow:inset 0 0 0 1px var(--sand); }
.tutor-done{ margin:0; color:var(--r); font-size:calc(15px * var(--jq-type-scale)); text-align:center; }
#tutorSlots{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
#tutorPool{ display:flex; flex-direction:column; gap:12px; }

/* ---------- MODAL / FX ---------- */
.modal{
  position:fixed;
  inset:0;
  z-index:10000;
  display:none;
  align-items:center;
  justify-content:center;
  padding:16px;
  background:rgba(10,11,14,.72);
}
.modal.show{ display:flex; }
.modal-box{
  width:min(440px, 100%);
  max-height:min(78vh, 640px);
  overflow:auto;
  padding:24px 20px;
  text-align:left;
  background:var(--bg-2);
  border:1px solid var(--line);
  border-radius:18px;
  box-shadow:var(--shadow);
}
.modal-box h3{ margin:0 0 12px; font-size:calc(20px * var(--jq-type-scale)); font-weight:700; line-height:1.35; text-align:center; }
.modal-box p{ margin:0 0 12px; font-size:calc(15px * var(--jq-type-scale)); line-height:1.65; }
.modal-box b{ font-size:calc(14px * var(--jq-type-scale)); }
.modal-box .btn, .modal-box .result-btns{ margin-top:8px; }

.toast{
  position:fixed;
  left:50%;
  top:max(56px, env(safe-area-inset-top, 0px));
  bottom:auto;
  z-index:40;
  max-width:min(420px, calc(100% - 32px));
  padding:10px 14px;
  border-radius:10px;
  background:var(--surface);
  border:1px solid var(--r);
  color:var(--text);
  font-size:calc(13px * var(--jq-type-scale));
  font-weight:700;
  line-height:1.4;
  text-align:center;
  pointer-events:none;
  opacity:0;
  transform:translateX(-50%) translateY(-6px);
  box-shadow:0 6px 16px rgba(70,55,35,.08);
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }
.toast.bad{ border-color:var(--s); }
.toast.gold{ border-color:var(--a); }
.fx-layer{ position:fixed; inset:0; z-index:25; pointer-events:none; }
.pop-score{
  position:fixed;
  font-size:calc(14px * var(--jq-type-scale));
  font-weight:700;
  color:var(--r);
  animation:floatUp .8s ease forwards;
  z-index:26;
}
.pop-score.bad{ color:var(--s); }
@keyframes floatUp{ to{ transform:translateY(-36px); opacity:0; } }
.confetti-layer{
  position:fixed;
  left:0;
  right:0;
  top:0;
  height:min(42vh, 360px);
  z-index:12;
  pointer-events:none;
  overflow:hidden;
}
.confetti{
  position:absolute;
  top:-12px;
  width:7px;
  height:7px;
  pointer-events:none;
}

@media (max-width:759px){
  .mode-grid{ grid-template-columns:1fr; }
  .mode-btn{ min-height:0; }
  .hud{ grid-template-columns:1fr 1fr; }
  #app{ padding:16px 12px 32px; }
  .home-wrap{ padding-top:12px; }
}
@media (max-width:380px){
  :root{ --fs-logo:calc(32px * var(--jq-type-scale)); }
  .lvl-btns{ grid-template-columns:1fr; }
  .stat-grid{ grid-template-columns:1fr; }
}
/* ---------- CLASS CHALLENGE ---------- */
.class-wrap{ text-align:left; gap:16px; }
.class-wrap .eyebrow,
.class-wrap .tutor-title,
.class-wrap .tutor-lead{ text-align:center; }
.class-wrap > .link-btn{ align-self:center; }
.class-actions{ display:flex; flex-wrap:wrap; gap:12px; }
.class-actions .btn{ flex:1 1 180px; }
.btn.line{
  background:transparent;
  color:var(--sand);
  box-shadow:inset 0 0 0 1px var(--line);
}
.btn.line:hover{ box-shadow:inset 0 0 0 1px var(--sand); }
.btn:disabled{ opacity:.45; cursor:default; }
.seg{ display:flex; flex-wrap:wrap; gap:8px; }
.seg .lvl-pick{ flex:1 1 90px; }
.field{ display:flex; flex-direction:column; gap:8px; min-width:0; }
.field span{ font-size:calc(12px * var(--jq-type-scale)); font-weight:700; letter-spacing:.06em; color:var(--muted); }
.field input, .field select, .code-box{
  width:100%;
  margin:0;
  padding:12px 14px;
  border-radius:12px;
  border:1px solid var(--line);
  background:var(--bg-2);
  color:var(--text);
  font:inherit;
  font-size:calc(16px * var(--jq-type-scale));
  line-height:1.5;
}
.field select{ min-height:48px; }
.code-box{ display:block; resize:vertical; overflow-wrap:anywhere; word-break:break-all; }
.qr-box{ display:flex; justify-content:center; }
.qr-box canvas{ width:min(168px, 70vw); height:auto; background:#f4efe6; border-radius:12px; }
.ticket{
  margin:0;
  padding:16px;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--surface);
}
.ticket p{ margin:0 0 8px; }
.ticket p:last-child{ margin:0; }
.fine-print{ margin:0; color:var(--faint); font-size:calc(13px * var(--jq-type-scale)); line-height:1.55; }
.check-line{ display:flex; align-items:center; gap:8px; min-height:48px; padding:8px 0; font-size:calc(15px * var(--jq-type-scale)); line-height:1.45; }
.check-line input{ width:24px; height:24px; margin:0; flex:none; }
.manual-box{
  margin:0;
  padding:12px 14px;
  border:1px solid var(--line);
  border-radius:14px;
  background:var(--bg-2);
}
.manual-box summary{ min-height:44px; cursor:pointer; font-weight:700; color:var(--sand); }
.manual-box:not([open]) > :not(summary){ display:none; }
.seg .field{ flex:1 1 140px; }
.rank-card{
  display:grid;
  grid-template-columns:auto minmax(0, 1fr) auto;
  gap:12px;
  align-items:center;
  margin:0 0 10px;
  padding:12px 14px;
  border:1px solid var(--line);
  border-radius:14px;
  background:var(--surface);
}
.rank-card.is-1{ border-color:var(--a); background:#f7f1e6; }
.rank-card.is-2{ border-color:var(--sand); }
.rank-card.is-3{ border-color:var(--accent); }
.rank-no{ font-size:calc(22px * var(--jq-type-scale)); font-weight:700; line-height:1; color:var(--sand); font-variant-numeric:tabular-nums; }
.rank-card strong{ font-size:calc(17px * var(--jq-type-scale)); line-height:1.35; overflow-wrap:anywhere; }
.rank-card p{ margin:4px 0 0; color:var(--muted); font-size:calc(14px * var(--jq-type-scale)); line-height:1.45; }
.badge{
  display:inline-block;
  margin-left:8px;
  padding:2px 8px;
  border:1px solid var(--line);
  border-radius:999px;
  color:var(--sand);
  font-size:calc(12px * var(--jq-type-scale));
  font-weight:700;
  vertical-align:1px;
}
.board-error{ margin:8px 0 0; color:var(--s); font-size:calc(14px * var(--jq-type-scale)); line-height:1.5; }
.challenge-result{ max-width:560px; margin:0 auto 16px; text-align:left; }
.q-focus{
  margin:0 0 8px;
  text-align:center;
  color:var(--muted);
  font-size:calc(13px * var(--jq-type-scale));
  line-height:1.4;
  overflow-wrap:anywhere;
}
.choice-row{ display:flex; flex-wrap:wrap; gap:8px; }
.choice-pick{
  min-height:44px;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:transparent;
  color:var(--text);
  font:inherit;
  font-size:calc(15px * var(--jq-type-scale));
  font-weight:700;
  line-height:1.35;
  cursor:pointer;
  touch-action:manipulation;
}
.choice-row .choice-pick{ flex:1 1 140px; }
.choice-pick.active{
  border-color:var(--sand);
  color:var(--text);
  background:#f7f1e6;
}
.job-list{
  display:flex;
  flex-direction:column;
  gap:8px;
  max-height:220px;
  overflow:auto;
}
.job-list .choice-pick{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  width:100%;
  text-align:left;
}
.job-name{ min-width:0; overflow-wrap:anywhere; }
.job-count{ flex:none; color:var(--faint); font-weight:500; font-variant-numeric:tabular-nums; }
#ceremony.screen.active{
  display:block;
  position:fixed;
  inset:0;
  z-index:40;
  overflow:auto;
  background:
    radial-gradient(circle at 50% 16%, rgba(226,182,86,.2), transparent 34%),
    var(--bg);
}
#awardFx{ position:fixed; inset:0; width:100%; height:100%; pointer-events:none; }
.award-stage{
  position:relative;
  z-index:1;
  width:min(720px, 100%);
  margin:0 auto;
  padding:28px 16px 48px;
  display:flex;
  flex-direction:column;
  gap:16px;
}
.award-count{
  margin:10vh 0 0;
  text-align:center;
  font-size:calc(72px * var(--jq-type-scale));
  font-weight:700;
  line-height:1.1;
  color:var(--sand);
}
.champion{ text-align:center; padding-top:8px; }
.trophy svg{ display:block; width:120px; height:140px; margin:0 auto; }
.champion-kicker{
  margin:12px 0 0;
  font-size:clamp(calc(22px * var(--jq-type-scale)), 5vw, calc(36px * var(--jq-type-scale)));
  font-weight:700;
  line-height:1.25;
  color:var(--sand);
}
.champion-name{
  margin:8px 0 0;
  font-size:clamp(calc(28px * var(--jq-type-scale)), 7vw, calc(56px * var(--jq-type-scale)));
  font-weight:700;
  line-height:1.25;
  overflow-wrap:anywhere;
}
.champion-score{
  margin:4px 0 0;
  font-size:clamp(calc(20px * var(--jq-type-scale)), 4vw, calc(32px * var(--jq-type-scale)));
  font-weight:700;
  line-height:1.3;
  color:var(--r);
  font-variant-numeric:tabular-nums;
}
.podium{ display:flex; flex-direction:column; }
@media (max-width:380px){
  .award-count{ font-size:calc(56px * var(--jq-type-scale)); }
  .rank-card{ grid-template-columns:auto minmax(0, 1fr); }
  .rank-card .btn{ grid-column:1 / -1; }
}

@media (prefers-reduced-motion: reduce){
  #starquest *, #starquest *::before, #starquest *::after{
    animation:none !important;
    transition:none !important;
  }
}
