/* menu.css — Rolling King shell layer (W14).
   Royal Match register: saturated cartoon-3D, gold accents, NO outlines.
   Mobile-first 375px baseline + landscape media query + safe-area insets. */

:root {
  --royal-deep:   #4a1466;
  --royal-light:  #a35bd0;
  --cream:        #fff6dc;
  --cream-shadow: #e9d9a8;
  --ink:          #1a0e2e;
  --ink-soft:     #38234a;
  --shadow-soft:  0 4px 0 var(--gold-deep);
  --shadow-card:  0 12px 28px rgba(26,14,46,.35);
  --radius-btn:   18px;
  --radius-card:  22px;
  --ease-pop:     cubic-bezier(.2,1.4,.4,1);
  --ease-slide:   cubic-bezier(.22,.61,.36,1);
  --ease-fade:    cubic-bezier(.4,0,.2,1);
}

/* ── Shared screen / panel scaffolding ─────────────────────────────────────── */
.screen, .panel {
  position: absolute;
  inset: 0;
  z-index: 36;
  display: flex;
  flex-direction: column;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  pointer-events: auto;
  animation: shellFade .24s var(--ease-fade) both;
}
@keyframes shellFade { from { opacity: 0; } to { opacity: 1; } }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-gold, .btn-ghost, .btn-quiet, .mm-btn, .icon-btn {
  font-family: inherit;
  border: none;
  cursor: pointer;
  pointer-events: auto;
  transition: transform .08s linear, box-shadow .08s linear, background .1s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn-gold {
  background: linear-gradient(180deg, var(--gold) 0%, #ffba2a 100%);
  color: var(--ink);
  font-weight: 900;
  letter-spacing: .04em;
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow-soft);
  min-height: 56px;
  padding: 0 26px;
}
.btn-gold:active { transform: translateY(2px); box-shadow: 0 0 0 var(--gold-deep); }
.btn-gold[disabled] {
  background: linear-gradient(180deg, #6c5a7e 0%, #574766 100%);
  color: rgba(255,255,255,.55);
  box-shadow: 0 4px 0 #3a2c4d;
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  border: 2px solid var(--gold);
  color: var(--gold);
  font-weight: 800;
  border-radius: var(--radius-btn);
  min-height: 50px;
  padding: 0 22px;
}
.btn-ghost:active { background: rgba(255,211,58,.12); }
.btn-quiet {
  background: transparent;
  border: 2px solid var(--ink-soft);
  color: var(--royal-light);
  font-weight: 700;
  border-radius: var(--radius-btn);
  min-height: 50px;
  padding: 0 22px;
}
.btn-quiet:active { background: rgba(56,35,74,.4); }
.btn-xl { min-height: 64px; font-size: 24px; }
.btn-lg { min-height: 56px; font-size: 20px; }

.icon-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--royal-deep);
  color: var(--gold);
  font-size: 20px;
  line-height: 44px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active { opacity: .7; }
.hud-corner {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(56px, calc(env(safe-area-inset-right) + 56px));
  z-index: 22;
}

.link-btn {
  background: none; border: none;
  color: var(--royal-light);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  pointer-events: auto;
}
.link-btn:active { text-decoration: underline; }

/* Image fallback placeholder (deferred art) */
.img-fallback {
  background: var(--royal-deep);
  color: var(--gold);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  padding: 16px;
  text-align: center;
  min-height: 64px;
}

/* ── Start screen ─────────────────────────────────────────────────────────── */
#start-screen {
  align-items: center;
  justify-content: space-between;
  background: radial-gradient(ellipse at 50% 30%, var(--royal-light) 0%, var(--royal-deep) 55%, var(--ink) 100%);
}
.start-bg { position: absolute; inset: 0; pointer-events: none; }
.start-logo-wrap {
  margin-top: 8vh;
  display: flex; justify-content: center;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,.45));
}
#start-logo { width: min(72vw, 320px); height: auto; }
.start-king-stage { flex: 1; min-height: 18vh; }
#start-cta { width: min(80vw, 360px); margin-bottom: 12px; }
.start-footer {
  display: flex; align-items: center; gap: 12px;
  font-size: 12px; color: rgba(255,255,255,.7);
  padding-bottom: 6px;
}

