@font-face {
  font-family: "Road Rage";
  src: url("../fonts/Road_Rage.otf") format("opentype");
  font-display: swap;
}
:root {
  --bg: #050403;
  --panel: #0c0906;
  --gold: #c9944a;
  --gold-bright: #e8c188;
  --tan: #967044;
  --line: #2b1d0d;
  --text: #d8c4a4;
  --good: #55d2b1;
  --bad: #ef875d;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  padding-top: 84px;
  background:
    radial-gradient(circle at 50% 12%, rgba(201,148,74,0.08), transparent 34%),
    var(--bg);
  color: var(--gold-bright);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.55;
  overflow-x: hidden;
}
#embers {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
}
button, select { font: inherit; }

/* ---- header (mirrors site) ---- */
.site-header {
  position: fixed; inset: 0 0 auto; z-index: 50; height: 84px;
  background: rgba(1,1,1,0.985);
  border-bottom: 1px solid rgba(201,148,74,0.68);
  box-shadow: 0 8px 34px rgba(0,0,0,0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.nav-shell {
  width: min(1220px, calc(100% - 32px)); height: 100%; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 34px;
}
.nav-brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--gold-bright); text-decoration: none; font-weight: 800; letter-spacing: 0.08em;
}
.nav-brand img { width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(232,193,136,0.55); }
.nav-brand span {
  font-family: "Road Rage", Georgia, serif;
  font-size: 1.7rem;
  font-weight: 400;
  line-height: 0.85;
  letter-spacing: 0.035em;
}
.nav-links { display: flex; align-items: center; gap: 34px; }
.nav-links a {
  color: var(--text); text-decoration: none; text-transform: uppercase;
  letter-spacing: 0.12em; font-family: Arial, sans-serif; font-size: 0.78rem; font-weight: 700;
  transition: color 0.18s ease;
}
.nav-links a:hover, .nav-links a.active { color: var(--gold-bright); }
.nav-links a.active { padding-bottom: 7px; border-bottom: 1px solid var(--gold); }
.nav-links .nav-buy {
  padding: 12px 21px; color: #120d06; border: 1px solid #edc06e; border-radius: 5px;
  background: linear-gradient(180deg, #efc56f, #a96f1e);
  box-shadow: 0 0 24px rgba(201,148,74,0.17);
}
.menu-toggle {
  display: none; width: 42px; height: 42px; color: var(--gold-bright);
  background: #17110a; border: 1px solid var(--line); border-radius: 6px; font-size: 1.25rem; cursor: pointer;
}

/* ---- layout ---- */
.game-shell {
  position: relative; z-index: 1;
  width: min(2400px, calc(100% - 40px)); margin: 0 auto; padding: 34px 0 60px;
}
.eyebrow {
  color: var(--gold); font-family: Arial, sans-serif; font-size: 0.72rem;
  font-weight: 800; letter-spacing: 0.26em; text-transform: uppercase;
}
.game-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 24px; margin-bottom: 20px;
}
.game-head h1 {
  font-family: "Road Rage", Georgia, serif; font-weight: 400;
  font-size: clamp(3.4rem, 7vw, 5.6rem); line-height: 0.85; letter-spacing: 0.035em;
}
.lede { max-width: 560px; margin-top: 14px; color: var(--text); font-size: 1.02rem; }
.lede strong { color: var(--gold-bright); }

