/* Pixel-art game UI over an ASCII scene. Frames (thorny borders, title tabs,
   ticked caption boxes, dithered fills) are painted on canvases by
   src/fishing/frames.js; this file handles layout, type and buttons. */
:root {
  color-scheme: dark;
  font-family: "Handjet", ui-monospace, Menlo, monospace;
  font-size: 22px;
  font-weight: 500;
  line-height: 1.15;
  font-synthesis: none;
  --ink: #0a1412;
  --deep: #13221f;
  --dark: #1e3833;
  --mid: #3c6860;
  --soft: #6e9a8c;
  --light: #a9c7b4;
  --bone: #e2e2c8;
  --gold: #e2b85e;
  --gold-dark: #8c6a2c;
  --ember: #c4643e;
}

* { box-sizing: border-box; }

html, body { width: 100%; min-width: 320px; min-height: 100%; margin: 0; }
/*
 * Played like an app: the page is pinned to the screen, so it can't be scrolled or
 * shifted under the status bar; no rubber-band, no double-tap zoom, no tap flashes.
 */
html, body { position: fixed; inset: 0; overflow: hidden; overscroll-behavior: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
/* iPhone home-screen app: unpinned, the scene takes the whole screen as 100vh (see main.js). */
html.ios-app, html.ios-app body { position: static; height: 100vh; }
html.ios-app .scene { position: absolute; inset: auto; top: 0; left: 0; width: 100%; height: 100vh; }
#layout-report {
  position: fixed;
  z-index: 100;
  top: calc(env(safe-area-inset-top, 0px) + 70px);
  left: 8px;
  right: 8px;
  margin: 0;
  padding: 10px;
  color: #e9e3cf;
  font: 13px/1.4 ui-monospace, Menlo, monospace;
  white-space: pre-wrap;
  background: rgba(10, 16, 14, 0.92);
  border: 2px solid #e9e3cf;
}
/* Nothing gets selected or pops a callout on a long press (holding to reel in), except text fields. */
* { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }

body {
  overflow: hidden;
  background: #14221f;
  color: var(--bone);
}

/* No double-tap zoom on controls. */
button { font: inherit; color: inherit; touch-action: manipulation; }

/* Hidden after a cast until the mouse moves again. */
.cursor-hidden, .cursor-hidden * { cursor: none !important; }

.sprite { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }

.scene {
  /*
   * Always exactly the screen, whatever the browser bars or the keyboard did.
   * In an iPhone web app main.js sets the full screen height instead (fillScreen).
   */
  position: fixed;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  background: #14221f;
}

/* Both canvases may be wider than the screen on a phone; main.js sizes and shifts them. */
#water-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.scene-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.scene::after {
  position: absolute;
  z-index: 1;
  inset: 0;
  content: "";
  pointer-events: none;
  /* A soft vignette closing in from the edges, over a faint top and bottom shade. */
  background:
    radial-gradient(ellipse 78% 72% at 50% 48%, transparent 50%, rgba(4, 8, 14, 0.55) 100%),
    linear-gradient(0deg, rgba(3, 12, 10, 0.2), transparent 22%, transparent 84%, rgba(4, 14, 12, 0.2));
}

/* ---------- Painted frames ---------- */

:where(.framed:not(dialog)) { position: relative; }
.framed {
  isolation: isolate;
  border: 0;
  background: transparent;
}
.frame-art {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  pointer-events: none;
}

.title-tab {
  display: inline-block;
  margin: 0;
  padding: 10px 16px;
  color: var(--bone);
  font-size: 30px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  outline: none;
}
.title-tab-small { padding: 8px 12px; font-size: 22px; }

.picture {
  display: grid;
  min-height: 140px;
  place-items: center;
  padding: 18px 12px 12px;
}
.picture .sprite { max-width: 100%; height: auto !important; filter: drop-shadow(3px 3px 0 rgba(10, 20, 18, 0.7)); }

.caption {
  display: grid;
  gap: 8px;
  padding: 16px 14px;
  text-align: center;
}

/* Title tab hangs over the top of its picture, like a card header. */
.card-scene { position: relative; padding-top: 22px; }
.card-scene > .title-tab { position: absolute; z-index: 2; top: 0; left: 50%; transform: translateX(-50%); }

/* ---------- Buttons ---------- */

