/* ========== Stellar Snake — Game Boy aesthetic ========== */

:root {
  /* Stellar brand tokens */
  --stellar-yellow: #FDDA24;
  --stellar-black: #0F0F0F;
  --lilac: #B7ACE8;
  --lilac-deep: #8575C9;
  --teal: #00A7B5;
  --teal-deep: #00707A;
  --navy: #002E5D;
  --coral: #FF6F61;
  --stone: #D6D2C4;
  --off-white: #F6F7F8;

  /* Game Boy Color screen palette — full vibrant Stellar */
  --gb-0: #0F0F0F;  /* black — outlines, text */
  --gb-1: #B7ACE8;  /* lilac — UI mid */
  --gb-2: #FDDA24;  /* stellar yellow — accents, snake body */
  --gb-3: #F6F7F8;  /* off-white — screen background */
  --gb-teal: #00A7B5;
  --gb-navy: #002E5D;
  --gb-coral: #FF6F61;

  /* Icon fill colors — cascade through SVG <use> shadow trees */
  --ic-yellow: #FDDA24;
  --ic-lilac:  #B7ACE8;
  --ic-white:  #FFFFFF;
  --ic-black:  #0F0F0F;
  --ic-stroke: #0F0F0F;

  /* Device chrome — vibrant translucent yellow shell */
  --device-shell:   #FDDA24;
  --device-shell-2: #E6C200;
  --device-shadow:  #B89A00;
  --device-trim:    #8A7300;
  --bezel:          #0F0F0F;
  --bezel-edge:     #2A2A2A;
  --power-led:      #FF6F61;
}

[data-palette="mono"] {
  --gb-0: #1B1A0E;
  --gb-1: #5C5731;
  --gb-2: #B0A453;
  --gb-3: #EFE8A8;
  --gb-teal: #5C5731;
  --gb-navy: #1B1A0E;
  --gb-coral: #5C5731;
  --ic-yellow: #B0A453;
  --ic-lilac:  #5C5731;
  --ic-white:  #EFE8A8;
  --ic-black:  #1B1A0E;
  --ic-stroke: #1B1A0E;
  --device-shell:   #E8E2D0;
  --device-shell-2: #D8D0BA;
  --device-shadow:  #B6AC91;
  --device-trim:    #98906F;
  --power-led:      #FF3B30;
}

[data-palette="berry"] {
  --gb-0: #1A0A26;
  --gb-1: #FF6F61;
  --gb-2: #FFD23F;
  --gb-3: #FFF1E5;
  --gb-teal: #00A7B5;
  --gb-navy: #6B2D5C;
  --gb-coral: #FF6F61;
  --ic-yellow: #FFD23F;
  --ic-lilac:  #FF6F61;
  --ic-white:  #FFF1E5;
  --ic-black:  #1A0A26;
  --ic-stroke: #1A0A26;
  --device-shell:   #FF6F61;
  --device-shell-2: #E04E40;
  --device-shadow:  #8A2820;
  --device-trim:    #5A1A14;
  --power-led:      #FFD23F;
}

[data-palette="cosmic"] {
  --gb-0: #0A0A1E;
  --gb-1: #B7ACE8;
  --gb-2: #00E5C8;
  --gb-3: #E8E3FF;
  --gb-teal: #00A7B5;
  --gb-navy: #002E5D;
  --gb-coral: #FF6F61;
  --ic-yellow: #00E5C8;
  --ic-lilac:  #B7ACE8;
  --ic-white:  #E8E3FF;
  --ic-black:  #0A0A1E;
  --ic-stroke: #0A0A1E;
  --device-shell:   #B7ACE8;
  --device-shell-2: #8575C9;
  --device-shadow:  #4A3A8A;
  --device-trim:    #2A1A5A;
  --power-led:      #00E5C8;
}

.arena-link {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border: 2px solid var(--gb-0);
  border-radius: 0;
  color: var(--gb-0);
  background: color-mix(in srgb, var(--gb-3) 88%, transparent);
  box-shadow: 3px 3px 0 var(--gb-0);
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  line-height: 1;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.arena-link:hover,
.arena-link:focus-visible {
  color: var(--gb-3);
  background: var(--gb-0);
  box-shadow: 3px 3px 0 var(--gb-2);
  outline: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(253, 218, 36, 0.08), transparent 70%),
    #0a0a08;
  font-family: "Press Start 2P", monospace;
  color: var(--off-white);
  overflow: hidden;
  image-rendering: pixelated;
  -webkit-font-smoothing: none;
  font-smooth: never;
}

