/*
 * 進化のきろく 体験版 — 子ども向けプレイ画面の見た目定義。
 * 通常画面はcanvasの水中だけを見せ、重ねるUIは「使えるポイントの数字」と
 * 「メニュー」ボタンの2つに絞る。メニューと進化えらびは同じ深海の操作盤
 * としてまとめ、PlayerRigが合成した魚のbitmapを常に主役へ置く。
 * 状態はJSが付与する data 属性へ反応するだけで、ここで再導出しない。
 */

* { box-sizing: border-box; }

:root {
  --sea-abyss: #030f19;
  --sea-deep: #071c2b;
  --sea-panel: #0a2233;
  --sea-panel-top: #0d2a3d;
  --sea-line: rgba(126, 196, 222, 0.22);
  --sea-line-strong: rgba(150, 215, 238, 0.45);
  --ink-bright: #eefaff;
  --ink-main: #cfe6f0;
  --ink-dim: #8fadbd;
  --glow-green: #7ce9c0;
  --glow-gold: #ffd97a;
  --tap-size: 3.4rem;
}

html {
  color-scheme: dark;
  height: 100%;
  /* 全UIの文字基準を画面サイズへ連続的に追従させる。1366x768でほぼ16pxになり、
     小画面でも読める下限を保ち、大画面では少し大きくなる。設定の
     「文字の大きさ」は --playable-text-scale の倍率としてそのまま効く。 */
  font-size: calc(clamp(14px, 0.45vw + 0.9vh + 3.2px, 19px) * var(--playable-text-scale, 1));
  background: var(--sea-abyss);
}