.hud {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: stretch;
  font-family: Arial, sans-serif;
}
.hud-item {
  min-width: 96px; padding: 10px 16px;
  border: 1px solid var(--line); border-radius: 6px; background: rgba(12,9,6,0.9);
  display: flex; flex-direction: column; gap: 4px;
}
.hud-label { color: var(--tan); font-size: 0.66rem; font-weight: 800; letter-spacing: 0.22em; text-transform: uppercase; }
.hud-value { color: var(--gold-bright); font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.hud-sub { color: var(--tan); font-size: 0.7rem; letter-spacing: 0.06em; }
.hud-wallet { justify-content: center; }
#scene-select {
  color: var(--gold-bright); background: #17110a; border: 1px solid var(--line);
  border-radius: 4px; padding: 4px 8px; font-size: 0.9rem; max-width: 220px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 11px 20px; border-radius: 5px; cursor: pointer; text-decoration: none;
  font-family: Arial, sans-serif; font-size: 0.78rem; font-weight: 800;
  letter-spacing: 0.12em; text-transform: uppercase; transition: transform 0.15s, box-shadow 0.15s;
}
.btn:hover { transform: translateY(-1px); }
.btn-gold {
  color: #120d06; border: 1px solid #edc06e;
  background: linear-gradient(180deg, #efc56f, #a96f1e);
  box-shadow: 0 0 24px rgba(201,148,74,0.17);
}
.btn-ghost { color: var(--gold-bright); border: 1px solid var(--gold); background: transparent; }
.btn[disabled] { opacity: 0.55; cursor: default; transform: none; }

/* ---- stage ---- */
.stage-wrap { position: relative; }
.stage {
  position: relative; width: 100%;
  height: clamp(420px, calc(100vh - 300px), 2000px);
  overflow: hidden; border: 1px solid rgba(201,148,74,0.5); border-radius: 8px;
  background: #020201; box-shadow: 0 20px 60px rgba(0,0,0,0.7), inset 0 0 80px rgba(0,0,0,0.6);
  touch-action: none; user-select: none; cursor: grab; outline: none;
}
.stage.dragging { cursor: grabbing; }
.stage:focus-visible { border-color: var(--gold-bright); }
.scene-layer {
  position: absolute; top: 0; left: 0;
  transform-origin: 0 0;
}
.scene-img { display: block; pointer-events: none; image-rendering: auto; }
.protected-media { -webkit-touch-callout: none; -webkit-user-drag: none; user-select: none; }
.marker {
  position: absolute; border: 3px solid var(--good); border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.6), 0 0 30px var(--good);
  pointer-events: none; animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 3px rgba(0,0,0,0.6), 0 0 8px var(--good); } }

.stage-loading, .stage-lock {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(2,2,1,0.85); color: var(--tan);
  font-family: Arial, sans-serif; letter-spacing: 0.2em; text-transform: uppercase; font-size: 0.8rem;
  z-index: 5;
}
.stage-lock { backdrop-filter: blur(10px); text-transform: none; letter-spacing: 0; }
.lock-card {
  max-width: 460px; padding: 32px; text-align: center;
  border: 1px solid rgba(201,148,74,0.55); border-radius: 8px; background: rgba(12,9,6,0.96);
}
.lock-card h2 { margin: 8px 0 12px; color: var(--gold-bright); font-size: 1.5rem; line-height: 1.2; }
.lock-card p { color: var(--text); font-size: 0.95rem; }
.lock-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }

