/* Samelet style2 "Tiny Worlds". Tokens come from the design package (light and dark); teal accent, red only for danger. */
@font-face { font-family: Nunito; font-weight: 600; font-style: normal; font-display: swap; src: url(fonts/nunito-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: Nunito; font-weight: 700; font-style: normal; font-display: swap; src: url(fonts/nunito-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: Nunito; font-weight: 800; font-style: normal; font-display: swap; src: url(fonts/nunito-latin-800-normal.woff2) format("woff2"); }
@font-face { font-family: Nunito; font-weight: 900; font-style: normal; font-display: swap; src: url(fonts/nunito-latin-900-normal.woff2) format("woff2"); }

:root {
  --bg: #F2F0FA; --bg2: #E3DFF3; --surface: #FFFFFF; --surface2: #E8E5F4; --line: #CFCBE6; --glass: #6A72A0;
  --text: #1C1A33; --muted: #55527A; --accent: #0B7578; --on-accent: #FFFFFF; --danger: #C62828; --ghost: #5B3FD0; --gold: #8A5A00;
  --shadow: rgba(40, 30, 90, 0.18); --accent-glow: rgba(11, 117, 120, 0.3);
  --gutter: 16px; --hudh: 56px;
  --font: Nunito, ui-rounded, "Segoe UI", system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D0B1E; --bg2: #171433; --surface: #1A1736; --surface2: #26224A; --line: #34305E; --glass: #8D92C4;
    --text: #F4F2FF; --muted: #ABA7D0; --accent: #3FD8C6; --on-accent: #06201D; --danger: #FF6B5E; --ghost: #B6A9FF; --gold: #FFD36B;
    --shadow: rgba(0, 0, 0, 0.5); --accent-glow: rgba(63, 216, 198, 0.3);
  }
}

* { box-sizing: border-box; }
/* painted once: html has no background, so the body's is propagated to the canvas (no second full-window paint). Explicit, because hosts (e.g. an artifact frame) may give body its own white background */
body { background: var(--bgimg, none) 0 0 / 100% 100% no-repeat, linear-gradient(180deg, var(--bg), var(--bg2)) !important; }
html, body {
  margin: 0; height: 100%; color: var(--text);
  font-family: var(--font); font-weight: 600; overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
}
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 60; pointer-events: none; }
button { font-family: inherit; }

#app {
  position: relative; height: 100dvh; max-width: 100vw; display: flex; flex-direction: column; gap: 6px;
  padding: max(8px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  user-select: none; -webkit-user-select: none;
}

