:root {
  --ink: #f4f1e8;
  --muted: #88929f;
  --line: rgba(244, 241, 232, 0.13);
  --panel: #171e28;
  --panel-light: #222c38;
  --lime: #d9fa74;
  --orange: #ff7a5c;
  --blue: #7ab9ff;
  --bg: #10161f;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; overflow: hidden; background: #090d12; color: var(--ink); font-family: "Space Grotesk", "Malgun Gothic", sans-serif; }
button { font: inherit; }
.app-shell { min-height: 100vh; overflow: hidden; position: relative; background: var(--bg); }
.screen { min-height: 100vh; position: relative; overflow: hidden; }
.hidden { display: none !important; }
.eyebrow { color: var(--lime); font: 500 13px/1.3 "DM Mono", monospace; letter-spacing: .17em; }
.eyebrow span, .brand span, h1 span { color: var(--orange); }

/* Start */
.start-screen { background: #0d131b; display: grid; place-items: center; isolation: isolate; }
.start-content { position: relative; z-index: 2; width: min(720px, 88vw); padding: 7vh 0 10vh; }
.start-content h1 { margin: 18px 0 24px; color: var(--ink); font-size: clamp(62px, 11vw, 148px); line-height: .8; letter-spacing: -.095em; font-weight: 600; }
.start-content h1 span { letter-spacing: -.11em; }
.start-copy { color: #aab3bb; font-size: 17px; line-height: 1.6; letter-spacing: -.03em; }
.primary-button { border: 0; background: var(--lime); color: #141a1d; min-width: 205px; margin-top: 32px; padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; font-size: 14px; font-weight: 700; letter-spacing: .08em; transition: transform .2s, background .2s; }
.primary-button:hover { transform: translateY(-3px); background: #e7ff99; }
.button-arrow { font-size: 21px; line-height: 10px; font-weight: 400; }
.start-meta { display: flex; align-items: center; gap: 15px; margin-top: 23px; color: #65717d; font: 12px "DM Mono", monospace; letter-spacing: .1em; }
.start-meta i { width: 4px; height: 4px; background: var(--orange); border-radius: 50%; }
.start-footer { position: absolute; bottom: 30px; left: 5.5vw; right: 5.5vw; display: flex; justify-content: space-between; color: #515d68; font: 12px "DM Mono", monospace; letter-spacing: .1em; border-top: 1px solid var(--line); padding-top: 14px; }
.orbit { position: absolute; border: 1px solid rgba(217,250,116,.15); border-radius: 50%; pointer-events: none; }
.orbit-one { width: min(70vw, 900px); height: min(70vw, 900px); right: -20vw; top: -12vh; }
.orbit-two { width: min(43vw, 560px); height: min(43vw, 560px); left: -14vw; bottom: -21vh; border-color: rgba(255,122,92,.12); }
.floating-number { position: absolute; color: #65717d; font: 500 clamp(18px, 2.5vw, 28px) "DM Mono", monospace; opacity: .68; animation: drift 7s ease-in-out infinite; }
.n-one { left: 12%; top: 20%; color: var(--orange); transform: rotate(-12deg); }
.n-two { right: 19%; top: 25%; animation-delay: -2s; }
.n-three { left: 17%; bottom: 26%; animation-delay: -4s; }
.n-four { right: 9%; bottom: 27%; color: var(--blue); animation-delay: -1s; }
.n-five { right: 29%; bottom: 14%; animation-delay: -5s; }
@keyframes drift { 0%,100% { translate: 0 0; } 50% { translate: 0 -15px; } }

/* Game */
.game-screen { height: 100vh; min-height: 100vh; overflow: hidden; background: #10161f; padding: 0 5vw; }
.game-header { height: 82px; display: grid; grid-template-columns: 1fr minmax(300px, 520px) 1fr; align-items: center; border-bottom: 1px solid var(--line); }
.brand { color: var(--ink); font-size: 17px; letter-spacing: -.07em; font-weight: 700; }
.progress-wrap { justify-self: center; width: 100%; }
.progress-label { display: flex; justify-content: flex-start; align-items: center; margin-bottom: 0; color: #ffffff; font: 14px "DM Mono", monospace; letter-spacing: .1em; }
.round-status { display: flex; align-items: center; color: #ffffff; }
.question-label { display: none; }
.progress-label span:first-child { color: var(--lime); }
.round-status { color: #ffffff; }
.round-status #round-label { color: #ffffff; font-size: 22px; font-weight: 500; letter-spacing: .04em; }
.header-actions { justify-self: end; color: #ffffff; display: flex; align-items: center; gap: 8px; font: 12px "DM Mono", monospace; letter-spacing: .08em; }
.timer-display { display: flex; align-items: baseline; gap: 6px; margin-left: 24px; color: #ffffff; font: 13px "DM Mono", monospace; letter-spacing: .1em; }
.timer-display span, .timer-display em { color: #ffffff; }
.timer-display strong { min-width: 52px; color: #ffffff; font: 500 38px/1 "DM Mono", monospace; text-align: right; letter-spacing: -.06em; }
.timer-display strong.urgent { color: #ffffff; }
.timer-display em { font-style: normal; }
.status-dot { width: 6px; height: 6px; background: var(--lime); border-radius: 50%; box-shadow: 0 0 10px var(--lime); }
.icon-button { margin-left: 22px; border: 1px solid var(--line); background: transparent; color: #ffffff; width: 32px; height: 32px; font-size: 23px; font-weight: 300; cursor: pointer; line-height: 1; }
.game-main { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(260px, 40vh) minmax(150px, 1fr) minmax(80px, 120px); gap: 16px; height: calc(100vh - 137px); min-height: 0; max-width: 1300px; margin: 18px auto 0; }
.graph-stage { position: relative; grid-column: 1; grid-row: 1; min-height: 0; overflow: hidden; border: 1px solid var(--line); background: #0d141c; z-index: 2; }
.player-graph-panel { grid-column: 2; grid-row: 1; opacity: 1; z-index: 1; }
.player-graph-panel.is-visible { opacity: 1; }
.stage-label { position: absolute; z-index: 2; left: 18px; top: 16px; display: flex; gap: 15px; color: #ffffff; font: 12px "DM Mono", monospace; letter-spacing: .1em; }
.stage-label span { color: #ffffff; }
.graph-reset-button { position: absolute; z-index: 2; top: 12px; right: 14px; padding: 6px 9px; border: 1px solid #596570; background: rgba(13,20,28,.86); color: #ffffff; cursor: pointer; font: 12px "DM Mono", monospace; letter-spacing: .05em; }
.graph-reset-button:hover { border-color: var(--lime); background: var(--lime); color: #141a1d; }
.graph-point-tooltip { position: absolute; z-index: 3; display: none; padding: 4px 6px; background: #ffffff; color: #141a1d !important; pointer-events: none; font: 11px "DM Mono", monospace; white-space: nowrap; }
.graph-point-tooltip.is-visible { display: block; }
#graph-canvas, #player-graph-canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#graph-canvas.is-panning, #player-graph-canvas.is-panning { cursor: grabbing; }
.graph-coordinates { position: absolute; right: 16px; bottom: 14px; left: 16px; display: flex; justify-content: space-between; color: #ffffff; font: 13px "DM Mono", monospace; }
.equation-card { grid-column: 1 / -1; grid-row: 2 / 4; border: 1px solid var(--line); background: var(--panel); padding: 14px 18px; display: flex; flex-direction: column; min-height: 0; }
.card-kicker { display: flex; justify-content: space-between; color: #ffffff; font: 12px "DM Mono", monospace; letter-spacing: .1em; }
#answer-state { color: var(--orange); }
.equation-slots { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 12px 0; min-height: 48px; padding: 9px 13px; border: 1px dashed #596570; background: rgba(255,255,255,.02); }
.eq-symbol { color: #d6dce0; font: 500 25px "DM Mono", monospace; }
.equation-slots.drop-ready { border-color: var(--lime); background: rgba(217,250,116,.06); }
.equation-placeholder { color: #ffffff; font: 13px "DM Mono", monospace; letter-spacing: .04em; }
.placed-token { border: 0; padding: 5px 8px; background: var(--panel-light); color: var(--lime); cursor: pointer; font: 500 20px "DM Mono", monospace; }
.placed-token:hover { color: #141a1d; background: var(--lime); }
.equation-hint { color: #ffffff; font-size: 13px; line-height: 1.35; }
.equation-hint strong { color: var(--ink); font-weight: 500; }
.check-button { width: 100%; margin-top: 12px; padding: 10px 13px; display: flex; justify-content: space-between; background: transparent; color: var(--lime); border: 1px solid #677742; cursor: pointer; font: 13px "DM Mono", monospace; letter-spacing: .04em; transition: .2s; }
.check-button:hover:not(:disabled) { background: var(--lime); color: #141a1d; }
.check-button:disabled { opacity: .35; cursor: not-allowed; }
.token-panel { min-height: 0; overflow: hidden; border-top: 1px solid var(--line); margin-top: 12px; padding: 12px 0 8px; }
.token-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 17px; }
.token-heading > div { display: flex; align-items: center; gap: 13px; }
.section-number { color: var(--orange); font: 13px "DM Mono", monospace; }
.token-heading h2 { margin: 0; color: var(--ink); font-size: 18px; font-weight: 500; letter-spacing: -.02em; }
.token-heading p { margin: 0; color: #ffffff; font-size: 14px; }
.token-tray { display: flex; gap: 10px; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; padding-bottom: 5px; scrollbar-color: #596570 transparent; }
.token { flex: 0 0 auto; min-width: 70px; height: 50px; padding: 0 16px; display: inline-flex; justify-content: center; align-items: center; background: var(--panel-light); border: 1px solid #35414d; color: var(--ink); cursor: pointer; user-select: none; font: 500 20px "DM Mono", monospace; transition: transform .18s, border .18s, opacity .18s; }
.token:hover { border-color: var(--lime); transform: translateY(-3px); }
.token.used { opacity: .2; cursor: default; transform: none; }
.feedback { position: fixed; z-index: 5; top: 106px; left: 50%; transform: translateX(-50%) translateY(-15px); opacity: 0; pointer-events: none; padding: 11px 18px; font: 13px "DM Mono", monospace; letter-spacing: .05em; transition: .25s; }
.feedback.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.feedback.success { color: #162016; background: var(--lime); }
.feedback.error { color: #fff1ed; background: var(--orange); }
.ranking-status { position: fixed; z-index: 10; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 10px 16px; border: 1px solid var(--line); background: #171e28; color: #ffffff; font: 13px "DM Mono", monospace; white-space: nowrap; }
.ranking-status:empty { display: none; }
.timeover-overlay { position: fixed; z-index: 8; inset: 0; display: grid; place-items: center; background: rgba(9,13,18,.83); backdrop-filter: blur(7px); }
.timeover-card { width: min(460px, 86vw); padding: 35px; border: 1px solid rgba(255,122,92,.5); background: #171e28; box-shadow: 0 20px 80px rgba(0,0,0,.35); }
.timeover-card h2 { margin: 35px 0 20px; font-size: clamp(58px, 9vw, 102px); line-height: .78; letter-spacing: -.09em; }
.timeover-card h2 em { color: var(--orange); font-style: normal; }
.timeover-card > p:not(.eyebrow) { color: #a1aab1; font-size: 13px; line-height: 1.6; }
.timeover-card .primary-button { margin-top: 28px; }
.game-footer { display: flex; justify-content: space-between; max-width: 1300px; margin: 10px auto 0; color: #ffffff; font: 12px "DM Mono", monospace; letter-spacing: .05em; }

/* Result */
.result-screen { display: grid; place-items: center; background: #11171f; }
.result-grid { position: absolute; inset: 0; opacity: .33; background-image: linear-gradient(rgba(217,250,116,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(217,250,116,.08) 1px, transparent 1px); background-size: 60px 60px; mask-image: linear-gradient(to right, black, transparent 75%); }
.result-content { position: relative; width: min(550px, 82vw); z-index: 1; }
.result-mark { color: var(--lime); font: 60px "DM Mono", monospace; margin: 40px 0 12px; }
.result-content h2 { margin: 0; font-size: clamp(60px, 10vw, 120px); letter-spacing: -.09em; line-height: .8; font-weight: 600; }
.result-content h2 em { color: var(--orange); font-style: normal; }
.result-content > p:not(.eyebrow) { color: #9aa5ae; margin: 27px 0; }
.result-stats { display: flex; gap: 35px; padding: 20px 0; border-top: 1px solid var(--line); }
.result-stats div { display: flex; flex-direction: column; gap: 7px; }
.result-stats strong { color: var(--ink); font: 24px "DM Mono", monospace; }
.result-stats span { color: #687681; font: 9px "DM Mono", monospace; letter-spacing: .05em; }
.result-orbit { position: absolute; width: 650px; height: 650px; right: -200px; top: 10%; border: 1px solid rgba(255,122,92,.2); border-radius: 50%; box-shadow: inset 0 0 0 80px rgba(255,122,92,.02); }

@media (max-width: 750px) {
  .game-screen { padding: 0 20px; }
  .game-header { height: 82px; grid-template-columns: 1fr auto; gap: 15px; }
  .progress-wrap { grid-row: 2; grid-column: 1 / -1; margin-bottom: 8px; }
  .header-actions { font-size: 0; }
  .game-main { grid-template-columns: 1fr; grid-template-rows: minmax(130px, 21vh) minmax(130px, 21vh) minmax(150px, 1fr) minmax(74px, 96px); height: calc(100vh - 102px); margin-top: 12px; gap: 10px; }
  .graph-stage { grid-column: 1; grid-row: 1; min-height: 0; }
  .player-graph-panel { grid-column: 1; grid-row: 2; }
  .equation-card { grid-row: 3 / 5; }
  .equation-card { min-height: 0; padding: 12px; }
  .equation-slots { margin: 10px 0; min-height: 44px; }
  .token-heading { align-items: start; flex-direction: column; gap: 8px; }
  .token-heading p { font-size: 12px; }
  .game-footer { display: none; }
  .game-footer span:first-child { max-width: 70%; }
  .start-footer { gap: 12px; flex-wrap: wrap; font-size: 10px; }
  .floating-number { opacity: .35; }
  .result-content h2 { font-size: 72px; }
  .result-stats { gap: 15px; }
  .result-stats strong { font-size: 19px; }
  .result-stats span { font-size: 10px; }
}

/* Text across the interface uses a single white tone. */
body, body * { color: #ffffff !important; }
button:hover:not(:disabled), button:hover:not(:disabled) * { color: #000000 !important; }
.primary-button, .primary-button *, .feedback.success, .feedback.success * { color: #000000 !important; }