/* ── Main menu ────────────────────────────────────────────────────────────── */
#main-menu {
  background: radial-gradient(ellipse at 50% 0%, rgba(108,42,150,.55) 0%, rgba(26,14,46,.92) 70%);
  gap: 12px;
}
.menu-header {
  display: flex; align-items: center; gap: 10px;
  min-height: 56px;
}
.menu-crest { width: 40px; height: 40px; }
.menu-title {
  flex: 1;
  font-size: clamp(20px, 6vw, 30px);
  font-weight: 900;
  color: var(--gold);
  letter-spacing: .04em;
  text-shadow: var(--shadow-soft), 0 0 24px rgba(255,211,58,.4);
  margin: 0;
}
.menu-coin-pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--royal-deep);
  border: 2px solid var(--gold);
  border-radius: 999px;
  padding: 5px 12px;
  font-weight: 900;
  color: var(--gold);
  min-height: 36px;
}
.menu-coin-pill img { width: 18px; height: 18px; }
.menu-coin-pill::after { content: '🪙'; font-size: 15px; }
.menu-coin-pill img + ::after { content: none; }

.menu-buttons {
  flex: 1;
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0;
}
.mm-btn {
  display: grid;
  grid-template-columns: 36px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  text-align: left;
  background: var(--royal-deep);
  border: 2px solid var(--gold);
  border-radius: var(--radius-card);
  color: var(--cream);
  min-height: 72px;
  padding: 10px 16px;
  box-shadow: var(--shadow-card);
}
.mm-btn:active { transform: translateY(2px); }
.mm-icon { grid-row: 1 / span 2; font-size: 22px; color: var(--gold); }
.mm-btn > span:nth-child(2) { font-size: 17px; font-weight: 900; letter-spacing: .03em; }
.mm-sub { grid-column: 2; font-size: 12px; font-weight: 600; color: var(--royal-light); }
.mm-btn-primary {
  min-height: 88px;
  background: linear-gradient(180deg, var(--gold) 0%, #ffba2a 100%);
  color: var(--ink);
  border-color: #fff0b0;
  animation: primaryGlow 2200ms ease-in-out infinite;
}
.mm-btn-primary .mm-icon { color: var(--ink); }
.mm-btn-primary .mm-sub { color: var(--ink-soft); }
@keyframes primaryGlow {
  0%,100% { box-shadow: var(--shadow-card), 0 0 0 rgba(255,211,58,0); }
  50%     { box-shadow: var(--shadow-card), 0 0 22px rgba(255,211,58,.7); }
}
.menu-footer {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 44px;
}

/* ── Slide panels (endless picker, achievements) ──────────────────────────── */
.slide-panel {
  background: radial-gradient(ellipse at 50% 0%, rgba(108,42,150,.55) 0%, rgba(26,14,46,.95) 70%);
  animation: panelSlide .28s var(--ease-slide) both;
}
@keyframes panelSlide { from { transform: translateX(100%); } to { transform: translateX(0); } }
.panel-header {
  display: flex; align-items: center; gap: 10px;
  min-height: 48px;
}
.panel-header h2 {
  flex: 1; margin: 0;
  font-size: clamp(18px, 5.5vw, 26px);
  font-weight: 900; color: var(--gold);
  letter-spacing: .06em;
}
.panel-back {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--royal-deep);
  border: 2px solid var(--gold);
  color: var(--gold);
  font-size: 22px;
  cursor: pointer;
}
.panel-back:active { opacity: .7; }
.panel-progress { font-size: 13px; font-weight: 700; color: var(--royal-light); }

.picker-cards { display: flex; gap: 12px; margin: 16px 0; }
.picker-card {
  flex: 1;
  background: var(--royal-deep);
  border: 3px solid rgba(255,255,255,.18);
  border-radius: var(--radius-card);
  color: var(--cream);
  padding: 14px 12px;
  cursor: pointer;
  text-align: center;
  transition: transform .1s var(--ease-pop), border-color .1s;
}
.picker-card img { width: 100%; height: auto; border-radius: 14px; margin-bottom: 8px; }
.picker-card h3 { margin: 4px 0; font-size: 18px; font-weight: 900; color: var(--gold); }
.picker-card p { margin: 4px 0; font-size: 12px; color: var(--royal-light); }
.picker-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(255,211,58,.6);
  transform: translateY(-2px);
}
.picker-best { font-size: 12px; font-weight: 700; color: var(--cream); margin-top: 6px; }
#endless-start { width: 100%; margin-top: auto; }

/* Achievements grid (scrollable, sticky header) */
#achievements-panel .panel-header { position: sticky; top: 0; }
.ach-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 2px;
}
.ach-tile {
  background: var(--royal-deep);
  border: 2px solid rgba(255,255,255,.16);
  border-radius: 16px;
  padding: 12px 10px;
  text-align: center;
}
.ach-tile.unlocked { border-color: var(--gold); box-shadow: 0 0 12px rgba(255,211,58,.4); }
.ach-tile.locked { opacity: .55; }
.ach-ico { font-size: 28px; }
.ach-name { font-size: 13px; font-weight: 900; color: var(--cream); margin-top: 4px; }
.ach-desc { font-size: 11px; color: var(--royal-light); margin-top: 2px; }

