:root {
  color-scheme: dark;
  --ink: #0b0d0d;
  --panel: rgba(19, 25, 21, 0.88);
  --panel-strong: rgba(13, 18, 15, 0.97);
  --line: rgba(111, 137, 101, 0.34);
  --muted: #929b8e;
  --text: #f5f6ef;
  --lime: #b4ff19;
  --moss: #6f9f5e;
  --amber: #e5ad2a;
  --danger: #e8482e;
  --mono: "Space Mono", ui-monospace, monospace;
  --body: "Barlow Condensed", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--ink); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  font-family: var(--body);
  background:
    repeating-linear-gradient(118deg, transparent 0 108px, rgba(180, 255, 25, .05) 109px 110px, transparent 111px 216px),
    linear-gradient(90deg, rgba(180, 255, 25, .018) 1px, transparent 1px),
    radial-gradient(circle at 74% 12%, #1d2b1b 0, #111712 38%, #0b0d0d 78%);
  background-size: auto, 42px 42px, auto;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(5, 8, 6, .7), transparent 15%, transparent 85%, rgba(5, 8, 6, .7));
}
button, input { color: inherit; font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 3px solid var(--lime); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: fixed; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.ambient { position: fixed; width: 32rem; height: 32rem; border-radius: 50%; filter: blur(110px); opacity: .1; pointer-events: none; }
.ambient-one { top: -12rem; right: -8rem; background: var(--moss); }
.ambient-two { bottom: -14rem; left: -10rem; background: var(--lime); }
.app-shell { position: relative; z-index: 1; width: min(1440px, calc(100% - 64px)); min-height: calc(100vh - 60px); margin: 0 auto; }

.brand-bar { height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; border: 1px solid #314331; border-top: 0; background: linear-gradient(105deg, #162019e6, #0d1210e8 55%, #182419d9); }
.brand { display: inline-flex; align-items: center; gap: 13px; padding: 0; color: #fff; background: transparent; font-size: 14px; font-weight: 800; letter-spacing: .14em; }
.brand b { color: var(--lime); }
.brand-mark { position: relative; width: 27px; height: 27px; display: inline-grid; place-items: center; transform: rotate(45deg); border: 1px solid var(--lime); box-shadow: 0 0 18px rgba(180, 255, 25, .2); }
.brand-mark i { position: absolute; width: 4px; height: 4px; background: #fff; }
.brand-mark i:nth-child(1) { transform: translate(-5px, -5px); }
.brand-mark i:nth-child(2) { transform: translate(5px, -5px); }
.brand-mark i:nth-child(3) { transform: translate(5px, 5px); background: var(--lime); }
.network-pill { display: flex; align-items: center; gap: 8px; color: #aab3a6; font: 8px var(--mono); letter-spacing: .14em; }
.network-pill span, .status-ready i { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 10px var(--lime); }

.screen { min-height: calc(100vh - 136px); }
.screen-home { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); align-items: center; gap: 70px; padding: 80px 7%; }
.eyebrow { display: flex; align-items: center; gap: 10px; color: #9ca597; font: 9px var(--mono); letter-spacing: .16em; }
.eyebrow span { color: var(--lime); }
.hero-copy h1 { margin: 28px 0 20px; max-width: 760px; font-size: clamp(64px, 7vw, 112px); line-height: .82; letter-spacing: -.055em; text-transform: uppercase; }
.hero-copy h1 em { color: var(--lime); font-style: normal; }
.hero-copy > p { max-width: 560px; color: var(--muted); font: 12px/1.9 var(--mono); }
.hero-actions { margin-top: 36px; }
.theme-picker-label { display: block; margin-bottom: 10px; color: #84907e; font: 8px var(--mono); letter-spacing: .14em; }
.theme-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 210px)); gap: 10px; }
.theme-card { position: relative; min-height: 118px; display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 16px; border: 1px solid #50624e; color: var(--text); text-align: left; background: rgba(19, 28, 20, .9); }
.theme-card:hover { border-color: var(--lime); background: rgba(180, 255, 25, .08); transform: translateY(-2px); }
.theme-card span, .theme-card small { color: #8a9685; font: 8px var(--mono); letter-spacing: .1em; }
.theme-card strong { grid-column: 1; margin: 8px 0 3px; color: var(--lime); font-size: 27px; line-height: .8; }
.theme-card b { grid-column: 2; grid-row: 1 / span 3; color: var(--lime); font: 22px var(--mono); }
.primary-button, .secondary-button { min-height: 50px; display: inline-flex; align-items: center; justify-content: space-between; gap: 28px; padding: 0 20px; font: 700 11px var(--mono); letter-spacing: .08em; }
.primary-button { color: #11170e; background: var(--lime); box-shadow: 0 0 24px rgba(180, 255, 25, .12); }
.primary-button:hover:not(:disabled) { background: #c5ff4d; }
.primary-button b { font-size: 18px; }
.secondary-button { border: 1px solid #50624e; color: var(--text); background: #182019; }
.secondary-button:hover:not(:disabled) { border-color: var(--lime); }
.compact { min-width: 150px; }
.text-button { min-height: 44px; padding: 8px; color: #aeb7aa; background: transparent; font: 700 9px var(--mono); letter-spacing: .12em; }
.text-button:hover { color: var(--lime); }
.icon-button { width: 44px; height: 44px; border: 1px solid var(--line); color: var(--lime); background: rgba(13, 18, 15, .82); font: 18px var(--mono); }
.run-meta { max-width: 620px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 54px; border: 1px solid var(--line); background: var(--line); }
.run-meta > div { padding: 16px; background: rgba(11, 13, 13, .88); }
.run-meta small, .game-topbar small, .result-stats span { display: block; color: #717c6d; font: 7px var(--mono); letter-spacing: .12em; }
.run-meta strong { display: flex; align-items: center; gap: 7px; margin-top: 7px; font: 600 17px var(--mono); }
.run-meta strong span { color: #596253; font-size: 9px; }
.status-ready { color: var(--lime); font-size: 11px !important; }

.hero-grid { position: relative; min-height: 520px; isolation: isolate; }
.orbit { position: absolute; z-index: 0; inset: 50%; border: 1px solid rgba(180, 255, 25, .17); border-radius: 50%; transform: translate(-50%, -50%); }
.orbit-outer { width: 440px; height: 440px; }
.orbit-inner { width: 270px; height: 270px; border-style: dashed; }
.hero-tile { position: absolute; z-index: 1; width: 100px; height: 100px; display: grid; place-items: center; border: 1px solid var(--lime); color: #172016; background: var(--lime); font-size: 58px; font-weight: 800; box-shadow: 0 0 28px rgba(180, 255, 25, .12); }
.tile-r { top: calc(50% - 200px); left: calc(50% - 50px); }
.tile-a { top: calc(50% - 96px); left: calc(50% + 93px); }
.tile-i { top: calc(50% + 71px); left: calc(50% + 38px); }
.tile-k { top: calc(50% + 71px); left: calc(50% - 138px); }
.tile-u { top: calc(50% - 96px); left: calc(50% - 193px); }
.hero-character-sticker { position: absolute; z-index: 3; top: 55%; left: 50%; width: clamp(250px, 28vw, 330px); pointer-events: none; transform: translate(-50%, -50%); filter: drop-shadow(0 18px 25px rgba(0, 0, 0, .38)); }
.hero-character-sticker::before, .hero-character-sticker::after { content: "✦"; position: absolute; z-index: 4; color: #fff; font: 22px var(--mono); text-shadow: 0 0 14px var(--lime); animation: hero-sparkle 2.6s ease-in-out infinite; }
.hero-character-sticker::before { top: 8%; left: 7%; }
.hero-character-sticker::after { right: 5%; bottom: 13%; animation-delay: -1.3s; }
.hero-character-overlay { display: block; width: 100%; height: auto; pointer-events: none; user-select: none; }
.scan-label { position: absolute; z-index: 4; right: 5%; bottom: 16%; color: var(--lime); font: 8px/1.6 var(--mono); letter-spacing: .15em; }

@keyframes hero-sparkle {
  0%, 100% { opacity: .2; transform: scale(.6) rotate(0); }
  50% { opacity: 1; transform: scale(1.15) rotate(24deg); }
}

.section-heading { display: flex; align-items: end; justify-content: space-between; padding: 58px 4% 30px; }
.section-heading h2 { margin: 12px 0 0; font-size: clamp(46px, 6vw, 78px); line-height: .9; text-transform: uppercase; }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; padding: 0 4% 70px; }
.level-card { min-height: 190px; display: flex; flex-direction: column; align-items: flex-start; padding: 18px; border: 1px solid var(--line); color: var(--text); text-align: left; background: linear-gradient(145deg, rgba(30, 43, 30, .88), rgba(12, 17, 14, .94)); }
.level-card:not(:disabled):hover { border-color: var(--lime); transform: translateY(-2px); }
.level-card .level-number { color: var(--lime); font: 28px var(--mono); }
.level-card h3 { margin: auto 0 5px; font-size: 21px; text-transform: uppercase; }
.level-card small { color: var(--muted); font: 7px var(--mono); letter-spacing: .08em; }
.level-card.is-complete { border-color: rgba(180, 255, 25, .55); }
.level-card.is-locked { filter: grayscale(1); }

.game-topbar { min-height: 70px; display: grid; grid-template-columns: 50px 80px 1fr 100px 100px; align-items: center; gap: 10px; margin-top: 20px; padding: 10px 14px; border: 1px solid var(--line); background: var(--panel-strong); }
.game-topbar > div { padding-left: 14px; border-left: 1px solid var(--line); }
.game-topbar strong { display: block; margin-top: 4px; color: var(--lime); font: 700 14px var(--mono); }
.game-topbar .game-title strong { color: var(--text); font-family: var(--body); font-size: 19px; text-transform: uppercase; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 430px; gap: 14px; padding: 14px 0 50px; }
.board-column { min-width: 0; }
.active-clue { min-height: 50px; display: flex; align-items: center; padding: 12px 18px; border: 1px solid var(--line); border-bottom: 0; color: var(--text); background: #121914; font: 600 17px/1.25 var(--body); }
.canvas-frame { position: relative; overflow: hidden; border: 1px solid #425442; background: radial-gradient(circle at 50% 100%, rgba(180,255,25,.1), transparent 35%), repeating-linear-gradient(118deg, transparent 0 96px, rgba(180,255,25,.025) 97px 98px, transparent 99px 192px), #080a09; box-shadow: inset 0 0 65px rgba(1,4,14,.7), 0 20px 60px rgba(0,0,0,.25); }
.canvas-frame::before { content: ""; position: absolute; inset: 10px; border: 1px solid rgba(180,255,25,.07); pointer-events: none; }
#game-canvas { display: block; width: 100%; height: min(62vh, 650px); min-height: 430px; touch-action: manipulation; cursor: pointer; }
.game-controls { display: flex; gap: 10px; padding-top: 12px; }
.letter-entry { min-width: 112px; display: grid; grid-template-columns: 1fr 50px; align-items: center; border: 1px solid var(--line); background: #111712; }
.letter-entry span { padding-left: 14px; color: #7f897b; font: 8px var(--mono); letter-spacing: .12em; }
.letter-entry input { width: 50px; height: 48px; border: 0; border-left: 1px solid var(--line); outline: 0; color: var(--lime); text-align: center; text-transform: uppercase; background: #0c100d; font: 700 24px var(--mono); }
.game-controls button { flex: 1; }
.game-message { min-height: 20px; margin: 9px 2px 0; color: var(--muted); font: 9px/1.5 var(--mono); }

.deck-panel { border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(12px); }
.clue-panel { min-width: 0; padding: 18px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding-bottom: 13px; border-bottom: 1px solid var(--line); color: #b6beb2; font: 8px var(--mono); letter-spacing: .13em; }
.panel-heading small { color: var(--lime); }
.clue-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-height: calc(62vh + 112px); overflow: auto; padding-top: 6px; }
.clue-columns h3 { position: sticky; top: 0; z-index: 1; margin: 0; padding: 14px 4px 9px; color: var(--lime); background: #111712; font: 700 12px var(--mono); letter-spacing: .09em; }
.clue-list { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.clue-button { width: 100%; min-height: 48px; display: grid; grid-template-columns: 28px 1fr; gap: 8px; align-items: start; padding: 10px 8px; border-left: 2px solid transparent; color: #b5bdb1; text-align: left; background: transparent; font-size: 15px; line-height: 1.15; }
.clue-button b { color: #707b6d; font: 9px var(--mono); }
.clue-button:hover, .clue-button.is-active { border-left-color: var(--lime); color: #fff; background: rgba(180, 255, 25, .07); }
.clue-button.is-correct { color: var(--moss); }
.clue-button.is-correct b::after { content: " ✓"; color: var(--lime); }

.screen-result { display: grid; place-items: center; padding: 50px 20px; }
.result-card { width: min(620px, 100%); padding: 40px; text-align: center; }
.result-glyph { width: 74px; height: 74px; display: grid; place-items: center; margin: 0 auto 24px; border: 1px solid var(--lime); border-radius: 50%; color: var(--lime); font: 32px var(--mono); box-shadow: 0 0 30px rgba(180, 255, 25, .15); }
.result-card .eyebrow { justify-content: center; }
.result-card h2 { margin: 20px 0 8px; font-size: 48px; text-transform: uppercase; }
.result-card > p { color: var(--muted); font: 10px var(--mono); }
.result-score { margin: 30px 0; padding: 22px; border-block: 1px solid var(--line); }
.result-score small { display: block; color: #727d6f; font: 8px var(--mono); letter-spacing: .13em; }
.result-score strong { display: block; margin-top: 8px; color: var(--lime); font: 34px var(--mono); }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); }
.result-stats > div { padding: 14px 8px; background: #111712; }
.result-stats strong { display: block; margin-top: 7px; font: 15px var(--mono); }
.result-actions { display: grid; grid-template-columns: 1fr 1.5fr; gap: 10px; margin-top: 25px; }
.result-card > .text-button { margin-top: 12px; }
.footer-bar { position: relative; z-index: 1; min-height: 38px; display: flex; align-items: center; justify-content: space-between; width: min(1440px, calc(100% - 64px)); margin: 0 auto; color: #515b4f; font: 7px var(--mono); letter-spacing: .12em; }

@media (max-width: 1050px) {
  .screen-home { grid-template-columns: 1fr; padding-block: 64px; }
  .hero-grid { display: none; }
  .level-grid { grid-template-columns: repeat(3, 1fr); }
  .game-layout { grid-template-columns: 1fr; }
  .clue-columns { max-height: none; }
}

@media (max-width: 680px) {
  .app-shell, .footer-bar { width: calc(100% - 24px); }
  .brand-bar { height: 62px; }
  .screen { min-height: calc(100vh - 112px); }
  .screen-home { padding: 60px 10px; }
  .hero-copy h1 { font-size: clamp(50px, 16vw, 78px); }
  .theme-picker { grid-template-columns: 1fr; max-width: 360px; }
  .run-meta { grid-template-columns: 1fr; }
  .section-heading { padding: 42px 4px 22px; }
  .level-grid { grid-template-columns: repeat(2, 1fr); padding-inline: 0; }
  .level-card { min-height: 150px; }
  .game-topbar { grid-template-columns: 44px 54px 1fr 62px; gap: 4px; margin-top: 10px; padding-inline: 6px; }
  .game-topbar > div { padding-left: 7px; }
  .game-topbar > div:last-child { display: none; }
  .game-topbar .game-title strong { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .game-layout { padding-top: 8px; }
  #game-canvas { height: min(66vw, 500px); min-height: 330px; }
  .game-controls { display: grid; grid-template-columns: 94px 1fr 1fr; }
  .game-controls button { min-width: 0; gap: 5px; padding-inline: 9px; font-size: 8px; }
  .letter-entry { min-width: 0; grid-template-columns: 1fr 44px; }
  .letter-entry span { padding-left: 8px; }
  .letter-entry input { width: 44px; }
  .clue-columns { grid-template-columns: 1fr; }
  .result-card { padding: 28px 16px; }
  .result-card h2 { font-size: 38px; }
  .result-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
  .hero-character-overlay { animation: none !important; }
}
