@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap");

:root {
  color: #263652;
  font-family: "VT323", monospace;
  background: #b6d8df;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow: hidden;
  background: #8fb8c2;
}

button { font: inherit; }
#app { min-height: 100vh; }

.title-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  text-align: center;
  background:
    radial-gradient(circle at 15% 20%, #fff 0 2px, transparent 3px),
    radial-gradient(circle at 75% 40%, #fff 0 3px, transparent 4px),
    radial-gradient(circle at 40% 80%, #fff 0 2px, transparent 3px),
    linear-gradient(#9bd0dc, #e7f5f3 60%, #fff 60%);
  background-size: 80px 80px, 120px 120px, 100px 100px, auto;
}

.title-snow { color: #fff; font-size: clamp(1.5rem, 5vw, 3rem); letter-spacing: 12px; text-shadow: 4px 4px #6592a0; }
.kicker { margin: 24px 0 16px; font-size: 1.5rem; letter-spacing: 3px; text-transform: uppercase; }

h1 {
  margin: 0;
  color: #263652;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(2rem, 7vw, 4.4rem);
  line-height: 1.25;
  text-shadow: 5px 5px 0 #fff, 8px 8px 0 #6e95a0;
}

h1 span { color: #e24e50; }

.pixel-pikachu {
  width: 100px;
  height: 100px;
  margin: 22px 0 12px;
  position: relative;
  border: 6px solid #263652;
  border-radius: 4px;
  background: #f6ce47;
  box-shadow: 8px 8px 0 #6e95a0;
}

.pixel-pikachu::before,
.pixel-pikachu::after {
  content: "";
  position: absolute;
  top: 29px;
  width: 10px;
  height: 15px;
  background: #263652;
  box-shadow: 0 22px #ed5951;
}

.pixel-pikachu::before { left: 21px; }
.pixel-pikachu::after { right: 21px; }
.pixel-pikachu span { position: absolute; right: -35px; top: 28px; color: #f6ce47; font-size: 3rem; text-shadow: 3px 3px #263652; }

.pixel-button,
.small-button,
.dpad button {
  cursor: pointer;
  color: #fff;
  border: 4px solid #17243b;
  border-radius: 2px;
  background: #e24e50;
  box-shadow: 4px 4px 0 #17243b;
}

.pixel-button {
  min-width: min(340px, 90vw);
  min-height: 62px;
  padding: 12px 20px;
  font-family: "Press Start 2P", monospace;
  font-size: .9rem;
}

button:hover { filter: brightness(1.08); transform: translate(-1px, -1px); }
button:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 #17243b; }
button:focus-visible { outline: 5px solid #f7d44b; outline-offset: 3px; }
.subtitle { margin: 20px 0 0; font-size: 1.45rem; }
.version { color: #60748a; font-size: 1rem; letter-spacing: 2px; }

.game-shell {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-columns: clamp(320px, 25vw, 390px) 1fr;
  overflow: hidden;
}

.side-panel {
  min-height: 0;
  position: relative;
  z-index: 3;
  overflow-y: auto;
  color: #fff;
  border-right: 7px solid #17243b;
  background:
    linear-gradient(90deg, rgba(255,255,255,.04) 50%, transparent 50%) 0 0 / 8px 8px,
    #314f63;
  box-shadow: 8px 0 0 rgba(23, 36, 59, .25);
}

.side-title {
  padding: 20px 20px 16px;
  border-bottom: 4px solid #17243b;
  background: #47758a;
}

.side-title .cycle-tag {
  display: inline-block;
  padding: 7px 9px;
  color: #263652;
  background: #f6ce47;
  font-family: "Press Start 2P", monospace;
  font-size: .62rem;
}

.side-title p { margin: 13px 0 8px; color: #cce6e6; font-size: 1rem; letter-spacing: 2px; }
.side-title h2 { margin: 0; color: #fff; font-family: "Press Start 2P", monospace; font-size: clamp(.9rem, 1.3vw, 1.18rem); line-height: 1.55; text-shadow: 3px 3px 0 #263652; }
.side-title h2 em { color: #f06a68; font-style: normal; }

.dashboard { padding: 14px; border-bottom: 4px solid #17243b; }

.dashboard-title,
.dash-card {
  width: 100%;
  min-height: 70px;
  display: grid;
  align-items: center;
  margin-bottom: 9px;
  color: #263652;
  border: 3px solid #17243b;
  border-radius: 0;
  background: #f8f6df;
  box-shadow: 4px 4px 0 #17243b;
}

.dashboard-title {
  min-height: 58px;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  padding: 7px 12px;
  color: #fff;
  background: #5a8092;
  font-family: "Press Start 2P", monospace;
  font-size: .68rem;
  line-height: 1.4;
}

.mini-ash {
  width: 30px;
  height: 38px;
  position: relative;
  border: 3px solid #17243b;
  background: linear-gradient(#e14848 0 25%, #f2bd83 25% 52%, #4278b7 52% 78%, #344968 78%);
  box-shadow: -5px 13px 0 -2px #e5bb43;
}

.dash-card {
  grid-template-columns: 52px 1fr;
  gap: 9px;
  padding: 9px 13px;
  text-align: left;
}

.dash-card > span { text-align: center; font-size: 2.4rem; line-height: 1; }
.dash-card > div { min-width: 0; display: flex; flex-direction: column; }
.dash-card small { color: #647487; font-size: 1rem; line-height: 1; letter-spacing: 1px; }
.dash-card strong { margin-top: 4px; overflow: hidden; font-family: "Press Start 2P", monospace; font-size: .82rem; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
.dash-card.money > span { color: #d4a42f; }
.dash-card.balls > span { color: #df4e52; }
.dash-card.items > span { color: #6e72a5; }

.dash-card.pokemon {
  min-height: 94px;
  cursor: pointer;
  grid-template-columns: 76px 1fr;
  appearance: none;
}

.dash-card.pokemon canvas { width: 72px; height: 72px; border: 3px solid #263652; image-rendering: pixelated; }
.dash-card.pokemon em { margin-top: 5px; color: #3a8862; font-size: 1rem; font-style: normal; font-weight: bold; }
.dash-card.pokemon:disabled { cursor: not-allowed; opacity: .7; filter: grayscale(.35); }
.collection-label { margin: 14px 2px 8px; color: #bfe0e2; font-family: "Press Start 2P", monospace; font-size: .55rem; line-height: 1.5; }
.pokemon-list .dash-card:last-child { margin-bottom: 0; }
.pokemon-health { margin-top: 5px; color: #405f75; font-size: 1.35rem; font-weight: bold; line-height: 1; }

.controls { padding: 13px 16px 22px; }
.controls h3 { margin: 0 0 11px; color: #f6ce47; font-family: "Press Start 2P", monospace; font-size: .75rem; }
.controls p { margin: 7px 0; color: #d8e8e8; font-size: 1.12rem; line-height: 1; }
.control-row { display: flex; align-items: center; gap: 17px; margin-bottom: 10px; }
.dpad { flex: none; display: grid; grid-template: repeat(2, 43px) / repeat(3, 43px); gap: 3px; }
.dpad button { min-width: 43px; min-height: 43px; padding: 0; background: #678b9d; box-shadow: 3px 3px 0 #17243b; }
.dpad button:nth-child(1) { grid-column: 2; }
.dpad button:nth-child(2) { grid-column: 1; grid-row: 2; }
.dpad button:nth-child(3) { grid-column: 2; grid-row: 2; }
.dpad button:nth-child(4) { grid-column: 3; grid-row: 2; }
.instructions { display: flex; flex-direction: column; color: #d8e8e8; font-size: 1.2rem; }
.instructions strong { color: #fff; font-family: "Press Start 2P", monospace; font-size: .62rem; line-height: 1.5; }
.small-button { width: 100%; min-height: 43px; margin-top: 12px; padding: 7px; background: #597b8f; font-family: "Press Start 2P", monospace; font-size: .55rem; }

.map-panel { min-width: 0; min-height: 0; height: 100vh; position: relative; overflow: hidden; background: #eaf7f7; }

.map-hud {
  position: absolute;
  z-index: 2;
  top: 18px;
  left: 18px;
  right: 18px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  pointer-events: none;
}

.map-hud div {
  min-width: 190px;
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  color: #fff;
  border: 4px solid #17243b;
  background: rgba(49, 79, 99, .94);
  box-shadow: 4px 4px 0 rgba(23, 36, 59, .45);
}

.map-hud div:last-child { align-items: flex-end; }
.map-hud small { color: #bde0e2; font-size: .92rem; letter-spacing: 2px; }
.map-hud strong { font-family: "Press Start 2P", monospace; font-size: .72rem; line-height: 1.5; }

.screen-frame { width: 100%; height: 100%; position: relative; overflow: hidden; background: #eaf7f7; }

#game { width: 100%; height: 100%; display: block; image-rendering: pixelated; background: #eaf7f7; }

.dialogue {
  position: absolute;
  z-index: 3;
  left: 5%;
  right: 5%;
  bottom: 5%;
  min-height: 135px;
  padding: 21px 26px;
  color: #263652;
  border: 6px solid #263652;
  background: #fffef2;
  box-shadow: inset 0 0 0 5px #9bbbc0, 8px 8px 0 rgba(38,54,82,.35);
}

.dialogue strong { display: block; color: #cf4648; font-family: "Press Start 2P", monospace; font-size: .9rem; }
.dialogue p { margin: 13px 70px 0 0; font-size: clamp(1.35rem, 2.2vw, 1.8rem); line-height: 1.05; }
.dialogue-continue { position: absolute; right: 21px; bottom: 15px; font-weight: bold; animation: blink .7s steps(2) infinite; }
.dialogue-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 17px; }
.dialogue-actions:empty { display: none; }
.dialogue-actions button { min-height: 42px; cursor: pointer; padding: 8px 14px; color: #fff; border: 3px solid #17243b; background: #47758a; box-shadow: 3px 3px 0 #17243b; font-family: "Press Start 2P", monospace; font-size: .58rem; }

.battle-panel {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 7vh 5vw 4vh;
  background: rgba(117, 176, 189, .48);
}

.battle-panel[hidden] { display: none; }

.battle-stage {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 1fr 70px 1fr;
  align-items: center;
  gap: 18px;
  padding: clamp(18px, 3vw, 34px);
  color: #263652;
  border: 7px solid #17243b;
  background: rgba(255, 254, 242, .96);
  box-shadow: 10px 10px 0 rgba(23, 36, 59, .38);
}

.battle-pokemon { min-width: 0; display: grid; grid-template-columns: 116px 1fr; align-items: center; gap: 13px; padding: 14px; border: 4px solid #263652; background: #dff2ee; box-shadow: 5px 5px 0 #8caeb4; }
.battle-pokemon canvas { width: 108px; height: 108px; border: 3px solid #263652; image-rendering: pixelated; background: #fff; }
.battle-pokemon h3 { margin: 0; font-family: "Press Start 2P", monospace; font-size: .78rem; }
.battle-pokemon p { margin: 6px 0; color: #587285; font-size: 1.2rem; text-transform: uppercase; }
.battle-burst { color: #e05453; font-size: 3.5rem; text-align: center; text-shadow: 3px 3px #263652; }
.ball-waiting { color: #df4e52; font-size: 4.5rem; text-align: center; }
.battle-health > div:first-child { display: flex; justify-content: space-between; font-size: 1.4rem; font-weight: bold; }
.battle-health .health-track { height: 13px; overflow: hidden; border: 3px solid #263652; background: #d5ddd9; }
.battle-health .health-track i { height: 100%; display: block; background: #55af70; }
.battle-health .health-track i.medium { background: #e1b949; }
.battle-health .health-track i.low { background: #dc5c59; }
.battle-message { grid-column: 1 / 4; min-height: 70px; padding: 14px 18px; color: #263652; border: 4px solid #263652; background: #fff; font-size: 1.45rem; line-height: 1.05; }
.battle-prompt { grid-column: 1 / 4; margin: 4px 0 -5px; color: #47758a; font-family: "Press Start 2P", monospace; font-size: .72rem; }
.battle-actions { grid-column: 1 / 4; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.battle-actions button { min-height: 67px; cursor: pointer; padding: 10px; color: #fff; border: 4px solid #17243b; background: #47758a; box-shadow: 4px 4px 0 #17243b; font-family: "Press Start 2P", monospace; font-size: .66rem; line-height: 1.35; }
.battle-actions button span,
.battle-actions button small { display: block; margin-bottom: 5px; color: #bfe2e3; font-family: "VT323", monospace; font-size: 1.25rem; }
.battle-actions button small { margin: 5px 0 0; }
.battle-actions button:disabled { cursor: not-allowed; opacity: .45; }
.choose-pokemon { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.result-actions { grid-template-columns: repeat(2, minmax(170px, 1fr)); }

@keyframes blink { 50% { opacity: 0; } }

@media (max-width: 850px) {
  body { overflow: auto; }
  .game-shell { height: auto; min-height: 100vh; grid-template-columns: 1fr; }
  .side-panel { max-height: none; border-right: 0; border-bottom: 7px solid #17243b; }
  .side-title { padding: 13px 16px; }
  .side-title h2 { font-size: .85rem; }
  .dashboard { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .dashboard-title { grid-column: 1 / 3; margin: 0; }
  .dash-card { margin: 0; }
  .controls { display: none; }
  .map-panel { height: 70vh; min-height: 520px; }
  .map-hud div { min-width: 140px; }
  .battle-stage { grid-template-columns: 1fr; }
  .battle-burst { display: none; }
  .battle-message,
  .battle-prompt,
  .battle-actions { grid-column: 1; }
  .battle-pokemon { grid-template-columns: 80px 1fr; }
  .battle-pokemon canvas { width: 72px; height: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}