/* ── Pause overlay ────────────────────────────────────────────────────────── */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 52; /* above #shop-modal/#settings-modal (z-50) so confirm-from-settings layers on top */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26,14,46,.6);
  pointer-events: auto;
}
/* pause overlay sits below modals (it never co-exists with one); confirm rides highest */
#pause-overlay { z-index: 49; }
#confirm-modal { z-index: 53; }
@supports (backdrop-filter: blur(6px)) {
  .overlay { backdrop-filter: blur(6px); background: rgba(26,14,46,.45); }
}
.pause-card, .confirm-card {
  width: min(86vw, 480px);
  background: linear-gradient(180deg, #2a1060 0%, #160838 100%);
  border: 2px solid rgba(255,211,58,.55);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 24px 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  animation: cardPop .18s var(--ease-pop) both;
}
@keyframes cardPop { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }
.pause-card h2, .confirm-card h3 {
  margin: 0 0 6px;
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 900;
  color: var(--gold);
  text-align: center;
  text-shadow: var(--shadow-soft);
}
.confirm-card p {
  margin: 0 0 6px;
  font-size: 15px;
  color: var(--cream);
  text-align: center;
  line-height: 1.4;
}
.confirm-cost {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-weight: 900; color: var(--gold); font-size: 18px;
}
.confirm-cost img { width: 22px; height: 22px; }
.confirm-actions { display: flex; gap: 10px; margin-top: 6px; }
.confirm-actions button { flex: 1; min-height: 48px; }
#confirm-yes.danger {
  background: linear-gradient(180deg, #ff6b5a 0%, #e02f2f 100%);
  color: #fff;
  box-shadow: 0 4px 0 #7a1010;
}

/* ── Accessibility toggles ────────────────────────────────────────────────── */
body.lg-text { font-size: 118%; }
body.lg-text .mm-btn > span:nth-child(2) { font-size: 19px; }
body.lg-text .mm-sub { font-size: 13px; }

body.reduce-motion .screen,
body.reduce-motion .panel,
body.reduce-motion .slide-panel,
body.reduce-motion .pause-card,
body.reduce-motion .confirm-card { animation-duration: .12s; }
body.reduce-motion .mm-btn-primary { animation: none; box-shadow: var(--shadow-card), 0 0 18px rgba(255,211,58,.5); }

/* ── Settings extended controls ───────────────────────────────────────────── */
.settings-extended { display: flex; flex-direction: column; gap: 8px; }
.set-section {
  font-size: 12px; font-weight: 900; letter-spacing: .1em;
  color: var(--royal-light); margin-top: 8px;
}
.set-row {
  display: flex; align-items: center; gap: 10px;
  color: var(--cream); font-size: 15px; font-weight: 700;
  min-height: 44px;
}
.set-row > span:first-child { width: 64px; }
.set-slider { flex: 1; accent-color: var(--gold); height: 28px; }
.set-val { width: 44px; text-align: right; color: var(--gold); font-weight: 800; }
.set-toggle {
  display: flex; align-items: center; gap: 10px;
  color: var(--cream); font-size: 15px; font-weight: 700;
  min-height: 44px; cursor: pointer;
}
.set-toggle input { width: 22px; height: 22px; accent-color: var(--gold); }
.set-select {
  flex: 1; min-height: 40px;
  background: var(--royal-deep); color: var(--cream);
  border: 2px solid rgba(255,255,255,.22); border-radius: 12px;
  padding: 0 10px; font-family: inherit;
}
.set-select:disabled { opacity: .6; }
.set-hint { font-size: 12px; color: var(--royal-light); font-style: italic; }

/* ── Landscape ────────────────────────────────────────────────────────────── */
@media (orientation: landscape) and (max-height: 500px) {
  #start-screen { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .start-logo-wrap { flex: 1; margin-top: 0; }
  .start-king-stage { flex: 1; }
  #start-cta { width: min(40vw, 320px); }
  #main-menu .menu-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: min-content;
  }
  .mm-btn-primary { grid-column: 1; }
  .pause-card, .confirm-card { max-width: 480px; }
}

/* ════════════════════════════════════════════════════════════════════════════
   W15 — Campaign / world map / chapter cards
   Royal Match register, gold accents, NO outlines. Uses the existing --gold /
   --royal / --royal-deep / --gold-deep palette (no new color tokens).
   All decorative motion is gated behind prefers-reduced-motion.
   ════════════════════════════════════════════════════════════════════════════ */

.hidden { display: none !important; }

