:root {
  color-scheme: dark;
  --ink: #11182a;
  --panel: #1a2438;
  --panel-hi: #26334c;
  --cream: #f4f1d8;
  --teal: #43b888;
  --teal-dark: #227455;
  --red: #9945ff;
  --yellow: #00d1ff;
  --green: #14f195;
  --text: #edf3ff;
  --muted: #9aa8c1;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #0b1020; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 80% -10%, rgba(153,69,255,.27), transparent 34rem),
    radial-gradient(circle at 10% 0%, rgba(20,241,149,.11), transparent 29rem),
    linear-gradient(145deg, #10121b 0%, #07080d 70%);
}
button { font: inherit; }

.page-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 48px; }
.topbar { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 7px; color: #14f195; font-size: .74rem; font-weight: 800; letter-spacing: .18em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.7rem, 3vw, 2.6rem); line-height: 1; letter-spacing: -.04em; }
.battle-brand { display: flex; flex-direction: column; width: fit-content; color: transparent; background: linear-gradient(105deg,#14f195,#00d1ff 48%,#9945ff); background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.battle-brand > span { display: flex; align-items: center; gap: 7px; }
.battle-brand img { width: 29px; height: 29px; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 0 8px rgba(20,241,149,.2)); }
.battle-brand small { margin-top: 6px; color: #8795aa; -webkit-text-fill-color: #8795aa; font-size: .56rem; letter-spacing: .32em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.battle-state { display: inline-flex; align-items: center; gap: 8px; color: #bdc8da; font-size: .88rem; }
.battle-state i { width: 8px; height: 8px; border-radius: 50%; background: #14f195; box-shadow: 0 0 12px #14f195; }
.ghost-button { border: 1px solid #394863; border-radius: 10px; padding: 9px 13px; color: #e8efff; background: #1a2438; cursor: pointer; }
.ghost-button:hover, .ghost-button:focus-visible { background: #26334c; outline: 2px solid #14f195; outline-offset: 2px; }
.home-link { color: #aebbd0; font-size: .88rem; font-weight: 700; text-decoration: none; }
.home-link:hover, .home-link:focus-visible { color: #fff; outline: none; text-decoration: underline; text-underline-offset: 4px; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
.console-frame { position: relative; padding: 21px 24px 16px; border: 1px solid #393b4f; border-radius: 28px; background: linear-gradient(150deg, #252838, #13151e 38%, #090b11); box-shadow: 0 30px 80px rgba(0,0,0,.5), 18px -16px 70px rgba(153,69,255,.08), -16px 18px 65px rgba(20,241,149,.06), inset 0 1px 1px rgba(255,255,255,.13); }
.console-lights { display: flex; gap: 6px; position: absolute; top: 9px; left: 35px; }
.console-lights span { width: 5px; height: 5px; border-radius: 50%; background: #51617b; }
.console-lights span:first-child { background: #14f195; box-shadow: 0 0 7px #14f195; }
.screen-bezel { padding: 8px; border: 2px solid #0a0f19; border-radius: 14px; background: #05080e; box-shadow: inset 0 0 0 1px #41506a; }
.battle-screen { position: relative; overflow: hidden; aspect-ratio: 3 / 2; min-height: 440px; border-radius: 7px; background: var(--cream); color: #34332f; font-family: "Courier New", ui-monospace, monospace; font-weight: 900; image-rendering: pixelated; }
.scanlines { position: absolute; z-index: 20; inset: 0; pointer-events: none; opacity: .08; background: repeating-linear-gradient(0deg, rgba(0,0,0,.5) 0, rgba(0,0,0,.5) 1px, transparent 1px, transparent 4px); }
.battle-field { position: absolute; inset: 0 0 30%; overflow: hidden; background: repeating-linear-gradient(0deg, #dff9df 0, #dff9df 6px, #daf5d8 6px, #daf5d8 10px); }
.battle-field::before { content: ""; position: absolute; inset: 0; opacity: .22; background: linear-gradient(90deg, transparent 0 47%, #fff 48% 50%, transparent 51%); background-size: 22px 100%; }
.platform { position: absolute; z-index: 1; height: 18%; border-radius: 50%; background: radial-gradient(ellipse at center, #80dd77 0 43%, #9af27f 44% 66%, transparent 68%); }
.enemy-platform { width: 47%; right: -2%; top: 28%; }
.player-platform { width: 55%; left: -9%; bottom: -2%; }
.pokemon-sprite { position: absolute; z-index: 3; width: 20%; height: auto; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(7px 8px 0 rgba(47,87,63,.22)); transition: transform .15s steps(2), opacity .15s steps(2), filter .15s; }
.enemy-sprite { top: 15%; right: 12%; }
.player-sprite { width: 25%; left: 10%; bottom: -1%; }
.pokemon-sprite.hit { animation: hit-flash .38s steps(2); }
.pokemon-sprite.attack-player { animation: lunge-player .42s steps(3); }
.pokemon-sprite.attack-enemy { animation: lunge-enemy .42s steps(3); }
.pokemon-sprite.fainted { transform: translateY(130%); opacity: 0; transition: transform .65s steps(7), opacity .65s; }
@keyframes hit-flash { 0%, 100% { opacity: 1; filter: none; } 25%, 70% { opacity: .18; filter: brightness(4); } }
@keyframes lunge-player { 0%,100% { transform: translate(0); } 45% { transform: translate(28px,-12px); } }
@keyframes lunge-enemy { 0%,100% { transform: translate(0); } 45% { transform: translate(-24px,10px); } }

.status-card { position: absolute; z-index: 5; width: 45%; padding: 9px 14px 8px; border: 4px solid #49583d; border-radius: 7px 5px 16px 5px; background: linear-gradient(#fffde8, #f0f0cd); box-shadow: 7px 8px 0 rgba(56,91,67,.55); font-size: clamp(.72rem, 2vw, 1.15rem); letter-spacing: .02em; }
.enemy-card { top: 7%; left: 5%; }
.player-card { right: 5%; bottom: 5%; }
.name-line { display: flex; justify-content: space-between; align-items: center; white-space: nowrap; }
.gender { color: #279fd3; }
.hp-line { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 4px; margin-top: 5px; padding: 2px 3px 2px 6px; color: #e4ad35; font-size: .72em; border-radius: 12px; background: #536057; }
.hp-track { height: 9px; overflow: hidden; border-radius: 9px; background: #24382e; }
.hp-fill { width: 100%; height: 100%; border-right: 2px solid rgba(255,255,255,.65); background: #55d287; transition: width .65s linear, background .25s; }
.hp-fill.medium { background: #e5c84b; }
.hp-fill.low { background: #df5b52; }
.hp-numbers { margin-top: 4px; text-align: right; font-size: .9em; }
.exp-line { display: flex; align-items: center; gap: 6px; margin-top: 3px; color: #d4b626; font-size: .6em; }
.exp-line > div { flex: 1; height: 5px; border-radius: 4px; background: #687174; overflow: hidden; }
.exp-line i { display: block; width: 44%; height: 100%; background: #54c7d8; }

.command-panel { position: absolute; z-index: 8; left: 0; right: 0; bottom: 0; height: 30%; display: grid; grid-template-columns: 56% 44%; background: #e9e9e4; border-top: 7px solid #4a4b6f; }
.dialogue-box { position: relative; padding: 20px 28px; color: #fff; font-size: clamp(1rem, 2.7vw, 1.7rem); line-height: 1.35; text-shadow: 2px 2px #355c50; background: var(--teal); border: 5px solid #9945ff; border-right: 7px solid #4a4b6f; box-shadow: inset 0 0 0 4px rgba(255,255,255,.26); }
.dialogue-box p { margin: 0; }
.advance-marker { position: absolute; right: 18px; bottom: 10px; font-size: .75em; animation: bob .8s steps(2) infinite; }
@keyframes bob { 50% { transform: translateY(4px); } }
.menu-grid, .moves-grid { display: grid; grid-template-columns: 1fr 1fr; padding: 9px; gap: 2px 7px; background: #f6f4eb; }
.menu-option, .move-option { position: relative; border: 0; padding: 7px 8px 7px 21px; color: #34332f; background: transparent; text-align: left; font-family: inherit; font-weight: 900; font-size: clamp(.85rem, 2.4vw, 1.45rem); cursor: pointer; }
.menu-option:hover, .move-option:hover { background: #ecebdc; }
.menu-option.selected::before, .move-option.selected::before { content: "▶"; position: absolute; left: 3px; top: 50%; color: #9945ff; font-size: .72em; transform: translateY(-50%); }
.menu-option:focus-visible, .move-option:focus-visible, .end-menu button:focus-visible { outline: 3px solid #9945ff; outline-offset: -2px; }
.move-menu { display: grid; grid-template-columns: 1fr 31%; min-width: 0; background: #f6f4eb; }
.moves-grid { padding: 7px; min-width: 0; }
.move-option { padding-left: 17px; font-size: clamp(.66rem, 1.85vw, 1.05rem); white-space: nowrap; }
.move-meta { display: flex; flex-direction: column; justify-content: center; gap: 12px; padding: 10px; border-left: 5px solid #4a4b6f; color: #3a3935; font-size: clamp(.62rem, 1.5vw, .84rem); background: #f0f0e7; }
.move-meta span { white-space: nowrap; }
.end-menu { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 12px; color: #34332f; background: #f6f4eb; }
.end-menu button { border: 3px solid #34332f; padding: 7px 12px; color: #fff; background: #8240db; font-family: inherit; font-weight: 900; cursor: pointer; box-shadow: 3px 3px 0 #34332f; }
.hidden { display: none !important; }
.impact-fx { position: absolute; z-index: 7; width: 55px; height: 55px; pointer-events: none; opacity: 0; }
.impact-fx.show { opacity: 1; animation: impact .42s steps(3); }
.impact-fx::before, .impact-fx::after { content: ""; position: absolute; inset: 0; background: repeating-conic-gradient(#fff 0 9deg, transparent 9deg 26deg); clip-path: polygon(48% 0,58% 34%,83% 11%,69% 42%,100% 48%,67% 57%,87% 86%,57% 68%,48% 100%,42% 68%,13% 88%,32% 58%,0 50%,34% 43%,12% 13%,42% 34%); }
.impact-fx::after { inset: 13px; background: #f0d85f; }
@keyframes impact { 0% { transform: scale(.3) rotate(0); } 70% { transform: scale(1.2) rotate(20deg); } 100% { transform: scale(.6) rotate(35deg); opacity: 0; } }
.battle-screen.shake { animation: screen-shake .32s steps(3); }
@keyframes screen-shake { 25% { transform: translateX(-5px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }
.console-footer { display: flex; align-items: center; gap: 7px; padding: 11px 10px 0; color: #71809a; font-size: .65rem; font-weight: 800; letter-spacing: .18em; }
.console-footer i { display: block; width: 5px; height: 5px; border-radius: 50%; background: #45536b; }
.console-footer i:first-of-type { margin-left: auto; background: #d65050; }

.battle-guide { min-height: 100%; padding: 23px; border: 1px solid #293852; border-radius: 18px; background: rgba(20,29,47,.74); box-shadow: inset 0 1px rgba(255,255,255,.05); }
.battle-guide h2 { margin-bottom: 10px; font-size: 1.4rem; letter-spacing: -.03em; }
.battle-guide > div > p:not(.eyebrow) { color: #aab7ca; font-size: .92rem; line-height: 1.55; }
.battle-guide dl { margin: 26px 0; }
.battle-guide dl div { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid #2e3b52; font-size: .86rem; }
.battle-guide dt { color: #8796ad; }
.battle-guide dd { margin: 0; color: #f0f4fb; font-weight: 700; text-align: right; }
.controls-card { padding: 15px; border: 1px solid #33445e; border-radius: 12px; background: #111a2b; }
.controls-card h3 { margin-bottom: 11px; font-size: .83rem; text-transform: uppercase; letter-spacing: .11em; }
.controls-card p { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin: 7px 0; color: #a9b5c8; font-size: .78rem; }
kbd { min-width: 25px; padding: 3px 6px; border: 1px solid #46536a; border-radius: 5px; color: #e7edf8; background: #253047; box-shadow: 0 2px 0 #0a0f19; text-align: center; font-family: inherit; }
.fan-note { margin: 18px 0 0; color: #6f7e95; font-size: .72rem; line-height: 1.5; }

@media (max-width: 900px) {
  .game-layout { grid-template-columns: 1fr; }
  .battle-guide { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; }
  .battle-guide dl { margin: 0; }
  .fan-note { grid-column: 1 / -1; }
}
@media (max-width: 620px) {
  .page-shell { width: min(100% - 18px, 580px); padding-top: 18px; }
  .topbar { align-items: center; }
  .battle-state { display: none; }
  .console-frame { padding: 14px 11px 12px; border-radius: 18px; }
  .screen-bezel { padding: 5px; }
  .battle-screen { min-height: 0; }
  .status-card { padding: 5px 7px; border-width: 3px; box-shadow: 4px 5px 0 rgba(56,91,67,.5); }
  .hp-track { height: 6px; }
  .hp-line { grid-template-columns: 22px 1fr; margin-top: 2px; }
  .hp-numbers { margin-top: 1px; }
  .exp-line { margin-top: 1px; }
  .dialogue-box { padding: 10px 13px; border-width: 3px; border-right-width: 4px; }
  .command-panel { border-top-width: 4px; }
  .menu-grid { padding: 4px; gap: 0; }
  .menu-option { padding: 3px 2px 3px 13px; }
  .move-menu { grid-template-columns: 1fr 32%; }
  .moves-grid { padding: 3px; }
  .move-option { padding: 2px 2px 2px 12px; }
  .move-meta { gap: 4px; padding: 4px; border-left-width: 3px; }
  .battle-guide { grid-template-columns: 1fr; }
  .fan-note { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