.pixel-btn {
  --cut: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 10px 12px 9px;
  border: 2px solid var(--bone);
  color: var(--bone);
  font-size: 22px;
  line-height: 1.3;
  background: var(--ink);
  clip-path: polygon(var(--cut) 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, var(--cut) 100%, 0 calc(100% - var(--cut)), 0 var(--cut));
  cursor: pointer;
}
.pixel-btn b { color: var(--gold); font-weight: 500; }
.pixel-btn:hover:not(:disabled) { background: var(--dark); }
.pixel-btn:active:not(:disabled) { transform: translateY(2px); }
.pixel-btn-primary { color: var(--ink); background: var(--bone); }
.pixel-btn-primary b { color: var(--ink); }
.pixel-btn-primary:hover:not(:disabled) { background: var(--light); }
.pixel-btn-quiet { border-color: var(--light); color: var(--light); }
.pixel-btn-square { width: 40px; padding: 0; font-size: 22px; }
.pixel-btn:disabled { border-color: var(--mid); color: var(--soft); background: var(--ink); cursor: not-allowed; }
.pixel-btn:disabled b { color: var(--mid); }

:is(.pixel-btn, .icon-btn, .slot, .pick):focus-visible { outline: 2px dashed var(--gold); outline-offset: 3px; }

/* ---------- HUD ---------- */

.hud { position: absolute; z-index: 3; }

.hud-top {
  /* Clear of a phone's notch and rounded corners. */
  top: calc(env(safe-area-inset-top, 0px) + clamp(12px, 3vh, 24px));
  right: calc(env(safe-area-inset-right, 0px) + clamp(12px, 3vw, 28px));
  left: calc(env(safe-area-inset-left, 0px) + clamp(12px, 3vw, 28px));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.hud-top .clock { min-height: 60px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 16px 10px 12px;
  color: var(--gold);
  font-size: 30px;
  font-variant-numeric: tabular-nums;
}
.chip-small { min-height: 42px; padding: 8px 12px 8px 10px; font-size: 22px; }

.icon-btn {
  position: relative;
  display: grid;
  width: 60px;
  height: 60px;
  place-items: center;
  padding: 0;
  cursor: pointer;
}
.icon-btn:hover .sprite { transform: translateY(-1px); }
.icon-btn:active { transform: translateY(2px); }

.badge {
  position: absolute;
  z-index: 2;
  top: -6px;
  right: -6px;
  min-width: 22px;
  padding: 5px 5px 4px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  text-align: center;
  background: var(--gold);
  box-shadow: 0 0 0 2px var(--ink);
}
.badge[hidden] { display: none; }

.loadout {
  bottom: calc(env(safe-area-inset-bottom, 0px) + clamp(12px, 3vh, 24px));
  left: calc(env(safe-area-inset-left, 0px) + clamp(12px, 3vw, 28px));
  display: flex;
  align-items: center;
  gap: 10px;
  transition: opacity 200ms steps(4), transform 200ms steps(4);
}
.pack-hud {
  right: calc(env(safe-area-inset-right, 0px) + clamp(12px, 3vw, 28px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + clamp(12px, 3vh, 24px));
  transition: opacity 200ms steps(4), transform 200ms steps(4);
}
.is-fishing :is(.loadout, .pack-hud) { opacity: 0.4; transform: translateY(6px); }

.slot {
  position: relative;
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  padding: 6px;
  cursor: pointer;
}
.slot:hover:not(:disabled) .sprite { transform: translateY(-2px); }
.slot:active:not(:disabled) { transform: translateY(2px); }
.slot:disabled { cursor: default; }
/* Item tiles in the backpack. */
.pick {
  position: relative;
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  padding: 2px 2px 18px;
  border: 2px solid var(--dark);
  background: var(--deep);
  cursor: pointer;
}
.pick:hover { border-color: var(--soft); }
.pick.is-selected { border-color: var(--bone); }
.pick-tag { position: absolute; right: 2px; bottom: 6px; left: 2px; color: var(--gold); font-size: 18px; line-height: 1; text-align: center; }

/* The bait in use, bottom left: tap it to change bait. */
.bait-chip {
  display: inline-flex;
  cursor: pointer;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 6px 14px 6px 10px;
  color: var(--gold);
  font-size: 26px;
  font-variant-numeric: tabular-nums;
}
.bait-chip-sprite .sprite { display: block; }
.bait-chip:hover:not(:disabled) .sprite { transform: translateY(-2px); }
.bait-chip:active:not(:disabled) { transform: translateY(2px); }
.bait-chip:disabled { cursor: default; }
.bait-chip.is-empty { color: var(--ember); }
.pack-hooks { margin-left: auto; color: var(--bone); }
.pack-hooks.is-empty { color: var(--ember); }
.sheet-heading .pack-hooks + form { margin-left: 0; }
.catch-actions [hidden] { display: none; }
.catch-note { margin: 6px 0 0; color: var(--gold); font-size: 18px; text-align: center; }
.catch-note[hidden] { display: none; }
.focus-sink { position: absolute; width: 1px; height: 1px; overflow: hidden; outline: none; }

/* ---------- Fight ---------- */

.fight-hud {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: clamp(24px, 6vh, 56px);
  display: flex;
  align-items: stretch;
  gap: 10px;
  width: min(500px, calc(100% - 24px));
  transform: translateX(-50%);
  pointer-events: none;
}
.fight-hud[hidden] { display: none; }
.tension {
  position: relative;
  flex: 1;
  height: 40px;
  padding: 10px;
}
.tension::after {
  position: absolute;
  inset: 10px;
  content: "";
  background: repeating-linear-gradient(90deg, transparent 0 calc(5% - 2px), var(--ink) calc(5% - 2px) 5%);
  pointer-events: none;
}
.tension-fill { width: 0; height: 100%; background: var(--light); }
.tension-fill[data-level="mid"] { background: var(--gold); }
.tension-fill[data-level="high"] { background: var(--ember); }

.toast {
  position: absolute;
  z-index: 5;
  top: 28%;
  left: 50%;
  padding: 14px 20px 13px;
  color: var(--bone);
  font-size: 22px;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: toast-in 240ms steps(4);
}
.toast[hidden] { display: none; }
.toast.is-bad { color: var(--ember); }
.toast.is-good { color: var(--gold); }

@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -20%); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(12px); } }