#root {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Scale wrapper: GB device is designed at 720x880, scale to fit ---------- */
.stage {
  width: 720px;
  height: 880px;
  transform-origin: center center;
  position: relative;
}

/* ---------- Game Boy device ---------- */
.gb-device {
  position: relative;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse 60% 40% at 30% 10%, rgba(255,255,255,0.4), transparent 60%),
    linear-gradient(180deg, var(--device-shell) 0%, var(--device-shell-2) 100%);
  border-radius: 18px 18px 64px 18px;
  box-shadow:
    inset 0 -8px 0 0 rgba(0,0,0,0.12),
    inset 0 4px 0 0 rgba(255,255,255,0.5),
    inset 0 0 0 4px var(--device-shadow),
    0 24px 60px rgba(0,0,0,0.7),
    0 4px 0 var(--device-shadow);
  padding: 32px 36px;
  overflow: hidden;
}

.gb-device::before {
  /* subtle dot texture on shell */
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(0,0,0,0.05) 1px, transparent 1px);
  background-size: 6px 6px;
  pointer-events: none;
  border-radius: inherit;
}

/* Top strip with brand + speaker grille later */
.gb-brand {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--stellar-black);
  display: flex;
  gap: 6px;
  align-items: baseline;
}
.gb-brand .mark { color: var(--stellar-black); }
.gb-brand .dot { color: var(--lilac); -webkit-text-stroke: 0.6px #0F0F0F; }

/* ---------- Bezel around screen ---------- */
.gb-bezel {
  position: relative;
  margin: 28px auto 0;
  width: 624px;
  height: 504px;
  background:
    linear-gradient(180deg, #2A2418 0%, #1A150C 100%);
  border-radius: 14px 14px 44px 14px;
  padding: 28px 40px 56px;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,0.08),
    inset 0 -2px 0 rgba(0,0,0,0.4),
    inset 0 0 0 2px #0a0805,
    0 6px 0 var(--device-shadow),
    0 8px 0 var(--device-trim);
}

.gb-bezel::before {
  /* engraved label "DOT MATRIX WITH STEREO SOUND" */
  content: "STELLAR DOT MATRIX · CATCH 'EM";
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  letter-spacing: 0.18em;
  color: #6F683F;
  font-style: italic;
}

/* Power LED */
.gb-led {
  position: absolute;
  top: 12px;
  left: 22px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--power-led);
  box-shadow:
    0 0 6px 1px rgba(255, 60, 50, 0.6),
    inset 0 1px 1px rgba(255,255,255,0.6);
}
.gb-led-label {
  position: absolute;
  top: 24px;
  left: 12px;
  font-size: 7px;
  color: #8A8262;
  letter-spacing: 0.15em;
}

/* ---------- The LCD screen ---------- */
.gb-screen {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--gb-3);
  border-radius: 6px;
  box-shadow:
    inset 0 0 0 2px #0a0805,
    inset 0 0 20px rgba(0,0,0,0.2);
  overflow: hidden;
  image-rendering: pixelated;
}

.gb-screen::after {
  /* scanlines */
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.04) 0px,
    rgba(0,0,0,0.04) 2px,
    transparent 2px,
    transparent 4px
  );
  pointer-events: none;
  z-index: 100;
  mix-blend-mode: multiply;
}

/* ---------- Controls below the screen ---------- */
.gb-controls {
  position: absolute;
  inset: 540px 36px 0 36px;
  height: 280px;
}