/* ---------- header ---------- */
.hud { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; position: relative; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; overflow: hidden; }
.logo { width: 34px; height: 34px; flex: none; }
.brand-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.wordmark { font-weight: 900; font-size: 22px; letter-spacing: -0.01em; white-space: nowrap; }
.sub { color: var(--muted); font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn, .pill-btn {
  appearance: none; border: 1.5px solid var(--glass); background: var(--surface); color: var(--text); cursor: pointer;
  width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; padding: 0;
  transition: transform 120ms; box-shadow: 0 2px 8px var(--shadow);
}
.pill-btn { width: auto; border-radius: 22px; padding: 0 20px; font-weight: 800; font-size: 16px; }
.pill-btn[hidden] { display: none; }
.fb-btn { padding: 0 11px; font-size: 12px; line-height: 1.15; height: 44px; white-space: nowrap; text-align: center; }
@media (max-width: 460px) {
  /* phones: the header (logo, name, date, Finish, Pause, Feedback, Sound) has to fit in one row */
  .hud { gap: 6px; }
  .logo { width: 28px; height: 28px; }
  .brand { gap: 8px; }
  .wordmark { font-size: 19px; }
  .brand-txt .sub { font-size: 12px; }
  .hud-actions { gap: 6px; }
  .hud-actions .icon-btn { width: 38px; height: 38px; }
  .hud-actions .pill-btn { height: 38px; padding: 0 12px; font-size: 14px; }
  .hud-actions .fb-btn { height: 38px; padding: 0 9px; font-size: 11px; }
}
@media (max-width: 400px) {
  .hud-actions { gap: 6px; }
  .hud-actions .icon-btn { width: 38px; height: 38px; }
  .hud-actions .fb-btn { height: 38px; padding: 0 9px; font-size: 11px; }
  body[data-screen="start"] #streakChip { padding: 7px 11px; font-size: 12px; }
}
.hud-actions > * { flex-shrink: 0; }
/* .icon-btn sets display, which beats the hidden attribute: a hidden Pause button in a live duel stayed on screen (F-11) */
.icon-btn[hidden] { display: none; }
.pill-btn.armed { background: var(--danger); color: #fff; border-color: transparent; }
.icon-btn:active, .pill-btn:active, .btn:active { transform: scale(0.96); }
.icon-btn .cross { display: none; }
.icon-btn[aria-pressed="true"] .wave { display: none; }
.icon-btn[aria-pressed="true"] .cross { display: block; }
.icon-btn:focus-visible, .pill-btn:focus-visible, .btn:focus-visible, input:focus-visible, .row-set:focus-within { outline: 3px solid var(--ghost); outline-offset: 2px; }
.soft-chip { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-weight: 800; font-size: 13px; }
.soft-chip[hidden] { display: none; }
.lbl-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mod-badge { flex: none; align-self: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 3px 10px; font-weight: 900; font-size: 11px; line-height: 1.2; white-space: nowrap; }
.mod-badge[hidden] { display: none; }
.mapcard .twist { font-size: 10px; font-weight: 900; line-height: 1.1; color: var(--accent); text-align: center; text-transform: uppercase; letter-spacing: 0.02em; }
#streakChip { display: none; }
body[data-screen="start"] #streakChip:not([hidden]) { display: inline-block; }
body[data-screen="start"] .brand { visibility: hidden; }

body[data-screen="start"] .hudcard, body[data-screen="start"] #stage, body[data-screen="start"] .worlds, body[data-screen="start"] .chain, body[data-screen="start"] .hint-line { visibility: hidden; }
body[data-screen="play"] #btnSettings { display: none; }

/* non-play screens: only sound and settings stay in the corner, above the full-screen overlay */
body:not([data-screen="play"]) .hud-actions { position: fixed; top: max(8px, env(safe-area-inset-top)); right: max(var(--gutter), env(safe-area-inset-right)); z-index: 40; }
body[data-screen="start"] #streakChip { position: fixed; top: max(14px, calc(env(safe-area-inset-top) + 6px)); left: max(var(--gutter), env(safe-area-inset-left)); z-index: 40; }
body[data-screen="settings"] .hud-actions { z-index: 5; }

.lbl { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 800; }

/* ---------- score row ---------- */
.hudcard { display: flex; flex-direction: column; gap: 4px; }
.scorebar { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'score next' 'count combo'; align-items: end; column-gap: 10px; row-gap: 2px; }
.score-block { grid-area: score; display: flex; flex-direction: column; min-width: 0; }
.combo { grid-area: combo; }
.next-block { grid-area: next; }
.countline { grid-area: count; }
.val { font-size: 44px; line-height: 1.02; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; white-space: nowrap; }
.countline { display: flex; align-items: center; gap: 12px; min-height: 20px; white-space: nowrap; min-width: 0; }
.pips { display: flex; gap: 1px; align-items: center; height: 14px; flex: 1 1 auto; max-width: 230px; min-width: 40px; }
.pips i { flex: 1 1 0; height: 12px; border-radius: 2px; background: var(--line); opacity: 0.8; }
.pips i.on { background: var(--accent); opacity: 1; }
.combo { display: flex; flex-direction: column; align-items: stretch; justify-self: end; gap: 3px; padding-bottom: 2px; min-width: 112px; transition: opacity 120ms; }
.combo.off { visibility: hidden; }
.chip { --chip: #FFC21A; display: flex; align-items: baseline; justify-content: center; gap: 8px; background: var(--chip); color: #1A1530; border: 1.2px solid #1A1530; border-radius: 999px; padding: 4px 14px; box-shadow: 0 3px 12px color-mix(in srgb, var(--chip) 55%, transparent); font-weight: 900; transform-origin: 100% 60%; /* P-06: the pop grows leftwards from the right edge */ }
.chip .mult { font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; }
.chip .cap { font-size: 11px; letter-spacing: 0.04em; }
.chip .max { font-size: 10px; background: #1A1530; color: var(--chip); border-radius: 6px; padding: 1px 5px; align-self: center; letter-spacing: 0.06em; }
.chip .max[hidden] { display: none; }
.chip-bar { height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--line) 70%, transparent); overflow: hidden; }
.chip-bar i { display: block; height: 100%; width: 100%; background: var(--chipc, #FFC21A); transform-origin: 0 50%; transform: scaleX(0); }
.next-block { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.next-row { display: flex; align-items: flex-end; gap: 5px; }
#next { width: 56px; height: 56px; display: block; }
#next2, #next3 { width: 36px; height: 36px; display: block; }
#next3 { opacity: 0.85; }

.pace { margin-top: 2px; font-size: 15px; font-weight: 800; }
.pace[hidden] { display: none; }
.pace-text { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
#paceGhost { color: var(--ghost); }
.pace-bar { position: relative; height: 8px; border-radius: 4px; background: var(--line); margin: 6px 8px 4px; }
.pace-bar .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 4px; background: var(--accent); transition: width 0.15s linear; }
.pace-bar .marker { position: absolute; top: 50%; width: 16px; height: 16px; border-radius: 50%; border: 3px solid var(--ghost); background: var(--bg); transform: translate(-50%, -50%); left: 0; transition: left 0.15s linear; }
.side-note, .hint-line, .chain { display: none; }
.side-note[hidden] { display: none !important; }

/* ---------- stage ---------- */
#stage { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
#jarstack { position: relative; line-height: 0; contain: layout; }
#jarBack { position: absolute; left: 0; top: 0; pointer-events: none; display: block; }
#game { position: relative; display: block; touch-action: none; cursor: crosshair; outline: none; }
/* the whole stage is the touch area for aiming (P-17), so a press in the margin beside the jar does not pan the page */
#stage { touch-action: none; }
/* F-10: the idle warning sits just above the jar (inside the jar wrapper), so the held piece, which hangs from the top of the jar, is never under it */
.toast { position: absolute; left: 50%; bottom: 100%; top: auto; margin-bottom: 6px; transform: translateX(-50%); background: var(--danger); color: #fff; font-size: 12px; line-height: 1.3; font-weight: 800; padding: 2px 10px; border-radius: 999px; pointer-events: none; white-space: nowrap; z-index: 3; }
.toast[hidden] { display: none; }

.worlds { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 36px; padding: 0 2px; }
.worlds .lbl { font-size: 14px; text-transform: none; letter-spacing: 0; }
.slots { display: flex; gap: 6px; flex: 1; justify-content: flex-end; }
.w { width: 28px; height: 28px; flex: none; position: relative; border-radius: 50%; display: inline-block; }
.w canvas { width: 100%; height: 100%; display: none; }
.w.on canvas { display: block; }
.w:not(.on) { border: 1.5px solid var(--line); background: var(--surface2); opacity: 0.8; }
.w:not(.on)::after { content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: var(--muted); opacity: 0.5; }

/* compact phones (under 720 px tall): no pips, worlds strip or date line */
@media (max-height: 719px) {
  :root { --hudh: 56px; }
  #app { gap: 4px; }
  .hud { min-height: 44px; }
  .sub#hudDate, .pips, .worlds { display: none; }
  .logo { width: 28px; height: 28px; }
  .wordmark { font-size: 20px; }
  .val { font-size: 34px; }
  .scorebar { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: 'score combo next' 'score combo next'; }
  .countline { grid-area: score; align-self: start; justify-self: end; min-height: 0; }
  #next { width: 44px; height: 44px; }
  #next2 { width: 30px; height: 30px; }
  #next3 { display: none; }
  .pace { font-size: 13px; }
  .pace-bar { margin: 4px 8px 2px; }
  .chip .mult { font-size: 22px; }
  .chip { padding: 3px 10px; gap: 6px; }
  .combo { min-width: 96px; }
}

/* ---------- screens (start, result, settings) ---------- */
.screen { position: fixed; inset: 0; z-index: 20; display: flex; justify-content: center; overflow-y: auto; padding: calc(var(--hudh) + env(safe-area-inset-top)) var(--gutter) max(16px, env(safe-area-inset-bottom)); background: transparent; animation: fadeIn 200ms ease-out both; }
.screen[hidden] { display: none; }
#result { background: color-mix(in srgb, var(--bg) 90%, transparent); animation: none; }
.sheet { background: color-mix(in srgb, var(--bg) 88%, transparent); z-index: 50; }
/* scrolled content fades out under the header on the menu screens (the header itself has no background) */
body:not([data-screen="play"]) #app::before { content: ""; position: fixed; left: 0; right: 0; top: 0; height: calc(var(--hudh) + env(safe-area-inset-top)); pointer-events: none; z-index: 25; background: linear-gradient(var(--bg) 60%, transparent); }
.screen-inner { width: min(100%, 420px); margin: auto 0; padding-bottom: 12px; text-align: center; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.hero { display: flex; flex-direction: column; align-items: center; }
.hero-logo { width: 76px; height: 76px; margin-top: 4px; filter: drop-shadow(0 8px 14px var(--shadow)); }
h1 { margin: 6px 0 2px; font-size: 44px; font-weight: 900; letter-spacing: -0.02em; line-height: 1.05; }
.tag { margin: 0 0 8px; color: var(--muted); font-size: 15px; font-weight: 700; }
.date-pill, .date { margin: 0 0 8px; color: var(--muted); font-size: 14px; font-weight: 700; }
.date-pill { display: inline-block; background: color-mix(in srgb, var(--surface2) 80%, transparent); border-radius: 999px; padding: 4px 14px; font-size: 13px; }
.orbit { position: relative; width: 100%; height: 130px; margin: 4px 0 8px; }
.orbit canvas { position: absolute; left: 0; top: 0; }
.orbit-planet { animation: floaty 4.4s ease-in-out infinite; }
.banner { margin: 0 0 14px; padding: 14px 16px; border-radius: 18px; background: color-mix(in srgb, var(--surface) 88%, transparent); border: 2px solid var(--ghost); font-size: 14px; line-height: 1.35; text-align: left; }
.banner[hidden] { display: none; }
.banner.error { border-color: var(--danger); text-align: center; }
/* start-screen notice for a waiting live duel (src/duel-notice.js); static, no animation */
.duel-notice .duel-notice-text { margin: 0 0 10px; color: var(--muted); }
.duel-notice .btn { width: 100%; min-height: 44px; }
/* start-screen note shown when every daily try on every jar is used: points to Voyage and the minigames */
.tries-done .tries-done-text { margin: 0 0 10px; color: var(--muted); }
.tries-done .tries-done-actions { display: flex; gap: 8px; }
.tries-done .btn { flex: 1 1 0; min-height: 44px; }
.banner .who { display: flex; align-items: center; gap: 12px; }
.banner .avatar { width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--ghost); color: var(--bg); font-weight: 900; font-size: 20px; display: flex; align-items: center; justify-content: center; }
.banner .who b { display: block; font-size: 18px; font-weight: 900; }
.banner .who span { color: var(--muted); font-size: 13px; }
.banner .beat { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); margin-top: 10px; padding-top: 8px; color: var(--muted); font-weight: 800; }
.banner .beat b { color: var(--ghost); font-size: 24px; font-weight: 900; font-variant-numeric: tabular-nums; }

.name-row { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; color: var(--muted); margin: 10px 0; font-weight: 700; }
.name-row input { width: 12em; max-width: 60%; padding: 10px 14px; font: inherit; font-size: 16px; border-radius: 14px; border: 1px solid var(--line); background: color-mix(in srgb, var(--surface2) 60%, transparent); color: var(--text); user-select: text; -webkit-user-select: text; }

.buttons { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.buttons .buttons { margin: 0; }
.buttons.row { flex-direction: row; }
.buttons.row .btn { flex: 1 1 0; }
.btn {
  appearance: none; border: 2px solid var(--glass); background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--text); font: inherit; font-weight: 800; font-size: 17px;
  padding: 10px 16px; min-height: 48px; border-radius: 999px; cursor: pointer; transition: transform 120ms; box-shadow: 0 2px 8px var(--shadow);
}
.btn[hidden] { display: none; }
/* disabled controls look disabled (the primary turquoise used to look live) */
.btn:disabled, .pill-btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; transform: none; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; min-height: 56px; font-size: 19px; box-shadow: 0 6px 18px var(--accent-glow); }

.small { margin: 6px 0 0; font-size: 13px; color: var(--muted); min-height: 1em; font-weight: 700; }
.hint { font-size: 12.5px; }

.card.plain { background: none; border: 0; box-shadow: none; padding: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 26px; padding: 18px 18px 14px; text-align: center; box-shadow: 0 14px 40px var(--shadow); }
.vs-pill { display: inline-block; margin: 0 0 4px; background: var(--gold); color: var(--bg); font-weight: 900; font-size: 16px; border-radius: 999px; padding: 6px 16px; }
.vs-pill[hidden] { display: none; }
.big-score { position: relative; font-size: 64px; font-weight: 900; letter-spacing: -0.02em; line-height: 1.05; font-variant-numeric: tabular-nums; }
#resScoreAnim { position: absolute; left: 0; right: 0; top: 0; display: none; }
.counting #resScore { visibility: hidden; }
.counting #resScoreAnim { display: block; }
.stats { margin: 2px 0 8px; font-size: 15px; font-weight: 700; color: var(--muted); }
.res-body { display: flex; gap: 14px; align-items: flex-start; text-align: left; margin: 6px 0 10px; }
.sil { width: 42%; max-width: 168px; display: block; flex: none; }
.res-side { flex: 1; min-width: 0; }
.res-side .lbl { margin: 4px 0 0; text-transform: none; letter-spacing: 0; font-size: 13px; }
.chain-val { margin: 0; font-size: 24px; font-weight: 900; }
.note { margin: 10px 0 0; font-size: 12.5px; color: var(--muted); font-weight: 700; line-height: 1.35; }
.share-box { width: 100%; font: inherit; font-size: 13px; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); user-select: text; -webkit-user-select: text; resize: none; }
.share-box[hidden] { display: none; }

@media (max-height: 899px) { .orbit { display: none; } .hint { display: none; } }
@media (max-height: 780px) { .hero-logo { width: 56px; height: 56px; } h1 { font-size: 36px; } }

/* result entrance: card in, buttons stagger, silhouette bottom-up; skipped by any tap or calm motion */
.enter .card { animation: cardIn 420ms cubic-bezier(0.34, 1.4, 0.64, 1) both; }
.enter .buttons > .btn:first-child, .enter .buttons .row { animation: btnIn 160ms ease-out both; }
.enter .buttons > .btn:first-child { animation-delay: 480ms; }
.enter .buttons > .row:nth-child(2) { animation-delay: 540ms; }
.enter .buttons > .row:nth-child(3) { animation-delay: 600ms; }
.enter .vs-pill { animation: pillIn 220ms cubic-bezier(0.34, 1.7, 0.64, 1) 780ms both; }
@keyframes cardIn { from { opacity: 0; transform: translateY(36px) scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes btnIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes pillIn { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
.enter.skip .card, .enter.skip .buttons > *, .enter.skip .vs-pill { animation: none; }
html[data-calm="1"] .enter .card { animation: fadeIn 150ms both; }
html[data-calm="1"] .enter .buttons > *, html[data-calm="1"] .enter .vs-pill { animation: none; }

/* settings sheet */
.settings { text-align: left; }
.settings h2 { margin: 0 0 8px; font-size: 24px; font-weight: 900; }
.row-set { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer; min-height: 56px; font-weight: 800; font-size: 16px; border-radius: 8px; }
.row-set small { display: block; margin-top: 2px; color: var(--muted); font-weight: 600; font-size: 13px; line-height: 1.3; }
.row-set input { appearance: none; flex: none; width: 52px; height: 30px; border-radius: 15px; background: var(--line); position: relative; cursor: pointer; transition: background 120ms; border: 0; }
.row-set input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 4px var(--shadow); transition: transform 120ms; }
.row-set input:checked { background: var(--accent); }
.row-set input:checked::after { transform: translateX(22px); }
.settings .btn { width: 100%; margin-top: 14px; }
.row-set[hidden] { display: none; }

/* calm motion: no transitions or looping effects in the page */
html[data-calm="1"] * { transition: none !important; }

/* ---------- desktop: left brand and chain, jar centre, score card right ---------- */
@media (min-width: 900px) and (min-aspect-ratio: 5/4) and (min-height: 520px) {
  :root { --hudh: 64px; }
  #app { display: grid; grid-template-columns: minmax(0, 1fr) var(--stage-w, 460px) minmax(0, 1fr); grid-template-rows: auto auto 1fr auto; column-gap: 32px; row-gap: 12px; padding-top: 24px; padding-bottom: 24px; }
  .hud { display: contents; }
  .brand { grid-column: 1; grid-row: 1; justify-self: start; padding-left: 24px; position: relative; z-index: 2; }
  .logo { width: 56px; height: 56px; }
  .wordmark { font-size: 40px; }
  .brand-txt .sub { font-size: 18px; margin-top: 6px; }
  .chain { display: block; grid-column: 1; grid-row: 2 / span 2; border-top: 1px solid var(--line); margin: 0 24px; padding-top: 18px; align-self: start; }
  .chain-title { margin: 0 0 12px; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
  .chain-title span { text-transform: none; letter-spacing: 0; }
  .chain-ring { position: relative; width: 260px; height: 260px; margin: 8px auto 0; }
  .chain-ring .node { position: absolute; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%; }
  .chain-ring .node canvas { width: 100%; height: 100%; display: none; }
  .chain-ring .node.on canvas { display: block; }
  .chain-ring .node:not(.on) { background: var(--surface2); border: 2px solid var(--line); opacity: 0.7; }
  .chain-ring .node.top.on { box-shadow: 0 0 0 4px var(--bg), 0 0 0 7px var(--accent); }
  .chain-ring .arr { position: absolute; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 8px solid var(--muted); opacity: 0.7; }
  .chain-mid { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; font-weight: 900; font-size: 22px; line-height: 1.2; }
  .chain-mid small { display: block; font-size: 14px; color: var(--muted); font-weight: 700; }
  .hint-line { display: block; grid-column: 1; grid-row: 4; color: var(--muted); font-size: 14px; font-weight: 700; margin: 0 0 0 24px; align-self: end; }
  #stage { grid-column: 2; grid-row: 1 / span 4; width: var(--stage-w, 460px); }
  .hudcard { grid-column: 3; grid-row: 1; align-self: start; max-width: 420px; background: color-mix(in srgb, var(--surface) 80%, transparent); border: 1px solid var(--line); border-radius: 24px; padding: 18px 20px; box-shadow: 0 10px 30px var(--shadow); gap: 12px; }
  .val { font-size: 64px; }
  #next { width: 64px; height: 64px; }
  #next2, #next3 { width: 40px; height: 40px; }
  .pips { flex: 1 1 auto; height: 18px; }
  .pips i { height: 16px; }
  .countline { margin-top: 8px; }
  .scorebar { grid-template-columns: 1fr auto; grid-template-areas: 'score score' 'next next' 'combo combo' 'count count'; row-gap: 8px; }
  .scorebar .next-block { align-items: flex-start; }
  .scorebar .combo { align-items: stretch; min-width: 0; }
  .scorebar .chip { padding: 4px 16px; }
  .scorebar .chip-bar { width: 100%; }
  .side-note { display: block; margin: 0; color: var(--muted); font-size: 14px; font-weight: 700; border-top: 1px solid var(--line); padding-top: 12px; }
  .hud-actions { grid-column: 3; grid-row: 2; align-self: start; justify-self: stretch; justify-content: space-between; max-width: 420px; }
  body:not([data-screen="play"]) .hud-actions { position: fixed; justify-content: flex-end; }
  .worlds { display: none; }
  .sub#hudDate { display: block; }
  .pips { display: flex; }
  #chain.compact-h { display: none; }
}
/* the merge chain ring is 260 px in its own box: on a window of 720 to 899 px tall it is scaled, and the keyboard hint is left out, so nothing overlaps */
@media (min-width: 900px) and (min-aspect-ratio: 5/4) and (min-height: 720px) and (max-height: 899px) {
  .chain-ring { zoom: 0.62; }
  .hint-line { display: none; }
}
/* live duel: the right column takes 420 px so the rival jar and the bar fit next to the score (the sheet is not changed) */
@media (min-width: 900px) and (min-aspect-ratio: 5/4) and (min-height: 520px) {
  body:has(#duelBar:not([hidden])) #app { grid-template-columns: minmax(0, 1fr) var(--stage-w, 460px) minmax(0, 390px); }
  body:has(#duelBar:not([hidden])) .wordmark { font-size: 34px; }
}
@media (min-width: 900px) and (min-aspect-ratio: 5/4) and (min-height: 520px) and (max-height: 719px) {
  .chain { display: none; }
  .wordmark { font-size: 28px; }
  .logo { width: 40px; height: 40px; }
  .val { font-size: 44px; }
  /* the score, combo chip and piece counter stay stacked (the base desktop areas): side by side they overlapped on tablets in landscape */
}

/* tall phones: use the spare height for a bigger HUD */
@media (max-width: 600px) { :root { --gutter: 8px; } }
@media (max-width: 600px) and (min-height: 780px) {
  .val { font-size: 52px; }
  #next { width: 60px; height: 60px; }
  #next2, #next3 { width: 38px; height: 38px; }
  .pace { font-size: 16px; }
  .pace-bar { height: 10px; margin: 8px 8px 6px; }
  .worlds { min-height: 44px; }
  .w { width: 32px; height: 32px; }
  .hud { min-height: 60px; }
  .countline { min-height: 24px; }
  .pips i { height: 14px; }
}

/* desktop: the combo slot keeps its room (visibility:hidden from the base rule) so the HUD does not jump when a chain starts or ends */

/* landscape phones (short and wide, e.g. 915 x 412): the jar takes the full height on the left, and one compact column on the right
   holds the brand, score and combo, the NEXT pieces, the piece counter, the worlds row and the Finish / Pause / sound / help buttons.
   The jar size comes from layout() in game.js (it uses the whole height; the column is --side-w wide). */
@media (orientation: landscape) and (max-height: 519px) and (min-width: 560px) {
  :root { --hudh: 44px; --side-w: 250px; }
  #app { display: grid; grid-template-columns: minmax(0, 1fr) var(--stage-w, 240px) var(--side-w) minmax(0, 0.45fr); grid-template-rows: auto auto minmax(0, 1fr) auto auto; column-gap: 16px; row-gap: 6px; padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .hud { display: contents; }
  #stage { grid-column: 2; grid-row: 1 / -1; width: var(--stage-w, 240px); min-height: 0; }
  .brand { grid-column: 3; grid-row: 1; justify-self: start; gap: 8px; }
  .logo { width: 24px; height: 24px; }
  .wordmark { font-size: 18px; }
  .brand-txt .sub { font-size: 13px; margin-top: 0; }
  .sub#hudDate { display: block; }
  .pips, .side-note, .hint-line, .chain { display: none; }
  .hudcard { grid-column: 3; grid-row: 2; align-self: start; width: 100%; max-width: none; gap: 6px; padding: 8px 10px; background: color-mix(in srgb, var(--surface) 84%, transparent); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 6px 18px var(--shadow); }
  .scorebar { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'score combo' 'next next' 'count count'; grid-template-rows: auto auto auto; align-items: center; column-gap: 8px; row-gap: 4px; }
  .score-block { grid-area: score; }
  .val { font-size: 40px; }
  .combo { grid-area: combo; min-width: 0; justify-self: end; padding-bottom: 0; }
  .chip .mult { font-size: 22px; }
  .chip { padding: 3px 10px; gap: 6px; }
  .next-block { grid-area: next; flex-direction: row; align-items: center; justify-self: start; gap: 8px; }
  #next { width: 46px; height: 46px; }
  #next2 { width: 34px; height: 34px; }
  #next3 { display: block; width: 26px; height: 26px; opacity: 0.85; }
  .countline { grid-area: count; min-height: 18px; justify-self: start; }
  .pace { font-size: 13px; margin-top: 0; }
  .pace-bar { margin: 4px 6px 2px; }
  .worlds { grid-column: 3; grid-row: 4; display: flex; min-height: 0; padding: 0; gap: 8px; }
  .worlds .lbl { font-size: 13px; }
  .slots { gap: 4px; justify-content: flex-start; flex: 0 1 auto; }
  .w { width: 20px; height: 20px; }
  .hud-actions { grid-column: 3; grid-row: 5; justify-self: stretch; justify-content: space-between; gap: 6px; }
  .icon-btn, .pill-btn { min-width: 44px; min-height: 44px; }
  .pill-btn { padding: 0 14px; }
}

/* live duel in landscape phones: your jar on the left, the score column in the middle, the rival column on the right
   (the duel bar: the rival jar on top, then the title, the rows and the emotes). The bar keeps its own rules (duel.css). */
@media (orientation: landscape) and (max-height: 519px) and (min-width: 560px) {
  body:has(#duelBar:not([hidden])) #app { grid-template-columns: minmax(0, 1fr) var(--stage-w, 240px) 200px 150px minmax(0, 0.3fr); column-gap: 12px; }
  body:has(#duelBar:not([hidden])) .hudcard { display: contents; }
  body:has(#duelBar:not([hidden])) .scorebar { grid-column: 3; grid-row: 2; align-self: start; grid-template-columns: minmax(0, 1fr); grid-template-areas: 'score' 'combo' 'next' 'count'; row-gap: 6px; background: color-mix(in srgb, var(--surface) 84%, transparent); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 6px 18px var(--shadow); padding: 8px 10px; }
  body:has(#duelBar:not([hidden])) .brand, body:has(#duelBar:not([hidden])) .worlds, body:has(#duelBar:not([hidden])) .hud-actions { grid-column: 3; }
  body:has(#duelBar:not([hidden])) #duelBar { grid-column: 4; grid-row: 1 / -1; align-self: stretch; display: flex; flex-direction: column; align-items: stretch; gap: 4px; width: 100%; min-width: 0; padding: 8px; border-radius: 18px; border: 1px solid var(--line); box-shadow: 0 6px 18px var(--shadow); }
  body:has(#duelBar:not([hidden])) .duel-jar { order: -1; align-self: center; }
  body:has(#duelBar:not([hidden])) .combo { justify-self: start; }
  body:has(#duelBar:not([hidden])) .worlds .lbl { display: none; }
  body:has(#duelBar:not([hidden])) .duel-jar-cv { width: 84px; height: 106px; }
  body:has(#duelBar:not([hidden])) .duel-cap { display: none; }
  body:has(#duelBar:not([hidden])) .duel-bar-main { gap: 3px; }
  body:has(#duelBar:not([hidden])) .duel-bar-title { font-size: 14px; }
  body:has(#duelBar:not([hidden])) .duel-bar-head { flex-wrap: wrap; }
  body:has(#duelBar:not([hidden])) .duel-bar-head .duel-bar-title { white-space: normal; flex: 1 1 100%; }
  body:has(#duelBar:not([hidden])) .duel-emote { min-height: 44px; font-size: 12px; }
  body:has(#duelBar:not([hidden])) .duel-mute, body:has(#duelBar:not([hidden])) .duel-leave { min-height: 44px; }
  body:has(#duelBar:not([hidden])) .duel-emote-line { min-height: 16px; font-size: 12px; }
}

/* live duel on a portrait screen (phones, tablets): the info and the rival's big jar on top (title, you, rival and the emotes on the left),
   your own jar below with the score and the piece counter on its left and the NEXT pieces in a column on its right.
   The rival's jar is as wide as the card allows next to a 131 px info column, capped at 40% of the screen height; your own jar is about the same size
   (the side columns are at least 84 and 60 px and grow on wide screens so that they stay next to the jar). */
@media (orientation: portrait) {
  body:has(#duelBar:not([hidden])) #app { display: grid; grid-template-columns: clamp(56px, calc(50vw - 190px), 220px) minmax(0, 1fr) clamp(50px, calc(50vw - 214px), 196px); grid-template-rows: auto auto auto minmax(0, 1fr) auto; column-gap: 6px; row-gap: 6px; }
  body:has(#duelBar:not([hidden])) .hud { grid-column: 1 / -1; grid-row: 1; }
  body:has(#duelBar:not([hidden])) .hudcard { display: contents; }
  body:has(#duelBar:not([hidden])) #duelBar { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; gap: 8px; padding: 8px; }
  body:has(#duelBar:not([hidden])) .duel-bar-main { grid-column: 1; grid-row: 1; justify-content: space-between; }
  body:has(#duelBar:not([hidden])) .duel-jar { grid-column: 2; grid-row: 1; width: auto; align-self: center; }
  body:has(#duelBar:not([hidden])) .duel-jar-cv { width: auto; height: clamp(190px, min(calc((100vw - 171px) * 1.445), 40vh), 460px); aspect-ratio: 360 / 520; }
  body:has(#duelBar:not([hidden])) .duel-jar-cv { width: auto; height: clamp(190px, min(calc((100vw - 171px) * 1.445), 40dvh), 460px); aspect-ratio: 360 / 520; }
  body:has(#duelBar:not([hidden])) .duel-cap { max-width: 100%; }
  body:has(#duelBar:not([hidden])) .duel-bar-head { flex-wrap: wrap; }
  body:has(#duelBar:not([hidden])) .duel-bar-head .duel-bar-title { flex: 1 1 100%; white-space: normal; font-size: 14px; }
  body:has(#duelBar:not([hidden])) .duel-bar-head .duel-mute { margin-left: 0; }
  body:has(#duelBar:not([hidden])) .duel-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'name num' 'track track'; row-gap: 3px; }
  body:has(#duelBar:not([hidden])) .duel-row-name { grid-area: name; max-width: none; }
  body:has(#duelBar:not([hidden])) .duel-row-num { grid-area: num; }
  body:has(#duelBar:not([hidden])) .duel-track { grid-area: track; }
  body:has(#duelBar:not([hidden])) .duel-emotes { grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr); gap: 6px 4px; padding: 3px 0; }
  /* taller touch targets where the screen has the height for them */
  body:has(#duelBar:not([hidden])) .duel-emote { position: relative; min-height: 30px; height: 30px; padding: 0 2px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--line)); background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 16%, var(--surface)), color-mix(in srgb, var(--accent) 6%, var(--surface))); color: var(--text); font-size: 11.5px; font-weight: 800; line-height: 1; letter-spacing: -0.01em; white-space: nowrap; box-shadow: inset 0 1px 0 color-mix(in srgb, var(--text) 10%, transparent); transition: transform 80ms ease-out, background-color 120ms; }
  body:has(#duelBar:not([hidden])) .duel-emote::after { content: ''; position: absolute; left: 0; right: 0; top: -3px; bottom: -3px; }
  body:has(#duelBar:not([hidden])) .duel-emote:active { transform: scale(0.94); background: color-mix(in srgb, var(--accent) 30%, var(--surface)); }
  body:has(#duelBar:not([hidden])) .duel-mute, body:has(#duelBar:not([hidden])) .duel-leave { min-height: clamp(36px, calc(12vh - 49px), 40px); }
  body:has(#duelBar:not([hidden])) .duel-mute, body:has(#duelBar:not([hidden])) .duel-leave { min-height: clamp(36px, calc(12dvh - 49px), 40px); }
  /* your jar: score and piece counter on the left, NEXT on the right */
  body:has(#duelBar:not([hidden])) .scorebar { display: contents; }
  body:has(#duelBar:not([hidden])) .score-block { grid-column: 1; grid-row: 3; align-self: start; }
  body:has(#duelBar:not([hidden])) .val { font-size: 22px; letter-spacing: -0.03em; }
  body:has(#duelBar:not([hidden])) .countline { grid-column: 2; grid-row: 3; align-self: end; justify-self: center; text-align: center; white-space: nowrap; min-height: 0; font-size: 14px; font-weight: 800; line-height: 1.2; }
  body:has(#duelBar:not([hidden])) .pips { display: none; }
  body:has(#duelBar:not([hidden])) .combo { grid-column: 1; grid-row: 4; align-self: start; margin-top: 2px; min-width: 0; justify-self: stretch; }
  body:has(#duelBar:not([hidden])) .chip { padding: 2px 6px; gap: 3px; flex-wrap: wrap; }
  body:has(#duelBar:not([hidden])) .chip .mult { font-size: 20px; }
  body:has(#duelBar:not([hidden])) .chip .cap { display: none; }
  body:has(#duelBar:not([hidden])) .next-block { grid-column: 3; grid-row: 3 / 5; align-self: start; align-items: center; }
  body:has(#duelBar:not([hidden])) .next-row { flex-direction: column; align-items: center; gap: 6px; }
  body:has(#duelBar:not([hidden])) #next { width: 46px; height: 46px; }
  body:has(#duelBar:not([hidden])) #next2 { width: 38px; height: 38px; }
  body:has(#duelBar:not([hidden])) #next3 { display: block; width: 30px; height: 30px; }
  body:has(#duelBar:not([hidden])) #stage { grid-column: 2; grid-row: 4; }
  body:has(#duelBar:not([hidden])) .worlds { grid-column: 1 / -1; grid-row: 5; }
  body:has(#duelBar:not([hidden])) .pace, body:has(#duelBar:not([hidden])) .side-note { grid-column: 1 / -1; }
}

/* landscape phones: the welcome sheet has two columns (title and fields on the left, the buttons on the right), so the buttons stay on the first screen */
@media (orientation: landscape) and (max-height: 519px) and (min-width: 560px) {
  #welcome .screen-inner { width: min(100%, 720px); }
  #welcome .card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 18px; row-gap: 8px; align-items: start; text-align: left; max-height: calc(100dvh - 24px); overflow-y: auto; padding: 14px 18px; }
  #welcome .card > [hidden] { display: none !important; }
  #welcome #welcomeTitle { grid-column: 1 / -1; margin: 0; text-align: center; font-size: 24px; }
  #welcome #welcomeIntro { grid-column: 1; grid-row: 2; margin: 0; }
  #welcome .welcome-field { grid-column: 1; }
  #welcome #welcomeMsg { grid-column: 1; margin: 0; }
  #welcome #welcomeGo { grid-column: 2; grid-row: 2; margin: 0; }
  #welcome #welcomeOffline { grid-column: 2; grid-row: 3; margin: 0; }
  #welcome #welcomeCancel { grid-column: 2; grid-row: 4; margin: 0; }
  #welcome #welcomeHaveBackup { grid-column: 2; grid-row: 5; margin: 0; }
  #welcome #welcomeClaimRow { grid-column: 2; grid-row: 2 / span 4; margin: 0; }
  #welcome .btn { min-height: 44px; font-size: 16px; padding: 8px 12px; }
  #welcome .btn.primary { min-height: 48px; font-size: 17px; }
}

/* landscape phones: the pause card and the result card scroll inside themselves when taller than the screen (no clipped buttons) */
@media (orientation: landscape) and (max-height: 519px) and (min-width: 560px) {
  .pause { overflow-y: auto; align-items: flex-start; }
  .pause-card { margin: auto; padding: 10px 16px; max-width: 300px; }
  .pause-card h2 { font-size: 24px; margin: 0 0 2px; }
  .pause-card p { margin: 0 0 8px; }
  .pause-card .tips { margin-top: 8px; padding-top: 8px; }
  #result .screen-inner { width: min(100%, 680px); }
  /* result: score and the jar silhouette on the left, the buttons on the right; the card scrolls if it is still taller */
  #resCard { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 18px; align-items: start; max-height: calc(100dvh - var(--hudh) - 24px); overflow-y: auto; padding: 12px 16px 10px; }
  #resCard [hidden] { display: none !important; }
  #resCard > .date, #resCard > .try-line, #resCard > .vs-pill, #resCard > .medal-box, #resCard > .big-score, #resCard > .stats, #resCard > .bots-line, #resCard > .res-body { grid-column: 1; }
  #resCard > .buttons { grid-column: 2; grid-row: 1 / span 6; align-self: center; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
  #resCard > .buttons > .row { grid-column: 1 / -1; }
  #resCard > .buttons:has(#btnAgain[hidden]) > #btnShare { grid-column: 1 / -1; }
  #resCard > .lb-post, #resCard > .lb-name-row, #resCard > .save-prompt, #resCard > #resStatus, #resCard > .share-box, #resCard > #resNext, #resCard > #resDebug { grid-column: 1 / -1; }
  #resCard .big-score { font-size: 44px; }
  #resCard .stats { margin: 0 0 4px; }
  #resCard .res-body { margin: 2px 0 0; }
  #resCard .sil { max-width: 120px; }
  #resCard .note { display: none; }
  #resCard .btn { min-height: 44px; font-size: 16px; padding: 8px 12px; margin: 0; }
  #resCard .btn.primary { min-height: 48px; font-size: 17px; }
}

/* release polish: gentle idle float on the start screen, stage fade-in, hover lift, MAX tag pulse */
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes stageIn { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }
.hero-logo { animation: floaty 5.2s ease-in-out infinite; }
body[data-screen="play"] #stage, body[data-screen="play"] .hudcard { animation: stageIn 300ms ease-out both; }
.chip .max { animation: maxPulse 1.4s ease-in-out infinite; }
@keyframes maxPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.65; } }
@media (hover: hover) {
  .btn:hover, .pill-btn:hover, .icon-btn:hover { transform: translateY(-1px); }
  .btn.primary:hover { filter: brightness(1.07); box-shadow: 0 8px 22px var(--accent-glow); }
}
/* nothing floats behind an open sheet (inert) */
[inert] .hero-logo, [inert] .orbit-planet, [inert] .chip .max { animation: none; }
html[data-calm="1"] .hero-logo, html[data-calm="1"] .orbit-planet, html[data-calm="1"] .chip .max, html[data-calm="1"] body[data-screen="play"] #stage, html[data-calm="1"] body[data-screen="play"] .hudcard { animation: none !important; }
html[data-calm="1"] .btn:hover, html[data-calm="1"] .pill-btn:hover, html[data-calm="1"] .icon-btn:hover { transform: none; }

/* music volume slider inside the settings sheet */
.row-set input[type="range"] { appearance: auto; -webkit-appearance: auto; width: 150px; height: 28px; border-radius: 0; background: transparent; accent-color: var(--accent); }
.row-set input[type="range"]::after { display: none; }

/* daily maps: cards on the start screen, try line on the result card */
.mapcards { display: flex; gap: 8px; margin: 4px 0 12px; justify-content: center; }
.mapcard { appearance: none; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px 8px; border: 2px solid var(--line); background: color-mix(in srgb, var(--surface) 86%, transparent); color: var(--text); border-radius: 16px; font: inherit; cursor: pointer; transition: transform 120ms, border-color 120ms; }
.mapcard.on { border-color: var(--accent); box-shadow: 0 4px 14px var(--accent-glow); }
.mapcard:active { transform: scale(0.97); }
.mapcard:focus-visible { outline: 3px solid var(--ghost); outline-offset: 2px; }
.mapcard .thumb { width: 56px; height: 66px; display: block; }
.mapcard .nm { font-weight: 900; font-size: 13px; line-height: 1.1; text-align: center; }
.mapcard .tpips { display: flex; gap: 4px; }
.mapcard .nolet { font-size: 11px; font-weight: 800; line-height: 1.15; text-align: center; opacity: 0.8; }
.mapcard .tpips i { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--glass); background: transparent; }
.mapcard .tpips i.on { background: var(--glass); }
.mapcard .bs { font-size: 11px; color: var(--muted); font-weight: 800; line-height: 1.1; }
/* medals, missions and stars */
.mapcard .stars { font-size: 12px; font-weight: 900; letter-spacing: 1px; color: var(--muted); line-height: 1.1; }
.mapcard .stars.full { color: var(--gold); }
.mapcard .star-on { color: var(--gold); }
.mapcard .star-off { color: var(--muted); opacity: 0.8; }
.mapcard .mw-bronze { color: #b8742f; }
.mapcard .mw-silver { color: #8f98a3; }
.mapcard .mw-gold { color: var(--gold); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mapcard .mw-silver, :root:not([data-theme="light"]) .medal-box .m-silver { color: #cfd6df; } :root:not([data-theme="light"]) .mapcard .mw-bronze { color: #d99a5b; } }
:root[data-theme="dark"] .mapcard .mw-silver, :root[data-theme="dark"] .medal-box .m-silver { color: #cfd6df; }
:root[data-theme="dark"] .mapcard .mw-bronze { color: #d99a5b; }
.medal-box { margin: 0 0 6px; font-size: 13px; font-weight: 800; color: var(--muted); text-align: center; }
.medal-box[hidden] { display: none; }
.medal-box .mline { margin: 0; }
.medal-box .mname { font-weight: 900; font-size: 15px; color: var(--text); }
.medal-box .m-bronze { color: #b8742f; }
.medal-box .m-silver { color: #8f98a3; }
.medal-box .m-gold { color: var(--gold); }
.medal-box ul { list-style: none; margin: 2px 0 0; padding: 0; }
.medal-box li.done { color: var(--text); }
.try-line { margin: 0 0 6px; font-weight: 800; font-size: 14px; color: var(--muted); }
.try-line[hidden] { display: none; }
select { font: inherit; font-size: 14px; font-weight: 700; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: color-mix(in srgb, var(--surface2) 60%, transparent); color: var(--text); }
@media (max-height: 700px) { .mapcard .thumb { width: 40px; height: 46px; } .mapcard .bs { display: none; } .tag { display: none; } .mapcards { margin: 2px 0 8px; } }
@media (max-height: 640px) { .hero-logo { display: none; } .res-body .note { display: none; } .res-body { margin: 2px 0 6px; } .sil { max-width: 120px; } .try-line { margin: 0 0 2px; font-size: 13px; } .stats { margin: 0 0 4px; } }
@media (max-height: 640px) { #resCard > .buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } #resCard > .buttons > .row { grid-column: 1 / -1; } #resCard > .buttons:has(#btnAgain[hidden]) > #btnShare { grid-column: 1 / -1; } }
@media (max-height: 640px) { .res-body { margin: 0 0 4px; } .sil { max-width: 104px; } #resCard > .buttons { gap: 6px; } }

/* pause: the stage is blurred and dimmed, the clock (the sim) does not run */
body:not([data-screen="play"]) #btnPause { display: none; }
.pause { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--bg) 92%, transparent); border-radius: 18px; }
.pause[hidden] { display: none; }
.pause-card { text-align: center; padding: 16px 22px; max-width: 280px; }
.pause-card h2 { margin: 0 0 4px; font-size: 30px; font-weight: 900; }
.pause-card p { margin: 0 0 14px; color: var(--muted); font-size: 14px; font-weight: 700; line-height: 1.35; }
.pause-card p.small { margin: 10px 0 0; }
.pause-card .btn { min-width: 180px; }
.icon-btn[aria-pressed="true"] .pausebar { opacity: 1; }

/* first-run / "?" how-to card on the start screen and the optional backup nudge on the result card */
.howto-card { margin: 4px 0 8px; text-align: left; background: color-mix(in srgb, var(--surface) 82%, transparent); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; }
.howto-card[hidden], .save-prompt[hidden] { display: none; }
.howto-card h2 { margin: 0 0 4px; font-size: 15px; font-weight: 900; }
.howto-card ul { margin: 0 0 6px; padding-left: 18px; font-size: 12.5px; font-weight: 700; color: var(--muted); line-height: 1.3; }
.howto-card li { margin: 0 0 2px; text-wrap: pretty; }
.howto-card b { color: var(--text); font-weight: 800; }
.howto-card .pill-btn { padding: 4px 14px; min-height: 30px; font-size: 13px; }
.qmark { font-size: 20px; font-weight: 900; line-height: 1; }
body:not([data-screen="start"]) #btnHelp { display: none; }
.save-prompt { margin: 10px 0 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--surface) 82%, transparent); text-align: left; }
.save-prompt p { margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--muted); line-height: 1.3; }
.save-prompt b { color: var(--text); }
@media (max-height: 700px) { .howto-card li:nth-child(n+4) { display: none; } .howto-card.open li:nth-child(n+4) { display: list-item; } }

/* start screen how-to (kept to about three lines: the start card must still fit a 360 x 640 phone) */
.howto { margin: 8px 0 0; text-align: left; font-size: 12.5px; font-weight: 700; color: var(--muted); background: color-mix(in srgb, var(--surface) 78%, transparent); border: 1px solid var(--line); border-radius: 14px; padding: 6px 12px; line-height: 1.3; text-wrap: pretty; }
.credit { margin: 6px 0 0; font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--muted); opacity: .8; }
.howto b { color: var(--text); font-weight: 800; }
.tips { margin: 12px 0 0; padding: 10px 0 0 18px; border-top: 1px solid var(--line); text-align: left; font-size: 13px; font-weight: 700; color: var(--muted); line-height: 1.3; }
.tips li { margin: 0 0 4px; }
.tips b { color: var(--text); }
.chain-sub { margin: 0; font-size: 13px; font-weight: 800; color: var(--muted); line-height: 1.25; text-wrap: balance; }
.chain-sub[hidden] { display: none; }

/* phones: the header holds Finish, Pause and Sound next to the brand, so the date loses the word "Drop" and the pill button is tighter */
@media (max-width: 600px) {
  .hud-actions { gap: 6px; }
  .pill-btn { padding: 0 14px; font-size: 15px; }
  .sub#hudDate .wide { display: none; }
}

/* progress sync (settings) */
.sync-box { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); text-align: left; }
.sync-box h3 { margin: 0 0 6px; font-size: 16px; }
.sync-box .buttons { margin-top: 8px; }
.sync-code { font-size: 28px; font-weight: 900; letter-spacing: 0.18em; text-align: center; margin: 4px 0; font-variant-numeric: tabular-nums; user-select: all; }
.sync-msg { min-height: 1.2em; }
.sync-box [hidden] { display: none !important; }
.sync-box .buttons { display: flex; flex-direction: column; gap: 8px; }
.sync-box .btn { width: 100%; min-height: 44px; }
.sync-label { font-size: 13px; opacity: 0.85; margin-top: 4px; }
.sync-code-in { display: block; width: 100%; box-sizing: border-box; min-height: 48px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); color: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 22px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; text-align: center; }
.sync-code-in:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sync-privacy { margin: 0; line-height: 1.4; }
.sync-box a { color: inherit; text-decoration: underline; }

/* ---------- weekly podium card ---------- */
.podium-card { min-width: 0; max-width: 100%; --gold: #E8B84A; --gold2: #8E6A1E; position: relative; margin: 0 0 12px; padding: 1.5px; border-radius: 18px; text-align: left; background: linear-gradient(135deg, var(--gold), var(--gold2) 38%, var(--gold) 62%, var(--gold2)); box-shadow: 0 0 18px color-mix(in srgb, var(--gold) 22%, transparent); }
.podium-card[hidden] { display: none; }
.podium-open { display: block; width: 100%; min-width: 0; max-width: 100%; overflow: hidden; box-sizing: border-box; margin: 0; padding: 10px 12px 8px; border: 0; border-radius: 16.5px 16.5px 0 0; font: inherit; color: var(--text); text-align: left; cursor: pointer; background: linear-gradient(180deg, color-mix(in srgb, var(--gold) 10%, var(--surface)), var(--surface)); -webkit-tap-highlight-color: transparent; }
.podium-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.podium-title { font-size: 20px; font-weight: 900; letter-spacing: -0.01em; }
.podium-left { color: var(--muted); }
.podium-strip { display: flex; width: calc(100% + 12px); max-width: none; min-width: 0; align-items: center; height: 86px; margin: 6px -12px 4px 0; padding-left: 2px; overflow: hidden; -webkit-mask-image: linear-gradient(90deg, #000 78%, transparent); mask-image: linear-gradient(90deg, #000 78%, transparent); }
.podium-tile { position: relative; flex: none; width: 66px; height: 78px; margin-right: -14px; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--gold) 55%, var(--line)); background: color-mix(in srgb, var(--text) 7%, var(--surface)); box-shadow: 0 4px 10px var(--shadow); overflow: hidden; }
.podium-tile:nth-child(odd) { transform: translateY(-3px) rotate(-2deg); }
.podium-tile:nth-child(even) { transform: translateY(3px) rotate(2deg); }
.podium-tile-in { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; font-size: 11px; }
.podium-tile-jar .podium-tile-in, .podium-tile-bg .podium-tile-in { align-items: flex-end; padding-bottom: 3px; }
.podium-tile .podium-thumb { height: 70px; width: auto; }
.podium-tap { display: block; margin-top: 2px; color: var(--gold); font-size: 13px; font-weight: 800; text-align: center; letter-spacing: 0.01em; }
.podium-prizes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 0; padding: 0 10px 10px; text-align: left; }
.podium-place { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 2px 6px; min-width: 0; padding: 6px 7px; border-radius: 12px; background: color-mix(in srgb, var(--text) 7%, transparent); border: 1px solid color-mix(in srgb, var(--medal, var(--line)) 55%, var(--line)); }
.podium-place-gold { --medal: #E8B84A; } .podium-place-silver { --medal: #B9C2D0; } .podium-place-bronze { --medal: #CD8B53; }
.podium-medal { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--medal); color: #1b1630; font-size: 14px; font-weight: 900; line-height: 1; }
.podium-place-text { display: contents; }
.podium-place-name { color: var(--muted); font-size: 11px; font-weight: 700; }
.podium-place-prize { grid-column: 1 / -1; font-size: 14px; font-weight: 900; line-height: 1.15; white-space: nowrap; }
.podium-fine { margin: 6px 2px 10px; color: var(--muted); }
.podium-prizes-big { grid-template-columns: 1fr; gap: 8px; padding: 0; margin: 10px 0; }
.podium-prizes-big .podium-place { display: flex; padding: 8px 14px; gap: 12px; border-radius: 16px; }
.podium-prizes-big .podium-medal { width: 34px; height: 34px; font-size: 21px; }
.podium-prizes-big .podium-place-text { display: flex; flex-direction: row; align-items: baseline; justify-content: space-between; flex: 1 1 auto; gap: 8px; }
.podium-prizes-big .podium-place-name { font-size: 15px; }
.podium-prizes-big .podium-place-prize { grid-column: auto; font-size: 21px; text-align: right; }
.podium-card > .podium-prizes { background: var(--surface); border-radius: 0 0 16.5px 16.5px; }
/* the window: frosted glass over the dimmed start screen */
.podium-modal { background: color-mix(in srgb, var(--bg) 84%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.podium-glass { position: relative; padding: 16px 16px 14px; border-radius: 26px; text-align: center; border: 1.5px solid color-mix(in srgb, #E8B84A 70%, transparent); background: linear-gradient(160deg, color-mix(in srgb, var(--surface2) 78%, transparent), color-mix(in srgb, var(--surface) 62%, transparent)); box-shadow: 0 18px 50px var(--shadow), inset 0 1px 0 color-mix(in srgb, var(--text) 25%, transparent); -webkit-backdrop-filter: blur(22px) saturate(1.3); backdrop-filter: blur(22px) saturate(1.3); }
.podium-glass h2 { margin: 0 0 4px; font-size: 24px; }
.podium-text { margin: 0 0 10px; }
.podium-big { display: flex; align-items: center; justify-content: center; height: 226px; border-radius: 20px; background: color-mix(in srgb, var(--bg) 40%, transparent); border: 1px solid var(--line); overflow: hidden; }
.podium-stage { display: flex; align-items: center; justify-content: center; max-width: 100%; max-height: 100%; font-size: 34px; }
.podium-stage[data-cat="flair"] { transform-origin: center; }
.podium-stage .podium-thumb { height: 208px; width: auto; border-radius: 10px; box-shadow: 0 10px 28px var(--shadow); }
.podium-turn { animation: podiumTurn 420ms cubic-bezier(.2, .8, .2, 1) both; }
@keyframes podiumTurn { from { opacity: 0; translate: 40px 0; scale: 0.92; } to { opacity: 1; translate: 0 0; scale: 1; } }
.podium-cap { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin: 10px 0 6px; }
.podium-label { font-size: 19px; font-weight: 900; }
.podium-kind { color: #E8B84A; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; }
.podium-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.podium-nav .pill-btn { min-width: 48px; min-height: 44px; font-size: 24px; line-height: 1; }
.podium-dots { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 0; flex: 1 1 auto; }
.podium-dot { width: 22px; height: 22px; padding: 0; border: 0; background: transparent; position: relative; cursor: pointer; }
.podium-dot::before { content: ''; position: absolute; left: 7px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: color-mix(in srgb, var(--text) 35%, transparent); }
.podium-dot.on::before { background: #E8B84A; box-shadow: 0 0 8px #E8B84A; }

.podium-close { width: 100%; min-height: 46px; }
@media (prefers-reduced-motion: reduce) { .podium-turn { animation: none; } }
@media (prefers-color-scheme: light) { .podium-tap, .podium-kind { color: #8E6A1E; } .podium-dot.on::before { background: #B8861B; box-shadow: none; } }
@media (max-height: 460px) { .podium-big { height: 190px; } .podium-stage .podium-thumb { height: 170px; } }

/* ---------- online leaderboard ---------- */
.lb-card { margin: 10px 0 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 18px; background: color-mix(in srgb, var(--surface) 82%, transparent); text-align: left; }
.lb-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lb-head h2 { margin: 0; font-size: 17px; font-weight: 900; }
.lb-tabs { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.lb-tabs[hidden] { display: none; } /* .lb-tabs sets display, which would otherwise win over the hidden attribute */
.lb-week-note { margin: 8px 0 0; }
.lb-week-note[hidden] { display: none; }
.lb-runs { font-size: 11px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.lb-tab { appearance: none; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 12px; min-height: 44px; font: inherit; font-size: 13px; font-weight: 800; cursor: pointer; }
.lb-tab.on { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.lb-tab:focus-visible, .lb-ghost:focus-visible { outline: 3px solid var(--ghost); outline-offset: 2px; }
.lb-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
.lb-row { display: grid; grid-template-columns: 26px 14px minmax(0, 1fr) auto auto; align-items: center; gap: 6px; padding: 5px 4px; border-bottom: 1px solid var(--line); font-size: 14px; font-weight: 700; }
.lb-row.own { background: color-mix(in srgb, var(--accent) 16%, transparent); border-radius: 8px; }
.lb-rank { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-variant-numeric: tabular-nums; font-weight: 900; }
.lb-old { font-size: 11px; font-weight: 700; color: var(--muted); white-space: nowrap; text-align: right; }
.lb-medal.m-gold { color: var(--gold); } .lb-medal.m-silver { color: #98A0B8; } .lb-medal.m-bronze { color: #B8742F; }
.lb-ghost { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ghost); border-radius: 999px; min-height: 30px; padding: 2px 10px; font: inherit; font-size: 12px; font-weight: 800; cursor: pointer; }
.lb-ghost { position: relative; } .lb-ghost::after { content: ""; position: absolute; inset: -8px -6px; } /* keeps the small Beat chip visually compact but gives it a 44px touch target */
.lb-report { appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; line-height: 1; padding: 2px 4px; margin-left: 4px; cursor: pointer; opacity: .6; position: relative; vertical-align: middle; }
.lb-report::after { content: ""; position: absolute; inset: -12px -8px; } /* the flag stays small but keeps a 44px touch target */
.lb-report:hover, .lb-report:focus-visible { opacity: 1; color: var(--text); }
.lb-msg[hidden], .lb-mine[hidden] { display: none; }
.lb-msg, .lb-mine { margin: 6px 0; }
.lb-privacy { margin: 8px 0 4px; }
.lb-name-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }
.lb-name-row label { flex: 1 1 100%; font-size: 13px; font-weight: 700; color: var(--muted); }
.lb-name-row input { flex: 1 1 120px; min-width: 0; min-height: 44px; border-radius: 12px; border: 1.5px solid var(--glass); background: var(--surface); color: var(--text); padding: 0 10px; font: inherit; }
.lb-name-row .btn { min-height: 44px; flex: 0 0 auto; }
.lb-name-row[hidden] { display: none; }

/* start screen on short screens: Play and the other main actions stay on the first screen without scrolling.
   Portrait phones (under 900 px tall): Practice and Minigames share a row, the how-to card shows two rules (the "?" button opens all).
   Landscape phones: two columns, brand and how-to on the left, maps and buttons on the right. Checked by qa/qa-start-fit.mjs. */
@media (max-height: 899px) {
  #start .buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
  #start .buttons > #btnPrimary, #start .buttons > #btnToday { grid-column: 1 / -1; }
  #start .buttons > .btn:not(.primary) { min-height: 44px; }
  .howto-card li:nth-child(n+3) { display: none; }
  .howto-card.open li:nth-child(n+3) { display: list-item; }
}
@media (orientation: landscape) and (max-height: 519px) {
  #start .screen-inner { width: min(100%, 780px); }
  #start .card.plain { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 20px; align-items: start; }
  #start .start-l, #start .start-r { min-width: 0; }
  #start .start-l { padding-top: 8px; }
  #start .start-r { padding-top: 6px; }
  #start .hero-logo, #start .orbit, #start .tag { display: none; }
  #start h1 { font-size: 34px; margin: 0 0 4px; }
  #start .date-pill { margin: 0 0 6px; }
  #start .howto-card { margin: 4px 0 0; padding: 6px 10px; }
  #start .howto-card.open li:nth-child(n+3) { display: list-item; }
  #start .mapcards { margin: 0 0 8px; gap: 6px; }
  #start .mapcard { padding: 4px 2px; gap: 2px; border-radius: 12px; }
  #start .mapcard .thumb { width: 30px; height: 36px; }
  #start .mapcard .nm { font-size: 12px; }
  #start .mapcard .tpips, #start .mapcard .bs, #start .mapcard .tag { display: none; }
  #start .btn.primary { min-height: 48px; font-size: 18px; }
  #start .small { margin: 4px 0 0; }
  #start .name-row { margin: 6px 0; }
  #start .screen-inner { padding-bottom: 4px; }
  #start .start-foot { grid-column: 2; margin-top: -6px; }
}

/* wide screens (desktop, large tablets): the start screen uses the width. Left column: brand, date and the how-to card;
   right column: maps, the mode buttons (Duel, Voyage, Shop above the fold) and the leaderboard. Phones keep one column. */
@media (min-width: 900px) and (min-height: 700px) {
  #start .screen-inner { width: min(100%, 940px); }
  #start .card.plain { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 32px; align-items: start; }
  #start .start-l, #start .start-r { min-width: 0; }
  #start .start-r { padding-top: 6px; }
  #start .howto-card { margin: 12px 0 0; text-align: left; }
  /* the start-foot wrapper (practice/compare/name rows, credit) sits in the right column after the leaderboard, as before */
  #start .start-foot { grid-column: 2; margin-top: -10px; }
}

/* desktop start screen (landscape, 900 px wide and up, 700 px tall and up; the desktop split of src/game.js mqDesktop).
   A centred 1140 px container. Left: the hero (planet icon, title, tagline, date) over the planet row, and below it the
   small settings rows and credit. Right: a fixed 540 px column: map cards, Play, the mode buttons (Practice, Minigames and
   Duel on one row, Voyage and Shop on the next) and the leaderboard, whose list flexes so the column fits the viewport.
   The grid gives the left column two rows (hero, foot) and the right column both rows, so the left block sits centred
   against the right one. The header corner buttons and the streak chip line up with the container edges. */
@media (min-width: 900px) and (min-aspect-ratio: 5/4) and (min-height: 700px) {
  body:not([data-screen="play"]) .hud-actions { right: max(var(--gutter), calc(50% - 570px)); }
  body[data-screen="start"] #streakChip { left: max(var(--gutter), calc(50% - 570px)); }
  #start .screen-inner { width: min(100%, 1140px); }
  #start .card.plain { display: grid; grid-template-columns: minmax(0, 1fr) 540px; grid-template-rows: auto auto; column-gap: 64px; align-items: start; }
  #start .start-l { grid-column: 1; grid-row: 1; align-self: end; min-width: 0; text-align: left; }
  #start .start-foot { grid-column: 1; grid-row: 2; align-self: start; min-width: 0; margin: 18px 0 0; text-align: left; }
  #start .start-r { grid-column: 2; grid-row: 1 / span 2; align-self: center; min-width: 0; padding-top: 0; display: flex; flex-direction: column; max-height: calc(100dvh - var(--hudh) - 40px); }
  #start .hero { align-items: flex-start; }
  #start .hero-logo { width: 88px; height: 88px; margin: 0 0 4px; }
  #start h1 { margin: 4px 0 0; font-size: 60px; text-align: left; }
  #start .tag { margin: 4px 0 12px; font-size: 18px; }
  #start .date-pill { margin: 0; }
  #start .orbit { display: block; width: 100%; height: 150px; margin: 6px 0 0; }
  #start .banner { text-align: left; }
  #start .howto-card { margin: 12px 0 0; max-width: 520px; text-align: left; }
  #start .start-foot .name-row { justify-content: flex-start; margin: 6px 0; }
  #start .start-foot .name-row > span { min-width: 8.5em; }
  #start .start-foot p.name-row { padding-left: calc(8.5em + 8px); }
  #start .start-foot .small { margin: 4px 0 0; }
  #start .start-foot .admin-stats { margin: 10px 0 4px; max-width: none; }
  #start .start-foot .credit { margin-top: 10px; }
  #start .mapcards { margin: 0 0 12px; }
  #start .buttons { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin: 0 0 6px; }
  #start .buttons > #btnPrimary, #start .buttons > #btnToday { grid-column: 1 / -1; }
  #start .buttons > #btnPractice, #start .buttons > #btnMinigames, #start .buttons > #btnDuel { grid-column: span 2; }
  #start .buttons > #btnVoyage, #start .buttons > #btnShop { grid-column: span 3; }
  #start .buttons > .btn:not(.primary) { min-height: 46px; }
  #start .start-r > #startMeta { margin: 2px 0 0; }
  /* only the leaderboard card and its list give up height; the .small rows (min-height 1em) must not shrink under their text */
  #start .start-r > * { flex-shrink: 0; }
  #start .start-r > .lb-card { flex: 0 1 auto; display: flex; flex-direction: column; min-height: 0; margin: 10px 0 0; padding: 10px 14px 12px; text-align: left; }
  #start .lb-card > * { flex-shrink: 0; }
  #start .start-r > .podium-card { margin: 8px 0 0; } /* the two-column layout is short: keep the podium card to a few lines */
  #start .podium-strip { height: 70px; }
  #start .podium-tile { width: 54px; height: 62px; }
  #start .podium-tile .podium-thumb { height: 56px; }
  #start .podium-prizes { margin: 6px 0 0; }
  #start .lb-card > .lb-list { flex: 0 1 auto; min-height: 0; }
  #start .lb-privacy { margin-top: 6px; }
}
/* desktop start screen on short screens (768 and 720 px tall): tighter hero, smaller map thumbs, no meta line under the buttons,
   so the Play button, the mode buttons and the leaderboard header and footer all fit in the viewport */
@media (min-width: 900px) and (min-aspect-ratio: 5/4) and (min-height: 700px) and (max-height: 800px) {
  #start .hero-logo { width: 72px; height: 72px; }
  #start h1 { font-size: 52px; }
  #start .tag { margin: 2px 0 8px; font-size: 16px; }
  #start .orbit { height: 118px; margin: 2px 0 0; }
  #start .start-foot { margin-top: 12px; }
  #start .start-foot .name-row { margin: 4px 0; }
  #start .start-foot .admin-stats { margin: 6px 0 2px; }
  #start .mapcards { margin: 0 0 10px; }
  #start .mapcard { padding: 6px 4px; }
  #start .mapcard .thumb { width: 40px; height: 46px; }
  #start .mapcard .bs { display: none; }
  #start .buttons { margin: 0 0 4px; }
  #start .buttons > #btnPrimary, #start .buttons > #btnToday { min-height: 50px; }
  #start .buttons > .btn:not(.primary) { min-height: 42px; }
  #start .start-r > #startMeta { display: none; }
  #start .start-r > .lb-card { margin-top: 8px; padding: 8px 12px 10px; }
  #start .start-r > .podium-card { display: none; } /* too short to fit it without squeezing the leaderboard */
  #start .lb-tabs { margin: 4px 0; }
  #start .lb-msg, #start .lb-mine { margin: 4px 0; }
  #start .lb-privacy { font-size: 12px; }
}

/* keyboard hints (P-10): shown only when a fine pointer that hovers is the main input; phones and tablets get the finger wording */
@media not all and (hover: hover) and (pointer: fine) { .kb-only { display: none !important; } }
@media (hover: hover) and (pointer: fine) { .touch-only { display: none !important; } }

/* Duel and Voyage buttons share the second row of the start buttons. "Voyage 0/45" must not wrap in the narrow landscape
   column (a wrapped label made the row 70 px tall and pushed the buttons off a 320 px screen). */
#start .buttons > #btnDuel, #start .buttons > #btnVoyage { min-height: 44px; white-space: nowrap; }

/* welcome sheet (first launch: create a unique username) and the owner's visitor panel */
.welcome-field { display: flex; flex-direction: column; gap: 6px; text-align: left; margin: 12px 0 4px; font-size: 14px; font-weight: 800; color: var(--muted); }
.welcome-field input { padding: 12px 14px; font: inherit; font-size: 18px; border-radius: 14px; border: 1px solid var(--line); background: color-mix(in srgb, var(--surface2) 60%, transparent); color: var(--text); user-select: text; -webkit-user-select: text; }
.welcome-field input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.welcome-msg { min-height: 2.6em; margin: 8px 0; font-weight: 700; }
.welcome-msg[data-kind="bad"] { color: var(--danger, #c0392b); }
.welcome-msg[data-kind="good"] { color: var(--accent); }
#welcome .btn { width: 100%; margin-top: 8px; }
.admin-stats { margin: 14px auto 6px; padding: 12px 14px; max-width: 360px; border-radius: 16px; border: 1px solid var(--line); background: color-mix(in srgb, var(--surface2) 60%, transparent); text-align: left; }
.admin-stats h2 { margin: 0 0 8px; font-size: 14px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.admin-stats-list { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0; font-size: 14px; }
.admin-stats-list dt { color: var(--muted); font-weight: 700; }
.admin-stats-list dd { margin: 0; font-weight: 900; font-variant-numeric: tabular-nums; }
.welcome-field[hidden] { display: none; }
.welcome-claim { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.welcome-claim[hidden] { display: none; }
#welcome .welcome-switch { background: transparent; box-shadow: none; }

/* "a new version is out" bar */
.update-bar { position: fixed; left: 50%; width: max-content; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px); padding: 10px 12px 10px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); box-shadow: 0 8px 24px var(--shadow); font-size: 14px; font-weight: 800; }
.update-bar[hidden] { display: none; }
/* the update bar waits for the run to end: during a run its Reload button sits under the thumb and over the jar floor */
body[data-screen="play"] .update-bar { display: none; }
.update-bar .pill-btn:first-of-type { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* "Report a problem": a link-style button in the start footer and in Settings, and the report sheet (same field look as the welcome sheet) */
.link-btn { appearance: none; border: 0; background: transparent; color: inherit; font: inherit; font-weight: 800; letter-spacing: inherit; text-decoration: underline; text-underline-offset: 2px; padding: 6px 4px; margin: -6px 0; cursor: pointer; border-radius: 6px; }
.link-btn:hover { color: var(--text); }
.link-btn:focus-visible { outline: 3px solid var(--ghost); outline-offset: 2px; }
.report-card { text-align: left; }
.report-card h2 { margin-top: 0; }
.welcome-field textarea, .welcome-field select { padding: 12px 14px; font: inherit; font-size: 16px; font-weight: 600; border-radius: 14px; border: 1px solid var(--line); background: color-mix(in srgb, var(--surface2) 60%, transparent); color: var(--text); user-select: text; -webkit-user-select: text; width: 100%; box-sizing: border-box; }
.welcome-field textarea { resize: vertical; min-height: 7.5em; max-height: 40vh; line-height: 1.35; }
.welcome-field input, .welcome-field select { width: 100%; box-sizing: border-box; }
.welcome-field textarea:focus-visible, .welcome-field select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.report-count { align-self: flex-end; color: var(--muted); font-weight: 700; font-size: 12px; }
.report-thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.report-thumbs[hidden] { display: none; }
.report-thumb { position: relative; width: 96px; display: flex; flex-direction: column; gap: 4px; }
.report-thumb img { width: 96px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--surface2); }
.report-rm { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 12px; font-weight: 800; border-radius: 999px; min-height: 32px; cursor: pointer; }
.report-rm:focus-visible { outline: 3px solid var(--ghost); outline-offset: 2px; }
.report-shots .buttons { margin: 4px 0 0; }
.report-shots .btn { font-size: 15px; padding: 8px 12px; min-height: 44px; }
.report-tech { margin-top: 8px; }
#reportSheet .btn { width: 100%; margin-top: 8px; }
#reportSheet .report-shots .btn { margin-top: 0; }
#settings #btnSettingsReport { width: 100%; margin-top: 12px; }
.pause-report { display: block; margin: 10px auto 0; font-size: 13px; color: var(--muted); }
@media (pointer: coarse) { .credit .link-btn { padding: 12px 8px; margin: -12px -4px; } .pause-report { padding: 12px 14px; } }
.credit .link-btn { font-size: 11px; text-transform: none; color: var(--muted); }

/* Ismo69-only victory look "Sun rises": the result card is translucent so the sun behind it shows through */
[data-vx="glass"] { background: color-mix(in srgb, var(--surface, #1b1838) 52%, transparent) !important; -webkit-backdrop-filter: blur(14px) saturate(1.15); backdrop-filter: blur(14px) saturate(1.15); }

/* weekly podium: a prize is waiting for this player */
.podium-won { display: block; width: 100%; margin: 8px 0 0; background: linear-gradient(135deg, #f5c842, #e8a317); color: #2a1d00; font-weight: 700; }
.podium-won[hidden] { display: none; }