body {
  display: grid;
  place-items: center;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  color: var(--ec-text, var(--ink-main));
  font-family: var(--ec-font-ui, sans-serif);
  background:
    radial-gradient(120% 90% at 50% 0%, #0d3550 0%, rgba(13, 53, 80, 0) 55%),
    var(--sea-abyss);
}

button, select, input { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: var(--ec-focus-ring-width, 3px) solid var(--ec-focus, #9ff2ff);
  outline-offset: var(--ec-focus-ring-offset, 2px);
}

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


.shared-chrome {
  position: fixed;
  inset: 0;
  z-index: 21;
  pointer-events: none;
}
.shared-chrome .hud,
.shared-chrome .desktop-evolution-guide,
.shared-chrome .touch-controls {
  pointer-events: auto;
}
/* ---- 通常画面: 水中と2つのUIだけ ----------------------------------- */

.playable {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 0.6rem;
}

.stage-frame {
  /* 画面全体をcanvasで埋める。canvasの論理解像度はJSが基準の1366x768を
     下回らない範囲で画面の縦横比へ広げているため、bitmapと表示領域の
     比率が一致し、伸びも黒帯も出ない。 */
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 0%, #0d3550 0%, rgba(13, 53, 80, 0) 55%),
    var(--sea-abyss);
}

#stage {
  /* canvasの論理解像度=表示アスペクト比はJS側(#resizeToDisplay)で一致させて
     いるので、そのまま全画面へ1:1表示する。object-fitは使わない
     (fill相当。引き伸ばしは起きない)。 */
  display: block;
  width: 100%;
  height: 100%;
}

.playable[data-status="loading"] #stage { opacity: 0.55; }
.playable[data-status="error"] .stage-frame { box-shadow: 0 0 0 2px var(--ec-danger, #ff8f8f); }

.canvas-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 2rem;
  color: var(--ec-danger, #ff8f8f);
  font-weight: 700;
}

.hud {
  position: fixed;
  z-index: 20;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.player-status-bar {
  position: fixed;
  z-index: 20;
  bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  width: min(36rem, calc(100% - 2rem));
  transform: translateX(-50%);
  pointer-events: none;
}

.play-hint {
  display: grid;
  gap: 0.12rem;
  width: 100%;
  padding: 0.45rem 0.85rem 0.5rem;
  border: 2px solid rgba(255, 214, 122, 0.78);
  border-radius: 0.75rem;
  background: rgba(8, 22, 18, 0.92);
  color: #fff;
  box-shadow: 0 0 1.4rem rgba(255, 214, 122, 0.18), 0 5px 22px rgba(0, 0, 0, 0.45);
}
.play-hint[hidden] { display: none !important; }
.play-hint strong {
  color: #ffe7a8;
  font-size: 0.92rem;
  font-weight: 1000;
  line-height: 1.25;
}
.play-hint span {
  color: #dff6ea;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}

.player-health-hud {
  position: relative;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: auto auto;
  align-content: center;
  gap: 0.28rem 1rem;
  min-width: 0;
  min-height: 4.35rem;
  padding: 0.55rem 1rem;
  border: 2px solid rgba(255, 158, 151, 0.78);
  border-radius: 0.75rem;
  background: rgba(25, 5, 10, 0.92);
  color: #fff;
  box-shadow: 0 0 1.5rem rgba(239, 74, 74, 0.25), 0 5px 22px rgba(0, 0, 0, 0.48);
  pointer-events: none;
}
.player-health-hud { grid-template-columns: auto 1fr auto auto; }
.player-health-hud span { align-self: end; color: #ffaaa5; font-size: 0.95rem; font-weight: 1000; white-space: nowrap; }
.player-health-hud .player-points-label { color: #9fd9c2; }
.player-health-hud strong { justify-self: end; color: #fff; font-size: 1.3rem; font-weight: 1000; white-space: nowrap; }
.player-health-hud #player-health-value { justify-self: start; }
.player-health-hud #confirmed-value { justify-self: start; }
.player-health-hud progress { grid-column: 1 / -1; width: 100%; height: 1rem; accent-color: #ef4f50; }
.hud-points { display: none !important; }
.player-health-hud[data-danger="true"] { border-color: #ff3945; background: rgba(89, 4, 14, 0.96); animation: health-danger 700ms ease-in-out infinite alternate; }
progress[data-danger="true"] { accent-color: #ff3b43; }
@keyframes health-danger {
  from { box-shadow: 0 0 1rem rgba(255, 38, 54, 0.35); }
  to { box-shadow: 0 0 3rem rgba(255, 38, 54, 0.85); }
}

.damage-feedback {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  pointer-events: none;
}
.damage-feedback[data-active="true"] { animation: damage-pulse 180ms ease-out 2 alternate; }
@keyframes damage-pulse {
  from { transform: translate(-50%, 4px); opacity: 0.7; }
  to { transform: translate(-50%, -4px); opacity: 1; }
}

.defeat-overlay {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(45, 0, 7, 0.9);
  backdrop-filter: blur(8px);
}
.defeat-overlay__panel {
  width: min(36rem, calc(100% - 1rem));
  padding: 2.2rem 1.5rem;
  border: 3px solid #ff6c72;
  border-radius: 1rem;
  background: linear-gradient(180deg, #5f0711, #230208);
  color: #fff;
  text-align: center;
  box-shadow: 0 0 4rem rgba(255, 26, 51, 0.55);
}
.defeat-overlay__eyebrow { margin: 0; color: #ffb4b6; font-size: 1rem; font-weight: 1000; }
.defeat-overlay h2 { margin: 0.35rem 0; color: #fff; font-size: clamp(2.8rem, 8vw, 5rem); line-height: 1; }
.defeat-overlay p:not(.defeat-overlay__eyebrow) { margin: 0.8rem 0 1.5rem; font-size: 1.1rem; font-weight: 800; }
.defeat-overlay button { min-height: 3.5rem; padding: 0.7rem 1.3rem; border: 0; border-radius: 0.6rem; background: #fff; color: #5b0710; font-size: 1rem; font-weight: 1000; }
.defeat-overlay__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.65rem; }
.defeat-overlay__actions button + button { border: 1px solid rgba(255, 255, 255, 0.55); background: transparent; color: #fff; }

.hud-points {
  display: grid;
  place-items: center;
  flex: 0 0 6.5rem;
  min-width: 6.5rem;
  min-height: var(--tap-size);
  padding: 0.35rem 0.6rem;
  border-radius: 0.5rem;
  background: rgba(4, 24, 34, 0.78);
  color: #a9f2cf;
  font: 800 1.45rem/1 var(--ec-font-num, inherit);
  text-shadow: 0 0 12px rgba(124, 233, 192, 0.5);
  box-shadow: inset 0 0 0 1px rgba(124, 233, 192, 0.4), 0 4px 18px rgba(0, 0, 0, 0.35);
}
.hud-points small { color: #9fd9c2; font: 800 0.65rem/1 var(--ec-font-ui, sans-serif); }
.hud-points strong { font: inherit; }

.hud-menu,
.hud-world {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: var(--tap-size);
  padding: 0 1.05rem;
  border: 0;
  border-radius: 0.5rem;
  background: rgba(4, 24, 34, 0.78);
  color: var(--ink-bright);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--sea-line-strong), 0 4px 18px rgba(0, 0, 0, 0.35);
}

.hud-menu:hover,
.hud-world:hover { background: rgba(15, 55, 75, 0.88); }
.hud-world:disabled { cursor: not-allowed; filter: saturate(0.45); opacity: 0.55; }

.hud-world > span:first-child { color: var(--glow-gold); font-size: 1.3rem; }

.hud-menu__icon {
  display: grid;
  gap: 0.24rem;
  width: 1.05rem;
}

.hud-menu__icon i {
  display: block;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
}


/* PCの常設進化操作。objective案内が消えた後も、解禁済みの操作を
   右上HUDの直下で短く示す。タッチ端末は画面ボタンを使うため非表示。 */
.desktop-evolution-guide {
  position: fixed;
  z-index: 20;
  top: 4.65rem;
  right: 0.75rem;
  display: flex;
  gap: 0.55rem;
  align-items: center;
  margin: 0;
  padding: 0.5rem 0.8rem;
  border: 1px solid rgba(124, 233, 192, 0.55);
  border-radius: 0.5rem;
  background: rgba(3, 24, 29, 0.88);
  color: #c8ffed;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  pointer-events: auto;
}

.desktop-evolution-guide:hover,
.desktop-evolution-guide:focus-visible {
  border-color: #baffea;
  background: rgba(8, 68, 56, 0.96);
}

.desktop-evolution-guide:disabled {
  cursor: wait;
  opacity: 0.55;
}

.desktop-evolution-guide kbd,
.desktop-burst-guide kbd {
  display: grid;
  place-items: center;
  min-width: 2rem;
  min-height: 2rem;
  border: 1px solid rgba(238, 250, 255, 0.75);
  border-bottom-width: 3px;
  border-radius: 0.35rem;
  background: rgba(238, 250, 255, 0.1);
  color: #ffffff;
  font: 900 1rem/1 var(--ec-font-num, inherit);
}

.desktop-burst-guide kbd {
  min-width: 3.6rem;
  padding: 0 0.35rem;
  font-size: 0.78rem;
}

.desktop-burst-guide {
  position: fixed;
  z-index: 20;
  top: 8.15rem;
  right: 0.75rem;
  display: flex;
  gap: 0.55rem;
  align-items: center;
  margin: 0;
  padding: 0.5rem 0.8rem;
  border: 1px solid rgba(255, 217, 122, 0.55);
  border-radius: 0.5rem;
  background: rgba(29, 22, 3, 0.88);
  color: #ffe7b0;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

@media (pointer: coarse), (hover: none), (max-width: 48rem) {
  .desktop-burst-guide { display: none; }
}

/* ---- スマホ・タブレットの画面操作 ---------------------------------- */

.touch-controls {
  display: none;
  position: fixed;
  z-index: 22;
  inset: auto 0.75rem 0.65rem;
  align-items: end;
  justify-content: space-between;
  pointer-events: none;
}

.touch-directions {
  position: relative;
  width: 9.75rem;
  height: 9.75rem;
  border: 1px solid rgba(190, 232, 246, 0.22);
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(110, 196, 220, 0.08) 0 32%, transparent 33%),
    linear-gradient(rgba(180, 230, 242, 0.08), rgba(180, 230, 242, 0.08)) center / 1px 72% no-repeat,
    linear-gradient(90deg, rgba(180, 230, 242, 0.08), rgba(180, 230, 242, 0.08)) center / 72% 1px no-repeat,
    rgba(3, 20, 30, 0.16);
  box-shadow: inset 0 0 2.4rem rgba(45, 132, 156, 0.06), 0 5px 18px rgba(0, 5, 10, 0.12);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.touch-joystick__ring {
  position: absolute;
  inset: 17%;
  border: 1px solid rgba(190, 232, 246, 0.14);
  border-radius: 50%;
  pointer-events: none;
}

.touch-joystick__thumb {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4.25rem;
  height: 4.25rem;
  border: 2px solid rgba(217, 247, 255, 0.38);
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, rgba(143, 224, 238, 0.22), rgba(12, 60, 76, 0.28) 70%);
  box-shadow: inset 0 0 0 0.35rem rgba(2, 25, 35, 0.08), 0 0.35rem 1rem rgba(0, 8, 13, 0.16);
  transform: translate(calc(-50% + var(--joystick-x, 0px)), calc(-50% + var(--joystick-y, 0px)));
  transition: transform 90ms ease-out, border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
  pointer-events: none;
}

.touch-joystick[data-active="true"] .touch-joystick__thumb {
  border-color: rgba(216, 255, 242, 0.7);
  background: radial-gradient(circle at 36% 30%, rgba(143, 224, 238, 0.34), rgba(12, 60, 76, 0.42) 70%);
  box-shadow: inset 0 0 0 0.35rem rgba(2, 25, 35, 0.12), 0 0 1.25rem rgba(124, 233, 192, 0.22);
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.touch-actions {
  display: grid;
  grid-template-columns: repeat(2, 4.4rem);
  gap: 0.65rem;
  align-items: center;
}

.touch-actions [data-touch-control="special"] {
  border-color: rgba(255, 186, 122, 0.38);
  background: rgba(78, 36, 8, 0.22);
  color: rgba(255, 215, 168, 0.78);
}

.touch-controls button {
  min-width: 3.25rem;
  min-height: 3.25rem;
  border: 1px solid rgba(190, 232, 246, 0.28);
  border-radius: 50%;
  background: rgba(3, 20, 30, 0.2);
  color: rgba(232, 248, 255, 0.78);
  font-size: 0.9rem;
  font-weight: 800;
  box-shadow: 0 5px 16px rgba(0, 5, 10, 0.12);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.touch-actions button {
  display: grid;
  place-items: center;
  min-width: 4.4rem;
  min-height: 4.4rem;
  padding: 0;
  border-radius: 50%;
  background: rgba(8, 36, 50, 0.2);
}

.touch-action__icon {
  width: 2.2rem;
  height: 2.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.touch-controls[hidden] {
  /* JSがクリア完了中に付けるhiddenを、pointer: coarseのdisplay: flexより
     優先させ、視覚・hit-testの両方から外す。inertでfocus/clickも無効。 */
  display: none !important;
  pointer-events: none !important;
  visibility: hidden;
}

/* 状況によりJS側がhiddenを付けるアクションボタンを、
   gridのdisplay指定より優先して隠す。 */
.touch-actions button[hidden] { display: none; }

.touch-actions .touch-action--primary {
  border-color: rgba(255, 217, 122, 0.4);
  background: rgba(84, 60, 12, 0.22);
  color: rgba(255, 233, 176, 0.82);
}

.touch-actions .touch-action--burst {
  border-color: rgba(142, 224, 255, 0.36);
  background: rgba(8, 47, 67, 0.22);
  color: rgba(200, 243, 255, 0.82);
}

.touch-controls button[data-pressed="true"] {
  translate: 0 2px;
  background: rgba(124, 233, 192, 0.42);
  color: #e8fff4;
  box-shadow: inset 0 3px 8px rgba(0, 27, 38, 0.18);
}

/* ---- ワールド選択 -------------------------------------------------- */

dialog.world-selector {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #031018;
  color: var(--ink-main);
}

dialog.world-selector::backdrop { background: #02080d; }

dialog.stage-briefing {
  width: min(42rem, calc(100vw - 1.6rem));
  max-height: calc(100dvh - 2rem);
  padding: 0;
  overflow: auto;
  border: 1px solid rgba(214, 243, 250, 0.28);
  border-radius: 1rem;
  background: linear-gradient(180deg, #0b2a38 0%, #071821 100%);
  color: #eefaff;
  box-shadow: 0 1.4rem 3.4rem rgba(0, 0, 0, 0.42);
}
dialog.stage-briefing::backdrop { background: rgba(2, 8, 13, 0.86); }
.stage-briefing__shell {
  display: grid;
  gap: 0.62rem;
  padding: 0 1.2rem 1.05rem;
}
.stage-briefing__scene {
  position: relative;
  width: calc(100% + 2.4rem);
  margin: 0 -1.2rem 0.2rem;
  height: 10.5rem;
  overflow: hidden;
  background: #04141c;
}
.stage-briefing__scene img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 42%;
}
.stage-briefing__years {
  margin: 0.75rem 0 0.08rem;
  color: #ffe39a;
  font-size: clamp(1.55rem, 3.4vw, 2.15rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1.15;
}
.stage-briefing h2 {
  margin: 0;
  color: #fff;
  font-size: clamp(1.55rem, 3.4vw, 2.15rem);
  line-height: 1.2;
}
.stage-briefing__title {
  margin: 0;
  color: #b7d4dd;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.35;
}
.stage-briefing__stars {
  margin: 0;
  color: #ffe39a;
  font-size: 1.05rem;
  letter-spacing: 0.12em;
}
/* The stage summary (also the map tooltip), readable on phones too. */
.stage-briefing__summary {
  margin: 0.1rem 0 0;
  color: #e7f6f8;
  font-size: 0.95rem;
  line-height: 1.65;
}
.guest-session-notice {
  padding: 0.65rem 0.85rem;
  border: 1px solid rgba(255, 220, 135, 0.65);
  border-radius: 0.6rem;
  background: rgba(52, 39, 12, 0.65);
  color: #ffe6ac;
  font-size: 0.82rem;
  line-height: 1.55;
}
.guest-session-notice p { margin: 0.3rem 0 0; }
.stage-briefing__enemies {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.4rem, 1fr));
  gap: 0.5rem;
}
.stage-briefing__enemy {
  display: grid;
  gap: 0.28rem;
  margin: 0;
}
.stage-briefing__enemy img {
  display: block;
  width: 100%;
  height: 4.6rem;
  object-fit: contain;
  object-position: center;
  border-radius: 0.4rem;
  background: rgba(4, 18, 24, 0.72);
}
.stage-briefing__enemy[data-seen="false"] img {
  filter: brightness(0) saturate(0);
  opacity: 0.86;
}
.stage-briefing__enemy figcaption {
  color: #e7f6f8;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
}
.stage-briefing__enemy[data-seen="false"] figcaption { color: #9bb3bb; }
.stage-briefing__block {
  display: grid;
  gap: 0.28rem;
}
.stage-briefing__block h3 {
  margin: 0.15rem 0 0;
  color: #ffe39a;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.4;
  overflow: visible;
  white-space: nowrap;
}
.stage-briefing__block p,
.stage-briefing__block ul {
  margin: 0;
  color: #e7f6f8;
  font-size: 0.92rem;
  line-height: 1.45;
}
.stage-briefing__block ul {
  display: grid;
  gap: 0.18rem;
  padding: 0;
  list-style: none;
}
/* Stays at the bottom edge while the dialog scrolls (short landscape
   phones), so the dialog can open at its top. */
.stage-briefing__actions {
  position: sticky;
  bottom: 0;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin: 0.35rem -1.2rem -1.05rem;
  padding: 0.6rem 1.2rem 1.05rem;
  background: linear-gradient(180deg, rgba(7, 24, 33, 0), #071821 38%);
}
.stage-briefing__actions button {
  min-height: 2.7rem;
  padding: 0.55rem 1.05rem;
  border-radius: 0.55rem;
  font-weight: 800;
  cursor: pointer;
}
#stage-briefing-cancel {
  border: 1px solid rgba(198, 231, 240, 0.28);
  background: transparent;
  color: #d7edf2;
}
#stage-briefing-start {
  border: 0;
  background: #ffe39a;
  color: #2a1a00;
}
/* Short landscape phones: a lower scene and smaller headings keep the
   summary above the pinned buttons when the dialog opens. */
@media (orientation: landscape) and (max-height: 30rem) {
  .stage-briefing__scene { height: 5.2rem; }
  .stage-briefing__years,
  .stage-briefing h2 { font-size: 1.3rem; }
  .stage-briefing__years { margin-top: 0.45rem; }
  .stage-briefing__shell { gap: 0.45rem; }
  .stage-briefing__summary { font-size: 0.88rem; line-height: 1.55; }
}
#stage-briefing-start:disabled {
  background: rgba(255, 227, 154, 0.28);
  color: rgba(255, 246, 220, 0.55);
  cursor: default;
}
.world-selector__shell { display: grid; grid-template-rows: minmax(0, 1fr); height: 100%; }
.world-selector__top { position: absolute; z-index: 4; inset: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; padding: 0.8rem 1rem 0.8rem 1.35rem; background: linear-gradient(180deg, rgba(3, 12, 18, 0.82), rgba(3, 12, 18, 0)); pointer-events: none; }
.world-selector__top > * { pointer-events: auto; }
.world-selector__top p { margin: 0 0 0.1rem; color: #76aabd; font-size: 0.65rem; font-weight: 800; letter-spacing: 0.22em; }
.world-selector__top h2 { margin: 0; color: #fff; font-size: 1.45rem; }
.world-selector__start {
  display: inline-grid;
  place-items: center;
  min-height: 2.7rem;
  padding: 0 1.15rem;
  border: 0;
  border-radius: 0.5rem;
  background: var(--glow-green);
  color: #062d21;
  font-size: 0.86rem;
  font-weight: 900;
  box-shadow: 0 0.4rem 1.1rem rgba(0, 0, 0, 0.28);
  pointer-events: auto;
}
.world-selector__start[data-status="locked"],
.world-selector__start[disabled] {
  background: rgba(11, 31, 42, 0.88);
  color: #a6bcc5;
  box-shadow: inset 0 0 0 1px rgba(166, 188, 197, 0.4);
}
.world-preview-notice { display: inline-block; margin-top: 0.25rem; padding: 0.18rem 0.45rem; border-radius: 0.25rem; background: #f1bc65; color: #2a1908; font-size: 0.7rem; }
.world-selector__body { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; height: 100%; }
.world-list { display: flex; gap: 0.55rem; padding: 0.7rem 0.9rem calc(0.85rem + env(safe-area-inset-bottom, 0px)); overflow-x: auto; background: linear-gradient(0deg, rgba(2, 10, 16, 0.96), rgba(2, 10, 16, 0.72)); }
.world-card { flex: 0 0 13.4rem; display: grid; gap: 0.12rem; min-height: 8.6rem; padding: 0; overflow: hidden; border: 1px solid rgba(176, 221, 230, 0.18); border-radius: 0.7rem; background: rgba(5, 22, 32, 0.82); color: var(--ink-main); text-align: left; cursor: pointer; }
.world-card:hover { background: rgba(118, 204, 229, 0.07); }
.world-card[aria-selected="true"] { border-color: var(--glow-gold); background: rgba(18, 64, 74, 0.94); box-shadow: inset 0 2px 0 var(--glow-gold); }
.world-card__scene { display: block; width: 100%; height: 3.8rem; overflow: hidden; background: #06212c; }
.world-card__scene img { display: block; width: 100%; height: 100%; object-fit: cover; }
.world-card__number { margin: 0.38rem 0.7rem 0; color: #ffe7a8; font-size: 0.72rem; font-weight: 900; letter-spacing: 0.08em; }
.world-card__world { margin: 0.08rem 0.7rem 0; color: #f2fbff; font-size: 0.92rem; line-height: 1.2; }
.world-card__era-name,
.world-card__era-years {
  overflow: hidden;
  margin: 0 0.7rem;
  color: #d7f0f6;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.25;
}
.world-card__era-years { margin-bottom: 0.5rem; color: #fff; font-size: 0.76rem; }
.world-scene { --world-deep: #031a2a; --world-mid: #076a7c; --world-light: #e7a75e; position: relative; min-width: 0; min-height: 0; overflow: hidden; background: linear-gradient(135deg, var(--world-deep), var(--world-mid)); }
.world-scene img { width: 100%; height: 100%; object-fit: cover; }
.world-scene img:not([src]) { display: none; }
.world-scene__shade { position: absolute; inset: 0; background: linear-gradient(0deg, rgba(2, 10, 15, 0.96), rgba(2, 10, 15, 0.05) 68%); }
.world-scene__copy { position: absolute; z-index: 2; inset: auto auto 8.4rem 1.4rem; max-width: min(36rem, calc(100% - 2rem)); text-shadow: 0 2px 12px #000; pointer-events: none; }
.world-scene__chapter { margin: 0 0 0.25rem; color: var(--world-light); font-size: 0.8rem; font-weight: 900; letter-spacing: 0.16em; }
.world-scene h3 { margin: 0; color: #fff; font-size: clamp(2rem, 4vw, 3.7rem); line-height: 1.05; }
.world-scene__era { margin: 0.45rem 0 0; color: #c2e5ed; font-size: 0.85rem; font-weight: 800; white-space: pre-line; }
.world-scene__summary { max-width: 38rem; margin: 0.7rem 0 0; color: #e7f4f7; font-size: 0.9rem; line-height: 1.7; }
.world-scene__features { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.8rem 0 0; padding: 0; list-style: none; }
.world-scene__features li { padding: 0.3rem 0.65rem; border: 1px solid rgba(220, 244, 250, 0.42); border-radius: 2rem; background: rgba(2, 16, 23, 0.58); color: #e8f8fb; font-size: 0.66rem; font-weight: 800; }
.world-scene__status { display: inline-grid; place-items: center; min-height: 2.75rem; margin: 1rem 0 0; padding: 0 1.2rem; border: 0; border-radius: 0.45rem; background: var(--glow-green); color: #062d21; font-size: 0.8rem; font-weight: 900; text-shadow: none; }
.world-scene__status[data-status="locked"] { background: rgba(11, 31, 42, 0.88); color: #a6bcc5; box-shadow: inset 0 0 0 1px rgba(166, 188, 197, 0.4); }
.world-scene__status[data-status="hidden"] { background: #d8af72; color: #291d0e; }
.world-stage-map {
  position: absolute;
  z-index: 2;
  inset: 4.4rem 0.8rem 0.2rem;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 0.55rem 0.35rem 0.2rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}
.world-stage-map:not([hidden]) ~ .world-scene__copy, .world-scene:has(.world-stage-map:not([hidden])) .world-scene__copy { display: none; }
.world-stage-map__header { display: flex; align-items: start; justify-content: space-between; gap: 0.8rem; }
.world-stage-map__header p { margin: 0; color: var(--world-light); font-size: 0.62rem; font-weight: 900; letter-spacing: 0.16em; }
.world-stage-map__header h3 { margin: 0.1rem 0 0; color: #fff; font-size: clamp(1.05rem, 2.4vw, 1.55rem); line-height: 1.2; white-space: pre-line; }
.world-stage-map__hint { padding: 0.25rem 0.45rem; border: 1px solid rgba(214, 243, 250, 0.3); border-radius: 999px; color: #cfe9ee; font-size: 0.62rem; font-weight: 800; }
.world-stage-map__actions { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; }
.world-stage-map__actions .world-scene__status {
  min-height: 2.35rem;
  margin: 0;
  padding: 0 0.95rem;
  pointer-events: auto;
}
.world-stage-scroll { min-width: 0; min-height: 0; margin-top: 0.7rem; overflow: auto; overscroll-behavior: contain; scrollbar-color: rgba(124, 233, 192, 0.55) rgba(2, 17, 26, 0.45); }
.world-stage-scroll:focus-visible { outline: 2px solid var(--glow-gold); outline-offset: 2px; }
.world-stage-list { position: relative; isolation: isolate; width: 120rem; min-height: 64rem; }
.world-stage-connections { position: absolute; z-index: 0; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.world-stage-edge { fill: none; stroke: rgba(124, 233, 192, 0.72); stroke-linecap: round; stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.world-stage-edge--optional { stroke: rgba(255, 217, 122, 0.95); stroke-dasharray: 5 4; }
.world-stage-edge--extra { stroke: rgba(218, 169, 255, 0.95); stroke-dasharray: 2 4; }
.world-stage-node { position: absolute; z-index: 1; top: var(--stage-y); left: var(--stage-x); display: grid; width: 10.4rem; min-height: 7.4rem; align-content: start; gap: 0.22rem; padding: 0; overflow: hidden; border: 1px solid rgba(198, 231, 240, 0.3); border-radius: 0.55rem; background: rgba(3, 27, 39, 0.94); color: #e9f8fb; text-align: left; cursor: pointer; transform: translate(-50%, -50%); }
.world-stage-node__scene { display: block; width: 100%; height: 4.4rem; overflow: hidden; background-color: #06212c; background-position: center; background-repeat: no-repeat; background-size: cover; }
.world-stage-node__scene img { display: block; width: 100%; height: 100%; object-fit: cover; }
.world-stage-node__era-name { margin: 0.28rem 0.55rem 0; color: #fff; font-size: max(0.92rem, 14.5px); line-height: 1.15; }
.world-stage-node__era-years { margin: 0 0.55rem 0.45rem; color: #d7edf2; font-size: max(0.82rem, 13px); font-weight: 800; line-height: 1.2; }
.world-stage-node:hover:not(:disabled), .world-stage-node:focus-visible { border-color: rgba(255, 217, 122, 0.85); background: rgba(14, 63, 77, 0.96); }
.world-stage-node:disabled { cursor: default; filter: saturate(0.52); opacity: 0.75; }
.world-stage-node[data-status="available"] { border-color: rgba(124, 233, 192, 0.72); box-shadow: inset 0 2px 0 var(--glow-green); }
.world-stage-node[data-status="cleared"] { border-color: rgba(255, 217, 122, 0.72); }
.world-stage-node[data-debug-unlocked="true"] { border-color: rgba(218, 169, 255, 0.85); box-shadow: inset 0 2px 0 rgba(218, 169, 255, 0.85); }
.world-stage-node[data-last-played="true"] { outline: 3px solid var(--glow-gold); outline-offset: 3px; }
.world-stage-node[data-kind="optional"] { border-style: dashed; }
.world-stage-node[data-kind="extra"] { border-style: double; border-color: rgba(218, 169, 255, 0.72); }
.world-stage-node__badge { justify-self: start; padding: 0.12rem 0.38rem; border-radius: 0.2rem; background: rgba(126, 196, 222, 0.17); color: #a7dce9; font-size: 0.66rem; font-weight: 900; letter-spacing: 0.08em; }
.world-stage-node[data-kind="optional"] .world-stage-node__badge { background: rgba(255, 217, 122, 0.14); color: #ffe2a0; }
.world-stage-node[data-kind="extra"] .world-stage-node__badge { background: rgba(218, 169, 255, 0.14); color: #e7c5ff; }
.world-stage-node__title { margin: 0.12rem 0 0; color: #fff; font-size: max(0.82rem, 13.66px); line-height: 1.25; }
.world-stage-node__star { display: none; margin-right: 0.28rem; color: #ffe39a; font-size: 0.92em; line-height: 1; text-shadow: 0 0 0.45rem rgba(255, 217, 122, 0.55); }
.world-stage-node[data-relic-found="true"] .world-stage-node__star,
.world-stage-node__star[data-found="true"] { display: inline; }
.world-stage-node__era { color: #a9c7d0; font-size: max(0.72rem, 11.7065px); line-height: 1.25; white-space: pre-line; }
.world-stage-node__status { margin-top: 0.15rem; color: #9debc4; font-size: max(0.72rem, 11.7065px); font-style: normal; font-weight: 800; line-height: 1.25; }
.world-stage-node[data-status="locked"] .world-stage-node__status { color: #a6b5bc; }
.world-stage-node[data-status="cleared"] .world-stage-node__status { color: #ffe2a0; }
.world-stage-node__cta { justify-self: start; margin-top: auto; color: #d7edf2; font-size: max(0.72rem, 11.7065px); font-weight: 800; line-height: 1.25; }
.world-return-after-clear {
  position: fixed;
  z-index: 12;
  left: 50%;
  top: calc(50% + 8.2rem);
  transform: translateX(-50%);
  min-width: 16rem;
  min-height: 3.4rem;
  padding: 0.85rem 1.6rem;
  border: 2px solid #ffe39a;
  border-radius: 0.7rem;
  background: linear-gradient(180deg, #f3c45a, #c98418);
  color: #2a1903;
  font-size: 1.15rem;
  font-weight: 1000;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  box-sizing: border-box;
}
.world-return-after-clear:hover { filter: brightness(1.06); }

/* ---- 第1章 Guest campaign runtime ------------------------------- */
.campaign-runtime {
  position: fixed;
  z-index: 7;
  inset: 0;
  display: block;
  background: #020b12;
  color: #eefbff;
}
.campaign-runtime[hidden] { display: none !important; }
.campaign-runtime__viewport { position: absolute; inset: 0; min-width: 0; min-height: 0; overflow: hidden; }
.campaign-runtime__viewport canvas { display: block; width: 100%; height: 100%; background: #031018; }
.campaign-clear-conditions {
  position: absolute;
  z-index: 7;
  top: max(0.8rem, env(safe-area-inset-top));
  left: max(0.8rem, env(safe-area-inset-left));
  width: max-content;
  max-width: min(16.5rem, calc(100% - 11rem));
  padding: 0.45rem 0.6rem;
  border: 1px solid rgba(208, 235, 226, 0.18);
  border-radius: 0.65rem;
  background: rgba(3, 17, 22, 0.42);
  box-shadow: 0 0.45rem 1.4rem rgba(0, 0, 0, 0.12);
  color: #f3fbf7;
  pointer-events: none;
  backdrop-filter: blur(4px);
}
.campaign-clear-conditions:has(details[open]) {
  width: min(16.5rem, calc(100% - 11rem));
}
.campaign-clear-conditions summary {
  display: list-item;
  cursor: pointer;
  pointer-events: auto;
  margin-bottom: 0.38rem;
  color: #ffe19a;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
}
.campaign-clear-conditions ul {
  display: grid;
  gap: 0.22rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.campaign-clear-conditions li {
  display: grid;
  grid-template-columns: 1.1rem 1fr;
  gap: 0.34rem;
  align-items: start;
  color: rgba(239, 249, 245, 0.88);
  font-size: 0.72rem;
  font-weight: 750;
  line-height: 1.35;
}
.campaign-clear-conditions li > span:first-child { color: #ffe19a; text-align: center; }
.campaign-clear-conditions li[data-done="true"] { color: #91d7b4; }
.campaign-clear-conditions li[data-done="true"] > span:first-child { color: #71e7a8; }
.campaign-runtime__hud { position: absolute; top: 0.75rem; left: 50%; display: grid; min-width: min(38rem, calc(100% - 2rem)); gap: 0.18rem; padding: 0.55rem 0.8rem; border: 1px solid rgba(199, 236, 243, 0.32); border-radius: 0.45rem; background: rgba(2, 15, 23, 0.86); text-align: center; transform: translateX(-50%); pointer-events: none; }
.campaign-runtime__hud strong { color: #fff; font-size: 0.9rem; }
.campaign-runtime__hud span { color: #b9dce3; font-size: 0.68rem; font-weight: 800; }
.campaign-runtime__hud small { color: #ffd99c; font-size: 0.6rem; font-weight: 700; }
.damage-feedback--campaign { position: absolute; }
.campaign-runtime__return {
  position: absolute;
  z-index: 12;
  left: 50%;
  top: min(calc(50% + 8.2rem), calc(100% - var(--campaign-footer-height, 5rem) - 5rem));
  transform: translateX(-50%);
  min-width: 16rem;
  min-height: 3.4rem;
  padding: 0.85rem 1.6rem;
  border: 2px solid #ffe39a;
  border-radius: 0.7rem;
  background: linear-gradient(180deg, #f3c45a, #c98418);
  color: #2a1903;
  font-size: 1.15rem;
  font-weight: 1000;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
/* Ended stages keep health/P visible, without combat hints crowding the return action. */
body:has(.campaign-runtime[data-ended="true"]:not([hidden])) .player-status-bar > :not(.player-health-hud) {
  display: none;
}
/* ---- 操作盤（メニュー・進化えらび）共通 ---------------------------- */

dialog.sea-panel {
  width: min(64rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 0;
  border: 1px solid var(--sea-line-strong);
  border-radius: 0.6rem;
  background: linear-gradient(180deg, var(--sea-panel-top) 0%, var(--sea-panel) 40%, #061826 100%);
  color: var(--ec-text, var(--ink-main));
  box-shadow: var(--ec-shadow-dialog, 0 30px 90px rgba(0, 0, 0, 0.6));
}

dialog.sea-panel::backdrop { background: rgba(1, 8, 14, 0.76); }

.sea-panel__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0.9rem 0.8rem 1.35rem;
  border-bottom: 1px solid var(--sea-line);
}

.sea-panel__top h2 {
  margin: 0;
  color: var(--ink-bright);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

dialog.book-detail .sea-panel__top h2 {
  font-size: 1.18rem;
  line-height: 1.55;
  ruby-position: over;
}
dialog.book-detail .sea-panel__top h2 ruby {
  ruby-align: center;
}
dialog.book-detail .sea-panel__top h2 rt {
  font-size: 0.46em;
  font-weight: 700;
  color: #b7dce6;
  letter-spacing: 0.02em;
}

.close-button {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: var(--tap-size);
  padding: 0 1rem;
  border: 0;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink-bright);
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--sea-line);
}

.close-button:hover { background: rgba(255, 255, 255, 0.12); }
.close-button span { font-size: 1.35rem; line-height: 1; }

/* ---- メニュー ------------------------------------------------------ */

dialog.game-menu {
  width: min(58rem, calc(100vw - 2rem));
  height: min(42rem, calc(100dvh - 2rem));
}

.game-menu .sea-panel__shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100%;
}

.menu-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border-bottom: 1px solid var(--sea-line);
}

.menu-tabs button {
  position: relative;
  min-height: 3.2rem;
  padding: 0 0.35rem;
  border: 0;
  background: transparent;
  color: var(--ink-dim);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.menu-tabs button:hover { background: rgba(126, 220, 245, 0.06); color: var(--ink-bright); }
.menu-tabs button[aria-selected="true"] { color: var(--ink-bright); }

.menu-tabs button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset: auto 22% 0;
  height: 3px;
  border-radius: 2px 2px 0 0;
  background: var(--glow-green);
}

.menu-pages {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
}

.menu-page { padding: 1.1rem 1.35rem 1.5rem; }

/* 今の魚。PlayerRigが合成した全身bitmapを主役として大きく見せる。 */
.fish-hero {
  position: relative;
  overflow: hidden;
  border-radius: 0.5rem;
  background:
    radial-gradient(90% 130% at 50% 42%, rgba(64, 158, 186, 0.32) 0%, rgba(10, 42, 60, 0.25) 55%, rgba(4, 18, 28, 0.1) 100%),
    linear-gradient(180deg, #0e3448, #07202f);
  box-shadow: inset 0 0 0 1px var(--sea-line);
}

#menu-build-preview {
  display: block;
  width: 100%;
  height: auto;
  max-height: 46dvh;
  object-fit: contain;
}

.fish-hero__caption {
  position: absolute;
  left: 0.8rem;
  bottom: 0.6rem;
  margin: 0;
  padding: 0.3rem 0.7rem;
  border-radius: 0.35rem;
  background: rgba(3, 16, 24, 0.72);
  color: #bdeee0;
  font-size: 0.8rem;
  font-weight: 800;
}

.equipped-parts {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: auto auto;
  justify-content: center;
  gap: 0.05rem 2.4rem;
  margin: 0.9rem 0 0;
}

.equipped-parts dt {
  color: #7fd2ea;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-align: center;
}

.equipped-parts dd {
  margin: 0;
  color: var(--ink-bright);
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
}

.grand-action {
  display: block;
  width: min(22rem, 100%);
  min-height: var(--tap-size);
  margin: 1.1rem auto 0;
  border: 0;
  border-radius: 0.5rem;
  background: var(--glow-green);
  color: #05301f;
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(124, 233, 192, 0.25);
}

.grand-action:hover { background: #98f2d2; }

.grand-action:disabled {
  background: #1c3a4a;
  color: #7794a3;
  cursor: default;
  box-shadow: none;
}

.quiet-note {
  margin: 0.6rem 0 0;
  color: var(--ink-dim);
  font-size: 0.78rem;
  text-align: center;
}

/* ---- 図鑑（ずかん） ------------------------------------------------ */

.page-lead {
  margin: 0 0 0.9rem;
  color: var(--ink-dim);
  font-size: 0.85rem;
  font-weight: 700;
}

.page-lead strong {
  color: var(--ink-bright);
  font: 800 1.05rem/1 var(--ec-font-num, inherit);
}

.book-discovery-heading {
  grid-column: 1 / -1;
  margin: 0.4rem 0 0;
  color: #ffe2a0;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}
.book-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem 1.1rem;
}

.book-entry {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
  text-align: center;
}

.book-entry__well {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 0.4rem;
  background:
    radial-gradient(80% 110% at 50% 45%, rgba(58, 148, 175, 0.28), rgba(5, 22, 33, 0.4) 70%),
    #081e2c;
  box-shadow: inset 0 0 0 1px var(--sea-line);
}

.book-entry canvas {
  display: block;
  width: 100%;
  height: auto;
}

.book-entry[data-found="false"] .book-entry__well { background: #050f17; }

.book-entry[data-found="false"] .book-entry__well::after {
  content: "？";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #33505f;
  font-size: 2.2rem;
  font-weight: 800;
}

.book-entry strong {
  overflow: hidden;
  color: var(--ink-bright);
  font-size: 0.85rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-entry__state { color: var(--ink-dim); font-size: 0.72rem; }

.book-entry__hint {
  margin: 0.18rem 0 0;
  color: #ffe2a0;
  font-size: 0.72rem;
  line-height: 1.45;
}

/* ---- ポイント4区分 ------------------------------------------------- */

.point-list {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.point-row {
  display: grid;
  grid-template-columns: 6.5rem auto minmax(0, 1fr);
  align-items: center;
  column-gap: 1.1rem;
  min-height: 3.9rem;
  padding: 0.55rem 1rem;
  border-left: 3px solid var(--row-glow, #6393a8);
  border-radius: 0.35rem;
  background: rgba(255, 255, 255, 0.035);
}

.point-row__name {
  color: var(--ink-main);
  font-size: 0.9rem;
  font-weight: 800;
}

.point-row__value {
  color: var(--row-ink, var(--ink-bright));
  font: 800 1.7rem/1 var(--ec-font-num, inherit);
}

.point-row__value small { margin-left: 0.15rem; font-size: 0.85rem; }

.point-row p {
  margin: 0;
  color: var(--ink-dim);
  font-size: 0.78rem;
  text-align: right;
}

.point-row--confirmed { --row-glow: #7ce9c0; --row-ink: #a9f2cf; }

/* ---- 設定 ---------------------------------------------------------- */

.settings-list { display: grid; gap: 0.55rem; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.9rem;
  padding: 0.6rem 1rem;
  border-radius: 0.35rem;
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
}

.setting-row__text { display: grid; gap: 0.15rem; }
.setting-row strong { color: var(--ink-bright); font-size: 0.9rem; }
.setting-row small { color: var(--ink-dim); font-size: 0.72rem; }

.setting-row select {
  min-height: 2.6rem;
  padding: 0 0.7rem;
  border: 1px solid var(--sea-line-strong);
  border-radius: 0.4rem;
  background: var(--sea-deep);
  color: var(--ink-bright);
}

.setting-row input[type="checkbox"] {
  width: 1.6rem;
  height: 1.6rem;
  accent-color: var(--glow-green);
}

.evolution-status[data-layout="ch02-parts"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 700px) {
  .evolution-status[data-layout="ch02-parts"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .sea-panel__top { flex-wrap: wrap; gap: 0.5rem; padding: 0.65rem 0.8rem; }
  .sea-panel__top h2, .sea-panel__top .close-button { white-space: nowrap; }
  .sea-panel__top .close-button { flex-shrink: 0; }
  .menu-page { padding: 0.8rem; }
  .setting-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.65rem; padding: 0.65rem; }
  .setting-row__text { min-width: 0; }
  .setting-row:has(select) { grid-template-columns: minmax(0, 1fr); }
  .setting-row select { min-width: 0; max-width: 100%; width: 100%; }
}

@media (max-width: 52rem) {
  .menu-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 360px) {
  .menu-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Non-compact chapters share the measured toolbar clearance in narrow viewports. */
@media (max-width: 520px) {
  html:not([data-campaign-compact="true"]) .shared-chrome .hud {
    left: 0.75rem;
    right: 0.75rem;
  }
  html:not([data-campaign-compact="true"]) .shared-chrome .hud button {
    flex: 1 1 0;
    min-width: 0;
    padding: 0.35rem;
    gap: 0.3rem;
  }
  html:not([data-campaign-compact="true"]) .shared-chrome .hud button > span {
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .campaign-runtime:is([data-chapter="ch00"], [data-chapter="ch02"], [data-chapter="ch03"], [data-chapter="ch04"], [data-chapter="ch05"], [data-chapter="ch06"]) .campaign-clear-conditions {
    top: var(--campaign-toolbar-bottom, 8rem);
    max-width: calc(100% - 1.5rem);
  }
}

.control-guide {
  margin-top: 0.8rem;
  border-radius: 0.35rem;
  background: rgba(255, 255, 255, 0.03);
}

.control-guide summary {
  min-height: 3rem;
  padding: 0.8rem 1rem;
  color: var(--ink-main);
  font-weight: 800;
  cursor: pointer;
}

.control-guide dl { display: grid; gap: 0.45rem; margin: 0; padding: 0 1rem 1rem; }
.control-guide dl div { display: grid; grid-template-columns: 4.5rem 1fr; gap: 0.8rem; }
.control-guide dt { color: #7fd2ea; font-size: 0.78rem; font-weight: 800; }
.control-guide dd { margin: 0; color: var(--ink-main); font-size: 0.78rem; }

/* ---- 進化えらび ---------------------------------------------------- */

dialog.evolution { width: min(74rem, calc(100vw - 2rem)); }

.evolution .sea-panel__shell {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto auto;
  max-height: calc(100dvh - 2rem);
}

.evolution-burst-help {
  margin: 0;
  padding: 0.55rem 1.35rem 0.2rem;
  color: #ffe7b0;
}

.evolution-cost {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
  margin: 0;
  padding: 0.65rem 1.35rem;
  border-bottom: 1px solid var(--sea-line);
  color: var(--ink-dim);
  font-size: 0.82rem;
  font-weight: 700;
}

.evolution-cost strong { color: var(--glow-gold); font-weight: 800; }
.evolution-cost span { color: var(--ink-main); }
.evolution-cost__points {
  margin-left: auto;
  padding: 0.22rem 0.7rem;
  border-radius: 999px;
  background: rgba(243, 196, 90, 0.16);
  color: #ffe39a;
  font-size: 1.05rem;
  font-style: normal;
  font-weight: 1000;
  letter-spacing: 0.04em;
}

.evolution-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
  margin: 0;
  padding: 0.7rem 1.35rem;
  border-bottom: 1px solid var(--sea-line);
}
.evolution-status__item {
  display: grid;
  gap: 0.12rem;
  padding: 0.45rem 0.55rem;
  border-radius: 0.4rem;
  background: rgba(8, 36, 48, 0.72);
}
.evolution-status__item span { color: #9fd4e4; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.06em; }
.evolution-status__item strong { color: #fff; font-size: 1rem; font-weight: 900; }

.evolution-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: 0;
  overflow-y: auto;
}

.named-evolution {
  display: grid;
  gap: 0.55rem;
  min-height: 12.5rem;
  max-height: 28vh;
  margin: 0;
  padding: 0.75rem 1.1rem 0.9rem;
  overflow: auto;
  border-top: 1px solid var(--sea-line);
  background: rgba(3, 18, 26, 0.55);
}
.named-evolution__title {
  margin: 0;
  color: #ffe7a8;
  font-size: 0.92rem;
  font-weight: 900;
}
.named-evolution__note {
  margin: 0;
  color: #cfe9ee;
  font-size: 0.72rem;
  font-weight: 700;
}
.named-card[data-locked="true"] canvas { filter: contrast(1.15); }
.named-card[data-locked="true"] strong { letter-spacing: 0.12em; }
.named-evolution__list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.55rem;
}
.named-card {
  display: grid;
  gap: 0.28rem;
  min-height: 11.5rem;
  padding: 0.4rem;
  border: 1px solid rgba(176, 221, 230, 0.22);
  border-radius: 0.45rem;
  background: rgba(6, 28, 38, 0.92);
  color: #edfaff;
}
.named-card[data-ready="true"] { border-color: #7ce9c0; box-shadow: inset 3px 0 0 #7ce9c0; }
.named-card canvas {
  display: block;
  width: 100%;
  height: 5.6rem;
  border-radius: 0.3rem;
  background: radial-gradient(85% 120% at 50% 45%, rgba(64, 158, 186, 0.3), rgba(6, 24, 36, 0.2) 70%), #0a2536;
}
.named-card strong { font-size: 0.78rem; line-height: 1.25; }
.named-card small { color: #a8c9d1; font-size: 0.62rem; line-height: 1.3; }
.named-card em { color: #93e4bd; font-size: 0.62rem; font-style: normal; font-weight: 800; }
.named-card__evolve {
  min-height: 44px;
  width: 100%;
  padding: 0.4rem;
  border: 1px solid #7ce9c0;
  border-radius: 0.3rem;
  background: #123d36;
  color: #edfaff;
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}
.named-card__evolve:disabled { opacity: 0.55; cursor: default; }
.named-card__evolve:focus-visible { outline: 2px solid #edfaff; outline-offset: 2px; }

/* 進化候補。装着後の全身bitmapを主役に、文字は最小限だけ添える。 */
.choice {
  display: grid;
  align-content: start;
  gap: 0.5rem 1rem;
  padding: 1.1rem;
  border: 0;
  background: transparent;
  color: var(--ec-text, var(--ink-main));
  text-align: left;
  cursor: pointer;
}

.choice + .choice { border-left: 1px solid var(--sea-line); }
.choice:hover { background: rgba(126, 220, 245, 0.07); }

.choice[data-equipped="true"] {
  background: rgba(124, 233, 192, 0.08);
  box-shadow: inset 0 3px 0 var(--glow-green);
}

.choice__fish {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0.4rem;
  background:
    radial-gradient(85% 120% at 50% 45%, rgba(64, 158, 186, 0.3), rgba(6, 24, 36, 0.2) 70%),
    #0a2536;
  box-shadow: inset 0 0 0 1px var(--sea-line);
}

.choice__slot {
  justify-self: start;
  padding: 0.2rem 0.6rem;
  border-radius: 0.3rem;
  background: rgba(127, 210, 234, 0.15);
  color: #a5e2f6;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.choice__name {
  margin: 0;
  color: var(--ink-bright);
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: keep-all;
  white-space: normal;
}

.choice__good,
.choice__weak {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.4;
}

.choice__good { color: #9debc4; }
.choice__weak { color: #f6b3c0; }

.choice__price {
  display: grid;
  place-items: center;
  min-height: 3rem;
  margin-top: 0.4rem;
  padding: 0.35rem 0.55rem;
  border-radius: 0.4rem;
  background: var(--glow-gold);
  color: #2b2410;
  font-size: 0.86rem;
  font-weight: 900;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
}

.choice[data-owned="true"] .choice__price { background: var(--glow-green); color: #05301f; }

.choice[data-equipped="true"] .choice__price,
.choice[data-maxed="true"] .choice__price {
  background: transparent;
  color: var(--glow-green);
  box-shadow: inset 0 0 0 1px var(--glow-green);
}

.choice[data-maxed="true"] {
  cursor: default;
  opacity: 0.92;
}

.choice[data-maxed="true"] .choice__good {
  color: #ffe7b0;
}

.purchase-reason {
  min-height: 1.4em;
  margin: 0;
  padding: 0.7rem 1.35rem 0.9rem;
  border-top: 1px solid var(--sea-line);
  color: var(--glow-gold);
  font-weight: 700;
}

/* ---- 狭い・低い画面への並べ替え ------------------------------------ */

@media (max-width: 40rem) and (orientation: portrait) {
  .evolution-status { grid-template-columns: 1fr; }
  .named-evolution { max-height: 28vh; }
  .named-evolution__list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .evolution-choices { grid-template-columns: 1fr; }

  .choice {
    grid-template-columns: minmax(0, 8.5rem) minmax(0, 1fr);
    grid-template-areas:
      "fish slot"
      "fish name"
      "fish good"
      "fish weak"
      "fish price";
    align-items: center;
    gap: 0.15rem 0.8rem;
    padding: 0.7rem 0.85rem;
  }

  .choice + .choice { border-top: 1px solid var(--sea-line); border-left: 0; }
  .choice__fish { grid-area: fish; align-self: center; }
  .choice__slot { grid-area: slot; }
  .choice__name { grid-area: name; }
  .choice__good { grid-area: good; }
  .choice__weak { grid-area: weak; }
  .choice__price { grid-area: price; justify-self: start; min-width: 8rem; }
}

@media (max-width: 52rem) {
  .book-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .point-row { grid-template-columns: 5.2rem minmax(0, 1fr); }
  .point-row p { grid-column: 1 / -1; text-align: left; }
  .menu-tabs button { min-height: 3rem; font-size: 0.85rem; }
}

/* ---- 非対応環境 ---------------------------------------------------- */

.support-gate {
  position: fixed;
  z-index: 99;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--sea-abyss);
}

.support-gate__panel {
  width: min(32rem, calc(100% - 2rem));
  padding: 1.6rem 1.8rem;
  border-left: 3px solid var(--glow-gold);
  border-radius: 0.5rem;
  background: var(--sea-panel);
  box-shadow: inset 0 0 0 1px var(--sea-line);
}

.support-gate h1 {
  margin: 0 0 0.4rem;
  color: var(--ink-bright);
  font-size: 1.4rem;
}

.support-gate p { margin: 0; color: var(--ink-main); }

/* ---- 動きの軽減 ---------------------------------------------------- */

.hud-menu,
.hud-world,
.close-button,
.menu-tabs button,
.grand-action,
.choice,
.touch-controls button {
  transition: background-color 140ms ease, color 140ms ease;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

[data-ec-reduced-motion="on"] *,
[data-ec-reduced-motion="on"] *::before,
[data-ec-reduced-motion="on"] *::after {
  animation-duration: 0.001ms !important;
  transition-duration: 0.001ms !important;
}

/* ---- タッチ端末と横向きスマホ -------------------------------------- */

@media (pointer: coarse), (hover: none), (max-width: 48rem) {
  /* 実機タッチだけでなく、狭いSP表示でも画面ボタンを出す。
     キャンペーン画面の下に隠れないよう共有HUDへ固定する。 */
  .touch-controls {
    display: flex;
    z-index: 22;
  }
  .desktop-evolution-guide kbd { display: none; }
  .desktop-evolution-guide { min-height: 2.4rem; padding: 0.35rem 0.7rem; }
}

@media (pointer: coarse) and (orientation: landscape),
       (pointer: coarse) and (max-width: 64rem) {
  /* タッチ操作盤があるときだけ、体力とメッセージを操作の上へ退ける。
     マウス操作の狭いブラウザ窓では画面下に置く。 */
  .player-status-bar {
    bottom: calc(11.25rem + env(safe-area-inset-bottom, 0px));
    width: min(28rem, calc(100% - 2rem));
  }
}

@media (max-width: 64rem) {
  .player-status-bar {
    width: min(28rem, calc(100% - 2rem));
  }
}

@media (pointer: coarse) and (orientation: portrait),
       (max-width: 48rem) and (orientation: portrait) {
  /* SP縦画面は操作を上、状態と通知を下へ分離する。指で体力や
     メッセージを隠さず、中央のプレイ領域も横断しない配置。 */
  .touch-controls {
    bottom: calc(8rem + env(safe-area-inset-bottom, 0px));
  }

  .player-status-bar {
    bottom: calc(0.45rem + env(safe-area-inset-bottom, 0px));
    gap: 0.3rem;
    width: min(28rem, calc(100% - 1rem));
  }

  .player-health-hud {
    min-height: 3.7rem;
    padding: 0.42rem 0.7rem;
  }

  .player-health-hud span { font-size: 0.78rem; }
  .player-health-hud strong { font-size: 1rem; }
  .player-health-hud progress { height: 0.72rem; }

  .play-hint {
    padding: 0.34rem 0.65rem 0.38rem;
  }

  .play-hint strong { font-size: 0.78rem; }
  .play-hint span { font-size: 0.68rem; }
}

@media (pointer: coarse) and (orientation: landscape),
       (max-width: 48rem) and (orientation: landscape) {
  /* 横画面は左右に操作、中央下に体力。重ならないよう幅と高さを抑える。 */

  .hud {
    top: calc(0.4rem + env(safe-area-inset-top, 0px));
    right: calc(0.45rem + env(safe-area-inset-right, 0px));
    gap: 0.35rem;
  }

  .player-status-bar {
    bottom: calc(0.45rem + env(safe-area-inset-bottom, 0px));
    top: auto;
    left: 50%;
    width: min(22rem, calc(100% - 16.5rem));
    gap: 0.22rem;
  }
  .play-hint { padding: 0.28rem 0.55rem 0.32rem; }
  .play-hint strong { font-size: 0.74rem; }
  .play-hint span { font-size: 0.62rem; }
  .player-health-hud { min-height: 3rem; padding: 0.28rem 0.55rem; }
  .player-health-hud span { font-size: 0.68rem; }
  .player-health-hud strong { font-size: 0.9rem; }
  .player-health-hud progress { height: 0.66rem; }

  .hud-points {
    flex-basis: 5rem;
    min-width: 5rem;
    min-height: 2.6rem;
    padding: 0 0.35rem;
    font-size: 1.05rem;
  }

  .hud-menu {
    min-height: 2.6rem;
    padding: 0 0.75rem;
    font-size: 0.76rem;
  }

  .hud-world { min-height: 2.6rem; padding: 0 0.65rem; font-size: 0.72rem; }

  .touch-controls {
    inset: auto 0.45rem 0.35rem;
    right: calc(0.45rem + env(safe-area-inset-right, 0px));
    bottom: calc(0.35rem + env(safe-area-inset-bottom, 0px));
    left: calc(0.45rem + env(safe-area-inset-left, 0px));
  }

  .touch-directions { width: 8.55rem; height: 8.55rem; }
  .touch-joystick__thumb { width: 3.7rem; height: 3.7rem; }
  .touch-controls button { min-width: 2.85rem; min-height: 2.85rem; }
  .touch-actions { grid-template-columns: repeat(2, 3.6rem); gap: 0.45rem; }
  .touch-actions button { min-width: 3.6rem; min-height: 3.6rem; }
  .touch-action__icon { width: 1.8rem; height: 1.8rem; }
}

/* 横画面は年代の全画面を維持し、操作盤だけ画面いっぱいに近づける。 */
@media (orientation: landscape) and (max-height: 46rem) {
  html { font-size: calc(clamp(13px, 1.15vh + 0.28vw + 4px, 17px) * var(--playable-text-scale, 1)); }

  dialog.world-selector {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
  }
  .world-selector__top {
    padding: 0.45rem 0.8rem 0.7rem calc(0.9rem + env(safe-area-inset-left, 0px));
  }
  .world-selector__top p { margin-bottom: 0; }
  .world-selector__top h2 { font-size: 1.15rem; }
  .world-selector__start { min-height: 2.35rem; padding: 0 0.9rem; font-size: 0.78rem; }
  .world-selector__body { grid-template-rows: minmax(0, 1fr) auto; }
  .world-list {
    gap: 0.4rem;
    padding: 0.4rem 0.7rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
  }
  .world-card {
    flex: 0 0 11.2rem;
    min-height: 7.4rem;
    padding: 0;
  }
  .world-card__scene { height: 3.2rem; }
  .world-card__world { font-size: 0.82rem; }
  .world-scene { overflow: hidden; }
  .world-scene > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
  .world-scene__copy {
    inset: auto auto 5.6rem calc(1rem + env(safe-area-inset-left, 0px));
    max-width: min(34rem, calc(100% - 2rem));
  }
  .world-scene h3 { font-size: clamp(1.45rem, 4.2vw, 2.4rem); }
  .world-scene__era { margin-top: 0.2rem; font-size: 0.74rem; }
  .world-scene__summary { max-width: 32rem; margin-top: 0.35rem; font-size: 0.76rem; line-height: 1.45; }
  .world-scene__features { margin-top: 0.4rem; }
  .world-scene__features li { padding: 0.16rem 0.45rem; font-size: 0.62rem; }
  .world-scene__status { min-height: 2.4rem; margin-top: 0.4rem; }
  .world-stage-map {
    position: absolute;
    inset: 3.4rem 0.55rem 0.15rem;
    padding: 0.2rem 0.15rem 0;
  }
  .world-stage-map__header h3 { font-size: 0.95rem; }
  .world-stage-scroll { margin-top: 0.35rem; max-height: none; }
  .world-stage-list { width: 108rem; min-height: 52rem; }
  .world-stage-node { width: 8.6rem; min-height: 5.1rem; padding: 0.4rem 0.48rem; }

  .campaign-runtime__hud { top: 0.25rem; min-width: min(30rem, calc(100% - 1rem)); padding: 0.3rem 0.45rem; }
  .campaign-runtime__hud strong { font-size: 0.72rem; }
  .campaign-runtime__hud span { font-size: 0.58rem; }

  dialog.sea-panel,
  dialog.game-menu,
  dialog.evolution {
    width: calc(100vw - 0.7rem);
    height: calc(100dvh - 0.7rem);
    max-width: none;
    max-height: calc(100dvh - 0.7rem);
  }
  dialog.book-detail.sea-panel {
    width: min(22.5rem, calc(100vw - 1.2rem));
    height: fit-content;
    max-width: min(22.5rem, calc(100vw - 1.2rem));
    max-height: min(28rem, calc(100dvh - 1.2rem));
  }

  .evolution .sea-panel__shell {
    height: 100%;
    max-height: calc(100dvh - 0.7rem);
  }

  .evolution-status { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0.4rem 0.9rem; }
  .evolution-choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .named-evolution { max-height: 24vh; padding: 0.45rem 0.8rem 0.55rem; }
  .named-evolution__list { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .named-card { min-height: 8.6rem; }
  .named-card canvas { height: 4.2rem; }

  .sea-panel__top { padding: 0.4rem 0.55rem 0.4rem 1rem; }
  .sea-panel__top h2 { font-size: 1.05rem; }
  .close-button { min-height: 2.6rem; }
  .menu-tabs button { min-height: 2.6rem; font-size: 0.82rem; }
  .menu-page { padding: 0.7rem 0.9rem 0.95rem; }
  #menu-build-preview { max-height: 34dvh; }
  .fish-hero__caption { padding: 0.2rem 0.55rem; font-size: 0.72rem; }
}

@media (orientation: landscape) and (max-width: 56rem) and (max-height: 46rem) {
  .evolution-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .named-evolution__list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .world-scene__summary { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .world-scene__features { display: none; }
}

/* 縦向きスマホでも章・ステージ選択は使える。ゲーム本編だけ横向きを要求する。
   DOM順は scene → list なので、上段に地図、下段に年代カードを置く。
   行を逆にすると list が画面全体を占有し、scene が 0 高になって潰れる。 */
@media (max-width: 40rem) and (orientation: portrait) {
  dialog.world-selector { width: 100vw; height: 100dvh; max-height: none; }
  .world-selector__top {
    padding: 0.55rem 0.65rem;
    background: linear-gradient(180deg, rgba(3, 12, 18, 0.96), rgba(3, 12, 18, 0.72) 70%, rgba(3, 12, 18, 0));
  }
  .world-selector__top p { display: none; }
  .world-selector__top h2 { font-size: 1.05rem; }
  .world-selector__start { min-height: 2.4rem; padding: 0 0.9rem; font-size: 0.78rem; }
  .world-preview-notice { display: none; }
  .world-selector__body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    min-height: 0;
  }
  .world-list {
    display: flex;
    align-items: stretch;
    gap: 0.3rem;
    padding: 0.45rem 0.45rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-top: 1px solid var(--sea-line);
    border-bottom: 0;
    background: rgba(2, 10, 16, 0.94);
    scroll-snap-type: x mandatory;
  }
  .world-card {
    flex: 0 0 10.8rem;
    min-height: 7.1rem;
    height: auto;
    padding: 0;
    scroll-snap-align: start;
  }
  .world-card__scene { height: 2.9rem; }
  .world-card__world {
    overflow-wrap: anywhere;
    word-break: keep-all;
    line-break: strict;
  }
  .world-card__era-name,
  .world-card__era-years {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: keep-all;
    line-break: strict;
  }
  .world-scene {
    display: block;
    position: relative;
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }
  .world-scene > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
  .world-scene__copy { display: none; }
  .world-stage-map {
    inset: 4.7rem 0.4rem 0.35rem;
    min-height: 0;
    height: auto;
    padding: 0.2rem 0.35rem 0.35rem;
  }
  .world-stage-map__header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 0.2rem;
  }
  .world-stage-map__header h3 {
    font-size: 0.92rem;
    line-height: 1.3;
    white-space: normal;
  }
  .world-stage-map__actions { justify-self: start; }
  .world-stage-map__hint {
    max-width: none;
    font-size: 0.56rem;
    text-align: left;
  }
  .world-stage-scroll { min-height: 0; margin-top: 0.35rem; overflow-x: hidden; overflow-y: auto; }
  .world-stage-list { display: grid; grid-template-columns: 1fr; gap: 0.45rem; width: auto; min-height: 0; padding: 0.15rem 0.1rem 1rem; }
  .world-stage-connections { display: none; }
  .world-stage-node {
    position: relative;
    top: auto;
    left: auto;
    display: grid;
    grid-template-columns: 6.4rem minmax(0, 1fr);
    grid-template-areas:
      "scene era-name"
      "scene era-years";
    width: 100%;
    min-height: 0;
    gap: 0.18rem 0.7rem;
    padding: 0;
    transform: none;
  }
  .world-stage-node__scene { grid-area: scene; height: 4.6rem; }
  .world-stage-node__era-name { grid-area: era-name; align-self: end; margin: 0.45rem 0.7rem 0 0; }
  .world-stage-node__era-years { grid-area: era-years; align-self: start; margin: 0 0.7rem 0.45rem 0; }
}

/* Fill the viewport with game art; the HUD overlays it without black bands. */
.campaign-runtime[data-chapter="ch01"] #campaign-stage {
  position: absolute;
  inset: 0;
  height: 100%;
}
.campaign-navigation {
  margin: 0.5rem 0 0;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(208, 235, 226, 0.25);
  color: #ffe19a;
  font-size: 0.74rem;
  line-height: 1.4;
  font-weight: 700;
}
@media (max-width: 48rem) {
  .campaign-runtime[data-chapter="ch01"] .campaign-clear-conditions {
    top: calc(4.2rem + env(safe-area-inset-top, 0px));
    width: max-content;
    max-width: min(15rem, calc(100% - 8rem));
    padding: 0.4rem 0.55rem;
  }
  .campaign-runtime[data-chapter="ch01"] .campaign-clear-conditions:has(details[open]) {
    width: min(15rem, calc(100% - 8rem));
  }
  .campaign-runtime[data-chapter="ch01"] .campaign-clear-conditions > strong { display: none; }
  .campaign-runtime[data-chapter="ch01"] .campaign-clear-conditions li[data-done="true"] { display: none; }
}

.campaign-condition-guidance,
.campaign-condition-controls,
.campaign-condition-pause { display: none; }
.campaign-clear-conditions summary:focus-visible { outline: 3px solid #ffe19a; outline-offset: 3px; }
html[data-campaign-compact="true"] .campaign-runtime[data-chapter="ch01"] .campaign-clear-conditions {
  top: max(0.35rem, env(safe-area-inset-top, 0px));
  left: max(0.45rem, env(safe-area-inset-left, 0px));
  width: max-content;
  max-width: min(14rem, calc(100% - 10rem));
  display: block;
  padding: 0.3rem 0.5rem;
  min-height: 2.3rem;
  pointer-events: auto;
}
html[data-campaign-compact="true"] .campaign-runtime[data-chapter="ch01"] .campaign-clear-conditions:has(details[open]) {
  width: min(16rem, calc(100% - 2rem));
  max-width: min(16rem, calc(100% - 2rem));
}
html[data-campaign-compact="true"] .campaign-runtime[data-chapter="ch01"] .campaign-clear-conditions summary { margin: 0; font-size: 0.72rem; white-space: nowrap; }
html[data-campaign-compact="true"] .campaign-navigation { margin: 0; padding: 0; border: 0; font-size: 0.72rem; line-height: 1.3; }
html[data-campaign-compact="true"] .campaign-condition-body {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  z-index: 30;
  width: min(28rem, calc(100vw - 1rem));
  max-height: calc(100dvh - 5rem);
  overflow-y: auto;
  padding: 0.75rem;
  border: 1px solid #547a7c;
  border-radius: 0.5rem;
  background: #071c24;
  box-shadow: 0 8px 24px #0009;
}
html[data-campaign-compact="true"] .campaign-condition-guidance,
html[data-campaign-compact="true"] .campaign-condition-controls,
html[data-campaign-compact="true"] .campaign-condition-pause { display: block; margin: 0.65rem 0 0; font-size: 0.78rem; line-height: 1.4; }
html[data-campaign-compact="true"] .campaign-condition-pause { color: #ffe19a; }
html[data-campaign-compact="true"] .campaign-runtime[data-chapter="ch01"] .campaign-clear-conditions li[data-done="true"] { display: grid; }
html[data-campaign-compact="true"] .hud { top: 0.35rem; right: 0.45rem; }
html[data-campaign-compact="true"] .hud button { min-height: 2.3rem; padding: 0.25rem 0.5rem; font-size: 0.72rem; }
/* Keep evolution on its own row, independent of the HUD labels' widths. */
html[data-campaign-compact="true"] .desktop-evolution-guide { top: 3.35rem; right: 0.45rem; min-height: 2.3rem; padding: 0.3rem 0.5rem; font-size: 0.72rem; }
html[data-campaign-compact="true"] .desktop-evolution-guide kbd { display: none; }
html[data-campaign-compact="true"] .player-status-bar { bottom: max(0.3rem, env(safe-area-inset-bottom, 0px)); gap: 0; }
html[data-campaign-compact="true"] .player-health-hud { min-height: 2.25rem; padding: 0.2rem 0.5rem; gap: 0.08rem 0.4rem; }
html[data-campaign-compact="true"] .player-health-hud span { font-size: 0.68rem; }
html[data-campaign-compact="true"] .player-health-hud strong { font-size: 0.8rem; }
html[data-campaign-compact="true"] .player-health-hud progress { height: 0.35rem; }
html[data-campaign-compact="true"] .play-hint { display: grid; }

/* Chapter 2: environment information belongs directly above health. */
.player-adaptation-hud:not([hidden]) {
  display: grid; grid-template-columns: 1fr auto; gap: 0.2rem 0.7rem;
  padding: 0.4rem 0.85rem; border: 1px solid #80cbb0; border-radius: 0.65rem;
  background: rgba(8, 32, 29, 0.95); color: #e1fff0; font-size: 0.85rem;
}
.player-adaptation-hud strong { font-variant-numeric: tabular-nums; }
.player-adaptation-hud progress { grid-column: 1 / -1; width: 100%; height: 0.6rem; accent-color: #83d5b0; }
.player-adaptation-hud p { grid-column: 1 / -1; margin: 0; color: #d9ebe3; font-size: 0.75rem; line-height: 1.4; }
.player-adaptation-hud[data-danger="true"] { border-color: #efa27c; }
.player-adaptation-hud[data-danger="true"] progress { accent-color: #efa27c; }
@media (max-height: 500px) {
  .player-adaptation-hud:not([hidden]) { padding: 0.2rem 0.5rem; gap: 0.08rem 0.4rem; font-size: 0.72rem; }
  .player-adaptation-hud p { font-size: 0.68rem; line-height: 1.25; }
  .player-adaptation-hud progress { height: 0.35rem; }
}

@media (pointer: coarse) and (orientation: portrait), (max-width: 48rem) and (orientation: portrait) {
  .touch-controls { bottom: var(--status-stack-offset, calc(8rem + env(safe-area-inset-bottom, 0px))); }
}

#named-evolution-list[data-layout="three-builds"] .named-evolution__list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#named-evolution-list[data-layout="three-builds"] .named-card { border-color: #375762; box-shadow: none; }
#named-evolution-list[data-layout="three-builds"] .named-card[data-current="true"] { border-color: #7ce9c0; box-shadow: inset 3px 0 0 #7ce9c0; }
#named-evolution-list[data-layout="three-builds"] .named-card small { font-size: 0.72rem; }
@media (max-width: 40rem) { #named-evolution-list[data-layout="three-builds"] .named-evolution__list { grid-template-columns: 1fr; } }

/* Three choices need one readable page, not two competing scroll panes. */
#evolution-dialog[data-build-system="three-axis"] .sea-panel__shell { display: block; overflow-y: auto; height: auto; max-height: calc(100dvh - 2rem); }
#evolution-dialog[data-build-system="three-axis"] .sea-panel__top { position: sticky; top: 0; z-index: 2; background: #102f40; }
#evolution-dialog[data-build-system="three-axis"] .evolution-choices { overflow: visible; }
#evolution-dialog[data-build-system="three-axis"] .choice { padding: 0.7rem 1rem; gap: 0.3rem; }
#evolution-dialog[data-build-system="three-axis"] .choice__fish { height: 90px; object-fit: contain; }
#evolution-dialog[data-build-system="three-axis"] .choice__good { font-size: 0.8rem; }
#evolution-dialog[data-build-system="three-axis"] .named-evolution { max-height: none; min-height: 0; overflow: visible; }
#evolution-dialog[data-build-system="three-axis"] .named-card { min-height: 0; }
#evolution-dialog[data-build-system="three-axis"] .named-card canvas { height: 100px; object-fit: contain; }
#evolution-dialog[data-build-system="three-axis"] .purchase-reason { position: sticky; bottom: 0; z-index: 2; background: #08212d; }
@media (max-width: 40rem) {
  #evolution-dialog[data-build-system="three-axis"] .choice { grid-template-columns: 6.5rem 1fr; }
  #evolution-dialog[data-build-system="three-axis"] .choice__fish { height: auto; }
}
#evolution-dialog[data-build-system="three-axis"] .evolution-cost[hidden] { display: none; }

#evolution-dialog[data-build-system="ch03-lineage"] .sea-panel__shell {
  display: block;
  overflow-y: auto;
  max-height: calc(100dvh - 2rem);
}
#evolution-dialog[data-build-system="ch03-lineage"] .sea-panel__top {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #102f40;
}
#evolution-dialog[data-build-system="ch03-lineage"] .evolution-choices {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem 0.9rem;
  overflow: visible;
}
#evolution-dialog[data-build-system="ch03-lineage"] .evolution-choice-group {
  display: grid;
  gap: 0;
  overflow: hidden;
  border: 1px solid rgba(176, 221, 230, 0.38);
  border-left-width: 4px;
  border-radius: 0.55rem;
  background: rgba(3, 18, 26, 0.52);
}
#evolution-dialog[data-build-system="ch03-lineage"] [data-choice-group="switch"] {
  border-left-color: #62cfe2;
}
#evolution-dialog[data-build-system="ch03-lineage"] [data-choice-group="upgrade"] {
  border-left-color: #ffd77b;
}
#evolution-dialog[data-build-system="ch03-lineage"] .evolution-choice-group__title {
  margin: 0;
  padding: 0.7rem 0.9rem 0.15rem;
  color: #fff1bd;
  font-size: 1rem;
  font-weight: 900;
}
#evolution-dialog[data-build-system="ch03-lineage"] .evolution-choice-group__note {
  margin: 0;
  padding: 0 0.9rem 0.65rem;
  color: #b8d9df;
  font-size: 0.76rem;
  line-height: 1.45;
}
#evolution-dialog[data-build-system="ch03-lineage"] .evolution-choice-group__choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--sea-line);
}
#evolution-dialog[data-build-system="ch03-lineage"] .choice {
  grid-template-columns: minmax(7rem, 32%) minmax(0, 1fr);
  grid-template-areas: "fish slot" "fish name" "fish price";
  align-items: center;
  gap: 0.2rem 0.8rem;
  padding: 0.65rem 0.8rem;
}
#evolution-dialog[data-build-system="ch03-lineage"] .choice__fish {
  grid-area: fish;
  align-self: center;
  height: clamp(5rem, 12vh, 6.5rem);
  object-fit: contain;
}
#evolution-dialog[data-build-system="ch03-lineage"] .choice__slot { grid-area: slot; }
#evolution-dialog[data-build-system="ch03-lineage"] .choice__name { grid-area: name; }
#evolution-dialog[data-build-system="ch03-lineage"] .choice__price {
  grid-area: price;
  justify-self: start;
  min-height: 2.4rem;
  margin-top: 0;
}
#evolution-dialog[data-build-system="ch03-lineage"] .choice--lineage-switch {
  background: rgba(64, 158, 186, 0.12);
}
#evolution-dialog[data-build-system="ch03-lineage"] .choice--lineage-upgrade {
  background: rgba(255, 215, 123, 0.085);
}
#evolution-dialog[data-build-system="ch03-lineage"] .choice--lineage-upgrade .choice__slot {
  background: rgba(255, 215, 123, 0.16);
  color: #ffe7a8;
}
#evolution-dialog[data-build-system="ch03-lineage"] .purchase-reason {
  position: static;
  z-index: auto;
  background: #08212d;
  overflow-wrap: anywhere;
}
#evolution-dialog[data-build-system="ch03-lineage"] .named-evolution {
  min-height: 0;
  max-height: none;
  overflow: visible;
}
@media (max-width: 40rem) {
  #evolution-dialog[data-build-system="ch03-lineage"] .evolution-choice-group__choices { grid-template-columns: 1fr; }
  #evolution-dialog[data-build-system="ch03-lineage"] .choice + .choice {
    border-top: 1px solid var(--sea-line);
    border-left: 0;
  }
}

#evolution-dialog[data-build-system="ch02-standard"] .choice__fish { height: clamp(80px, 14vh, 140px); object-fit: contain; }

.named-confirm { max-width: 42rem; }
.named-confirm__body { display:grid; gap:0.8rem; padding:0 1.1rem 0.4rem; }
.named-confirm__body canvas { display:block; width:100%; height:auto; aspect-ratio:640 / 280; max-height: min(16rem, 35dvh); object-fit:contain; border-radius:0.45rem; background: radial-gradient(90% 140% at 50% 40%, rgba(64,158,186,.32), rgba(6,24,36,.25) 72%), #0a2536; }
.named-confirm__ability { margin:0; color:#7ce9c0; font-weight:800; }
.named-confirm__encyclopedia { margin:0; color:#edfaff; line-height:1.55; }
.named-confirm__recipe { margin:0; color:#a8c9d1; font-size:0.78rem; }
.named-confirm__actions { display:flex; gap:0.7rem; justify-content:flex-end; margin:0; padding:0.8rem 1.1rem 1rem; }
.named-confirm__cancel, .named-confirm__accept { min-height:44px; padding:0.45rem 1rem; border-radius:0.35rem; font:inherit; cursor:pointer; }
.named-confirm__cancel { border:1px solid rgba(176,221,230,.35); background:#10232c; color:#edfaff; }
.named-confirm__accept { border:1px solid #7ce9c0; background:#123d36; color:#edfaff; font-weight:800; }
.named-memory-toast { position:relative; left:auto; bottom:auto; z-index:8; width:100%; transform:none; display:grid; grid-template-columns:5.2rem 1fr; gap:0.75rem; padding:0.7rem 0.85rem; border:1px solid #ffe7a8; border-radius:0.55rem; background:rgba(8,24,32,.94); color:#edfaff; box-shadow:0 10px 32px rgba(0,0,0,.35); }
.named-memory-toast[hidden] { display:none; }
.named-memory-toast canvas { width:5.2rem; height:5.2rem; border-radius:0.35rem; background:#0a2536; }
.named-memory-toast strong { display:block; color:#ffe7a8; }
.named-memory-toast em { display:block; margin-top:0.15rem; color:#7ce9c0; font-style:normal; font-weight:800; }
.named-memory-toast span { display:block; margin-top:0.25rem; color:#cfe9ee; font-size:0.78rem; line-height:1.4; }

.named-confirm__accept[hidden] { display: none; }

.book-entry[data-openable="true"] { cursor: pointer; }
.book-entry[data-openable="true"]:hover .book-entry__well,
.book-entry[data-openable="true"]:focus-visible .book-entry__well {
  box-shadow: inset 0 0 0 2px #ffe39a;
}
.book-entry__name {
  display: block;
  overflow: hidden;
  color: var(--ink-bright);
  font-size: 0.85rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: none;
  border: 0;
  padding: 0;
  cursor: inherit;
}
dialog.book-detail.sea-panel {
  position: fixed;
  inset: unset;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(22.5rem, calc(100vw - 1.6rem));
  height: fit-content;
  max-width: min(22.5rem, calc(100vw - 1.6rem));
  max-height: min(34rem, calc(100dvh - 2.4rem));
  margin: 0;
  overflow: hidden;
}
dialog.book-detail .sea-panel__shell,
.book-detail__form {
  display: flex;
  flex-direction: column;
  height: fit-content;
  max-height: min(34rem, calc(100dvh - 2.4rem));
  overflow: hidden;
}
.book-detail__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  padding: 0.15rem 1rem 0.95rem;
  overflow: auto;
}
.book-detail__art {
  position: relative;
  width: min(12.5rem, calc(100vw - 5.2rem));
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 0.85rem;
  background:
    radial-gradient(70% 80% at 50% 42%, rgba(90, 168, 188, 0.28), rgba(6, 20, 30, 0.92) 72%),
    #071824;
  box-shadow:
    inset 0 0 0 1px rgba(168, 224, 238, 0.28),
    0 10px 28px rgba(0, 0, 0, 0.35);
}
.book-detail__art canvas,
.book-detail__body img,
#book-detail-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
  border-radius: 0;
}
.book-detail__copy {
  width: 100%;
  display: grid;
  gap: 0.45rem;
  text-align: center;
}
.book-detail__ability {
  margin: 0;
  color: #ffe39a;
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.4;
}
.book-detail__encyclopedia {
  margin: 0;
  color: #d7eef4;
  font-size: 0.82rem;
  line-height: 1.55;
}
.book-detail__stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 0.85rem;
  margin: 0;
}
.book-detail__stats dt {
  margin: 0;
  color: #8fd9b8;
  font-size: 0.68rem;
  font-weight: 800;
}
.book-detail__stats dd {
  margin: 0;
  color: #edfaff;
  font-size: 0.78rem;
  font-weight: 700;
}
@media (max-width: 40rem) {
  dialog.book-detail.sea-panel {
    width: min(20.5rem, calc(100vw - 1.2rem));
    max-height: min(32rem, calc(100dvh - 2rem));
  }
  .book-detail__art { width: min(11.5rem, calc(100vw - 4.4rem)); }
}

.evolution-result {
  display: grid;
  gap: 0.45rem;
  margin: 0.35rem 0 0.7rem;
  padding: 0.85rem 1rem;
  border: 2px solid #ffe39a;
  border-radius: 0.7rem;
  background: linear-gradient(180deg, rgba(48, 36, 12, 0.96), rgba(18, 32, 28, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.evolution-result[hidden] { display: none !important; }
.evolution-result__summary {
  margin: 0;
  color: #ffe39a;
  font-size: 1.12rem;
  font-weight: 1000;
  line-height: 1.4;
}
.evolution-result__changes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.evolution-result__changes li {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.38rem 0.65rem;
  border-radius: 999px;
  background: rgba(8, 22, 28, 0.72);
  color: #edfaff;
}
.evolution-result__changes strong {
  color: #9debc4;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}
.evolution-result__changes span {
  color: #fff;
  font-size: 0.92rem;
  font-weight: 900;
}
.evolution-result__hint {
  margin: 0.1rem 0 0;
  color: #d7edf2;
  font-size: 0.78rem;
  font-weight: 700;
}

.player-status-bar .play-hint,
.player-status-bar .player-adaptation-hud:not([hidden]) {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  width: 100%;
}

html[data-campaign-compact="true"] dialog.book-detail.sea-panel,
dialog.book-detail.sea-panel {
  position: fixed !important;
  inset: unset !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: min(22.5rem, calc(100vw - 1.6rem)) !important;
  height: fit-content !important;
  max-width: min(22.5rem, calc(100vw - 1.6rem)) !important;
  max-height: min(34rem, calc(100dvh - 2.4rem)) !important;
  margin: 0 !important;
}

/* Chapter 2: a horizontal main route, with optional branches above/below.
   Scoped overrides also keep the compact/mobile map out of the vertical list. */
.world-stage-scroll[data-layout="linear"] {
  overflow-x: auto;
  overflow-y: hidden;
}
.world-stage-list[data-layout="linear"] {
  display: block;
  width: max(100%, var(--stage-map-width, 170rem));
  height: 100%;
  min-height: 26rem;
  padding: 0;
}
.world-stage-list[data-layout="linear"] .world-stage-connections { display: block; }
.world-stage-list[data-layout="linear"] .world-stage-edge--main { stroke-width: 3; }
.world-stage-list[data-layout="linear"] .world-stage-node {
  position: absolute;
  top: var(--stage-y);
  left: var(--stage-x);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 2.8rem 2.4rem minmax(0, 1fr);
  grid-template-areas: none;
  width: 10.4rem;
  height: 7.2rem;
  min-height: 0;
  gap: 0.22rem;
  padding: 0;
  transform: translate(-50%, -50%);
}
.world-stage-list[data-layout="linear"] .world-stage-node__scene { grid-area: auto; height: 2.8rem; }
.world-stage-list[data-layout="linear"] .world-stage-node__era-name { grid-area: auto; align-self: auto; margin: 0.2rem 0.55rem 0; }
.world-stage-list[data-layout="linear"] .world-stage-node__era-years { grid-area: auto; align-self: end; margin: 0 0.55rem 0.3rem; color: #ffe39a; font-size: 0.72rem; white-space: nowrap; }
.world-stage-list[data-layout="linear"] .world-stage-node__era-years:empty { display: none; }
@media (max-height: 40rem) {
  .world-stage-list[data-layout="linear"] { min-height: 14rem; }
  .world-stage-list[data-layout="linear"] .world-stage-node {
    grid-template-columns: 3.5rem minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas: "scene era-name" "scene era-years";
    width: 11rem;
    height: 3.8rem;
    min-height: 3.8rem;
    gap: 0.12rem 0.4rem;
  }
  .world-stage-list[data-layout="linear"] .world-stage-node__scene { grid-area: scene; height: 3.8rem; }
  .world-stage-list[data-layout="linear"] .world-stage-node__era-name { grid-area: era-name; align-self: end; margin: 0.25rem 0.35rem 0 0; font-size: 0.8rem; }
  .world-stage-list[data-layout="linear"] .world-stage-node__era-years { grid-area: era-years; align-self: start; margin: 0 0.35rem 0.25rem 0; font-size: 0.7rem; white-space: normal; }
}
@media (max-height: 30rem) {
  /* Only the side branches may need vertical access on very short screens. */
  .world-stage-scroll[data-layout="linear"] { overflow-y: auto; }
}

/* ---- 学習：はじめての出会い・手がかりクイズ ---------------------- */
dialog.learning-pop.sea-panel {
  position: fixed;
  inset: unset;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(30rem, calc(100vw - 1.6rem));
  max-width: min(30rem, calc(100vw - 1.6rem));
  height: fit-content;
  max-height: calc(100dvh - 1.6rem);
  margin: 0;
  overflow: hidden;
}
.learning-pop__form {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 1.6rem);
  overflow: hidden;
}
.learning-pop__head {
  padding: 0.9rem 1.1rem 0.2rem;
  text-align: center;
}
.learning-pop__kicker {
  margin: 0;
  color: var(--glow-gold);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}
dialog.learning-pop[data-kind="item"] .learning-pop__kicker,
dialog.learning-pop[data-kind="memory"] .learning-pop__kicker { color: #9fe8ff; }
dialog.learning-pop[data-kind="quiz"] .learning-pop__kicker { color: var(--glow-green); }
.learning-pop__title {
  margin: 0.15rem 0 0;
  color: var(--ink-bright);
  font-size: 1.25rem;
  line-height: 1.35;
}
dialog.learning-pop[data-kind="quiz"] .learning-pop__title { font-size: 1rem; line-height: 1.55; }
.learning-pop__body {
  display: grid;
  gap: 0.65rem;
  padding: 0.5rem 1.1rem 0.4rem;
  overflow: auto;
}
.learning-pop__art {
  justify-self: center;
  width: auto;
  max-width: 100%;
  height: min(11.25rem, 30dvh);
  aspect-ratio: 8 / 5;
  border-radius: 0.8rem;
  background:
    radial-gradient(70% 80% at 50% 45%, rgba(90, 168, 188, 0.3), rgba(6, 20, 30, 0.92) 72%),
    #071824;
  box-shadow: inset 0 0 0 1px rgba(168, 224, 238, 0.28);
  overflow: hidden;
}
.learning-pop__art[hidden] { display: none; }
.learning-pop__image { display: block; width: 100%; height: 100%; }
.learning-pop__story {
  margin: 0;
  color: var(--ink-main);
  font-size: 0.95rem;
  line-height: 1.75;
}
.learning-pop__story:empty { display: none; }
.learning-pop__note {
  margin: 0;
  padding: 0.45rem 0.65rem;
  border-radius: 0.5rem;
  background: rgba(255, 217, 122, 0.1);
  color: var(--glow-gold);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.5;
}
.learning-pop__choices { display: grid; gap: 0.45rem; }
.learning-pop__choices[hidden] { display: none; }
.learning-pop__choice {
  min-height: 2.9rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--sea-line-strong);
  border-radius: 0.6rem;
  background: rgba(13, 42, 61, 0.9);
  color: var(--ink-bright);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}
.learning-pop__choice:hover:not(:disabled) { background: rgba(40, 96, 120, 0.9); }
.learning-pop__choice:disabled { cursor: default; opacity: 0.6; }
.learning-pop__choice[data-answer="true"] { border-color: var(--glow-green); color: var(--glow-green); opacity: 1; }
.learning-pop__choice[data-picked="true"]:not([data-answer="true"]) { border-color: #ff9a8a; color: #ffb4a8; opacity: 1; }
.learning-pop__result {
  margin: 0;
  padding: 0.6rem 0.75rem;
  border-radius: 0.6rem;
  background: rgba(124, 233, 192, 0.1);
  color: var(--ink-bright);
  font-size: 0.9rem;
  line-height: 1.65;
}
.learning-pop__result[data-correct="false"] { background: rgba(255, 154, 138, 0.1); }
.learning-pop__result[hidden] { display: none; }
.learning-pop__actions {
  display: flex;
  justify-content: center;
  margin: 0;
  padding: 0.6rem 1.1rem 1rem;
}
.learning-pop__primary {
  min-width: 10rem;
  min-height: 2.9rem;
  border: 0;
  border-radius: 999px;
  background: var(--glow-gold);
  color: #1b1405;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}
.learning-pop__primary[hidden] { display: none; }
.learning-pop__actions { gap: 0.6rem; flex-wrap: wrap; }
.learning-pop__secondary {
  min-width: 8rem;
  min-height: 2.9rem;
  padding: 0 1rem;
  border: 1px solid var(--sea-line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-bright);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}
.learning-pop__secondary[hidden] { display: none; }
dialog.learning-pop[data-kind="quiz"] .learning-pop__result[data-correct="false"] { color: #ffe2a0; }

/* 進化の「なぜ？」 */
.choice__why {
  margin: 0;
  color: #bfe9f5;
  font-size: 0.72rem;
  line-height: 1.5;
  text-align: left;
}
.evolution-result__why {
  margin: 0.3rem 0 0;
  color: #bfe9f5;
  font-size: 0.8rem;
  line-height: 1.55;
}

/* 図鑑の段階 */
.book-entry__stage {
  color: var(--glow-gold);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
}
.book-detail__section {
  margin: 0;
  text-align: left;
}
.book-detail__section h3 {
  margin: 0 0 0.15rem;
  color: #8fd9b8;
  font-size: 0.78rem;
}
.book-detail__section p {
  margin: 0;
  color: #d7eef4;
  font-size: 0.82rem;
  line-height: 1.6;
}
.book-detail__section[data-locked="true"] p { color: var(--ink-dim); }

/* いのちの樹 */
.tree-of-life {
  display: grid;
  gap: 0.55rem;
  margin: 0.4rem 0 0;
  padding: 0;
  list-style: none;
}
.tree-row {
  position: relative;
  display: grid;
  justify-items: center;
}
.tree-row--branches {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.7rem;
  justify-items: stretch;
}
.tree-row + .tree-row::before,
.tree-branch-labels + .tree-row::before {
  content: "";
  position: absolute;
  top: -0.6rem;
  left: 50%;
  width: 2px;
  height: 0.55rem;
  background: var(--sea-line-strong);
}
.tree-row--branches + .tree-row--branches::before { display: none; }
.tree-row--branches > .tree-node::before {
  content: "";
  position: absolute;
  top: -0.6rem;
  left: 50%;
  width: 2px;
  height: 0.55rem;
  background: var(--sea-line-strong);
}
.tree-node {
  position: relative;
  display: grid;
  gap: 0.2rem;
  width: min(26rem, 100%);
  box-sizing: border-box;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--sea-line);
  border-radius: 0.7rem;
  background: rgba(8, 30, 44, 0.85);
}
.tree-row--branches > .tree-node { width: 100%; }
.tree-node[data-reached="false"] { opacity: 0.55; }
.tree-node[data-path="true"] {
  border-color: var(--glow-green);
  box-shadow: 0 0 0 1px rgba(124, 233, 192, 0.35), 0 0 18px rgba(124, 233, 192, 0.18);
}
.tree-node__age { color: var(--ink-dim); font-size: 0.72rem; }
.tree-node__title { color: var(--ink-bright); font-size: 0.92rem; font-weight: 800; }
.tree-node__text { margin: 0; color: var(--ink-main); font-size: 0.78rem; line-height: 1.55; }
.tree-node__you { color: var(--glow-green); font-size: 0.72rem; font-weight: 800; }
.tree-event {
  display: grid;
  gap: 0.15rem;
  padding: 0.5rem 0.75rem;
  border-top: 2px dashed rgba(255, 140, 120, 0.55);
  border-bottom: 2px dashed rgba(255, 140, 120, 0.55);
  background: rgba(60, 16, 16, 0.35);
}
.tree-event__title { color: #ffb4a8; font-size: 0.85rem; font-weight: 800; }
.tree-event__text { margin: 0; color: #f3d6d0; font-size: 0.76rem; line-height: 1.55; }
.tree-branch-labels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  text-align: center;
  color: var(--glow-gold);
  font-size: 0.78rem;
  font-weight: 800;
}
.book-detail__sections { display: grid; gap: 0.5rem; }
.book-detail__sections:empty { display: none; }
/* The generic ".defeat-overlay p" rule is more specific; keep the hint compact
   so the retry buttons stay clear of the HUD below the panel. */
.defeat-overlay p.defeat-overlay__tip {
  max-width: 28rem;
  margin: -0.8rem auto 1rem;
  padding: 0.45rem 0.75rem;
  border-radius: 0.55rem;
  background: rgba(124, 233, 192, 0.1);
  color: #cdf5e6;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.55;
}
.defeat-overlay p.defeat-overlay__tip[hidden] { display: none; }
@media (orientation: landscape) and (max-height: 480px) {
  .defeat-overlay h2 { font-size: 2.4rem; }
  .defeat-overlay p:not(.defeat-overlay__eyebrow) { margin: 0.4rem 0 0.8rem; font-size: 0.95rem; }
  .defeat-overlay p.defeat-overlay__tip { margin: -0.4rem auto 0.7rem; padding: 0.35rem 0.6rem; font-size: 0.72rem; line-height: 1.45; }
  .defeat-overlay button { min-height: 2.9rem; }
}

@media (orientation: landscape) and (max-height: 480px) {
  .learning-pop__body {
    grid-template-columns: minmax(0, 13rem) minmax(0, 1fr);
    align-items: start;
  }
  .learning-pop__art {
    grid-row: 1 / span 4;
    width: 100%;
    height: auto;
  }
  .learning-pop__body:has(> .learning-pop__art[hidden]) { grid-template-columns: minmax(0, 1fr); }
  .learning-pop__head { padding-top: 0.6rem; }
  .learning-pop__actions { padding: 0.4rem 1.1rem 0.7rem; }
}
#evolution-dialog[data-build-system="ch03-lineage"] .choice__why { grid-column: 1 / -1; }
/* 図鑑の詳細：低い横画面では絵を左、文を右に並べて、文を読みやすくする */
@media (orientation: landscape) and (max-height: 480px) {
  html[data-campaign-compact="true"] dialog.book-detail.sea-panel,
  dialog.book-detail.sea-panel {
    /* The base rule pins the phone width with !important. */
    width: min(42rem, calc(100vw - 1.2rem)) !important;
    max-width: min(42rem, calc(100vw - 1.2rem)) !important;
    max-height: calc(100dvh - 1.2rem) !important;
  }
  dialog.book-detail .sea-panel__shell,
  .book-detail__form { max-height: calc(100dvh - 1.2rem); }
  .book-detail__body {
    flex-direction: row;
    align-items: flex-start;
    gap: 0.9rem;
    min-height: 0;
  }
  .book-detail__art {
    position: sticky;
    top: 0;
    width: min(11rem, 34vw);
  }
  .book-detail__copy { flex: 1 1 auto; text-align: left; }
  .book-detail__stats { justify-content: flex-start; }
}
.choice__price + .choice__why { margin-top: 0.3rem; }
/* 小さい画面の進化画面：候補・固有進化・購入結果を1枚のページとして
   縦にスクロールさせる。文字拡大時も固定グリッドの行を潰さない。 */
@media (orientation: landscape) and (max-height: 480px), (orientation: portrait) and (max-width: 520px) {
  #evolution-dialog:not([data-build-system="ch03-lineage"]) .sea-panel__shell {
    display: block;
    height: auto;
    max-height: calc(100dvh - 0.7rem);
    overflow-y: auto;
  }
  #evolution-dialog:not([data-build-system="ch03-lineage"]) .sea-panel__top {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #102f40;
  }
  #evolution-dialog:not([data-build-system="ch03-lineage"]) .evolution-choices { overflow: visible; }
  #evolution-dialog:not([data-build-system="ch03-lineage"]) .named-evolution { max-height: none; min-height: 0; overflow: visible; }
  #evolution-dialog:not([data-build-system="ch03-lineage"]) .purchase-reason {
    position: sticky;
    bottom: 0;
    z-index: 3;
    background: #08212d;
  }
  #evolution-dialog .purchase-reason:empty { display: none; }
}

@media (orientation: portrait) and (max-width: 520px) {
  /* Text grows independently of icon-only touch hit targets. Rem-sized
     joysticks previously doubled to 312px and pushed actions offscreen. */
  .touch-controls { left: 12px; right: 12px; }
  .touch-directions { width: 88px; height: 88px; flex-shrink: 0; }
  .touch-joystick__thumb { width: 42px; height: 42px; }
  .touch-actions { grid-template-columns: repeat(2, 64px); gap: 8px; }
  .touch-actions button { min-width: 64px; min-height: 48px; border-radius: 24px; }
  .touch-action__icon { width: 32px; height: 32px; }
  .player-health-hud { column-gap: 8px; padding: 8px; }
  .player-health-hud strong { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
  body:has(.campaign-runtime[data-short-portrait="true"]:not([hidden])) .player-status-bar {
    max-height: var(--campaign-footer-budget);
    overflow-y: auto;
    overscroll-behavior: contain;
    pointer-events: auto;
    touch-action: pan-y;
  }
  body:has(.campaign-runtime[data-short-portrait="true"]:not([hidden])) .player-status-bar > * { flex-shrink: 0; }
  body:has(.campaign-runtime[data-short-portrait="true"]:not([hidden])) .player-health-hud {
    order: -1;
    position: sticky;
    top: 0;
    z-index: 1;
    background: #250b0b;
    padding: 8px;
  }
  .player-health-hud { grid-template-columns: auto minmax(0, 1fr); }
  .player-health-hud #player-health-value { justify-self: end; }
  .campaign-runtime .campaign-clear-conditions {
    max-height: var(--campaign-conditions-height, 12rem);
    overflow-y: auto;
    pointer-events: auto;
    box-sizing: border-box;
  }
  .campaign-runtime[data-chapter] .campaign-clear-conditions:has(details[open]) {
    width: min(16.5rem, calc(100% - 1.5rem));
    max-width: calc(100% - 1.5rem);
  }
  .campaign-runtime[data-chapter="ch01"] .campaign-clear-conditions {
    top: var(--campaign-toolbar-bottom, 5rem);
  }
  #evolution-dialog[data-build-system] .sea-panel__shell { max-height: calc(100dvh - 2rem - 2px); }
  #evolution-dialog[data-build-system] .choice {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "fish" "slot" "name" "good" "weak" "price";
  }
  #evolution-dialog .choice__fish { height: 8rem; object-fit: contain; }
  #evolution-dialog .choice__price { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
  /* At large text sizes, one narrow column per toolbar button made the
     toolbar 200px tall. Give the note its own row and evolution a real cell. */
  html:is([data-ec-text-scale="150"], [data-ec-text-scale="175"], [data-ec-text-scale="200"]) .shared-chrome {
    display: block;
    padding: 12px;
  }
  html:is([data-ec-text-scale="150"], [data-ec-text-scale="175"], [data-ec-text-scale="200"]) .shared-chrome .hud {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }
  html:is([data-ec-text-scale="150"], [data-ec-text-scale="175"], [data-ec-text-scale="200"]) #learning-notice { grid-column: 1 / -1; margin-right: 88px; min-height: 80px; }
  html:is([data-ec-text-scale="150"], [data-ec-text-scale="175"], [data-ec-text-scale="200"]) .shared-chrome .desktop-evolution-guide {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 80px;
    min-width: 0;
    max-width: 100%;
    padding: 6px 4px;
  }
  html:is([data-ec-text-scale="150"], [data-ec-text-scale="175"], [data-ec-text-scale="200"]) .shared-chrome .hud button { min-height: 44px; padding: 4px; }
  html:is([data-ec-text-scale="150"], [data-ec-text-scale="175"], [data-ec-text-scale="200"]) .hud-world > span:first-child,
  html:is([data-ec-text-scale="150"], [data-ec-text-scale="175"], [data-ec-text-scale="200"]) .hud-menu__icon { display: none; }
}

/* Account save chip and dialog (account-save.js). Top centre: the corners hold the HUD and the world selector. */
.account-save-chip {
  position: fixed;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background: rgba(10, 20, 30, 0.72);
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
}
.account-save-chip[data-state="signed-in"] { border-color: rgba(140, 230, 160, 0.8); }
.account-save-chip[data-state="offline"] { border-color: rgba(255, 190, 120, 0.9); }
.account-save-dialog {
  position: fixed;
  left: 50%;
  top: 44px;
  transform: translateX(-50%);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(320px, calc(100vw - 16px));
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  background: rgba(10, 20, 30, 0.94);
  color: #fff;
  font-size: 13px;
}
.account-save-dialog[hidden], .account-save-dialog [hidden] { display: none; }
.account-save-text { margin: 0; line-height: 1.5; }
.account-save-input { padding: 8px; border-radius: 6px; border: 1px solid #789; background: #fff; color: #111; font-size: 16px; }
.account-save-button { padding: 8px 10px; border-radius: 6px; border: 0; background: #3a8f5c; color: #fff; font-size: 14px; cursor: pointer; }
.account-save-button--quiet { background: #4a5a6a; }
.account-save-button:disabled { opacity: 0.6; cursor: default; }