/* ── World map screen ──────────────────────────────────────────────────────── */
#world-map {
  position: fixed; inset: 0; z-index: 30;
  display: none; flex-direction: column;
  background: radial-gradient(ellipse at 50% 20%, var(--royal, #6f2f9a) 0%, var(--royal-deep) 60%, var(--ink) 100%);
  pointer-events: auto;
  overflow: hidden;
}
.wm-backdrop {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; filter: blur(8px) brightness(0.55);
  transform: scale(1.08); z-index: 0; pointer-events: none;
}
.wm-topbar, .wm-totals, .wm-scroll { position: relative; z-index: 1; }
.wm-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 6px;
}
.wm-title { font-weight: 900; font-size: 18px; color: var(--gold, #ffd33a); letter-spacing: .5px; }
.wm-icon-btn {
  width: 44px; height: 44px; border: none; border-radius: 12px;
  background: var(--royal-deep); color: var(--gold, #ffd33a);
  font-size: 22px; font-weight: 900; cursor: pointer;
  box-shadow: var(--shadow-soft);
}
.wm-icon-btn:active { transform: translateY(2px); }
.wm-totals {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  padding: 2px 14px 10px; font-weight: 800; font-size: 14px;
  color: var(--cream);
}
.wm-star-total .wm-star { color: var(--gold, #ffd33a); }
.wm-level-total { color: var(--royal-light); }
.wm-scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 4px 14px calc(env(safe-area-inset-bottom, 0px) + 24px);
}

/* ── Chapter zone card ─────────────────────────────────────────────────────── */
.wm-chapter {
  position: relative; margin: 0 auto 18px; max-width: 460px;
  background: linear-gradient(180deg, rgba(74,20,102,.92), rgba(40,12,60,.92));
  border: 2px solid var(--gold, #ffd33a);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 14px 16px 18px;
}
.wm-chapter-locked {
  filter: saturate(.4) brightness(.7);
  border-color: rgba(255,255,255,.18);
  text-align: center; padding: 22px 16px;
}
.wm-ch-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.wm-ch-num { font-size: 11px; font-weight: 800; color: var(--royal-light); text-transform: uppercase; letter-spacing: 1px; }
.wm-ch-name { font-size: 19px; font-weight: 900; color: var(--gold, #ffd33a); }
.wm-ch-stars { margin-left: auto; font-size: 13px; font-weight: 800; color: var(--cream); }
.wm-ch-title { font-size: 19px; font-weight: 900; color: var(--cream); margin-bottom: 6px; }
.wm-ch-lock { font-size: 34px; margin: 6px 0; }
.wm-ch-need { font-size: 14px; font-weight: 700; color: var(--cream); }
.wm-ch-have { color: var(--royal-light); }

/* ── Node grid (zig-zag, 3-wide) + connectors ──────────────────────────────── */
.wm-grid { position: relative; min-height: 96px; }
.wm-connectors { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.wm-node-pad {
  position: absolute; transform: translateX(-50%);
  width: 56px; height: 56px;  /* tap-pad ≥ HIG floor even though disc is smaller */
  padding: 0; margin: 0; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; z-index: 1;
}
.wm-node-pad[disabled] { cursor: default; }
.wm-node {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  position: relative; font-weight: 900; font-size: 16px;
}
.wm-node-num { color: var(--ink); }
.wm-node-pips { font-size: 9px; letter-spacing: -1px; color: var(--gold, #ffd33a); margin-top: 1px; line-height: 1; }

.wm-node.locked { background: #5a4a6e; color: rgba(255,255,255,.5); }
.wm-node.locked .wm-node-lock { font-size: 18px; }
.wm-node.unlocked { background: #6a5a7e; border: 2px solid var(--gold, #ffd33a); }
.wm-node.unlocked .wm-node-num { color: var(--cream); }
.wm-node.played { background: linear-gradient(180deg, var(--gold, #ffd33a), #ffba2a); box-shadow: var(--shadow-soft); }
.wm-node.perfect {
  background: linear-gradient(180deg, var(--gold, #ffd33a), #ffba2a);
  box-shadow: 0 0 0 3px rgba(255,211,58,.35), var(--shadow-soft);
}
.wm-node.boss { width: 58px; height: 58px; font-size: 18px; }
.wm-node-crown { position: absolute; top: -14px; font-size: 18px; color: var(--gold, #ffd33a); text-shadow: 0 2px 0 var(--gold-deep, #b87f00); }

/* ── Replay tooltip (long-press) ───────────────────────────────────────────── */
.wm-tip {
  position: absolute; bottom: 58px; left: 50%; transform: translateX(-50%);
  width: 168px; z-index: 5;
  background: var(--ink-soft); border: 2px solid var(--gold, #ffd33a);
  border-radius: 14px; padding: 8px 10px; text-align: center;
  box-shadow: var(--shadow-card);
}
.wm-tip-name { font-size: 13px; font-weight: 900; color: var(--gold, #ffd33a); }
.wm-tip-stars { font-size: 14px; color: var(--gold, #ffd33a); letter-spacing: 1px; }
.wm-tip-row { font-size: 10px; color: var(--cream); margin: 2px 0 6px; }
.wm-tip-play {
  width: 100%; border: none; border-radius: 10px; padding: 7px;
  background: linear-gradient(180deg, var(--gold, #ffd33a), #ffba2a);
  color: var(--ink); font-weight: 900; font-size: 13px; cursor: pointer;
}

/* ── Lose-screen world-map chevron (secondary, small) ──────────────────────── */
.lose-chevron {
  position: absolute; top: 14px; left: 14px;
  border: 2px solid var(--gold, #ffd33a); border-radius: 12px;
  background: rgba(74,20,102,.6); color: var(--gold, #ffd33a);
  font-weight: 800; font-size: 13px; padding: 6px 12px; cursor: pointer;
}

/* ── Chapter intro card ────────────────────────────────────────────────────── */
#chapter-card {
  position: fixed; inset: 0; z-index: 35;
  display: none; align-items: center; justify-content: center;
  background: rgba(20,8,40,.82); pointer-events: auto;
}
.cc-art {
  position: absolute; inset: 0; background-size: cover; background-position: center;
  z-index: 0;
}
.cc-art-fallback.theme-plains  { background: linear-gradient(160deg, #ffd98a, #ff9a6a, #6f2f9a); }
.cc-art-fallback.theme-cavern  { background: linear-gradient(160deg, #2a6a8a, #112244, #0a0820); }
.cc-art-fallback.theme-forge   { background: linear-gradient(160deg, #ff8a3a, #b03010, #2a0808); }
.cc-art-fallback.theme-summit  { background: linear-gradient(160deg, #cfe8ff, #88aacc, #4a1466); }
.cc-art-fallback.theme-variety { background: linear-gradient(160deg, #e8b0ff, #8a44cc, #2a1060); }
.cc-art-fallback.theme-boss    { background: linear-gradient(160deg, #c060ff, #6a1a8a, #0c0418); }
.cc-art-fallback.theme-final   { background: linear-gradient(160deg, #ffe6b0, #8899aa, #16161c); }
.cc-panel {
  position: relative; z-index: 1; text-align: center;
  padding: 28px 26px; max-width: 360px;
}
.cc-name { font-size: 30px; font-weight: 900; color: var(--gold, #ffd33a); text-shadow: 0 3px 0 var(--gold-deep, #b87f00); }
.cc-sub { font-size: 14px; font-weight: 800; color: var(--cream); text-transform: uppercase; letter-spacing: 2px; margin: 6px 0 22px; }

/* ── Chapter complete overlay ──────────────────────────────────────────────── */
#chapter-complete {
  position: fixed; inset: 0; z-index: 35;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(20,8,40,.86); pointer-events: auto; text-align: center;
}
.ccx-burst { position: absolute; top: 38%; left: 50%; width: 0; height: 0; z-index: 0; }
.ccx-particle {
  position: absolute; width: 10px; height: 10px; border-radius: 50%;
  background: var(--gold, #ffd33a); box-shadow: 0 0 8px var(--gold, #ffd33a);
}
.ccx-crown { display: none; font-size: 48px; color: var(--gold, #ffd33a); text-shadow: 0 3px 0 var(--gold-deep, #b87f00); z-index: 1; }
.ccx-name { position: relative; z-index: 1; font-size: 28px; font-weight: 900; color: var(--gold, #ffd33a); }
.ccx-stars { position: relative; z-index: 1; font-size: 22px; font-weight: 900; color: var(--cream); margin: 8px 0; }
.ccx-msg { position: relative; z-index: 1; font-size: 15px; font-weight: 800; color: var(--royal-light); text-transform: uppercase; letter-spacing: 2px; margin-bottom: 22px; }

/* ── Animations — decorative only, gated on reduced-motion ─────────────────── */
@media (prefers-reduced-motion: no-preference) {
  @keyframes wm-pulse-glow {
    0%, 100% { box-shadow: 0 0 0 3px rgba(255,211,58,.25), var(--shadow-soft); }
    50%      { box-shadow: 0 0 0 6px rgba(255,211,58,.55), var(--shadow-soft); }
  }
  @keyframes wm-bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
  }
  @keyframes wm-next-pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(255,211,58,.4); }
    50%      { box-shadow: 0 0 0 5px rgba(255,211,58,.0); }
  }
  @keyframes wm-unlock-fall {
    0%   { transform: translateY(0) rotate(0); opacity: 1; }
    100% { transform: translateY(40px) rotate(40deg); opacity: 0; }
  }
  @keyframes cc-in { 0% { opacity: 0; transform: scale(.92); } 100% { opacity: 1; transform: scale(1); } }
  @keyframes ccx-in { 0% { opacity: 0; transform: scale(.9); } 100% { opacity: 1; transform: scale(1); } }
  @keyframes ccx-burst { 0% { transform: translate(0,0) scale(1); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(.3); opacity: 0; } }
  @keyframes ccx-crown-spin { 0% { transform: rotateY(0) scale(.4); opacity: 0; } 60% { opacity: 1; } 100% { transform: rotateY(360deg) scale(1); opacity: 1; } }

  .wm-node.perfect { animation: wm-pulse-glow 2s ease-in-out infinite; }
  .wm-node.boss { animation: wm-bob 2.2s ease-in-out infinite; }
  .wm-node.next-up { animation: wm-next-pulse 1.6s ease-in-out infinite; }
  #chapter-card.cc-in { animation: cc-in .35s var(--ease-pop) both; }
  #chapter-complete.ccx-in .ccx-name { animation: ccx-in .4s var(--ease-pop) both; }
  .ccx-particle { animation: ccx-burst .9s var(--ease-fade) forwards; }
  #chapter-complete.ccx-perfect .ccx-crown { animation: ccx-crown-spin 1.1s var(--ease-pop) both; }
}

/* ════════════════════════════════════════════════════════════════════════════
   W16 — Daily Challenge. Uses --gold / --royal / --gold-deep only. All
   decorative motion gated behind prefers-reduced-motion: no-preference. Status
   is encoded by SHAPE/ICON as well as colour (colourblind-safe).
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Top-bar daily button (pill: 📅 <streak>) ── */
#hud-daily-button {
  position: absolute;
  top: 36px; right: 176px;
  min-width: 44px; height: 32px;          /* >=44x44 effective tap target via padding */
  padding: 0 9px;
  display: flex; align-items: center; gap: 3px;
  background: rgba(10, 5, 30, 0.68);
  border: 2px solid var(--gold);
  border-radius: 16px;
  font-size: 13px; font-weight: 800;
  line-height: 1; color: #fff;
  cursor: pointer; pointer-events: auto;
  transition: opacity 0.12s ease, box-shadow 0.2s ease;
}
#hud-daily-button:active { opacity: 0.65; }
#hud-daily-button #hud-daily-streak { color: var(--gold); }
/* gold pulse = not yet cleared today; red pulse = streak about to break */
@media (prefers-reduced-motion: no-preference) {
  #hud-daily-button.daily-pulse-gold { animation: dailyGoldPulse 1.8s ease-in-out infinite; }
  #hud-daily-button.daily-pulse-red  { animation: dailyRedPulse  1.0s ease-in-out infinite; }
}
/* reduced-motion: a static ring instead of an animation */
@media (prefers-reduced-motion: reduce) {
  #hud-daily-button.daily-pulse-gold { box-shadow: 0 0 0 3px rgba(255,211,58,0.5); }
  #hud-daily-button.daily-pulse-red  { box-shadow: 0 0 0 3px rgba(255,80,80,0.6); border-color:#ff5050; }
}
@keyframes dailyGoldPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,211,58,0.0); }
  50%     { box-shadow: 0 0 0 6px rgba(255,211,58,0.28); }
}
@keyframes dailyRedPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,60,60,0.0); border-color: var(--gold); }
  50%     { box-shadow: 0 0 0 6px rgba(255,60,60,0.40); border-color: #ff5050; }
}

/* ── Daily entry overlay ── */
#daily-entry {
  position: absolute; inset: 0;
  display: none;                          /* JS sets flex */
  align-items: center; justify-content: center;
  background: rgba(20, 8, 44, 0.82);
  z-index: 60;
  pointer-events: auto;
  padding: 16px;
}
#daily-entry-card {
  position: relative;
  width: 100%; max-width: 380px;
  max-height: 92vh; overflow-y: auto;
  box-sizing: border-box;
  background: linear-gradient(180deg, #2a1450 0%, #1a0c34 100%);
  border: 2px solid var(--gold);
  border-radius: 20px;
  padding: 22px 18px 18px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.55);
  text-align: center;
}
#daily-entry-close {
  position: absolute; top: 10px; right: 12px;
  width: 34px; height: 34px;
  background: rgba(0,0,0,0.3); color: #fff;
  border: none; border-radius: 50%;
  font-size: 16px; cursor: pointer;
}
#daily-entry-title {
  font-size: clamp(20px, 6vw, 26px); font-weight: 900;
  color: var(--gold);
  text-shadow: 0 2px 0 var(--gold-deep), 0 0 12px rgba(255,200,0,0.4);
  letter-spacing: 0.04em;
}
#daily-date { color: rgba(230,215,255,0.75); font-size: 13px; margin-top: 2px; font-weight: 700; }

/* calendar strip: rolling 7-day window, today on the far right */
#daily-calendar-strip {
  display: flex; gap: 4px;
  justify-content: center;
  min-width: 280px;                       /* fits 320px-wide devices */
  margin: 14px auto 10px;
}
.daily-cal-cell {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center;
  gap: 1px; padding: 4px 0;
  border-radius: 8px;
  background: #2a2a3a;
  border: 1.5px solid transparent;
}
.daily-cal-cell .dc-dow { font-size: 9px; font-weight: 800; color: rgba(255,255,255,0.55); }
.daily-cal-cell .dc-dom { font-size: 13px; font-weight: 800; color: #fff; }
.daily-cal-cell .dc-status { font-size: 13px; line-height: 1; }
.daily-cal-cell.dc-cleared  { background: #3a7a3a; }
.daily-cal-cell.dc-cleared3 { background: var(--gold); }
.daily-cal-cell.dc-cleared3 .dc-dom,
.daily-cal-cell.dc-cleared3 .dc-dow { color: #2a1450; }
.daily-cal-cell.dc-lost    { background: #5a2a2a; }
.daily-cal-cell.dc-skipped { background: #24242c; }
.daily-cal-cell.dc-pre     { background: #1d1d26; opacity: 0.55; }
.daily-cal-cell.dc-today   { background: var(--royal); border-color: var(--gold); }
@media (prefers-reduced-motion: no-preference) {
  .daily-cal-cell.dc-today { animation: dailyTodayPulse 1.8s ease-in-out infinite; }
}
@keyframes dailyTodayPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,211,58,0.0); }
  50%     { box-shadow: 0 0 0 3px rgba(255,211,58,0.35); }
}

/* modifier card */
#daily-modifier-card {
  display: flex; align-items: center; gap: 12px;
  text-align: left;
  background: var(--royal);
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 8px 0 12px;
}
#daily-mod-icon { font-size: 30px; line-height: 1; }
.daily-mod-text { flex: 1; min-width: 0; }
#daily-mod-name { font-size: 16px; font-weight: 900; color: var(--gold); }
#daily-mod-rule { font-size: 12px; color: rgba(230,215,255,0.85); margin-top: 2px; }

#daily-level-name { font-size: 14px; font-weight: 800; color: #fff; margin-bottom: 6px; }
.daily-best-row {
  display: flex; justify-content: space-between;
  font-size: 12px; color: rgba(220,205,255,0.8);
  padding: 2px 4px;
}
.daily-best-row span:last-child { font-weight: 800; color: var(--gold); }

#daily-entry-play { margin: 14px auto 4px; min-width: 180px; }
#daily-replay-note { font-size: 11px; color: rgba(220,205,255,0.7); margin-bottom: 4px; }
#daily-streak-line { font-size: 14px; font-weight: 800; color: var(--gold); margin: 6px 0; }
#daily-entry-footer {
  display: flex; justify-content: space-between;
  font-size: 12px; font-weight: 700;
  color: rgba(220,205,255,0.85);
  margin-top: 8px; padding: 0 4px;
}
#daily-gems { color: var(--gold); }

/* ── Win-screen daily action row ── */
#daily-win-actions {
  display: none;                          /* JS sets flex */
  gap: 8px; justify-content: center;
  margin: 6px 0 10px;
}
.daily-action-btn {
  background: var(--royal);
  color: #fff;
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px; font-weight: 800;
  cursor: pointer; pointer-events: auto;
}
.daily-action-btn:active { opacity: 0.7; }

/* ── Post-run toast ── */
#daily-toast {
  position: absolute;
  left: 50%; bottom: 64px;
  transform: translate(-50%, 30px);
  background: rgba(20, 8, 44, 0.94);
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 10px 18px;
  font-size: 14px; font-weight: 800; color: var(--gold);
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  z-index: 70;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#daily-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* On very narrow screens, let the daily button shrink rather than overflow. */
@media (max-width: 360px) {
  #hud-daily-button { right: 170px; font-size: 12px; padding: 0 7px; }
}

/* ───────────────────────── W20 — Achievements + Objectives ───────────────── */
/* Palette: --gold / --gold-deep / --royal-deep / --royal-light / --cream only.
   All motion gated behind prefers-reduced-motion (static fallback otherwise). */

/* Category filter tabs */
.ach-tabs {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 12px 4px; justify-content: center;
}
.ach-tab {
  font: inherit; font-size: 12px; font-weight: 800;
  padding: 5px 11px; border-radius: 14px;
  background: var(--royal-deep); color: var(--royal-light);
  border: 2px solid transparent; cursor: pointer;
}
.ach-tab.active { background: var(--gold); color: var(--royal-deep); border-color: var(--gold-deep); }

/* Secret tile look */
.ach-tile.secret.locked .ach-name { color: var(--royal-light); letter-spacing: 2px; }
.ach-tile.secret.locked { border-style: dashed; }
.ach-rew { font-size: 11px; font-weight: 900; color: var(--gold); margin-top: 3px; }
.ach-tile.unlocked .ach-rew { color: #8fe28f; }

/* Weekly objectives card (inside the achievements panel) */
.weekly-card {
  margin: 10px 12px 4px; padding: 12px 14px;
  background: var(--royal-deep); border: 2px solid var(--gold);
  border-radius: 14px;
}
.weekly-head {
  font-size: 13px; font-weight: 900; color: var(--gold);
  letter-spacing: 1px; margin-bottom: 8px; text-align: center;
}
.wk-row {
  display: grid; grid-template-columns: 1fr 90px 60px; align-items: center;
  gap: 8px; padding: 5px 0;
}
.wk-desc { font-size: 12px; color: var(--cream); }
.wk-bar { height: 8px; border-radius: 4px; background: rgba(0,0,0,.35); overflow: hidden; }
.wk-fill { height: 100%; background: linear-gradient(90deg, var(--gold) 0%, #ffba2a 100%); }
.wk-rew { font-size: 12px; font-weight: 900; color: var(--gold); text-align: right; }
.wk-row.wk-done .wk-rew { cursor: pointer; }
.wk-row.wk-claimed .wk-rew { color: #8fe28f; }
.wk-row.wk-claimed { opacity: .65; }
.weekly-cos { font-size: 11px; color: var(--royal-light); text-align: center; margin-top: 6px; }

/* Daily login modal */
.dl-card {
  position: relative; max-width: 92vw; width: 420px;
  background: linear-gradient(180deg, var(--royal-deep) 0%, #2a0d40 100%);
  border: 3px solid var(--gold); border-radius: 20px;
  padding: 20px 18px 22px; text-align: center;
}
.dl-close {
  position: absolute; top: 8px; right: 10px;
  background: none; border: none; color: var(--royal-light);
  font-size: 20px; cursor: pointer;
}
.dl-title { color: var(--gold); font-size: 22px; font-weight: 900; margin: 0 0 4px; }
.dl-streak { color: var(--cream); font-size: 13px; margin-bottom: 12px; }
.dl-strip {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-bottom: 16px;
}
.dl-cell {
  background: rgba(0,0,0,.3); border: 2px solid transparent; border-radius: 10px;
  padding: 6px 2px; min-height: 70px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.dl-day { font-size: 9px; font-weight: 800; color: var(--royal-light); }
.dl-ico { font-size: 18px; margin: 2px 0; }
.dl-rew { font-size: 8px; color: var(--cream); line-height: 1.1; }
.dl-cell.dl-today { border-color: var(--gold); box-shadow: 0 0 10px rgba(255,211,58,.5); }
.dl-cell.dl-claimed { opacity: .5; }
.dl-cell.dl-keepsake .dl-ico { filter: drop-shadow(0 0 4px var(--gold)); }

/* Achievement-unlock toast queue */
#toast-root {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 60;
  pointer-events: none;
}
.rk-toast {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(180deg, var(--gold) 0%, #ffba2a 100%);
  color: var(--royal-deep); font-weight: 800; font-size: 13px;
  padding: 9px 16px; border-radius: 14px;
  border: 2px solid var(--gold-deep);
  opacity: 0; transform: translateY(-12px);
}
.rk-toast.show { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: no-preference) {
  .rk-toast { transition: opacity .3s ease, transform .3s ease; }
}
.rk-toast-ico { font-size: 18px; }

/* ── W21 — Accessibility pack (design-06 slot 8) ──────────────────────────── */
/* UI scale: RRMeta sets --rk-ui-scale on :root (1.0 / 1.25 / 1.5). We scale the
   HUD overlay's font-size off it so clamp()-based type grows uniformly without a
   per-selector px audit (adversarial fix #8 — completable, non-lossy for em/clamp
   text). World coords (canvas) are untouched. */
:root { --rk-ui-scale: 1.0; }
#hud-overlay { font-size: calc(16px * var(--rk-ui-scale, 1)); }
/* Larger-text toggle stacks on top of UI scale. */
body.lg-text #hud-overlay { font-size: calc(18px * var(--rk-ui-scale, 1)); }

/* Reduce-motion: kill decorative pulses/shakes app-wide (camera shake is gated
   in rr-game._takeDamage; this covers CSS keyframe motion the shell still runs). */
body.reduce-motion * {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

/* Colorblind body classes — the real correction is the post-FX daltonize shader
   (rr-scene ColorblindShader); these classes are a hook for any future CSS-only
   HUD swatch tweaks and a debug marker. cb-off is the default no-op. */
body.cb-off, body.cb-deut, body.cb-prot, body.cb-trit { /* shader-driven */ }