/* ---------- Dialogs ---------- */

.sheet {
  width: min(420px, calc(100% - 24px));
  max-height: calc(100% - 32px);
  padding: 30px 28px 28px;
  color: var(--bone);
  overflow: visible;
}
.sheet[open] { display: flex; flex-direction: column; gap: 16px; animation: pop-in 200ms steps(4); }
.sheet-wide { width: min(660px, calc(100% - 24px)); }
.sheet::backdrop { background: rgba(6, 12, 11, 0.72); }
.sheet h2 { margin: 0; font-size: 30px; font-weight: 500; line-height: 1.4; }
.sheet-heading { display: flex; align-items: center; gap: 12px; }
.sheet-heading .title-tab { margin-right: auto; }
.sheet-heading form { margin: 0; }

.catch-sheet .picture { min-height: 170px; }
.catch-weight { color: var(--gold); font-size: 30px; }
.catch-actions { display: grid; gap: 10px; }
.catch-actions .pixel-btn { justify-content: space-between; min-height: 46px; padding-inline: 16px; white-space: nowrap; }
.catch-actions .pixel-btn-quiet { justify-content: center; min-height: 40px; }

.tabs { display: flex; gap: 8px; }
.tab { flex: 1; }
.tab.is-active { color: var(--ink); background: var(--bone); }

.card-grid,
.trophy-wall {
  min-height: 0;
  max-height: min(60vh, 560px);
  overflow-y: auto;
  margin: 0;
  padding: 4px 6px 4px 0;
  list-style: none;
  scrollbar-color: var(--mid) transparent;
}
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.card-grid[hidden] { display: none; }
.card {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 14px 12px 12px;
  text-align: center;
}
.card-art { display: grid; height: 64px; place-items: center; }
.card strong { font-size: 30px; font-weight: 500; }
.card small { min-height: 21px; color: var(--light); font-size: 18px; line-height: 1.4; }
/* Price and stock sit on separate lines so neither gets lost. */
.card-price { color: var(--gold); font-size: 26px; line-height: 1.1; }
/* An owned rod or extra: a plain label where the buy button was, same height. */
.card-owned { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 44px; color: var(--light); font-size: 22px; opacity: 0.8; }
.card-stock { margin-top: -6px; color: var(--light); font-size: 20px; letter-spacing: 0.02em; opacity: 0.85; }
.card .pixel-btn { width: 100%; }

.trophy-wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.trophy { display: grid; gap: 10px; }
.trophy .picture { min-height: 120px; }
.trophy .caption strong { color: var(--gold); font-size: 22px; font-weight: 500; }
.trophy .caption small { color: var(--light); font-size: 18px; }
.trophy .caption small + small { display: block; }
.trophy-player { display: block; color: var(--bone); font-size: 19px; }
.trophy-hint { margin-top: 0; font-size: 18px; }
.trophy-hint[hidden], #trophy-empty[hidden] { display: none; }
.empty-note { margin: 0; color: var(--light); font-size: 22px; text-align: center; }
.empty-note[hidden] { display: none; }