.toast {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  padding: 10px 20px; border-radius: 6px; z-index: 6;
  background: rgba(12,9,6,0.95); border: 1px solid var(--line); color: var(--gold-bright);
  font-family: Arial, sans-serif; font-size: 0.85rem; letter-spacing: 0.06em;
  pointer-events: none; animation: rise 0.25s ease-out;
}
.toast.bad { border-color: var(--bad); color: var(--bad); }
.toast.good { border-color: var(--good); color: var(--good); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

.zoom-controls {
  position: absolute; right: 14px; top: 14px; z-index: 6;
  display: flex; flex-direction: column; gap: 6px;
}
.zoom-controls button {
  width: 42px; height: 42px; border-radius: 6px; cursor: pointer;
  color: var(--gold-bright); background: rgba(23,17,10,0.92); border: 1px solid var(--line);
  font-size: 1.3rem; line-height: 1;
}
.zoom-controls button:hover { border-color: var(--gold); }

.rules {
  display: grid; grid-template-columns: 52px minmax(0, 1fr); margin-top: 22px;
  overflow: hidden; border: 1px solid var(--line); border-radius: 8px;
  background: rgba(12,9,6,0.82);
}
.rules-tag {
  display: flex; align-items: center; justify-content: center; padding: 16px 10px;
  writing-mode: vertical-rl; transform: rotate(180deg);
  color: #120d06; background: var(--gold);
  font-family: Arial, sans-serif; font-size: 0.68rem; font-weight: 900;
  letter-spacing: 0.18em; text-transform: uppercase; text-align: center;
}
.rules-body { padding: clamp(20px, 3vw, 36px); }
.rules-grid {
  display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
  gap: clamp(24px, 4vw, 52px); align-items: stretch;
}
.rules h2 {
  color: var(--gold-bright); font-family: "Road Rage", Georgia, serif;
  font-size: clamp(3rem, 5vw, 4.8rem); font-weight: 400;
  line-height: 0.9; letter-spacing: 0.035em;
}
.rules-list { display: grid; gap: 12px; margin-top: 22px; list-style: none; }
.rules-list li {
  display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px;
  align-items: start; padding: 13px 14px;
  color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  background: rgba(5,4,3,0.72);
}
.rules-num {
  display: inline-grid; place-items: center; width: 30px; height: 30px;
  border-radius: 50%; color: #120d06; background: var(--gold);
  font-family: Arial, sans-serif; font-size: 0.78rem; font-weight: 900;
}
.rules-list strong {
  color: var(--gold-bright); font-family: Arial, sans-serif;
  font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase;
}
.prize-block {
  padding: clamp(20px, 3vw, 30px); border: 1px solid rgba(201,148,74,0.58);
  border-radius: 8px;
  background: radial-gradient(circle at 50% 0, rgba(201,148,74,0.16), transparent 55%), #080603;
  text-align: center;
}
.prize-kicker, .after-grad {
  color: var(--gold); font-family: Arial, sans-serif; font-size: 0.7rem;
  font-weight: 900; letter-spacing: 0.2em; text-transform: uppercase;
}
.prize-block h3 {
  margin-top: 8px; color: var(--gold-bright);
  font-family: "Road Rage", Georgia, serif; font-size: clamp(2.6rem, 4vw, 4rem);
  font-weight: 400; line-height: 0.88; letter-spacing: 0.025em;
}
.prize-block h3 span {
  display: block; margin-top: 7px; font-family: Arial, sans-serif;
  font-size: 0.72rem; font-weight: 900; letter-spacing: 0.22em;
}
.after-grad { margin-top: 12px; }
.medals { display: grid; gap: 8px; margin-top: 22px; text-align: left; }
.medal {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 5px;
  background: rgba(18,13,6,0.8); font-family: Arial, sans-serif;
}
.medal strong { color: var(--gold-bright); text-transform: uppercase; }
.medal span { color: var(--text); font-size: 0.82rem; font-weight: 800; }
.medal:nth-child(2) strong { color: #d3d3d3; }
.medal:nth-child(3) strong { color: #c88b62; }
.prize-note { margin-top: 16px; color: var(--text); font-size: 0.86rem; }
.bonding-cta {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
  color: var(--gold-bright); font-size: 0.88rem;
}
.rules-buy { width: 100%; margin-top: 12px; }
.rules-footer {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 14px;
  margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line);
  color: var(--tan); font-family: Arial, sans-serif; font-size: 0.72rem;
  font-weight: 900; letter-spacing: 0.15em; text-transform: uppercase;
}
.rules-footer a { color: var(--gold-bright); text-decoration: none; }
.rules-footer a:hover { color: var(--gold); }

/* ---- modal ---- */
.modal {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center;
  background: rgba(0,0,0,0.78); backdrop-filter: blur(6px); padding: 20px;
  overflow-y: auto;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(520px, 100%); padding: 36px; text-align: center;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  border: 1px solid rgba(201,148,74,0.65); border-radius: 10px;
  background: linear-gradient(180deg, rgba(201,148,74,0.08), transparent 40%), #0c0906;
  box-shadow: 0 30px 80px rgba(0,0,0,0.8);
}
.modal-card h2 {
  margin-top: 10px; font-family: "Road Rage", Georgia, serif; font-weight: 400;
  font-size: 3rem; line-height: 0.95; letter-spacing: 0.03em;
}
.win-stats { margin-top: 18px; font-size: 1.25rem; color: var(--gold-bright); font-variant-numeric: tabular-nums; }
.win-note { margin-top: 8px; color: var(--tan); font-size: 0.9rem; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 24px; }

footer {
  position: relative; z-index: 1;
  padding: 28px 20px 40px; text-align: center; border-top: 1px solid var(--line);
  color: var(--tan); font-size: 0.85rem;
}
.disclaimer { max-width: 820px; margin: 10px auto 0; font-size: 0.72rem; line-height: 1.5; opacity: 0.8; }

@media (max-width: 900px) {
  .menu-toggle { display: inline-grid; place-items: center; }
  .nav-links {
    position: absolute; top: 84px; left: 0; right: 0; display: none; flex-direction: column;
    align-items: stretch; gap: 0; background: rgba(1,1,1,0.98); border-bottom: 1px solid var(--line);
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 16px 24px; border-top: 1px solid var(--line); }
  .nav-links a.active { border-bottom: 0; padding-bottom: 16px; }
  .nav-links .nav-buy { margin: 12px 24px 16px; text-align: center; }
  .rules { grid-template-columns: 1fr; }
  .rules-tag {
    padding: 11px 14px; writing-mode: horizontal-tb; transform: none;
  }
  .rules-grid { grid-template-columns: 1fr; }
  .rules-body { padding: 20px 16px; }
  .stage { height: clamp(380px, calc(100vh - 340px), 800px); }
}
@media (prefers-reduced-motion: reduce) {
  .marker { animation: none; }
}

/* ---- v2: chapters, clock, lives, load screen, cursor, fx ---- */
.hud-value small { font-size: 0.8rem; color: var(--tan); font-weight: 600; margin-left: 2px; }
.hud-value.paws { font-size: 1.15rem; letter-spacing: 0.04em; filter: sepia(1) saturate(2.4) hue-rotate(-12deg) brightness(1.15); }
.hud-value.paws.low { color: var(--bad); }
.sound-toggle {
  align-self: center; width: 44px; height: 44px; border-radius: 6px; cursor: pointer;
  color: var(--gold-bright); background: rgba(12,9,6,0.9); border: 1px solid var(--line); font-size: 1.15rem;
}
.sound-toggle[aria-pressed="true"] { border-color: var(--gold); }

.chapters { margin: 0 0 14px; }
.chapter-strip {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.chapter {
  flex: 0 0 auto; min-width: 118px; padding: 8px 12px; text-align: left; cursor: pointer;
  color: var(--text); background: rgba(12,9,6,0.9); border: 1px solid var(--line); border-radius: 6px;
  display: grid; gap: 2px; font-family: Arial, sans-serif; transition: border-color 0.15s, transform 0.15s;
}
.chapter:hover { border-color: var(--gold); transform: translateY(-1px); }
.chapter.current { border-color: var(--gold-bright); box-shadow: 0 0 18px rgba(201,148,74,0.25); }
.chapter.cleared .ch-num { color: var(--good); }
.chapter.cleared .ch-num::after { content: ' ✓'; }
.ch-num { color: var(--gold); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.2em; }
.ch-title { color: var(--gold-bright); font-size: 0.82rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; }
.ch-meta { color: var(--tan); font-size: 0.68rem; letter-spacing: 0.12em; }

/* magnifying-glass cursor (cosmetic — zoom is wheel/pinch) */
.stage, .stage.dragging {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='36' height='36' viewBox='0 0 36 36'><circle cx='14' cy='14' r='9.5' fill='rgba(232,193,136,0.12)' stroke='%23e8c188' stroke-width='2.5'/><circle cx='14' cy='14' r='9.5' fill='none' stroke='%23000' stroke-width='0.8' opacity='.6'/><line x1='21' y1='21' x2='32' y2='32' stroke='%23000' stroke-width='6' stroke-linecap='round' opacity='.6'/><line x1='21' y1='21' x2='32' y2='32' stroke='%23c9944a' stroke-width='4' stroke-linecap='round'/><line x1='10' y1='11' x2='13' y2='8' stroke='%23fff' stroke-width='1.6' stroke-linecap='round' opacity='.7'/></svg>") 14 14, crosshair;
}

.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.miss-x {
  position: absolute; transform: translate(-50%, -50%); color: var(--bad);
  font: 800 34px/1 Arial, sans-serif; text-shadow: 0 0 12px rgba(0,0,0,0.9), 0 0 18px var(--bad);
  animation: missx 0.8s ease-out forwards;
}
@keyframes missx { 0% { opacity: 0; transform: translate(-50%,-50%) scale(0.4); } 20% { opacity: 1; transform: translate(-50%,-50%) scale(1.25); } 100% { opacity: 0; transform: translate(-50%,-70%) scale(1); } }

.clock { min-width: 190px; border-color: rgba(201,148,74,0.55); background: rgba(6,4,2,0.95); box-shadow: inset 0 0 18px rgba(0,0,0,0.6); }
.clock-digits {
  color: var(--good); font-family: "Courier New", ui-monospace, monospace; font-size: clamp(1.5rem, 2.6vw, 2.3rem);
  font-weight: 700; letter-spacing: 0.08em; text-shadow: 0 0 12px rgba(85,210,177,0.55); font-variant-numeric: tabular-nums;
}
.clock.danger .clock-digits { color: var(--bad); text-shadow: 0 0 14px rgba(239,135,93,0.8); animation: blink 0.5s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.55; } }

.zoom-readout { color: var(--tan); font-family: Arial, sans-serif; font-size: 0.66rem; text-align: center; letter-spacing: 0.1em; }

.overlay { position: absolute; inset: 0; z-index: 7; display: grid; place-items: center; background: rgba(2,2,1,0.9); }
.load-screen {
  background: radial-gradient(circle at 50% 40%, rgba(201,148,74,0.14), transparent 50%), #040302;
  transition: opacity 0.32s ease; opacity: 1;
}
.load-screen.prestart {
  background:
    linear-gradient(rgba(2,2,1,0.72), rgba(2,2,1,0.72)),
    url("scenes/ch01-beach-normal.webp") center / cover no-repeat;
}
.load-screen.out { opacity: 0; }
.load-card {
  display: grid; justify-items: center; gap: 8px;
  width: min(460px, 92%); padding: 24px 28px;
  text-align: center;
  background: rgba(4,3,2,0.78);
  border: 1px solid rgba(201,148,74,0.42);
  border-radius: 22px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.55);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.load-art { width: clamp(120px, 22vh, 200px); aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 18px 24px rgba(0,0,0,0.7)); animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }
.load-card h2 { font-family: "Road Rage", Georgia, serif; font-weight: 400; color: var(--gold-bright); font-size: clamp(2.2rem, 4vw, 3.4rem); line-height: 0.9; letter-spacing: 0.03em; }
.tight { font-family: Arial, sans-serif; font-size: 0.7rem; letter-spacing: 0.24em; text-transform: uppercase; color: var(--tan); }
.tight-dots { color: var(--gold-bright); letter-spacing: 0.18em; }
.load-rules { color: var(--text); font-size: 0.92rem; }
.start-rules {
  display: grid; gap: 7px; width: min(360px, 100%); margin: 8px 0;
  color: var(--text); font-family: Arial, sans-serif; font-size: 0.82rem;
  line-height: 1.35; text-align: left;
}
.start-btn { margin-top: 6px; min-width: 190px; }
.load-bar { width: 100%; height: 3px; margin-top: 8px; background: var(--line); border-radius: 2px; overflow: hidden; }
.load-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--gold-bright)); transition: width 0.15s linear; }
.stage-lock, .fail-screen { backdrop-filter: blur(10px); background: rgba(2,2,1,0.82); }
.fail-screen .lock-card { border-color: rgba(239,135,93,0.6); }
.fail-screen h2 { color: var(--bad); }