/* D-pad */
.gb-dpad {
  position: absolute;
  left: 30px;
  top: 30px;
  width: 132px;
  height: 132px;
}
.gb-dpad::before {
  /* the cross */
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(#1A1611 0 0) center / 44px 132px no-repeat,
    linear-gradient(#1A1611 0 0) center / 132px 44px no-repeat;
  border-radius: 6px;
  box-shadow:
    inset 0 -2px 0 rgba(255,255,255,0.04),
    0 2px 0 #0a0805;
}
.dpad-btn {
  position: absolute;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 0;
  z-index: 2;
}
.dpad-btn.up { top: 0; left: 44px; }
.dpad-btn.down { bottom: 0; left: 44px; }
.dpad-btn.left { left: 0; top: 44px; }
.dpad-btn.right { right: 0; top: 44px; }
.dpad-btn:active::after,
.dpad-btn.active::after {
  content: "";
  position: absolute;
  inset: 4px;
  background: rgba(253,218,36,0.4);
  border-radius: 4px;
  mix-blend-mode: screen;
}
.dpad-arrow {
  position: absolute;
  width: 0; height: 0;
  pointer-events: none;
  z-index: 3;
}
.dpad-arrow.up    { top: 8px;    left: 50%; transform: translateX(-50%); border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 8px solid #5C5731; }
.dpad-arrow.down  { bottom: 8px; left: 50%; transform: translateX(-50%); border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 8px solid #5C5731; }
.dpad-arrow.left  { left: 8px;   top: 50%;  transform: translateY(-50%); border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-right: 8px solid #5C5731; }
.dpad-arrow.right { right: 8px;  top: 50%;  transform: translateY(-50%); border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 8px solid #5C5731; }

/* A / B buttons */
.gb-ab {
  position: absolute;
  right: 22px;
  top: 20px;
  display: flex;
  gap: 14px;
  transform: rotate(-22deg);
}
.ab-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gb-coral), #8E2B22 70%);
  border: 0;
  cursor: pointer;
  position: relative;
  box-shadow:
    inset 0 -3px 0 rgba(0,0,0,0.3),
    inset 0 2px 0 rgba(255,255,255,0.3),
    0 3px 0 #5A0F25,
    0 5px 6px rgba(0,0,0,0.4);
  font-family: inherit;
  color: var(--off-white);
  font-size: 0;
}
.ab-btn:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 -1px 0 rgba(0,0,0,0.3),
    inset 0 2px 0 rgba(255,255,255,0.3),
    0 1px 0 #5A0F25;
}
.ab-btn .label {
  position: absolute;
  font-size: 9px;
  color: var(--navy);
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%) rotate(22deg);
  letter-spacing: 0.1em;
}

/* Start / Select */
.gb-startsel {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) rotate(-22deg);
  display: flex;
  gap: 22px;
}
.ss-btn {
  width: 56px;
  height: 16px;
  background: linear-gradient(180deg, #6E6555 0%, #4F4839 100%);
  border-radius: 10px;
  border: 0;
  cursor: pointer;
  position: relative;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.2),
    inset 0 -1px 0 rgba(0,0,0,0.4),
    0 2px 0 #2A2418;
  font-size: 0;
}
.ss-btn:active { transform: translateY(1px); }
.ss-btn .label {
  position: absolute;
  font-size: 7px;
  color: var(--navy);
  top: 22px;
  left: 50%;
  transform: translateX(-50%) rotate(22deg);
  letter-spacing: 0.15em;
}

/* Speaker grille bottom-right */
.gb-speaker {
  position: absolute;
  bottom: 40px;
  right: 36px;
  width: 80px;
  height: 60px;
  transform: rotate(-22deg);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 3px;
}
.gb-speaker div {
  background: #1A1611;
  border-radius: 2px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

/* ---------- SCREEN content ---------- */
.screen-content {
  position: absolute;
  inset: 0;
  font-family: "Press Start 2P", monospace;
  color: var(--gb-0);
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: 0.04em;
}

/* Generic UI */
.gb-text { color: var(--gb-0); }
.gb-text-mid { color: var(--gb-1); }
.gb-text-light { color: var(--gb-2); }
.gb-bg-dark { background: var(--gb-0); color: var(--gb-3); }
.gb-bg-mid { background: var(--gb-1); color: var(--gb-3); }

.gb-window {
  background: var(--gb-3);
  border: 2px solid var(--gb-0);
  border-radius: 0;
  padding: 8px 10px;
  box-shadow: 2px 2px 0 var(--gb-0);
  position: relative;
}
.gb-window-thick {
  border-width: 3px;
  box-shadow: 4px 4px 0 var(--gb-0);
}

/* ---------- Title screen ---------- */
.title {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 50% 30%, rgba(253, 218, 36, 0.4), transparent 70%),
    linear-gradient(180deg, var(--gb-3) 0%, var(--gb-3) 60%, var(--gb-1) 60%, var(--gb-1) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 28px;
  overflow: hidden;
}
.title h1 {
  font-size: 30px;
  color: var(--gb-0);
  margin: 0;
  text-align: center;
  line-height: 1;
  text-shadow:
    2px 0 0 var(--gb-3),
    4px 4px 0 var(--gb-2);
  letter-spacing: 0.04em;
}
.title h1 .accent-inline {
  color: var(--gb-coral);
  text-shadow:
    2px 0 0 var(--gb-3),
    4px 4px 0 var(--gb-0);
}
.title .sub {
  font-size: 9px;
  color: var(--gb-0);
  margin-top: 10px;
  letter-spacing: 0.2em;
  background: var(--gb-2);
  padding: 4px 10px;
  border: 2px solid var(--gb-0);
  box-shadow: 2px 2px 0 var(--gb-0);
}
.title .hero {
  margin-top: 8px;
  width: 220px;
  height: 180px;
  position: relative;
}
.title .footer {
  position: absolute;
  bottom: 18px;
  left: 0; right: 0;
  text-align: center;
  font-size: 8px;
  color: var(--gb-3);
  letter-spacing: 0.18em;
}
.title .press-start {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--gb-0);
  animation: blink 1.2s steps(2, jump-none) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Map / route select ---------- */
.map-screen {
  position: absolute;
  inset: 0;
  background: var(--gb-3);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
}
.gb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 2px solid var(--gb-0);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--gb-0);
}
.gb-header .right { color: var(--gb-1); }

