/* ============================================================
   base.css  -  colours, page frame, buttons, dialogs and other
   pieces that every screen shares.

   Colours live in CSS variables (custom properties) at the top.
   Change one here and it changes everywhere.
   ============================================================ */

/* Press Start 2P (Google Fonts, OFL), the 8x8 Game Boy-style font. Declared here instead of through the
   Google stylesheet so size-adjust can shrink it: its letters are far bigger than other fonts' at the
   same font-size, and font-size-adjust measured it inconsistently between elements. */
@font-face {
  font-family: "PokeDB Pixel";
  src: url(https://fonts.gstatic.com/s/pressstart2p/v16/e3t4euO8T-267oIAQAu6jDQyK3nVivM.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  size-adjust: 66%;
  font-display: swap;
}
@font-face {
  font-family: "PokeDB Pixel";
  src: url(https://fonts.gstatic.com/s/pressstart2p/v16/e3t4euO8T-267oIAQAu6jDQyK3nbivN04w.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+A720-A7FF;
  size-adjust: 66%;
  font-display: swap;
}

:root {
  --bg: #12142a;
  --panel: rgba(22, 26, 58, 0.86);
  --panel-edge: rgba(255, 255, 255, 0.14);
  --ink: #f4f6ff;
  --muted: #aab2d8;
  --gold: #ffcb05;
  --blue: #2a4b9b;
  --good: #58d68d;
  --bad: #ff6b6b;
  --warn: #ffb84d;

  /* the accent colour changes with the starter's type (see body[data-theme]) */
  --accent: #ff7a45;
  --accent-dark: #d4501f;

  --radius: 16px;
  --topbar-h: 52px;
  /* Pokégear windows (dialogs, the Bag, the Poké Ball menu): a muted parchment that sits between the dark game and a bright menu */
  --win-bg: #e4dcc4;
  --win-panel: #d6ccae;
  --win-edge: #b8aa84;
  --win-tile: #eee7d2;
  --win-shadow: #9c8c64;
  --win-ink: #241c14;
  --win-muted: #574b36;
  --win-gold: #8e4c06;
  /* soft corners for the pixel windows: windows and panels, buttons and tiles, tiny bits */
  --round: 12px;
  --round-sm: 8px;
  --round-xs: 4px;
  --pixel-font: "PokeDB Pixel", var(--font);   /* Press Start 2P, see the @font-face above */
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

/* The Pokédex device's shell (Settings > Device colour, js/settings.js sets data-shell): light to dark, the cover's
   fold, the outline and the darkest shade under the buttons */
:root {
  --shell-hi: #e0343a; --shell: #c41f2a; --shell-lo: #b01822; --shell-fold: #a8141e;
  --shell-rim: #7a1016; --shell-deep: #5a0c12; --shell-hinge: #8a1018;
  /* the buttons, swapped where a shell would swallow them: the D-pad (and pressed), the A / round buttons */
  --pad: #2a2a30; --pad-on: #48484f;
  --btn-a: radial-gradient(circle at 35% 30%, #a8dcff 0 12%, #3d8ae0 40%, #1d4fa0);
}
/* a friend's Trainers page wears their shell (js/trainers.js): red's colours first, so a shell that sets fewer doesn't
   keep the viewer's own */
[data-shell-of] {
  --shell-hi: #e0343a; --shell: #c41f2a; --shell-lo: #b01822; --shell-fold: #a8141e;
  --shell-rim: #7a1016; --shell-deep: #5a0c12; --shell-hinge: #8a1018;
  --btn-a: radial-gradient(circle at 35% 30%, #a8dcff 0 12%, #3d8ae0 40%, #1d4fa0);
}
:root[data-shell="blue"], [data-shell-of="blue"] {
  --shell-hi: #3a7ae0; --shell: #245cc4; --shell-lo: #1a4aac; --shell-fold: #16409c;
  --shell-rim: #0f2a6e; --shell-deep: #0a1d4f; --shell-hinge: #133584;
  --btn-a: radial-gradient(circle at 35% 30%, #ffc0d8 0 12%, #e0407a 40%, #a01c50);
}
:root[data-shell="yellow"], [data-shell-of="yellow"] {
  --shell-hi: #f8d040; --shell: #ecb818; --shell-lo: #d8a20c; --shell-fold: #cc960a;
  --shell-rim: #7a5608; --shell-deep: #573c04; --shell-hinge: #8c6408;
}
:root[data-shell="green"], [data-shell-of="green"] {
  --shell-hi: #3cbc58; --shell: #229a3e; --shell-lo: #198632; --shell-fold: #157a2c;
  --shell-rim: #0c4e1c; --shell-deep: #083814; --shell-hinge: #10602a;
}
:root[data-shell="pink"], [data-shell-of="pink"] {
  --shell-hi: #f070a8; --shell: #dc4c8c; --shell-lo: #c63a78; --shell-fold: #ba3270;
  --shell-rim: #7a1a48; --shell-deep: #561034; --shell-hinge: #8c2058;
}
:root[data-shell="gold"], [data-shell-of="gold"] {   /* Grand Champion's, the Trainer's Journal's top rank */
  --shell-hi: #f8d868; --shell: #d8a830; --shell-lo: #c09020; --shell-fold: #b0841a;
  --shell-rim: #6a4a08; --shell-deep: #4a3204; --shell-hinge: #7a5a10;
  --btn-a: radial-gradient(circle at 35% 30%, #ffc0b0 0 12%, #d83a2a 40%, #8a1810);
}
:root[data-shell="gilded"], [data-shell-of="gilded"] {   /* a Level 8 win's (LEVEL_SHELLS in js/data/difficulty.js): polished, so wider
  from light to dark than Grand Champion's flat gold */
  --shell-hi: #fff2a8; --shell: #e8b42c; --shell-lo: #b47c10; --shell-fold: #9c680a;
  --shell-rim: #5a3a02; --shell-deep: #3a2400; --shell-hinge: #84580a;
  --btn-a: radial-gradient(circle at 35% 30%, #ffc8d8 0 12%, #d8284a 40%, #84081e);
}
:root[data-shell="clear"], [data-shell-of="clear"] {   /* a Pokémon Master's: the see-through Game Boy, the scenery showing through */
  --shell-hi: rgba(240, 248, 255, 0.62); --shell: rgba(196, 216, 236, 0.46); --shell-lo: rgba(168, 192, 220, 0.56);
  --shell-fold: rgba(150, 176, 208, 0.6); --shell-rim: #6a84a4; --shell-deep: #3e4e66; --shell-hinge: rgba(120, 146, 180, 0.8);
  --btn-a: radial-gradient(circle at 35% 30%, #e8d8ff 0 12%, #8a5ae0 40%, #4a2690);
}
:root[data-shell="black"], [data-shell-of="black"] {
  --shell-hi: #50505c; --shell: #383840; --shell-lo: #2a2a32; --shell-fold: #26262c;
  --shell-rim: #101014; --shell-deep: #060608; --shell-hinge: #1c1c22;
  --pad: #a8a8b4; --pad-on: #d0d0da;
  --btn-a: radial-gradient(circle at 35% 30%, #ffb0b0 0 12%, #e03a3a 40%, #9a1414);
}

:root[data-shell="silver"], [data-shell-of="silver"] {   /* the Grand Catalogue's shells from here (js/data/catalogue.js), bought at the PC */
  --shell-hi: #d4d8e2; --shell: #b4b8c4; --shell-lo: #9ea2b0; --shell-fold: #9296a4;
  --shell-rim: #5a5e6a; --shell-deep: #3e424c; --shell-hinge: #6a6e7a;
}
:root[data-shell="crystal"], [data-shell-of="crystal"] {
  --shell-hi: #a898ec; --shell: #8a78d8; --shell-lo: #7664c4; --shell-fold: #6c5ab8;
  --shell-rim: #3e2e7a; --shell-deep: #2a1e58; --shell-hinge: #4a3a8c;
  --btn-a: radial-gradient(circle at 35% 30%, #c8fff4 0 12%, #3cc8b0 40%, #148a78);
}
:root[data-shell="teal"], [data-shell-of="teal"] {
  --shell-hi: #30b8b0; --shell: #189a94; --shell-lo: #12867f; --shell-fold: #0f7a74;
  --shell-rim: #08504c; --shell-deep: #053835; --shell-hinge: #0a605b;
  --btn-a: radial-gradient(circle at 35% 30%, #ffd8b0 0 12%, #f08a3a 40%, #a84e10);
}
:root[data-shell="orange"], [data-shell-of="orange"] {
  --shell-hi: #f8904a; --shell: #e8742a; --shell-lo: #d4621c; --shell-fold: #c85818;
  --shell-rim: #7a320a; --shell-deep: #562206; --shell-hinge: #8c3e0e;
}
:root[data-shell="purple"], [data-shell-of="purple"] {
  --shell-hi: #8a4ad0; --shell: #6a32b0; --shell-lo: #5a2898; --shell-fold: #52228c;
  --shell-rim: #301258; --shell-deep: #200a3e; --shell-hinge: #3c1868;
  --btn-a: radial-gradient(circle at 35% 30%, #fff4b0 0 12%, #e8c030 40%, #9a7a10);
}
:root[data-shell="white"], [data-shell-of="white"] {
  --shell-hi: #fbfbf8; --shell: #ecebe6; --shell-lo: #dcdbd4; --shell-fold: #d2d1ca;
  --shell-rim: #8a8a84; --shell-deep: #5e5e5a; --shell-hinge: #9a9a94;
  --btn-a: radial-gradient(circle at 35% 30%, #ffb0b0 0 12%, #e03a3a 40%, #9a1414);
}

body[data-theme="fire"]  { --accent: #ff7a45; --accent-dark: #d4501f; }
body[data-theme="water"] { --accent: #3fa3ff; --accent-dark: #1f6fd0; }
body[data-theme="grass"] { --accent: #4fcf6c; --accent-dark: #2a9a45; }
body[data-theme="psychic"] { --accent: #c080f0; --accent-dark: #8a45c0; }
body[data-theme="electric"] { --accent: #f8c820; --accent-dark: #b88a00; }
body[data-theme="ice"] { --accent: #66d8f0; --accent-dark: #2a8cb8; }
body[data-theme="fighting"] { --accent: #e0603c; --accent-dark: #a03420; }
body[data-theme="ground"] { --accent: #d8a850; --accent-dark: #946a2c; }
body[data-theme="flying"] { --accent: #a8a0f8; --accent-dark: #6a5cc8; }
body[data-theme="dark"] { --accent: #a88c74; --accent-dark: #5c4636; }

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* no hold-to-magnify loupe anywhere (the user's ask, 2026-10-15; the double tap held is js/no-loupe.js); typing still selects */
html { -webkit-text-size-adjust: 100%; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, [contenteditable] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--pixel-font); font-synthesis-weight: none;   /* every word on screen is pixel text (the user's call, 2026-09-28); cards keep their own type */
  line-height: 1.4;
}
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Pixel-art sprites should stay crisp when scaled up */
.pixel { image-rendering: pixelated; image-rendering: crisp-edges; }

/* ---------- behind everything: the pixel scene (#scene-bg, js/scene.js) under this dimming layer ---------- */
#backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--bg);
}
.has-scene #backdrop { background: none; }
.has-scene[data-screen="battle-screen"] #backdrop { display: none; }   /* battles show the scene at full strength */
#backdrop::after {                       /* darkens the scene so text stays readable */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 12, 32, 0.55), rgba(10, 12, 32, 0.78));
}

/* ---------- top bar ---------- */
.topbar {
  height: var(--topbar-h);
  padding: 0 max(14px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
  pointer-events: none;      /* no bar: the empty space between buttons lets taps through */
}
.topbar > * { pointer-events: auto; }
.topbar::before {   /* a fade behind the buttons once the page scrolls (body.scrolled, js/main.js), so the coins don't sit on the run card's name */
  content: "";
  position: absolute;
  inset: 0 0 -22px;
  z-index: -1;
  background: linear-gradient(180deg, rgba(10, 12, 30, 0.88), rgba(10, 12, 30, 0.6) 65%, transparent);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
body.scrolled .topbar::before { opacity: 1; }
.topbar-actions { position: relative; display: flex; align-items: center; gap: 8px; }   /* position: the Bag drops down from its right edge */

/* the Pokédex (top left): a clean 18x18 pixel sprite (index.html), drawn at 2x so its pixels stay even; it opens the
   Collection device over any screen (js/collection.js openPokedex()) */
.home-dex {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: none;
  line-height: 1;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.45));
}
.dex-sprite { width: 36px; height: 36px; transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); }
.home-dex:hover .dex-sprite { transform: rotate(-8deg) scale(1.08); }
.home-dex:active .dex-sprite { transform: scale(0.9); }

/* rows in the device's Settings app (#dev-settings) */
.dev-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 12px 9px 8px;
  border: 0;
  border-radius: var(--round-sm);
  background: none;
  color: var(--win-ink);
  font-family: var(--pixel-font);
  font-synthesis-weight: none;
  font-size: 0.75rem;
  text-align: left;
}
.dev-row:hover, .dev-row:focus-visible { background: var(--win-panel); }
.dev-row[hidden] { display: none; }
.dev-row.danger { color: #b02828; }
.mi-icon { width: 32px; height: 32px; display: grid; place-items: center; font-size: 1rem; flex: 0 0 auto; }
/* Sound's pop-out (SOUND_POPS in js/audio.js): a speaker (tap to mute; SOUND_TOGGLES) and a volume bar beside it
   (VOLUME_SLIDERS), in the Pokédex's Settings and under the title's speaker; a pixel track (the HP bar's outline) and a square knob */
.sound-ctl { display: flex; align-items: center; gap: 8px; }
.sound-mute { flex: none; display: grid; place-items: center; padding: 4px; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; border-radius: var(--round-sm); }
.sound-mute:active .snd-icon { translate: 0 2px; }
/* the title's two bars, music (🎵) over effects (🔔); the Settings app adds Cries: VOLUME_SLIDERS */
.vol-rows { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.vol-row { display: flex; align-items: center; gap: 6px; }
.vol-tag { flex: none; font-size: 0.85rem; line-height: 1; }
@keyframes cursorBlink { 50% { opacity: 0; } }
.vol-slider {
  --fill: calc(var(--v, 100) * 1%);
  flex: 1 1 auto;
  min-width: 0;
  display: block;
  height: 26px;
  margin: 0;
  background: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  touch-action: none;
}
.vol-slider::-webkit-slider-runnable-track { height: 10px; border: 2px solid #181818; border-radius: 3px; background: linear-gradient(90deg, #48c848 var(--fill), #f0f0e8 var(--fill)); }
.vol-slider::-moz-range-track { height: 6px; border: 2px solid #181818; border-radius: 3px; background: #f0f0e8; }
.vol-slider::-moz-range-progress { height: 6px; border: 2px solid #181818; border-radius: 3px 0 0 3px; background: #48c848; }
.vol-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 18px; margin-top: -6px; border: 2px solid #181818; border-radius: 3px; background: #f8f8f8; box-shadow: inset -2px -2px 0 #b8b8c8; }
.vol-slider::-moz-range-thumb { width: 12px; height: 14px; border: 2px solid #181818; border-radius: 3px; background: #f8f8f8; box-shadow: inset -2px -2px 0 #b8b8c8; }
.vol-slider:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
/* a finger's size: a taller bar to land on and a bigger thumb (js/audio.js's fingerSlider() takes a touch anywhere on it) */
@media (pointer: coarse) {
  .vol-slider { height: 40px; }
  .vol-slider::-webkit-slider-runnable-track { height: 14px; }
  .vol-slider::-webkit-slider-thumb { width: 28px; height: 30px; margin-top: -10px; border-radius: 6px; }
  .vol-slider::-moz-range-track, .vol-slider::-moz-range-progress { height: 10px; }
  .vol-slider::-moz-range-thumb { width: 24px; height: 26px; border-radius: 6px; }
}
/* muted: the bar greys out, still draggable (turning it up unmutes) */
.sound-ctl.muted .vol-slider { filter: grayscale(1); opacity: 0.55; }
/* The Settings app (#dev-settings, js/settings.js), a games' OPTIONS screen: a card per group, its head a band in the
   group's colour with a smooth icon; volume bars with an LCD number, every other option a row of chips, the picked one lit */
.dev-settings { display: flex; flex-direction: column; gap: 14px; }
.set-group {
  --tone: #3c8cf0; --tone-dk: #1e4fa0;
  display: block; overflow: hidden; border: 3px solid var(--win-ink); border-radius: 12px; background: #fbf7ea;
  box-shadow: 0 4px 0 rgba(36, 28, 20, 0.22);
}
.set-group[data-tone="display"] { --tone: #4cb84a; --tone-dk: #257a38; }
.set-group[data-tone="battle"] { --tone: #e8483c; --tone-dk: #a82420; }
.set-group[data-tone="save"] { --tone: #8a64d8; --tone-dk: #4e3290; }
.set-group[data-tone="trainer"] { --tone: #e89a20; --tone-dk: #9a5a10; }
.set-name-row { display: flex; gap: 6px; margin-top: 4px; }
.set-name-input {
  flex: 1; min-width: 0; padding: 8px 9px 7px; border: 2px solid #1f3a14; border-radius: 7px; background: #b6d68e; color: #1f3a14;
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.12); font: 0.75rem/1 var(--pixel-font); text-transform: uppercase;
}
@media (pointer: coarse) { .set-name-input { font-size: 16px; padding: 6px 8px 5px; } }   /* iOS zooms in on a smaller box */
.set-name-input::placeholder { color: rgba(31, 58, 20, 0.45); }
.set-name-input:focus { outline: 2px solid var(--tone); outline-offset: 1px; }
.set-chip.set-name-save { flex: none; padding: 8px 14px 7px; }
/* Save holds only Sign in and Abandon run, each shown only sometimes */
.set-group[data-tone="save"]:not(:has(> .dev-row:not([hidden]))) { display: none; }
.set-head {
  display: flex; align-items: center; gap: 9px; min-height: 42px; padding: 5px 8px 5px 7px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent 55%), var(--tone);
  border-bottom: 3px solid var(--win-ink); color: #fff; text-shadow: 2px 2px 0 var(--tone-dk);
}
.set-head b { font-weight: 400; font-size: 0.75rem; letter-spacing: 2px; text-transform: uppercase; }
.set-ico { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border: 2px solid var(--win-ink); border-radius: 50%; background: #fff; }
.set-ico svg { width: 20px; height: 20px; }
.set-head .sound-mute { margin-left: auto; width: 36px; height: 30px; border: 2px solid var(--win-ink); border-radius: 8px; background: #fff; box-shadow: 0 2px 0 var(--tone-dk); }
.set-head .sound-mute:active { translate: 0 2px; box-shadow: none; }
.set-head .snd-icon { font-size: 1rem; }
.set-head .snd-icon svg { width: 20px; height: 20px; }
.set-group > :is(.vol-row, .set-opt, .dev-row) + :is(.vol-row, .set-opt, .dev-row) { border-top: 2px dashed rgba(36, 28, 20, 0.14); }
.dev-settings .vol-row { display: grid; grid-template-columns: 22px 4.6em minmax(0, 1fr) 38px; align-items: center; gap: 8px; padding: 9px 10px; }
.dev-settings .vol-tag svg { display: block; width: 22px; height: 22px; }
.vol-name, .set-name { font-size: 0.75rem; color: var(--win-ink); }
.vol-num {
  padding: 5px 0 4px; border: 2px solid #1f3a14; border-radius: 5px; background: #b6d68e; color: #1f3a14;
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.12); font-size: 0.75rem; text-align: center;
}
.sound-ctl.muted .vol-num { opacity: 0.5; }
.dev-settings .vol-slider::-webkit-slider-runnable-track { background: linear-gradient(90deg, var(--tone) var(--fill), #f0f0e8 var(--fill)); }
.dev-settings .vol-slider::-moz-range-progress { background: var(--tone); }
.set-opt { display: flex; flex-direction: column; gap: 4px; padding: 10px 10px 11px; }
.set-opt small { font-size: 0.75rem; line-height: 1.4; color: #6a5e48; }
.reload-log small span { display: block; }
.set-chips {
  display: grid; grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)); gap: 3px; margin-top: 4px; padding: 3px;
  border-radius: 9px; background: #e6dec6; box-shadow: inset 0 2px 0 rgba(36, 28, 20, 0.14);
}
.set-chip {
  min-width: 0; padding: 8px 0 7px; border: 0; border-radius: 7px; background: none; color: #6a5e48; cursor: pointer;
  font: 0.75rem/1 var(--pixel-font); font-synthesis-weight: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background-color 0.15s, color 0.15s;
}
@media (hover: hover) { .set-chip:hover:not([aria-checked="true"]) { background: rgba(255, 255, 255, 0.6); color: var(--win-ink); } }
.set-chip[aria-checked="true"] {
  background: var(--tone); color: #fff; text-shadow: 1px 1px 0 var(--tone-dk);
  box-shadow: 0 2px 0 var(--tone-dk), inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}
.set-chip:active { translate: 0 1px; }
.set-picked { color: var(--tone-dk); }
.set-chip.swatch { display: grid; place-items: center; padding: 5px 0; }
.set-chip.swatch::before {
  content: ""; width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.45) 0 18%, transparent 20%), var(--sw);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.25), 0 2px 0 rgba(36, 28, 20, 0.25);
}
.set-chip.swatch[aria-checked="true"]::before { box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.25), 0 0 0 3px #fff; }
.set-chip:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.set-group > .dev-row { border-radius: 0; padding: 10px 12px 10px 8px; font-size: 0.75rem; }
@keyframes menuDrop {
  from { opacity: 0; transform: translateY(-6px) scale(0.92); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .drop { animation: none; }
}
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(12, 14, 34, 0.55);          /* frosted glass, so it reads over any backdrop */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
  font-weight: 700;
}
.icon-btn:hover { background: rgba(40, 46, 96, 0.75); }

main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.screen { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 18px 16px 24px; }

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--gold);
  text-decoration: underline;
  font-size: inherit;
}

/* ---------- panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 16px;
  backdrop-filter: blur(6px);
}

/* ---------- buttons: Gen 1-3 menu options ----------
   A cream box in a dark pixel frame with pixel text. A ▶ cursor blinks beside the one you point at
   (the left padding keeps room for it). Primary buttons get an orange frame, danger a red one. */
.btn {
  position: relative;
  padding: 9px 20px 9px 26px;
  border: 3px solid #b8b8c8;
  border-radius: var(--round-sm);
  background: var(--win-tile);
  color: var(--win-ink);
  font-family: var(--pixel-font); font-synthesis-weight: none;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow: none;
  box-shadow: 0 0 0 2px #303038, inset 0 0 0 2px #303038, 3px 3px 0 2px rgba(0, 0, 0, 0.4);
}
.btn::before {
  content: '▶';
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.6em;
  opacity: 0;
}
.btn:where(:not(:disabled)):where(:hover, :focus-visible)::before { animation: cursorBlink 1s steps(1) infinite; opacity: 1; }
.btn:hover:not(:disabled) { background: #fffaf0; }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 0 0 0 2px #303038, inset 0 0 0 2px #303038, 1px 1px 0 2px rgba(0, 0, 0, 0.4); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { border-color: #f89030; }
.btn.danger { border-color: #e04040; color: #a01818; }
.btn.small { padding: 5px 12px 5px 20px; font-size: 0.82rem; }
.btn.small::before { left: 7px; }
.btn.big { padding: 13px 34px 13px 40px; font-size: 1.15rem; }
.btn.big::before { left: 14px; }

/* ---------- small pieces ---------- */
.chip {
  display: inline-block;
  white-space: nowrap;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.16);
}

/* Health bars */
.bar {
  position: relative;
  height: 20px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.3);
}
.bar-fill {
  height: 100%;
  width: 100%;
  background: var(--good);
  transition: width 0.5s ease, background-color 0.3s;
}
.bar-fill[data-level="mid"] { background: var(--warn); }
.bar-fill[data-level="low"] { background: var(--bad); }
.bar-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 800;
  text-shadow: 0 1px 2px #000;
}

/* ---------- tap-to-read hint (js/tips.js): a title's text, for touch screens that can't hover ---------- */
/* a mini copy of the battle's Gold/Silver text box; it stays up until the next tap anywhere */
.tap-tip {
  position: fixed;
  z-index: 110;
  max-width: min(300px, calc(100vw - 16px));
  padding: 8px 24px 8px 12px;
  border: 3px solid #b8b8c8;
  border-radius: var(--round);
  background: var(--win-bg);
  color: var(--win-ink);
  box-shadow: 0 0 0 2px #303038, inset 0 0 0 2px #303038, 3px 3px 0 2px rgba(0, 0, 0, 0.4);
  font-family: var(--pixel-font); font-synthesis-weight: none;
  font-size: 0.8rem;
  line-height: 1.4;
  text-align: left;
  animation: tipIn 0.15s ease-out;
}
.tap-tip::after {
  content: '▼';
  position: absolute;
  right: 8px;
  bottom: 5px;
  font-size: 0.75rem;
  color: #c02020;
  animation: cursorBlink 1s steps(1) infinite;
}
@keyframes tipIn { from { opacity: 0; transform: scale(0.9); } }

/* ---------- dialogs ---------- */
.dialog {
  width: min(600px, 92vw);
  max-height: 88vh;
  max-height: 88dvh;
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--panel-edge);
  border-radius: 20px;
  background: #1b2046;
  color: var(--ink);
}
.dialog::backdrop { background: rgba(5, 6, 20, 0.72); backdrop-filter: blur(3px); }
.dialog h2 { margin-bottom: 12px; color: var(--gold); }
.dialog h3 { margin: 16px 0 6px; }
.dialog p, .dialog li { margin-bottom: 8px; }
.dialog a { color: var(--gold); }
.dialog.small-dialog { width: min(400px, 92vw); }
.crossroads-paths { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.crossroads-path { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px; }
.crossroads-types { font-size: 0.85rem; opacity: 0.85; }

/* Every window and panel is a light Pokégear menu, like the Bag: cream inside a chunky grey frame.
   Re-pointing the colour tokens here re-themes whatever sits inside; only the game cards keep
   their own look. A panel inside a window is a flat inset box instead of a second frame. */
:is(.dialog, .panel) {
  --ink: var(--win-ink);
  --muted: var(--win-muted);
  --panel: var(--win-panel);
  --panel-edge: var(--win-edge);
  --gold: var(--win-gold);
  color: var(--win-ink);
  font-family: var(--pixel-font); font-synthesis-weight: none;
}
.dialog {
  border-radius: var(--round);
  border: 3px solid #b8b8c8;
  background: var(--win-bg);
  box-shadow: 0 0 0 2px #303038, inset 0 0 0 2px #303038, 0 20px 60px rgba(0, 0, 0, 0.55);
}
.panel {
  border-radius: var(--round);
  border: 3px solid #b8b8c8;
  background: var(--win-bg);
  box-shadow: 0 0 0 2px #303038, inset 0 0 0 2px #303038, 4px 4px 0 2px rgba(0, 0, 0, 0.4);
  backdrop-filter: none;
}
.dialog .panel { border: 2px solid var(--win-edge); background: var(--win-panel); box-shadow: none; }
.dev-settings { font-family: var(--pixel-font); font-synthesis-weight: none; }
:is(.dialog, .panel) h2 { color: #283060; padding-bottom: 6px; border-bottom: 3px dashed var(--win-edge); }
:is(.dialog, .panel) h3 { color: #283060; }
:is(.dialog, .panel) :not(.card, .card *) { text-shadow: none; }
:is(.dialog, .panel) .hint { color: var(--muted); }
.dialog .howto-prev { color: var(--ink); background: var(--panel); }
.dialog .howto-dot { background: var(--panel-edge); }
.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 16px;
}
.dialog-actions form { margin: 0; }
.credits, .unlocks { padding-left: 22px; }
.disclaimer {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.9rem;
}
.unlocks { list-style: none; padding: 0; }
.unlocks li { background: rgba(88, 214, 141, 0.18); border-radius: 8px; padding: 6px 10px; }
/* the Sealed Gate's HP bar (gateBar() in js/gate.js: the gate scene and the result window): the seal's gem at
   its head, a dark crystal track in a stone frame, a rune at 75 / 50 / 25% that goes dark once passed, and a pale trail
   that lags behind a hit. Sizes: default, .big (the scene). */
.unlocks .gate-line { background: rgba(160, 120, 255, 0.18); }
.unlocks .seal-bar { margin: 8px 2px 2px; }
.gate-hp { display: block; margin-top: 2px; font-size: 0.75rem; text-align: right; color: #d8c8f8; }
.seal-bar { --gem: 16px; --tall: 10px; --edge: 2px; position: relative; display: flex; align-items: center; height: var(--gem); }
.seal-bar.big { --gem: 22px; --tall: 14px; }
.seal-bar-track {
  position: relative; flex: 1; height: var(--tall); margin-left: calc(var(--gem) * -0.4);
  background: repeating-linear-gradient(-45deg, #170c2c 0 3px, #0c0618 3px 6px);
  box-shadow: 0 0 0 var(--edge) #0e0818, 0 0 0 calc(var(--edge) * 2) #7a6ea2, 0 0 0 calc(var(--edge) * 3) #0e0818, inset 0 var(--edge) 0 rgba(0, 0, 0, 0.6);
}
.seal-bar-fill, .seal-bar-trail { position: absolute; left: 0; top: 0; bottom: 0; }
.seal-bar-trail { width: calc(var(--trail, 1) * 100%); background: #fff0f8; transition: width 0.6s ease-in; }
.seal-bar-fill {
  width: calc(var(--hp, 1) * 100%); overflow: hidden;
  background: linear-gradient(#ffd0e8 0 20%, #ff6aa8 20% 50%, #e02a70 50% 80%, #8a1040 80%);
}
.seal-bar-fill::after {   /* light running along it */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 42%, rgba(255, 255, 255, 0.6) 50%, transparent 58%) no-repeat;
  background-size: 250% 100%; animation: sealShine 2.8s linear infinite;
}
@keyframes sealShine { from { background-position: 160% 0; } to { background-position: -60% 0; } }
.seal-bar-gem {
  position: relative; z-index: 2; flex: none; width: var(--gem); height: var(--gem); rotate: 45deg; scale: 0.72;
  background: linear-gradient(135deg, #ffd0e8 0 22%, #ff70b0 22% 45%, #c02068 45% 75%, #5a0c38 75%);
  box-shadow: 0 0 0 var(--edge) #0e0818, 0 0 0 calc(var(--edge) * 2) #a498c8, 0 0 0 calc(var(--edge) * 3) #0e0818, 0 0 10px 2px rgba(255, 90, 170, 0.55);
  animation: sealGem 2.4s ease-in-out infinite;
}
@keyframes sealGem { 50% { box-shadow: 0 0 0 var(--edge) #0e0818, 0 0 0 calc(var(--edge) * 2) #a498c8, 0 0 0 calc(var(--edge) * 3) #0e0818, 0 0 16px 4px rgba(255, 120, 190, 0.8); } }
.seal-bar-rune {
  position: absolute; top: 50%; z-index: 1; width: calc(var(--tall) * 0.8 + 2px); aspect-ratio: 1; translate: -50% -50%; rotate: 45deg;
  background: #ffd0e8; box-shadow: 0 0 0 var(--edge) #0e0818, 0 0 6px 1px rgba(255, 106, 168, 0.9);
}
.seal-bar:is([data-stage="1"], [data-stage="2"], [data-stage="3"], [data-stage="4"]) .seal-bar-rune[data-k="1"],
.seal-bar:is([data-stage="2"], [data-stage="3"], [data-stage="4"]) .seal-bar-rune[data-k="2"],
.seal-bar:is([data-stage="3"], [data-stage="4"]) .seal-bar-rune[data-k="3"] { background: #3a3256; box-shadow: 0 0 0 var(--edge) #0e0818; }
.seal-bar.big:is([data-stage="1"], [data-stage="2"], [data-stage="3"]) .seal-bar-rune[data-k="1"],
.seal-bar.big:is([data-stage="2"], [data-stage="3"]) .seal-bar-rune[data-k="2"],
.seal-bar.big[data-stage="3"] .seal-bar-rune[data-k="3"] { animation: runeBreak 0.7s ease-out both; }
@keyframes runeBreak { 0% { background: #fff; scale: 2.2; box-shadow: 0 0 0 var(--edge) #0e0818, 0 0 18px 6px #fff; } 40% { background: #ff6aa8; scale: 1.4; } }
/* past 25% the seal is failing: the bar and its gem flicker */
.seal-bar[data-stage="3"] .seal-bar-fill, .seal-bar[data-stage="3"] .seal-bar-gem { animation: sealFail 1.3s steps(1) infinite; }
@keyframes sealFail { 0%, 62%, 74%, 100% { filter: none; } 66%, 86% { filter: brightness(1.7) saturate(1.2); } 70% { filter: brightness(0.6); } }
@media (prefers-reduced-motion: reduce) { .seal-bar *, .seal-bar *::after { animation: none !important; } .seal-bar-trail { transition: none; } }

.noscript { padding: 20px; text-align: center; }

/* ---------- respect people who turn animations off ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 8-bit pixel icons that js/icons.js swaps in for emoji; they size with the text like the emoji did */
.px-wrap { display: inline-block; line-height: 1; vertical-align: -0.2em; }
.px-icon { display: block; width: 1.15em; height: 1.15em; }
/* inside the Collection device the same emoji become smooth vector art (SMOOTH_EMOJI in js/smooth-icons.js) */
.si-wrap > .smooth-icon { width: 1.15em; height: 1.15em; }
/* PokéSprite item/relic art (itemSprite() in js/ui.js): 32px sprites with padding, so a little bigger than a pixel icon */
.item-sprite { display: block; width: 1.6em; height: 1.6em; max-width: none; flex: none; image-rendering: pixelated; }
/* PokéCoins spin like an arcade coin every few seconds: stepped frames, so it stays pixel art */
.px-wrap[aria-label="💰"] .px-icon { animation: coinSpin 2.4s steps(1) infinite; }
@keyframes coinSpin {
  0%, 55%, 100% { transform: scaleX(1); filter: none; }
  59% { transform: scaleX(0.7); }
  63% { transform: scaleX(0.35); filter: brightness(1.2); }
  67% { transform: scaleX(0.12); filter: brightness(1.4); }
  71% { transform: scaleX(-0.35); filter: brightness(1.2); }
  75% { transform: scaleX(-0.7); }
  79% { transform: scaleX(-1); }
  83% { transform: scaleX(-0.7); }
  87% { transform: scaleX(-0.35); filter: brightness(1.2); }
  91% { transform: scaleX(0.12); filter: brightness(1.4); }
  95% { transform: scaleX(0.7); }
}
/* the Game Corner perk arrow hops up like a stat raise, flashing at the top */
.px-wrap[aria-label="⏫"] .px-icon { animation: statUp 1.6s steps(1) infinite; }
@keyframes statUp {
  0%, 60%, 100% { transform: translateY(0); filter: none; }
  10% { transform: translateY(-8%); }
  20% { transform: translateY(-17%); filter: brightness(1.25) drop-shadow(0 0 2px #fff4b0); }
  30% { transform: translateY(-25%); filter: brightness(1.45) drop-shadow(0 0 3px #fff4b0); }
  40% { transform: translateY(-17%); filter: brightness(1.2); }
  50% { transform: translateY(-8%); }
}
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Scrollbars: chunky square Game Boy-style bars instead of the browser's own (the user's call). A light grey
   bevelled thumb in a dark slot on the page, and in a parchment slot inside windows. Chrome ignores the
   ::-webkit-scrollbar rules once scrollbar-color is set, so that's only for browsers without them (Firefox). */
::-webkit-scrollbar { width: 14px; height: 14px; }
::-webkit-scrollbar-track { background: #303038; box-shadow: inset 0 0 0 2px #181010; }
::-webkit-scrollbar-thumb {
  background: #c8c8d0;
  border: 2px solid #181010;
  box-shadow: inset 2px 2px 0 #f8f8f8, inset -2px -2px 0 #888890;
}
::-webkit-scrollbar-thumb:hover { background: #e0e0e8; }
::-webkit-scrollbar-thumb:active { background: #f8d030; box-shadow: inset 2px 2px 0 #fff0a0, inset -2px -2px 0 #c88810; }
::-webkit-scrollbar-corner { background: transparent; }
:is(.dialog, .panel, .bag) ::-webkit-scrollbar-track, :is(.dialog, .panel)::-webkit-scrollbar-track {
  background: var(--win-panel);
  box-shadow: inset 0 0 0 2px var(--win-edge);
}
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-color: #c8c8d0 #303038; }
  :is(.dialog, .panel, .bag), :is(.dialog, .panel, .bag) * { scrollbar-color: #888890 var(--win-panel); }
}

/* ---------- the cloud save windows (js/cloud.js) ---------- */
.cloud-google { width: 100%; margin: 4px 0 12px; }
.cloud-or { margin-bottom: 6px; }
.cloud-email { display: flex; gap: 8px; flex-wrap: wrap; }
.cloud-email input {
  flex: 1 1 100%; min-width: 0;
  padding: 10px; font: inherit; font-size: 0.8rem;
  color: var(--win-ink); background: #fff;
  border: 2px solid var(--win-edge); border-radius: var(--round-xs);
}
.cloud-email input:focus { outline: 3px solid #6890f0; outline-offset: 1px; }
.cloud-email-actions, .cloud-email-extra { display: flex; gap: 8px; width: 100%; }
.cloud-email-actions .btn { flex: 1; }
.cloud-email-extra { justify-content: space-between; flex-wrap: wrap; }
#cloud-note:empty { display: none; }
#cloud-note { margin-top: 12px; }
.cloud-saves { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.cloud-save { padding: 12px; display: flex; flex-direction: column; }
.cloud-save h3 { margin: 0 0 4px; }
.cloud-lines { list-style: none; padding: 0; margin: 6px 0 12px; flex: 1; font-size: 0.8rem; line-height: 1.5; }
.dialog .cloud-lines li { margin: 0 0 2px; }
.cloud-save .btn { align-self: stretch; }
@media (max-width: 520px) {
  .cloud-saves { grid-template-columns: 1fr; gap: 8px; }
  .cloud-save { padding: 8px 10px; }
  .cloud-save .hint { margin-bottom: 0; }
  .cloud-lines { margin: 4px 0 8px; }
}

/* names are in capitals everywhere (the user's call, 2026-10-11): every box you type one in shows it so as you type */
.tdx-field, .tc-name-input, .pc-name-box, .lb-name-input, .set-name-input { text-transform: uppercase; }

/* iOS can't lock a page's rotation, so a phone held sideways gets this cover instead; tablets and PCs keep landscape.
   `html.sideways` is set by index.html from the device's orientation, not a media query on the viewport's shape: the
   on-screen keyboard shrinks the viewport, which made a phone held upright read as landscape while typing a name.
   Modal dialogs sit in the top layer over any z-index, so they're faded out under it. */
#rotate-cover { display: none; }
html.sideways #rotate-cover {
  position: fixed; inset: 0; z-index: 2147483647; display: grid; place-content: center; justify-items: center; gap: 18px;
  background: #1b1f3a; color: #fff; text-align: center; font: 0.875rem/1.6 var(--pixel-font); font-synthesis-weight: none;
}
html.sideways #rotate-cover svg { width: 72px; height: 72px; color: #ffcb05; }
html.sideways dialog, html.sideways dialog::backdrop { opacity: 0 !important; pointer-events: none !important; }
