:root {
  color-scheme: dark;
  --ink: #eef2ff;
  --muted: #a8b0c8;
  --panel: rgba(20, 25, 43, 0.88);
  --line: rgba(255, 255, 255, 0.1);
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --danger: #fb7185;
  --success: #4ade80;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(139, 92, 246, .2), transparent 32rem),
    radial-gradient(circle at 85% 20%, rgba(34, 211, 238, .12), transparent 28rem),
    #080b14;
  font: 16px/1.65 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; }
.shell { width: min(1160px, calc(100% - 32px)); margin: 0 auto; }
.nav { display: flex; align-items: center; justify-content: space-between; min-height: 72px; gap: 24px; }
.brand { text-decoration: none; font-weight: 900; letter-spacing: -.04em; font-size: 1.15rem; }
.brand span { color: var(--accent-2); }
.nav-links { display: flex; flex-wrap: wrap; gap: 18px; color: var(--muted); font-size: .92rem; }
.nav-links a { text-decoration: none; }
.nav-links a:hover { color: white; }
.hero { padding: 76px 0 56px; display: grid; grid-template-columns: 1.15fr .85fr; gap: 48px; align-items: center; }
.eyebrow { color: var(--accent-2); text-transform: uppercase; letter-spacing: .16em; font-size: .78rem; font-weight: 800; }
h1, h2, h3 { line-height: 1.08; letter-spacing: -.04em; }
h1 { font-size: clamp(3rem, 7vw, 6.4rem); margin: 14px 0 20px; }
h2 { font-size: clamp(2rem, 4vw, 3.4rem); margin: 0 0 18px; }
h3 { font-size: 1.3rem; }
.lead { color: var(--muted); font-size: 1.12rem; max-width: 660px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 30px; }
.button, button {
  appearance: none; border: 1px solid var(--line); border-radius: 12px; padding: 11px 17px;
  color: white; background: rgba(255,255,255,.06); font: inherit; font-weight: 750; cursor: pointer;
  text-decoration: none; transition: .18s ease;
}
.button:hover, button:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.28); background: rgba(255,255,255,.1); }
.button.primary, button.primary { border: 0; background: linear-gradient(120deg, var(--accent), #6366f1); box-shadow: 0 12px 32px rgba(99,102,241,.25); }
.hero-card, .card, .content-panel, .game-panel {
  border: 1px solid var(--line); background: var(--panel); box-shadow: 0 24px 80px rgba(0,0,0,.28); border-radius: 24px;
}
.hero-card { padding: 20px; transform: rotate(1.5deg); }
.mini-board { aspect-ratio: 1; border-radius: 18px; background: #0d1324; position: relative; overflow: hidden; }
.mini-board::before { content: "↗  ←  ↘\A ↑  ↙  →\A ↖  ↓  ↗"; white-space: pre; position: absolute; inset: 12%; display: grid; place-items: center; font-size: clamp(2rem, 6vw, 4.7rem); line-height: 1.55; color: #c4b5fd; text-shadow: 0 0 22px rgba(139,92,246,.7); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.stat { background: rgba(255,255,255,.04); border-radius: 14px; padding: 12px; text-align: center; }
.stat strong { display: block; font-size: 1.35rem; }
.stat span { color: var(--muted); font-size: .75rem; }
.section { padding: 56px 0; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.card { padding: 24px; }
.card p { color: var(--muted); }
.ad-slot { margin: 28px auto; min-height: 96px; border: 1px dashed rgba(255,255,255,.18); border-radius: 18px; color: #6f7894; display: grid; place-items: center; text-align: center; }
.content-panel { max-width: 860px; margin: 42px auto 72px; padding: clamp(24px, 5vw, 56px); }
.content-panel p, .content-panel li { color: #bdc4d8; }
.content-panel h2 { margin-top: 42px; font-size: 2rem; }
.error-panel { margin-top: 12vh; text-align: center; }
.error-panel h1 { font-size: clamp(2.8rem, 7vw, 5.6rem); }
.error-panel .lead { margin-inline: auto; }
.error-panel .actions { justify-content: center; }
.footer { border-top: 1px solid var(--line); color: var(--muted); padding: 32px 0 50px; font-size: .9rem; }

.game-page .shell { width: min(1320px, calc(100% - 20px)); }
.game-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr) 250px; gap: 16px; align-items: start; padding-bottom: 48px; }
.game-panel { padding: 16px; }
.controls { display: grid; gap: 12px; }
label { color: var(--muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
select, input {
  width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; background: #0c1120; color: white; font: inherit;
}
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.board-wrap { position: relative; min-width: 0; }
#game-canvas { width: 100%; height: min(76vh, 860px); display: block; border-radius: 18px; background: #090e1b; touch-action: manipulation; }
.hud { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 12px; }
.hud strong { font-size: 1.08rem; }
.pill { border: 1px solid var(--line); background: rgba(255,255,255,.04); padding: 7px 10px; border-radius: 999px; font-size: .84rem; }
.message { min-height: 48px; margin-top: 12px; color: var(--muted); }
.progress-track { height: 8px; border-radius: 999px; overflow: hidden; background: rgba(255,255,255,.07); }
.progress-track i { height: 100%; display: block; width: 0; background: linear-gradient(90deg,var(--accent),var(--accent-2)); transition: width .2s; }
.mode-list { display: grid; gap: 8px; }
.mode-list button { text-align: left; padding: 10px 12px; }
.mode-list button.active { border-color: var(--accent); background: rgba(139,92,246,.18); }
.data-note { color: var(--muted); font-size: .82rem; }
.loading { position: absolute; inset: 52px 0 0; display: grid; place-items: center; background: rgba(8,11,20,.78); border-radius: 18px; font-weight: 800; }
.loading[hidden] { display: none; }

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .hero-card { max-width: 560px; }
  .grid { grid-template-columns: 1fr 1fr; }
  .game-layout { grid-template-columns: 220px minmax(0,1fr); }
  .game-layout > aside:last-child { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .nav { align-items: flex-start; padding: 18px 0; }
  .nav-links { justify-content: flex-end; gap: 10px; }
  .hero { padding-top: 42px; }
  .grid, .game-layout { grid-template-columns: 1fr; }
  .game-layout > aside:first-child { order: 2; }
  .board-wrap { order: 1; }
  .game-layout > aside:last-child { order: 3; }
  #game-canvas { height: 68vh; min-height: 480px; }
}

/* Immersive game UI */
.game-page { background: #070a12; }
.play-screen {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 22px;
  padding: 24px;
  background:
    radial-gradient(circle at 50% -10%, rgba(139,92,246,.24), transparent 34rem),
    radial-gradient(circle at 8% 70%, rgba(34,211,238,.08), transparent 28rem),
    #070a12;
}
.game-shell {
  width: min(720px, 100%);
  padding: 16px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 28px;
  background: linear-gradient(165deg, rgba(25,30,52,.98), rgba(12,16,29,.98));
  box-shadow: 0 36px 100px rgba(0,0,0,.48), inset 0 1px rgba(255,255,255,.06);
}
.game-chrome { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; padding: 2px 2px 12px; }
.level-heading { text-align: center; line-height: 1.15; }
.level-heading span { display: block; color: var(--accent-2); font-size: .72rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.level-heading strong { display: block; margin-top: 4px; font-size: 1.28rem; }
.chrome-actions { display: flex; gap: 8px; }
.icon-button, .round-button {
  display: inline-grid; place-items: center; padding: 0; width: 46px; height: 46px; border-radius: 15px;
  background: rgba(255,255,255,.06); font-size: 1.15rem;
}
.game-stats { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin-bottom: 12px; }
.game-chip { min-width: 92px; padding: 7px 12px; border-radius: 999px; text-align: center; background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.08); color: #dfe5f8; font-size: .84rem; font-weight: 800; }
.life-chip { color: #fb7185; letter-spacing: .12em; }
.game-stats .progress-track { height: 9px; }
.mission-strip { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; margin: -2px 4px 10px; color: #8f9ab7; font-size: .72rem; font-weight: 800; letter-spacing: .04em; }
.mission-strip strong { color: #f8fafc; }
.mission-strip #combo { min-width: 58px; text-align: right; color: #67e8f9; transform-origin: right center; }
.mission-strip #combo.chain-pulse { animation: chain-pulse .28s ease-out; }
.game-shell .board-wrap { padding: 10px; border-radius: 22px; background: #090e1b; box-shadow: inset 0 0 0 1px rgba(255,255,255,.035), inset 0 18px 50px rgba(0,0,0,.28); overflow: hidden; }
.game-shell #game-canvas { height: min(66vh, 720px); min-height: 540px; border-radius: 16px; }
.game-shell #game-canvas.impact-shake { animation: canvas-impact .22s ease-out; }
@keyframes canvas-impact {
  0%,100% { transform: translateX(0); filter: brightness(1); }
  20% { transform: translateX(-3px); filter: brightness(1.24); }
  45% { transform: translateX(4px); }
  70% { transform: translateX(-2px); }
}
.game-toast { min-height: 42px; margin: 10px 4px 6px; padding: 8px 12px; border-radius: 12px; text-align: center; color: #aeb8d1; background: rgba(255,255,255,.035); font-size: .9rem; }
.tutorial-card { position: absolute; left: 50%; bottom: 28px; z-index: 6; width: min(390px, calc(100% - 38px)); transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 13px 16px; border: 1px solid rgba(103,232,249,.35); border-radius: 16px; color: #f8fafc; background: rgba(12,18,34,.92); box-shadow: 0 18px 60px rgba(0,0,0,.38), 0 0 30px rgba(34,211,238,.08); backdrop-filter: blur(10px); animation: tutorial-in .3s ease-out; pointer-events: none; }
.tutorial-card[hidden], .eagle-eye[hidden] { display: none; }
.tutorial-card > span { display: grid; place-items: center; flex: 0 0 38px; height: 38px; border-radius: 12px; color: #081019; background: #67e8f9; font-size: 1.25rem; }
.tutorial-card strong, .tutorial-card small { display: block; }
.tutorial-card small { margin-top: 2px; color: #aeb8d1; line-height: 1.35; }
.combo-flash { position: absolute; inset: 10px; z-index: 5; border-radius: 16px; opacity: 0; pointer-events: none; }
.combo-flash.replay { animation: flow-flash .8s ease-out forwards; }
.combo-flash.unstoppable { --flash-color: 254,240,138; }
@keyframes tutorial-in { from { opacity: 0; transform: translate(-50%, 10px); } }
@keyframes chain-pulse { 0%,100% { transform: scale(1); } 45% { color: #fef08a; transform: scale(1.16); text-shadow: 0 0 18px rgba(103,232,249,.75); } }
@keyframes flow-flash { 0% { opacity: 0; box-shadow: inset 0 0 0 1px rgba(var(--flash-color,103,232,249),0); } 20% { opacity: 1; box-shadow: inset 0 0 44px rgba(var(--flash-color,103,232,249),.22),inset 0 0 0 2px rgba(var(--flash-color,103,232,249),.48); } 100% { opacity: 0; box-shadow: inset 0 0 90px rgba(var(--flash-color,103,232,249),0),inset 0 0 0 1px rgba(var(--flash-color,103,232,249),0); } }
.eagle-eye { position: absolute; left: 50%; top: 50%; z-index: 7; width: 76px; height: 76px; transform: translate(-50%,-50%); display: grid; place-items: center; border: 1px solid rgba(103,232,249,.35); border-radius: 50%; background: radial-gradient(circle,rgba(15,35,53,.75),rgba(8,15,29,.08) 68%,transparent 70%); box-shadow: 0 0 58px rgba(34,211,238,.2); pointer-events: none; }
.eagle-eye.replay { animation: eagle-eye-in 3.55s ease both; }
.eagle-reticle { position: relative; flex: 0 0 42px; height: 42px; border: 2px solid #67e8f9; border-radius: 50%; box-shadow: inset 0 0 14px rgba(34,211,238,.22),0 0 16px rgba(34,211,238,.28); }
.eagle-reticle::before,.eagle-reticle::after { content: ""; position: absolute; background: #67e8f9; }
.eagle-reticle::before { left: 50%; top: -6px; width: 1px; height: 52px; }
.eagle-reticle::after { top: 50%; left: -6px; width: 52px; height: 1px; }
.eagle-reticle i { position: absolute; inset: 13px; border-radius: 50%; background: #fef08a; box-shadow: 0 0 13px #67e8f9; }
.eagle-scan { position: absolute; z-index: 6; left: 10px; right: 10px; top: -18%; height: 18%; opacity: 0; border-bottom: 1px solid rgba(103,232,249,.76); background: linear-gradient(to bottom,transparent,rgba(34,211,238,.13)); pointer-events: none; }
.eagle-scan.replay { animation: eagle-scan 1.3s cubic-bezier(.25,.1,.25,1) forwards; }
@keyframes eagle-eye-in { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.55); } 10%,72% { opacity: 1; transform: translate(-50%,-50%) scale(1); } 82% { opacity: .9; transform: translate(-50%,-50%) scale(1.12); } 100% { opacity: 0; transform: translate(-50%,-50%) scale(.84); } }
@keyframes eagle-scan { 0% { top: -18%; opacity: 0; } 16% { opacity: 1; } 84% { opacity: .8; } 100% { top: 100%; opacity: 0; } }
.power-bar { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; margin-top: 10px; }
.power-button { min-height: 62px; display: flex; align-items: center; justify-content: center; gap: 8px; border-radius: 17px; }
.power-button span { font-size: 1.25rem; }
.power-button strong { font-size: .9rem; }
.primary-power { background: linear-gradient(135deg, #7c3aed, #6366f1); border-color: transparent; }
.play-side { width: 260px; padding: 26px 22px; position: sticky; top: 24px; border: 1px solid var(--line); border-radius: 24px; background: rgba(18,23,40,.82); box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.play-side p { color: var(--muted); font-size: .9rem; }
.play-side nav { display: grid; gap: 8px; }
.play-side nav a { padding: 10px 0; color: #c4cbe0; text-decoration: none; border-bottom: 1px solid var(--line); }
.compact-ad { min-height: 120px; font-size: .78rem; }
.pause-overlay { position: absolute; inset: 10px; z-index: 8; display: grid; place-items: center; border-radius: 16px; background: rgba(7,10,18,.88); backdrop-filter: blur(12px); text-align: center; }
.pause-overlay[hidden] { display: none; }
.pause-overlay span { display: block; color: var(--accent-2); font-size: 2rem; }
.pause-overlay h2 { margin: 8px 0 18px; font-size: 2rem; }
.celebration { position: absolute; inset: 10px; z-index: 7; display: grid; place-content: center; justify-items: center; gap: 10px; border-radius: 16px; background: rgba(8,12,22,.72); backdrop-filter: blur(5px); animation: celebration-in .35s ease-out; }
.celebration[hidden] { display: none; }
.celebration span { display: grid; place-items: center; width: 82px; height: 82px; border-radius: 50%; color: #07150d; background: #4ade80; font-size: 2.8rem; box-shadow: 0 0 50px rgba(74,222,128,.45); }
.celebration strong { font-size: 2rem; }
.celebration small { color: rgba(255,255,255,.72); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.result-overlay { position: absolute; inset: 10px; z-index: 10; display: grid; place-items: center; padding: 20px; border-radius: 16px; background: rgba(5,8,16,.82); backdrop-filter: blur(10px); animation: celebration-in .25s ease-out; }
.result-overlay[hidden] { display: none; }
.result-card { width: min(360px, 100%); padding: 26px; border: 1px solid rgba(255,255,255,.12); border-radius: 24px; background: linear-gradient(155deg, rgba(30,41,70,.98), rgba(12,17,31,.98)); box-shadow: 0 24px 70px rgba(0,0,0,.5); text-align: center; }
.result-icon { display: grid; place-items: center; width: 70px; height: 70px; margin: 0 auto 14px; border-radius: 50%; color: white; background: linear-gradient(145deg,#fb7185,#e11d48); font-size: 2.8rem; line-height: 1; box-shadow: 0 0 40px rgba(244,63,94,.32); }
.success-icon { color: #052e1a; background: linear-gradient(145deg,#86efac,#22c55e); box-shadow: 0 0 45px rgba(74,222,128,.38); }
.result-card > p { margin: 0; color: #fb7185; font-size: .72rem; font-weight: 900; letter-spacing: .18em; }
.result-card .result-explanation { margin: 0 0 18px; color: #aeb8d1; font-size: .88rem; font-weight: 500; letter-spacing: 0; line-height: 1.5; }
.result-card h2 { margin: 6px 0 18px; font-size: 2rem; }
.result-action { width: 100%; }
.result-stars { margin: -5px 0 18px; color: #facc15; font-size: 2rem; letter-spacing: .12em; text-shadow: 0 0 24px rgba(250,204,21,.25); }
.result-stars .empty { color: rgba(255,255,255,.15); text-shadow: none; }
.result-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 14px; }
.result-stats div { padding: 11px 6px; border-radius: 13px; background: rgba(255,255,255,.045); }
.result-stats strong, .result-stats span { display: block; }
.result-stats strong { color: white; font-size: 1rem; }
.result-stats span { margin-top: 3px; color: #8792ad; font-size: .64rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.best-banner { margin: 0 0 14px; padding: 8px; border-radius: 10px; color: #86efac; background: rgba(34,197,94,.1); font-size: .76rem; font-weight: 900; letter-spacing: .05em; text-transform: uppercase; }
.best-banner[hidden] { display: none; }
.unlock-banner { margin: 0 0 12px; padding: 10px; border: 1px solid rgba(250,204,21,.22); border-radius: 12px; color: #fef08a; background: rgba(250,204,21,.08); }
.unlock-banner[hidden] { display: none; }
.unlock-banner strong, .unlock-banner span { display: block; }
.unlock-banner strong { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.unlock-banner span { margin-top: 2px; color: #cbd5e1; font-size: .72rem; }
.result-secondary { display: grid; grid-template-columns: 1fr 1fr; }
.text-button { margin-top: 12px; border: 0; color: rgba(255,255,255,.68); background: transparent; font: inherit; font-weight: 700; cursor: pointer; }
.journey-card { margin: 24px 0; padding: 18px; border-radius: 18px; background: linear-gradient(145deg, rgba(124,58,237,.18), rgba(34,211,238,.08)); border: 1px solid rgba(167,139,250,.2); }
.journey-card span, .journey-card small { display: block; }
.journey-card span { color: #67e8f9; font-size: .68rem; font-weight: 900; letter-spacing: .13em; }
.journey-card strong { display: block; margin: 6px 0 4px; font-size: 1.05rem; }
.journey-card small { color: #9da8c4; line-height: 1.4; }
@keyframes celebration-in { from { opacity: 0; transform: scale(.92); } }
.mode-drawer { position: fixed; inset: 0; z-index: 50; display: grid; grid-template-columns: minmax(0,1fr) min(420px,90vw); }
.mode-drawer[hidden] { display: none; }
.drawer-backdrop { width: 100%; height: 100%; border: 0; border-radius: 0; background: rgba(2,4,10,.68); backdrop-filter: blur(5px); }
.drawer-panel { height: 100%; padding: 28px; overflow: auto; background: #11172a; box-shadow: -30px 0 80px rgba(0,0,0,.45); }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; }
.drawer-head span { color: var(--accent-2); font-size: .7rem; font-weight: 900; letter-spacing: .14em; }
.drawer-head h2 { margin: 4px 0 0; font-size: 2rem; }
.drawer-panel .mode-list { grid-template-columns: 1fr; }
.drawer-panel .mode-list button { min-height: 92px; display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 12px; padding: 14px; border-radius: 16px; text-align: left; }
.mode-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; color: #f5f3ff; background: linear-gradient(145deg,rgba(124,58,237,.65),rgba(34,211,238,.35)); font-size: 1.25rem; }
.mode-copy strong, .mode-copy small, .mode-copy em { display: block; }
.mode-copy small { margin: 3px 0 6px; color: #9ba6c0; font-size: .73rem; line-height: 1.3; }
.mode-copy em { color: #67e8f9; font-size: .67rem; font-style: normal; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.drawer-panel .mode-list button.active { box-shadow: inset 0 0 0 1px var(--accent); }

.home-game { padding: 28px 0 70px; }
.home-game-head { max-width: 760px; margin-bottom: 24px; }
.game-embed { width: 100%; height: 1040px; border: 0; border-radius: 30px; background: #070a12; box-shadow: 0 35px 100px rgba(0,0,0,.38); }
.embedded-game { background: transparent; }
.embedded-game .play-screen { min-height: 0; padding: 0; display: block; background: transparent; }
.embedded-game .play-side { display: none; }
.embedded-game .game-shell { width: 100%; max-width: none; min-height: 100vh; border-radius: 0; }

@media (max-width: 980px) {
  .play-screen { padding: 12px; }
  .play-side { display: none; }
  .game-embed { height: 980px; }
}
@media (max-width: 620px) {
  .play-screen { padding: 0; }
  .game-shell { border-radius: 0; border-left: 0; border-right: 0; padding: 10px; }
  .game-shell #game-canvas { height: 60vh; min-height: 440px; }
  .game-chip { min-width: 76px; font-size: .74rem; padding-inline: 8px; }
  .power-button { min-height: 56px; padding: 8px; flex-direction: column; gap: 1px; }
  .drawer-panel { padding: 20px; }
  .drawer-panel .mode-list { grid-template-columns: 1fr; }
  .game-embed { height: 880px; border-radius: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .mission-strip #combo.chain-pulse,.combo-flash.replay,.eagle-eye.replay,.eagle-scan.replay,.game-shell #game-canvas.impact-shake { animation-duration: .01ms; animation-iteration-count: 1; }
}