/* ---------- Gameplay ---------- */
.game-screen {
  position: absolute;
  inset: 0;
  background: var(--gb-3);
  display: flex;
  flex-direction: column;
}
.hud {
  height: 36px;
  background: var(--gb-0);
  color: var(--gb-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  font-size: 9px;
  letter-spacing: 0.1em;
  border-bottom: 2px solid var(--gb-2);
  flex-shrink: 0;
}
.hud .label { color: var(--gb-2); margin-right: 6px; }
.hud .group { display: flex; gap: 14px; }

.hud .lives { display: inline-flex; align-items: center; gap: 2px; }
.hud .heart {
  font-size: 11px;
  display: inline-block;
  margin-left: 1px;
  text-shadow: 0 0 0 var(--gb-0);
}
.hud .heart.on { color: var(--gb-coral); }
.hud .heart.off { color: var(--gb-1); opacity: 0.35; }

/* ---------- Life lost overlay ---------- */
.life-lost {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 50% 50%, rgba(255,111,97,0.35), transparent 65%),
    var(--gb-0);
  color: var(--gb-3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 70;
  animation: lifeLostIn 200ms ease-out;
}
@keyframes lifeLostIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.life-lost-inner {
  text-align: center;
  padding: 24px 32px;
}
.life-lost-title {
  font-size: 24px;
  color: var(--gb-coral);
  letter-spacing: 0.1em;
  text-shadow: 3px 3px 0 var(--gb-0), 6px 6px 0 var(--gb-2);
  margin-bottom: 12px;
  animation: bigShake 0.5s steps(6);
}
@keyframes bigShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
.life-lost-reason {
  font-size: 10px;
  color: var(--gb-2);
  letter-spacing: 0.16em;
  margin-bottom: 22px;
}
.life-lost-hearts {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}
.life-lost-hearts .heart.big {
  font-size: 32px;
}
.life-lost-hearts .heart.big.on { color: var(--gb-coral); }
.life-lost-hearts .heart.big.off { color: var(--gb-1); opacity: 0.4; }
.life-lost-msg {
  font-size: 9px;
  color: var(--gb-3);
  letter-spacing: 0.18em;
  animation: blink 0.6s steps(2, jump-none) infinite;
}

.board-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background:
    linear-gradient(rgba(183, 172, 232, 0.18) 1px, transparent 1px) 0 0 / 100% 24px,
    linear-gradient(90deg, rgba(183, 172, 232, 0.18) 1px, transparent 1px) 0 0 / 24px 100%,
    var(--gb-3);
}