/* ---------- Main menu ---------- */

.in-menu .game-only { display: none; }
.in-game .menu { display: none; }

.menu {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Centred, but never pushed up under the top bar with the title. */
  justify-content: safe center;
  gap: 12px;
  padding: calc(clamp(12px, 3vh, 24px) + 70px) 14px clamp(12px, 2.5vh, 24px);
  overflow-y: auto;
  /* The live scene only glimmers through: dark in the middle, near black at the edges. */
  background: radial-gradient(ellipse at 50% 50%, rgba(6, 10, 12, 0.82), rgba(4, 6, 8, 0.95) 75%);
}
.menu-top {
  position: absolute;
  top: clamp(12px, 3vh, 24px);
  right: clamp(12px, 3vw, 28px);
  left: clamp(12px, 3vw, 28px);
  /* Clock on the left, the game's name dead centre, money on the right. */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
}
.menu-top h1 { grid-column: 2; grid-row: 1; font-size: 30px; }
.menu-top .clock { grid-column: 1; grid-row: 1; justify-self: start; }
.menu-top .chip { grid-column: 3; grid-row: 1; justify-self: end; }

.spot-slider { display: flex; align-items: center; gap: 14px; width: min(620px, 100%); }
.spot-arrow { flex: none; width: 48px; min-height: 64px; font-size: 22px; }
.spot-card { display: grid; flex: 1; gap: 12px; min-width: 0; }
.spot-card .title-tab { font-size: 26px; }
.spot-picture { height: clamp(120px, 20vh, 240px); }
.spot-traits {
  grid-template-columns: auto 1fr;
  gap: 2px 18px;
  margin: 0;
  padding: 10px 22px;
  text-align: left;
}
.spot-traits dt { color: var(--light); }
.spot-traits dd { margin: 0; color: var(--bone); }
.spot-dots { display: flex; justify-content: center; gap: 8px; }
.spot-dots span { width: 10px; height: 10px; background: var(--dark); box-shadow: 0 0 0 2px var(--ink); }
.spot-dots .is-active { background: var(--bone); }

.fish-button { min-width: min(320px, 80%); min-height: 56px; font-size: 30px; }

.menu-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
/* Icon and label side by side: compact enough to leave room for the account line. */
.menu-item {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  min-width: 140px;
  min-height: 56px;
  padding: 8px 12px;
  color: var(--bone);
  font-size: 20px;
  text-align: left;
  cursor: pointer;
}
.menu-item:hover .sprite { transform: translateY(-2px); }
.menu-item:active { transform: translateY(2px); }
.menu-item .badge { top: 4px; right: 6px; }

.icon-btn:disabled { opacity: 0.45; cursor: default; }

.clock {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 8px 16px 8px 12px;
  color: var(--bone);
  font-size: 30px;
  font-variant-numeric: tabular-nums;
}
.clock-icon .sprite { display: block; }
.weather-icon { display: inline-flex; margin-left: 4px; }
.weather-icon[hidden] { display: none; }


/* ---------- Shop extras ---------- */

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper .pixel-btn-square { width: 40px; min-height: 40px; font-size: 28px; line-height: 1; }
.stepper-value { min-width: 40px; color: var(--bone); font-size: 30px; text-align: center; }

/* ---------- Settings ---------- */

.setting-row { display: grid; gap: 10px; }
.setting-label { color: var(--light); }
.segmented { display: flex; gap: 10px; }
.segmented .pixel-btn { flex: 1; min-height: 46px; }

/* ---------- Account ---------- */

/* Menu line under the buttons: a small amber marker while progress is only local, calm once it's in the cloud. */
.account-strip {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 10px;
  max-width: min(620px, 100%);
  color: var(--light);
  font-size: 18px;
  line-height: 1.25;
  text-align: center;
}
.account-dot { flex: none; width: 8px; height: 8px; background: var(--gold); box-shadow: 0 0 0 2px var(--ink); }
.account-strip.is-safe .account-dot { background: var(--light); }
.account-strip .link-btn { font-size: 18px; color: var(--bone); }
.account-strip .link-btn[hidden] { display: none; }
.warning-text { margin: 0; color: var(--gold); font-size: 18px; line-height: 1.3; }