@media (prefers-reduced-motion: reduce) { .load-art, .clock.danger .clock-digits { animation: none; } }

/* ---- v3: leaderboard ---- */
.board { margin-top: 22px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 8px; background: rgba(12,9,6,0.8); }
body:not(.online) .board { opacity: 0.6; }
.board-head h2 { margin-top: 4px; font-family: "Road Rage", Georgia, serif; font-weight: 400; font-size: 2rem; line-height: 1; letter-spacing: 0.03em; }
.board-rows { list-style: none; margin-top: 12px; display: grid; gap: 6px; font-family: Arial, sans-serif; font-size: 0.9rem; }
.board-rows li { display: grid; grid-template-columns: 34px 1fr auto auto auto; gap: 14px; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: rgba(6,4,2,0.9); }
.board-rows .rank { color: var(--gold); font-weight: 800; }
.board-rows .who { color: var(--gold-bright); font-family: "Courier New", monospace; }
.board-rows .found { color: var(--gold-bright); font-weight: 800; }
.board-rows .t { color: var(--good); font-weight: 800; font-variant-numeric: tabular-nums; }
.board-rows .m { color: var(--tan); font-size: 0.78rem; }
.board-rows .muted { display: block; color: var(--tan); border-style: dashed; }
.board-note { margin-top: 12px; color: var(--tan); font-size: 0.78rem; line-height: 1.5; }