.board {
  position: relative;
  display: grid;
  gap: 0;
  background: var(--gb-3);
  border: 2px solid var(--gb-0);
  box-shadow: 3px 3px 0 var(--gb-0);
}
.board.shake { animation: shake .35s steps(4); }
@keyframes shake {
  0%, 100% { transform: translate(0,0); }
  25% { transform: translate(-3px, 2px); }
  50% { transform: translate(3px, -2px); }
  75% { transform: translate(-2px, -2px); }
}
.cell {
  position: relative;
  border-right: 1px dashed rgba(27, 26, 14, 0.12);
  border-bottom: 1px dashed rgba(27, 26, 14, 0.12);
}
.cell.snake-head {
  background: var(--gb-0);
  z-index: 2;
}
.cell.snake-head::after {
  content: "";
  position: absolute;
  inset: 4px;
  background: var(--gb-2);
  box-shadow:
    inset 0 0 0 2px var(--gb-0);
}
.cell.snake-head[data-dir="right"]::before { content: ""; position: absolute; right: -3px; top: 8px; width: 8px; height: 8px; background: var(--gb-0); }
.cell.snake-head[data-dir="left"]::before  { content: ""; position: absolute; left: -3px; top: 8px; width: 8px; height: 8px; background: var(--gb-0); }
.cell.snake-head[data-dir="up"]::before    { content: ""; position: absolute; top: -3px; left: 8px; width: 8px; height: 8px; background: var(--gb-0); }
.cell.snake-head[data-dir="down"]::before  { content: ""; position: absolute; bottom: -3px; left: 8px; width: 8px; height: 8px; background: var(--gb-0); }

.cell.snake-body {
  background: var(--gb-2);
}
.cell.snake-body::after {
  content: "";
  position: absolute;
  inset: 3px;
  background: var(--gb-0);
}
.cell.snake-tail {
  background: var(--gb-1);
}

.cell.berry {
  background: var(--gb-3);
}
.cell.berry::after {
  content: "";
  position: absolute;
  inset: 5px;
  background: var(--gb-coral);
  border: 2px solid var(--gb-0);
  border-radius: 50%;
  animation: pulse 1s ease-in-out infinite alternate;
}
@keyframes pulse {
  from { transform: scale(.9); }
  to   { transform: scale(1.1); }
}

.cell.wild {
  background: var(--gb-3);
  z-index: 1;
}
.cell.wild::after {
  content: "!";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--gb-0);
  animation: bounce 0.7s ease-in-out infinite alternate;
}
@keyframes bounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-3px); }
}
.cell.wild .wild-spr {
  position: absolute;
  inset: 2px;
  z-index: 1;
}
.cell.wild::after {
  display: none;
}

/* ---------- Encounter / Battle ---------- */
.battle {
  position: absolute;
  inset: 0;
  background: var(--gb-3);
  display: flex;
  flex-direction: column;
}
.battle-arena {
  flex: 1;
  position: relative;
  background:
    radial-gradient(ellipse 70% 60% at 20% 30%, rgba(183, 172, 232, 0.4), transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 20%, rgba(253, 218, 36, 0.3), transparent 60%),
    linear-gradient(180deg, var(--gb-3) 0%, var(--gb-3) 55%, var(--gb-1) 55%, var(--gb-1) 100%);
  overflow: hidden;
}
.battle-arena::before {
  /* horizon dotted line */
  content: "";
  position: absolute;
  left: 0; right: 0; top: 55%;
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--gb-0) 0 4px, transparent 4px 8px);
}