.account-body { display: grid; gap: 10px; }
.account-form { display: grid; gap: 10px; margin: 0; }
.account-note { margin: 0; color: var(--light); font-size: 19px; line-height: 1.3; }
/* Sync state with a dot: gold while waiting, pale once safely in the cloud. */
.account-status { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--gold); font-size: 19px; }
.account-status::before { content: ""; flex: none; width: 8px; height: 8px; background: var(--gold); box-shadow: 0 0 0 2px var(--ink); }
.account-status.is-synced { color: var(--light); }
.account-status.is-synced::before { background: var(--light); }
.account-error, .account-message.is-bad { color: var(--ember); }
.account-hint { margin: 0; color: var(--mid); font-size: 17px; line-height: 1.3; }
.account-name { margin: 0; color: var(--bone); font-size: 24px; line-height: 1.1; overflow-wrap: anywhere; }
.account-email { margin: 0; color: var(--light); font-size: 18px; overflow-wrap: anywhere; }
/* The profile: a lettered badge beside the name and email. */
.account-profile { display: flex; align-items: center; gap: 12px; }
.account-avatar { display: grid; flex: none; width: 52px; height: 52px; place-items: center; color: var(--ink); font-size: 32px; line-height: 1; background: var(--gold); box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--gold-dark); }
.account-who { display: grid; gap: 2px; min-width: 0; }
.account-tabs .tab { min-height: 44px; }
/* Labelled fields: the label stays above while typing; passwords have a Show button. */
.field { display: grid; gap: 4px; }
.field-label { color: var(--light); font-size: 18px; }
.field-row { display: flex; gap: 8px; }
.field-row .text-input { flex: 1; min-width: 0; }
.field-row .pixel-btn { flex: none; min-height: 46px; padding-inline: 16px; }
.field-hint { color: var(--mid); font-size: 16px; line-height: 1.25; }
.reveal-btn { flex: none; min-width: 96px; padding: 0 10px; border: 2px solid var(--soft); color: var(--light); font-size: 18px; background: var(--deep); cursor: pointer; }
.reveal-btn:hover { color: var(--bone); border-color: var(--bone); }
.account-submit { min-height: 52px; margin-top: 4px; font-size: 22px; }
.link-btn.account-signout { justify-self: center; margin-top: 6px; color: var(--mid); }
.account-email[hidden] { display: none; }
/* A quiet text button for secondary actions like password recovery. */
.link-btn { justify-self: start; padding: 2px 0; border: 0; color: var(--light); font-size: 18px; text-decoration: underline; text-underline-offset: 3px; background: none; cursor: pointer; }
.link-btn:hover { color: var(--bone); }
.account-message { margin: 0; color: var(--gold); font-size: 18px; line-height: 1.3; }
.account-message:empty { display: none; }
.link-btn:disabled { opacity: 0.5; cursor: default; }
.text-input {
  width: 100%;
  min-height: 46px;
  padding: 8px 12px;
  border: 2px solid var(--soft);
  color: var(--bone);
  font: inherit;
  font-size: 20px;
  background: var(--ink);
  outline: none;
}
.text-input:focus { border-color: var(--bone); }
.text-input::placeholder { color: var(--mid); }
.sync-text { margin: 0; color: var(--light); font-size: 20px; line-height: 1.3; }
.sync-choices { display: grid; gap: 10px; }
.sync-choice { flex-direction: column; align-items: flex-start; gap: 2px; min-height: 60px; padding: 10px 14px; }
.sync-choice small { font-size: 17px; opacity: 0.8; }

/* ---------- Backpack & handbook ---------- */

.pack-body { min-height: 0; max-height: min(64vh, 600px); overflow-y: auto; padding-right: 6px; }
.pack-body h3 { margin: 6px 0 8px; color: var(--light); font-size: 22px; font-weight: 500; }
.item-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 12px; padding: 0; list-style: none; }
.pack-item { width: 104px; height: 108px; padding: 6px 4px 34px; }
.pack-name { position: absolute; right: 2px; bottom: 20px; left: 2px; overflow: hidden; color: var(--bone); font-size: 18px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }

