/* 끝까지 진화 — 어두운 원시 바다 + 생물발광(GDD §1-5a). 글자·버튼 = DOM 층, 월드만 캔버스. 버튼 최소 48px · 대비 ≥ 4.5:1 */
:root {
  --bg: #050b1a; --bg2: #0a1630; --panel: rgba(10, 22, 48, 0.86); --line: rgba(120, 220, 255, 0.22);
  --ink: #eaf6ff; --muted: #a9c3dc; --glow: #5ff2e8; --violet: #a68bff; --warn: #ff6b6b; --gold: #ffd54a; --ok: #6cff9a;
  --r: 16px; --gap: 12px; --tap: 52px;
  --font: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); overflow: hidden; overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; touch-action: none; }
input, select { user-select: text; -webkit-user-select: text; font: inherit; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
#world { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); gap: var(--gap); z-index: 5; background: radial-gradient(ellipse at 50% 30%, rgba(30, 60, 120, 0.25), rgba(5, 11, 26, 0.55) 70%); }
.top, .bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.top { flex-wrap: nowrap; } .top .chip { min-width: 0; flex-shrink: 1; } .top .icon, .top .tix { flex-shrink: 0; }
.bar { justify-content: space-between; }
.bar b { font-size: 1.15rem; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); max-width: 46vw; }
.chip b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip small { color: var(--muted); }
#fsBtn { margin-left: auto; }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--glow); box-shadow: 0 0 10px var(--glow); }
.tix b { color: var(--gold); font-size: 1.2rem; }
.icon { width: 48px; height: 48px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); font-size: 1.3rem; }
.brand { text-align: center; margin-top: 2vh; }
.brand h1 { margin: 0; font-size: clamp(2rem, 7vw, 3.4rem); letter-spacing: 0.04em; background: linear-gradient(90deg, #7ff8ee, #b49bff); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: 0 0 30px rgba(95, 242, 232, 0.25); }
.brand p { margin: 4px 0 0; color: var(--muted); }
.cards { flex: 1; display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--gap); align-content: center; max-width: 760px; width: 100%; margin: 0 auto; min-height: 0; }
.card { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 4px; padding: 16px; min-height: 96px; max-height: 22vh; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); text-align: left; position: relative; overflow: hidden; }
.card i { font-style: normal; font-size: 1.6rem; position: absolute; top: 12px; right: 14px; opacity: 0.85; }
.card b { font-size: 1.15rem; }
.card small { color: var(--muted); }
.c-quiz { border-color: rgba(255, 213, 74, 0.5); box-shadow: inset 0 0 40px rgba(255, 213, 74, 0.08); }
.c-play { border-color: rgba(95, 242, 232, 0.6); box-shadow: inset 0 0 40px rgba(95, 242, 232, 0.12); }
.c-prac { border-color: rgba(166, 139, 255, 0.5); }
.rankbar { text-align: center; color: var(--muted); padding: 8px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-size: 0.95rem; }
.rankbar b { color: var(--gold); }
.back { min-height: 44px; padding: 0 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: center; }
.pill { min-height: 44px; padding: 0 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.pill.on { background: rgba(95, 242, 232, 0.2); border-color: var(--glow); }
.big { min-height: 56px; padding: 0 28px; border-radius: 14px; background: linear-gradient(90deg, #1fb5ad, #6d55e8); font-weight: 700; font-size: 1.1rem; box-shadow: 0 0 20px rgba(95, 242, 232, 0.25); }
.big:disabled { opacity: 0.45; }
.mid { min-height: 48px; padding: 0 18px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.quiz-setup, .quiz-done { display: flex; flex-direction: column; gap: 16px; align-items: center; justify-content: center; flex: 1; text-align: center; }
.quiz-run { flex: 1; display: flex; flex-direction: column; gap: 14px; max-width: 720px; width: 100%; margin: 0 auto; justify-content: center; }
.qprog { display: flex; gap: 6px; justify-content: center; }
.qprog span { width: 28px; height: 8px; border-radius: 4px; background: var(--line); }
.qprog span.cur { background: var(--glow); }
.qprog span.done { background: var(--violet); }
.qtext { font-size: clamp(1.2rem, 4.5vw, 1.7rem); text-align: center; line-height: 1.45; padding: 12px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); }
.qchoices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qchoices button { min-height: 60px; padding: 10px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); font-size: 1.1rem; }
.qnum { display: flex; gap: 10px; justify-content: center; }
.qnum input { width: 9ch; min-height: 56px; text-align: center; font-size: 1.6rem; letter-spacing: 0.3em; border-radius: 14px; border: 2px solid var(--glow); background: #071226; color: var(--ink); }
.qres { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.qres span { padding: 6px 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.qres .r { border-color: var(--ok); } .qres .w { border-color: var(--warn); }
.mode-list { display: grid; gap: 10px; max-width: 640px; width: 100%; margin: 0 auto; }
.mode { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; text-align: left; padding: 14px 16px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); min-height: 72px; }
.mode b { font-size: 1.15rem; } .mode small { color: var(--muted); grid-column: 1; } .mode em { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-style: normal; color: var(--gold); }
.mode:disabled { opacity: 0.5; }
.friend { max-width: 640px; width: 100%; margin: 0 auto; padding: 12px; border-radius: var(--r); border: 1px dashed var(--line); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.friend input { width: 9ch; min-height: 48px; text-align: center; border-radius: 12px; border: 1px solid var(--line); background: #071226; color: var(--ink); text-transform: uppercase; letter-spacing: 0.15em; }
.waitbox, .resbox { margin: auto; display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; padding: 24px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); max-width: 560px; width: 100%; max-height: 92vh; overflow: auto; }
.big-num { font-size: 3rem; font-weight: 800; color: var(--glow); }
.code { font-size: 1.6rem; letter-spacing: 0.3em; color: var(--gold); }
/* ── HUD ── */
#hud { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
#hud button, #hud .evo, #hud .spec { pointer-events: auto; }
.hud-tl { position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 4px; text-shadow: 0 1px 4px #000; }
.energy b { font-size: 1.7rem; color: var(--glow); } .energy small, .dna small { color: var(--muted); }
.dna span { font-size: 0.75rem; color: var(--violet); margin-right: 4px; } .dna b { color: #d6c8ff; }
.stage { font-size: 0.95rem; } .lives { color: #ff9eb0; letter-spacing: 0.1em; }
.hud-tc { position: absolute; left: 50%; top: max(10px, env(safe-area-inset-top)); transform: translateX(-50%); text-align: center; text-shadow: 0 1px 4px #000; }
.clock { font-size: 1.3rem; font-weight: 700; } .alive { color: var(--muted); font-size: 0.9rem; } .nextev { color: var(--gold); font-size: 0.85rem; }
#minimap { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); width: 120px; height: 120px; border-radius: 50%; border: 1px solid var(--line); background: rgba(5, 11, 26, 0.6); }
.banner { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); padding: 10px 18px; border-radius: 14px; background: rgba(40, 8, 8, 0.85); border: 1px solid var(--warn); font-size: 1.15rem; font-weight: 700; text-align: center; max-width: 90vw; }
.banner.info { background: rgba(8, 30, 40, 0.85); border-color: var(--glow); }
.tip { position: absolute; left: 50%; bottom: 26%; transform: translateX(-50%); padding: 8px 14px; border-radius: 12px; background: rgba(60, 10, 10, 0.85); border: 1px solid var(--warn); white-space: nowrap; }
.hint { position: absolute; left: 50%; bottom: 34%; transform: translateX(-50%); padding: 8px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); max-width: 86vw; text-align: center; }
.evo { position: absolute; right: max(12px, env(safe-area-inset-right)); top: 150px; display: flex; flex-direction: column; gap: 8px; width: min(46vw, 230px); }
.evo button { text-align: left; padding: 10px 12px; min-height: 56px; border-radius: 14px; background: rgba(20, 16, 50, 0.92); border: 1px solid var(--violet); box-shadow: 0 0 16px rgba(166, 139, 255, 0.35); }
.evo button b { display: block; } .evo button small { color: var(--muted); }
.evo .evt { font-size: 0.8rem; color: var(--muted); text-align: right; }
.ctl { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: 14px; }
.dash { width: 92px; height: 92px; border-radius: 50%; background: radial-gradient(circle, rgba(95, 242, 232, 0.35), rgba(10, 22, 48, 0.85)); border: 2px solid var(--glow); font-weight: 800; }
.abil { width: 60px; height: 60px; border-radius: 50%; background: rgba(20, 16, 50, 0.85); border: 2px solid var(--violet); font-size: 1.4rem; }
.abil:disabled { opacity: 0.35; }
.stick { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.05); }
.knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(95, 242, 232, 0.45); }
body.left .evo { right: auto; left: max(12px, env(safe-area-inset-left)); }
body.left .ctl { right: auto; left: max(18px, env(safe-area-inset-left)); flex-direction: row-reverse; }
body.left #minimap { right: auto; left: max(12px, env(safe-area-inset-left)); top: 150px; }
.spec { position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; padding: 10px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); max-width: 94vw; }
.cheers button { width: 44px; height: 44px; font-size: 1.3rem; border-radius: 12px; background: rgba(255, 255, 255, 0.06); }
.arrow { position: absolute; width: 0; height: 0; border-left: 10px solid transparent; border-right: 10px solid transparent; border-bottom: 18px solid var(--warn); filter: drop-shadow(0 0 6px var(--warn)); }
.res-rank { font-size: 3rem; font-weight: 800; color: var(--gold); }
.res-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.res-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.res-table tr.me td { color: var(--glow); font-weight: 700; }
.codex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; overflow: auto; padding-bottom: 20px; }
.cx { padding: 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); min-height: 120px; display: flex; flex-direction: column; gap: 4px; }
.cx .sw { width: 34px; height: 34px; border-radius: 50%; }
.cx.locked { opacity: 0.4; filter: grayscale(1); }
.cx small { color: var(--muted); }
dialog { border: 1px solid var(--line); border-radius: 18px; background: #0a1630; color: var(--ink); padding: 0; max-width: min(560px, 94vw); width: 100%; }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dlg { display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.dlg select, .dlg input { min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: #071226; color: var(--ink); padding: 0 10px; }
.dlg input { flex: 1; min-width: 8ch; }
.list { display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow: auto; }
.list button { text-align: left; min-height: 48px; padding: 8px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.sw { display: flex; gap: 10px; align-items: center; min-height: 44px; }
.sw input { width: 24px; height: 24px; }
.toast { position: fixed; left: 50%; bottom: 18%; transform: translateX(-50%); z-index: 20; padding: 10px 16px; border-radius: 14px; background: rgba(10, 22, 48, 0.95); border: 1px solid var(--glow); max-width: 90vw; text-align: center; }

/* ── 로비 = 기본틀(학교 순위 맨 위 · 모드 카드 4 · 주 단추 1) ── */
.gb-home { gap: 10px; }
.rank-card { max-width: 760px; width: 100%; margin: 0 auto; padding: 10px 14px; border-radius: var(--r); background: var(--panel); border: 1px solid rgba(255, 213, 74, 0.4); display: flex; flex-direction: column; gap: 4px; min-height: 96px; }
.rk-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rk-head b { color: var(--gold); }
.gb-link { min-height: 32px; padding: 0 8px; border-radius: 10px; color: var(--glow); font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52%; }
.rk-list { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; font-size: 0.9rem; }
.rk-list li { display: flex; gap: 6px; white-space: nowrap; overflow: hidden; }
.rk-list li span { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.rk-list li em { font-style: normal; color: var(--muted); }
.rk-list li.me span { color: var(--glow); font-weight: 700; }
.rk-mine { font-size: 0.9rem; color: var(--muted); }
.rk-mine b { color: var(--gold); }
.brand { margin-top: 0; }
.brand h1 { font-size: clamp(1.7rem, 6vw, 2.8rem); }
.gb-modes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; max-width: 760px; width: 100%; margin: 0 auto; }
.gb-mode { height: 78px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 2px; padding: 8px 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); text-align: left; position: relative; }
.gb-mode b { font-size: 1.02rem; } .gb-mode small { color: var(--muted); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.gb-mode em { position: absolute; top: 8px; right: 10px; font-style: normal; color: var(--gold); font-size: 0.85rem; }
.gb-mode[aria-pressed="true"] { border-color: var(--glow); background: rgba(95, 242, 232, 0.14); box-shadow: 0 0 18px rgba(95, 242, 232, 0.25); }
.play { max-width: 760px; width: 100%; margin: 0 auto; }
.sub { max-width: 760px; width: 100%; margin: 0 auto; }
.sub .mid { flex: 1; padding: 0 8px; white-space: nowrap; }
.sub small { color: var(--muted); }
@media (min-width: 900px) { .gb-modes { grid-template-columns: repeat(4, 1fr); } }
@media (max-height: 520px) {
  .brand { display: none; } .gb-home { gap: 6px; }
  .gb-modes { grid-template-columns: repeat(4, 1fr); } .gb-mode { height: 64px; } .rk-list { grid-template-columns: repeat(3, 1fr); }
  .dash { width: 78px; height: 78px; } .evo { top: 110px; }
}
@media (max-width: 380px) { .chip { max-width: 40vw; } .card b { font-size: 1rem; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.rk-list li.muted { grid-column: 1 / -1; white-space: normal; }