.foe-mon {
  position: absolute;
  top: 18px;
  right: 24px;
  width: 110px;
  height: 110px;
  z-index: 2;
}
.foe-mon.enter { animation: foe-in .6s var(--ease, ease-out) both; }
@keyframes foe-in {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.foe-mon.shake { animation: hit .35s steps(4); }
@keyframes hit {
  0%, 100% { transform: translate(0,0); }
  25% { transform: translate(-5px, 3px); }
  50% { transform: translate(5px, -3px); }
  75% { transform: translate(-3px, -2px); }
}
.foe-mon.flee { animation: flee .5s ease-in both; }
@keyframes flee {
  to { transform: translateX(120px); opacity: 0; }
}

.player-mon {
  position: absolute;
  bottom: 0;
  left: 16px;
  width: 110px;
  height: 110px;
  z-index: 2;
}
.player-mon.enter { animation: ply-in .6s ease-out both; }
@keyframes ply-in {
  from { transform: translateX(-40px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.mon-platform {
  position: absolute;
  width: 140px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(ellipse, var(--gb-1), transparent 70%);
  z-index: 1;
}
.mon-platform.foe { top: 110px; right: 8px; }
.mon-platform.player { bottom: 0; left: 0; }

.hpbar {
  position: absolute;
  background: var(--gb-3);
  border: 2px solid var(--gb-0);
  padding: 4px 6px 4px 8px;
  box-shadow: 2px 2px 0 var(--gb-0);
  font-size: 7px;
  color: var(--gb-0);
  letter-spacing: 0.1em;
  width: 180px;
}
.hpbar.foe { top: 14px; left: 14px; }
.hpbar.player { bottom: 16px; right: 14px; }
.hpbar .name { font-size: 9px; margin-bottom: 4px; display: flex; justify-content: space-between; align-items: center; }
.hpbar .name .lvl { font-size: 7px; color: var(--gb-1); }
.hpbar .bar-row { display: flex; align-items: center; gap: 4px; font-size: 7px; }
.hpbar .bar-track {
  flex: 1;
  height: 6px;
  background: var(--gb-2);
  position: relative;
  border: 1px solid var(--gb-0);
}
.hpbar .bar-fill {
  position: absolute;
  inset: 0;
  background: var(--gb-0);
  transition: width 600ms steps(20);
}
.hpbar.foe .bar-fill { background: var(--gb-1); }
.hpbar .hp-num { font-size: 7px; margin-top: 4px; text-align: right; color: var(--gb-1); }

.battle-msg {
  height: 96px;
  background: var(--gb-3);
  border-top: 3px solid var(--gb-0);
  display: flex;
  align-items: stretch;
}
.battle-msg .msg-text {
  flex: 1;
  padding: 12px 14px;
  font-size: 10px;
  line-height: 1.5;
  color: var(--gb-0);
  position: relative;
}
.battle-msg .msg-text .caret {
  position: absolute;
  bottom: 10px; right: 14px;
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--gb-0);
  animation: blink 0.8s steps(2) infinite;
}
.battle-msg .menu {
  width: 180px;
  border-left: 2px solid var(--gb-0);
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.battle-msg .menu button {
  background: var(--gb-3);
  border: 0;
  border-right: 1px solid var(--gb-0);
  border-bottom: 1px solid var(--gb-0);
  font-family: inherit;
  font-size: 10px;
  color: var(--gb-0);
  cursor: pointer;
  letter-spacing: 0.08em;
  position: relative;
  padding: 0;
}
.battle-msg .menu button.selected {
  background: var(--gb-0);
  color: var(--gb-3);
}
.battle-msg .menu button.selected::before {
  content: "▶";
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 8px;
}

/* ---------- Catch animation ---------- */
.ball {
  position: absolute;
  width: 32px;
  height: 32px;
  z-index: 5;
}
.ball .top { position: absolute; inset: 0 0 50% 0; background: var(--gb-0); border-radius: 50% 50% 0 0; }
.ball .bot { position: absolute; inset: 50% 0 0 0; background: var(--gb-3); border-radius: 0 0 50% 50%; border: 2px solid var(--gb-0); border-top: 0; }
.ball .belt { position: absolute; left: 0; right: 0; top: 50%; height: 4px; background: var(--gb-0); transform: translateY(-50%); }
.ball .btn { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; background: var(--gb-3); border: 2px solid var(--gb-0); border-radius: 50%; transform: translate(-50%, -50%); }
.ball.throw { animation: ball-throw 0.7s cubic-bezier(.4,1.6,.6,1) forwards; }
@keyframes ball-throw {
  0%   { left: 60px; top: 200px; transform: rotate(0deg) scale(.6); }
  60%  { left: 380px; top: 60px;  transform: rotate(540deg) scale(1); }
  100% { left: 420px; top: 90px;  transform: rotate(720deg) scale(1); }
}
.ball.wiggle { animation: ball-wiggle 0.7s ease-in-out; }
@keyframes ball-wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-22deg); }
  75% { transform: rotate(22deg); }
}

.flash-white {
  position: absolute;
  inset: 0;
  background: var(--gb-3);
  z-index: 4;
  animation: flash 0.3s ease-out forwards;
}
@keyframes flash {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ---------- Pause overlay ---------- */
.pause-overlay {
  position: absolute;
  inset: 0;
  background: rgba(27, 26, 14, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.pause-menu {
  width: 240px;
  background: var(--gb-3);
  border: 3px solid var(--gb-0);
  box-shadow: 4px 4px 0 var(--gb-0);
  padding: 12px;
}
.pause-menu h2 {
  margin: 0 0 10px;
  font-size: 11px;
  color: var(--gb-0);
  letter-spacing: 0.16em;
  text-align: center;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--gb-0);
}
.pause-menu ul { margin: 0; padding: 0; list-style: none; }
.pause-menu li {
  font-size: 10px;
  padding: 6px 10px 6px 22px;
  position: relative;
  cursor: pointer;
  color: var(--gb-0);
}
.pause-menu li.selected { background: var(--gb-0); color: var(--gb-3); }
.pause-menu li.selected::before {
  content: "▶";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 8px;
}

/* ---------- Game over ---------- */
.gameover {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 50% 30%, rgba(255, 111, 97, 0.3), transparent 70%),
    var(--gb-0);
  color: var(--gb-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 40px;
  text-align: center;
}
.gameover h1 {
  font-size: 22px;
  color: var(--gb-2);
  letter-spacing: 0.08em;
  margin: 0 0 20px;
  text-shadow: 3px 3px 0 var(--gb-coral);
}
.gameover .stats {
  background: var(--gb-3);
  color: var(--gb-0);
  border: 3px solid var(--gb-3);
  padding: 14px 18px;
  width: 280px;
  margin: 0 auto;
  text-align: left;
  font-size: 10px;
  line-height: 1.8;
}
.gameover .stats .row { display: flex; justify-content: space-between; }
.gameover .cta {
  margin-top: 24px;
  font-size: 9px;
  color: var(--gb-2);
  animation: blink 1.2s steps(2, jump-none) infinite;
  letter-spacing: 0.2em;
}

/* ---------- Collection / Stellardex ---------- */
.collection {
  position: absolute;
  inset: 0;
  background: var(--gb-3);
  display: flex;
  flex-direction: column;
}
.dex-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px 10px;
  overflow: auto;
}
.dex-cell {
  background: var(--gb-3);
  border: 2px solid var(--gb-0);
  aspect-ratio: 1;
  position: relative;
  cursor: pointer;
}
.dex-cell.selected {
  box-shadow: 3px 3px 0 var(--gb-coral);
  transform: translate(-1px,-1px);
  background: var(--gb-2);
}
.dex-cell .num {
  position: absolute;
  top: 1px; left: 3px;
  font-size: 6px;
  color: var(--gb-1);
}
.dex-cell.locked { background: var(--gb-2); }
.dex-cell.locked .silhouette {
  position: absolute;
  inset: 6px;
  background: var(--gb-1);
  -webkit-mask: var(--silhouette-mask) center / contain no-repeat;
  mask: var(--silhouette-mask) center / contain no-repeat;
}
.dex-detail {
  height: 110px;
  background: var(--gb-0);
  color: var(--gb-3);
  padding: 8px 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  border-top: 3px solid var(--gb-2);
}
.dex-detail .portrait {
  width: 90px;
  height: 90px;
  background: var(--gb-3);
  border: 2px solid var(--gb-3);
  flex-shrink: 0;
}
.dex-detail .info { flex: 1; font-size: 9px; line-height: 1.6; }
.dex-detail .info .name { font-size: 12px; color: var(--gb-2); margin-bottom: 4px; }
.dex-detail .info .meta { color: var(--gb-2); }
.dex-detail .info .desc { color: var(--gb-3); font-size: 8px; margin-top: 4px; }

/* ---------- Catch popup ---------- */
.catch-popup {
  position: absolute;
  inset: 0;
  background: var(--gb-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 30px;
  z-index: 60;
}
.catch-popup h2 {
  font-size: 14px;
  color: var(--gb-0);
  letter-spacing: 0.12em;
  margin: 0;
  text-align: center;
  line-height: 1.4;
  text-shadow: 2px 2px 0 var(--gb-1);
}
.catch-popup .portrait-big {
  width: 200px;
  height: 200px;
  margin: 24px 0;
  background: var(--gb-3);
  border: 3px solid var(--gb-0);
  box-shadow: 4px 4px 0 var(--gb-1);
  position: relative;
  overflow: hidden;
}
.catch-popup .info-line {
  font-size: 9px;
  color: var(--gb-1);
  letter-spacing: 0.1em;
  line-height: 1.8;
  text-align: center;
}
.sparkle {
  position: absolute;
  width: 8px; height: 8px;
  background: var(--gb-0);
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
  animation: sparkle 1s linear infinite;
}
@keyframes sparkle {
  0%, 100% { transform: scale(.6) rotate(0deg); opacity: 0; }
  50% { transform: scale(1) rotate(180deg); opacity: 1; }
}

/* ---------- Map ---------- */
.map-board {
  flex: 1;
  position: relative;
  background:
    radial-gradient(circle at 30% 70%, rgba(183, 172, 232, 0.5) 0%, transparent 50%),
    radial-gradient(circle at 80% 30%, rgba(0, 167, 181, 0.4) 0%, transparent 50%),
    var(--gb-3);
  margin: 6px;
  border: 2px solid var(--gb-0);
  box-shadow: inset 0 0 0 2px var(--gb-3), inset 0 0 0 4px var(--gb-0);
}
.route-node {
  position: absolute;
  width: 48px;
  height: 48px;
  background: var(--gb-3);
  border: 2px solid var(--gb-0);
  box-shadow: 2px 2px 0 var(--gb-0);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--gb-0);
}
.route-node.selected {
  background: var(--gb-2);
  color: var(--gb-0);
  box-shadow: 2px 2px 0 var(--gb-0), 0 0 0 4px rgba(253, 218, 36, 0.4);
  animation: blink 1.2s steps(2, jump-none) infinite;
}
.route-node.locked { background: var(--gb-2); color: var(--gb-1); }
.route-line {
  position: absolute;
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--gb-0) 0 4px, transparent 4px 8px);
  transform-origin: 0 50%;
}
.route-label {
  position: absolute;
  font-size: 7px;
  color: var(--gb-0);
  letter-spacing: 0.1em;
  white-space: nowrap;
}