@media (max-width: 700px) {
  .board-rows li { grid-template-columns: 28px 1fr auto; gap: 6px 10px; }
  .board-rows .rank { grid-column: 1; grid-row: 1 / span 2; }
  .board-rows .who { grid-column: 2; grid-row: 1; }
  .board-rows .found { grid-column: 2; grid-row: 2; }
  .board-rows .t { grid-column: 3; grid-row: 1; }
  .board-rows .m { grid-column: 3; grid-row: 2; text-align: right; }
}

/* ---- v4: share card + scorecard ---- */
.share-card { display: block; width: 100%; max-width: 520px; margin: 18px auto 0; border: 1px solid rgba(201,148,74,0.5); border-radius: 8px; background: #050403; }
.card-actions { margin-top: 12px; }
.scorecard { margin-top: 22px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 8px; background: rgba(12,9,6,0.8); }
.score-summary { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 10px; font-family: Arial, sans-serif; color: var(--text); font-size: 0.9rem; }
.score-summary b { color: var(--gold-bright); font-size: 1.2rem; margin-right: 4px; }
.score-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; }
.score-cell { padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: rgba(6,4,2,0.9); font-family: Arial, sans-serif; display: grid; gap: 3px; }
.score-cell .ch-num { color: var(--gold); font-size: 0.66rem; font-weight: 800; letter-spacing: 0.2em; }
.score-cell .ch-title { color: var(--gold-bright); font-size: 0.8rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.score-cell .best { color: var(--good); font-weight: 800; font-variant-numeric: tabular-nums; }
.score-cell .best.none { color: var(--tan); font-weight: 400; }
.score-cell.done { border-color: rgba(85,210,177,0.45); }

.chapter.soon { cursor: default; opacity: 0.55; border-style: dashed; }
.chapter.soon:hover { transform: none; border-color: var(--line); }

/* ---- in-frame sticky HUD ---- */
.hud-anchor {
  position: sticky; top: 84px; height: 0; z-index: 30;
  pointer-events: none;
}
.hud-bar {
  position: absolute; top: 8px; left: 8px; right: 68px;
  padding: 8px; border: 1px solid rgba(201,148,74,0.35); border-radius: 8px;
  background: rgba(5,4,3,0.92); box-shadow: 0 8px 24px rgba(0,0,0,0.55);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  pointer-events: auto;
}
.hud-bar .hud {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
  align-items: center;
}
.hud-scores {
  grid-column: 2; display: flex; gap: 14px;
  justify-content: center;
}
.hud-account {
  grid-column: 3; display: flex; gap: 14px;
  align-items: center; justify-content: flex-end;
}
@media (max-width: 900px) {
  .hud-bar .hud {
    display: flex; flex-wrap: nowrap;
    overflow-x: auto; scrollbar-width: thin;
  }
  .hud-scores, .hud-account {
    display: flex; flex: 0 0 auto; gap: 8px;
  }
  .hud-account { margin-left: auto; }
}

@media (max-width: 700px),
       (orientation: landscape) and (max-width: 1200px) and (max-height: 700px) {
  .game-shell {
    width: calc(100% - 16px);
  }

  .game-head,
  .chapters {
    display: none;
  }

  /* Keep the HUD above the map instead of covering it. */
  .hud-anchor {
    position: relative;
    top: auto;
    height: auto;
  }

  .hud-bar {
    position: relative;
    inset: auto;
    margin-bottom: 3px;
    padding: 3px 5px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .hud-bar .hud {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 5px;
    overflow: visible;
  }

  .hud-scores {
    display: grid;
    grid-template-columns:
      minmax(105px, 1.5fr)
      minmax(40px, 0.55fr)
      minmax(52px, 0.65fr);
    gap: 5px;
    min-width: 0;
    flex: 1 1 auto;
  }

  .hud-scores > .hud-item:nth-child(4) {
    display: none;
  }

  .hud-account {
    display: flex;
    flex: 0 0 auto;
    gap: 4px;
    margin-left: 0;
  }

  .hud-item,
  .clock {
    min-width: 0;
    padding: 2px 3px;
    gap: 0;
    border: 0;
    background: transparent;
  }

  .hud-label {
    font-size: 0.48rem;
  }

  .clock-digits {
    font-size: clamp(1rem, 5vw, 1.3rem);
    letter-spacing: 0.03em;
  }

  .hud-value {
    font-size: 0.82rem;
  }

  .hud-value.paws {
    font-size: 0.7rem;
  }

  .hud-sub {
    display: none;
  }

  .hud-wallet {
    padding: 0;
  }

  .hud-account .btn {
    padding: 6px 7px;
    font-size: 0.5rem;
    white-space: nowrap;
  }

  .hud-account:has(#signin-btn:not([hidden])) .hud-wallet {
    display: none;
  }

  .sound-toggle {
    display: none;
  }

  /* Guarantee enough room for the complete start card. */
  .stage {
    height: calc(100dvh - 220px);
    min-height: 620px;
    max-height: 800px;
  }

  .load-screen.prestart {
    place-items: start center;
    overflow-y: auto;
    padding: 14px 8px;
  }

  .load-screen.prestart .load-card {
    width: min(100%, 420px);
    margin: auto;
    padding: 16px;
    gap: 6px;
  }

  .load-screen.prestart .load-art {
    width: 88px;
  }

  .load-screen.prestart .load-card h2 {
    font-size: clamp(1.9rem, 10vw, 2.6rem);
  }

  .load-screen.prestart .start-rules {
    margin: 4px 0;
    gap: 4px;
    font-size: 0.76rem;
  }

  .load-screen.prestart .start-btn {
    min-width: 160px;
    padding: 10px 14px;
  }
}

@media (orientation: landscape) and (max-width: 1200px) and (max-height: 700px) {
  body {
    padding-top: 0;
  }

  .site-header {
    display: none;
  }

  .game-shell {
    width: 100%;
    padding: 0;
  }

  .stage {
    height: calc(100dvh - 40px);
    min-height: 0;
    max-height: none;
    border: 0;
    border-radius: 0;
  }
}

/* Phone landscape: reduce the in-game HUD to a tiny countdown clock. */
@media (orientation: landscape) and (max-height: 520px) {
  .modal {
    padding: 8px;
  }

  .modal-card {
    width: min(680px, 100%);
    max-height: calc(100dvh - 16px);
    padding: 12px 16px;
  }

  .modal-card h2 {
    margin-top: 4px;
    font-size: 2rem;
  }

  .win-stats,
  .modal-actions,
  .share-card {
    margin-top: 8px;
  }

  .share-card {
    max-width: 320px;
  }

  .modal-actions {
    gap: 6px;
  }

  .hud-anchor {
    height: 0;
    z-index: 31;
  }

  .hud-bar {
    position: absolute;
    top: 7px;
    left: 7px;
    right: auto;
    margin: 0;
    padding: 0;
  }

  .hud-bar .hud,
  .hud-scores {
    display: block;
  }

  .hud-scores > .hud-item:not(.clock),
  .hud-account {
    display: none;
  }

  .clock {
    min-width: auto;
    padding: 4px 7px;
    border: 1px solid rgba(85, 210, 177, 0.38);
    border-radius: 7px;
    background: rgba(3, 8, 7, 0.72);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.55);
  }

  .clock .hud-label {
    display: none;
  }

  .clock-digits {
    font-size: 0.92rem;
    letter-spacing: 0.03em;
  }

  /* Before Start, retain wallet/sign-in controls above the scene. */
  .stage-wrap:has(.load-screen.prestart) .hud-anchor {
    height: auto;
  }

  .stage-wrap:has(.load-screen.prestart) .hud-bar {
    position: relative;
    inset: auto;
    padding: 3px 5px;
  }

  .stage-wrap:has(.load-screen.prestart) .hud-bar .hud {
    display: flex;
    justify-content: flex-end;
  }

  .stage-wrap:has(.load-screen.prestart) .hud-scores {
    display: none;
  }

  .stage-wrap:has(.load-screen.prestart) .hud-account {
    display: flex;
  }
}
.game-head { margin-bottom: 12px; }