.handbook { display: grid; gap: 10px; min-height: 0; max-height: min(64vh, 620px); overflow-y: auto; margin: 0; padding: 0 6px 0 0; list-style: none; }
.handbook-page { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 14px; padding: 14px 16px; }
.handbook-page.handbook-text { grid-template-columns: 1fr; }
.handbook-art { display: grid; place-items: center; }
/* A small picture of each water, painted like the menu's spot picture. */
.handbook-spot { width: 120px; height: 76px; }
.handbook-tabs .pixel-btn { min-height: 44px; padding-inline: 6px; }
/* Facts as label / value rows, split by faint rules so sections don't run together. */
.handbook-body small { display: block; margin-top: 2px; }
.handbook-facts { display: grid; grid-template-columns: max-content 1fr; gap: 0 14px; margin: 10px 0 0; }
.handbook-facts dt, .handbook-facts dd { padding: 6px 0; border-top: 1px solid rgba(160, 176, 168, 0.18); }
.handbook-facts dt { color: var(--gold); font-size: 17px; opacity: 0.85; }
.handbook-facts dd { display: grid; gap: 2px; margin: 0; color: var(--light); font-size: 18px; }
.handbook-page strong { display: block; color: var(--bone); font-size: 22px; font-weight: 500; }
.handbook-page small { color: var(--gold); font-size: 18px; }
.handbook-page p { margin: 4px 0 0; color: var(--light); font-size: 18px; }
@media (max-width: 520px) { .handbook-facts { grid-template-columns: 1fr; } .handbook-facts dd { border-top: 0; padding-top: 0; } }
.handbook-rules { grid-template-columns: 1fr; }
.handbook-rules dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 6px 0 0; }
.handbook-rules dt { color: var(--gold); font-size: 18px; }
.handbook-rules dd { margin: 0; color: var(--light); font-size: 18px; }

/* Phones held upright: bigger, evenly sized targets within thumb reach, nothing overlapping. */
@media (max-width: 520px) {
  :root { font-size: 22px; }

  /* Menu: a compact top bar, content starting below it so nothing overlaps. */
  .menu {
    justify-content: flex-start;
    gap: 14px;
    padding: calc(env(safe-area-inset-top, 0px) + 78px) 12px calc(env(safe-area-inset-bottom, 0px) + 16px);
  }
  .menu-top { top: calc(env(safe-area-inset-top, 0px) + 12px); right: 12px; left: 12px; }
  .menu-top { gap: 6px; }
  .menu-top h1 { padding: 8px 10px; font-size: 24px; }
  .menu-top .clock { min-height: 46px; padding: 6px 10px 6px 8px; font-size: 22px; }
  .menu-top .chip { min-height: 46px; padding: 6px 10px 6px 8px; font-size: 20px; }
  .spot-slider { gap: 8px; margin-top: 0; }
  .spot-arrow { width: 40px; min-height: 56px; }
  .spot-picture { height: clamp(140px, 24vh, 200px); }
  .spot-traits { padding: 12px 16px; }
  .fish-button { width: 100%; min-height: 60px; }
  .menu-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
  .menu-item {
    grid-template-columns: auto 1fr;
    justify-items: start;
    align-items: center;
    gap: 8px;
    min-width: 0;
    min-height: 64px;
    padding: 10px 10px;
    font-size: 19px;
    text-align: left;
  }

  /* In game. */
  .slot { width: 64px; height: 64px; }
  .icon-btn { width: 52px; height: 52px; }
  .chip { min-height: 48px; font-size: 22px; }
  .hud-top .clock { min-height: 52px; font-size: 26px; }
  .bait-chip { min-height: 48px; font-size: 22px; }

  /* Dialogs use almost the whole screen and scroll inside. */
  .sheet, .sheet-wide { width: calc(100% - 16px); max-height: calc(100dvh - 16px); padding: 22px 14px 16px; }
  .sheet h2 { font-size: 26px; }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-height: calc(100dvh - 210px); }
  .card { min-width: 0; padding: 12px 8px 10px; }
  .card .pixel-btn { padding-inline: 6px; font-size: 18px; }
  .card strong { font-size: 22px; }
  .card small { font-size: 16px; }
  .card-price { font-size: 22px; }
  .card-stock { font-size: 17px; }
  .card-owned { font-size: 19px; }
  .stepper { gap: 4px; }
  .stepper .pixel-btn-square { width: 40px; min-height: 44px; }
  .stepper-value { min-width: 28px; font-size: 26px; }
  .tabs .pixel-btn { min-height: 44px; padding-inline: 6px; font-size: 18px; }
  .pack-body { max-height: calc(100dvh - 150px); }
  .pack-item { width: calc(33.3% - 7px); min-width: 92px; }
  .catch-actions .pixel-btn { min-height: 52px; font-size: 18px; }
  .handbook { max-height: calc(100dvh - 150px); }
  .handbook-page { grid-template-columns: 1fr; }
}

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