/* ---------- Stellar icon renderer ---------- */
.stellar-icon {
  width: 100%;
  height: 100%;
  display: block;
}
.stellar-icon svg { width: 100%; height: 100%; display: block; }

/* GLOBAL icon class colors — apply to the master sprite's elements directly.
   These selectors target the original Icons.svg classes wherever they appear
   (including inside <use> shadow trees, since CSS variables cascade through use). */
.st23, .st33, .st19, .st47 { fill: var(--ic-yellow) !important; stroke: var(--ic-stroke) !important; stroke-width: 1.5px !important; }
.st29, .st34             { fill: var(--ic-lilac)  !important; stroke: var(--ic-stroke) !important; stroke-width: 1.5px !important; }
.st27, .st30             { fill: var(--ic-white)  !important; stroke: var(--ic-stroke) !important; stroke-width: 1.5px !important; }
.st35                    { fill: var(--ic-black)  !important; }
.st2, .st3, .st4, .st5, .st6, .st13, .st14, .st16, .st17, .st18,
.st26, .st28, .st31, .st12, .st8 { stroke: var(--ic-stroke) !important; stroke-width: 1.5px !important; fill: none !important; }

/* Inverted (dark bg) — flip white/black so icon reads on dark */
.inverted .stellar-icon .st27,
.inverted .stellar-icon .st30 { fill: var(--ic-black) !important; }
.inverted .stellar-icon .st35 { fill: var(--ic-white) !important; }

/* In-cell mini sprite */
.cell .stellar-icon { padding: 0; }

/* utility */
.row { display: flex; align-items: center; gap: 6px; }

/* small badges */
.type-tag {
  display: inline-block;
  font-size: 7px;
  padding: 2px 5px;
  border: 1px solid var(--gb-3);
  letter-spacing: 0.1em;
}
