/* Hidden Weights — one stylesheet.
   Concept: a warm, tactile miniature workshop. Walnut and brass under a low
   light from the upper left; two-layer shadows (contact + diffuse). Light: cream
   paper and warm ink; dark: a deep blue-grey evening with darker wood and
   brighter brass. Objects are domed weights in six colours, each with a letter
   and a symbol; reference weights are engraved brass cylinders.
   Type: the system's rounded face, tabular numbers. Motion: springy, physical. */

:root {
  color-scheme: light;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Quicksand", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #f6efe3;
  --bg-2: #efe5d4;
  --surface: #fff9f0;
  --surface-2: #f8f0e3;
  --surface-3: #efe4d3;
  --ink: #3a2e25;
  --ink-2: #5d4d40;
  --ink-3: #6e5e50;
  --line: rgba(58, 46, 37, 0.12);
  --line-2: rgba(58, 46, 37, 0.2);
  --brass: #b8893a;
  --brass-ink: #855c1c;
  --brass-soft: #f3e3c2;
  --gold: #d9a422;
  --focus: #8a6220;
  --ca-accent: #8a6220;
  --primary: #8a6220;
  --primary-2: #73501a;
  --primary-ink: #ffffff;
  --warn: #c2412f;
  --good: #3f7d55;
  --shadow-1: 0 1px 1px rgba(60, 40, 20, 0.08), 0 3px 10px -2px rgba(60, 40, 20, 0.1);
  --shadow-2: 0 2px 4px rgba(60, 40, 20, 0.08), 0 14px 34px -8px rgba(60, 40, 20, 0.22);
  /* wood and brass for the balance */
  --wood-1: #8a5f3d;
  --wood-2: #a87650;
  --wood-3: #5c3c24;
  --grain: rgba(40, 22, 10, 0.22);
  --brass-0: #fff0bf;
  --brass-1: #e2b862;
  --brass-2: #b8893a;
  --brass-3: #7c5520;
  --brass-edge: rgba(90, 58, 18, 0.55);
  --chain: #8b6a35;
  --shade-0: rgba(60, 35, 15, 0.28);
  --shade-1: rgba(60, 35, 15, 0);
  /* the six objects (the letter is dark ink on every one: ≥ 4.5:1) */
  --it-A: #f08a76;
  --it-B: #6cc9a4;
  --it-C: #7aa8e2;
  --it-D: #e6b544;
  --it-E: #c592bd;
  --it-F: #52c3cb;
  --piece-ink: #241a12;
  --radius: 18px;
  --radius-s: 12px;
  --bar-h: 58px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --chapter-tint: transparent;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1e2530;
  --bg-2: #19202a;
  --surface: #28313e;
  --surface-2: #232b37;
  --surface-3: #303a49;
  --ink: #ece6dc;
  --ink-2: #c9c0b3;
  --ink-3: #ada395;
  --line: rgba(236, 230, 220, 0.1);
  --line-2: rgba(236, 230, 220, 0.18);
  --brass: #d4ae5c;
  --brass-ink: #e2c27b;
  --brass-soft: rgba(212, 174, 92, 0.16);
  --gold: #f2c14a;
  --focus: #d4ae5c;
  --primary: #d4ae5c;
  --primary-2: #c39a45;
  --primary-ink: #231910;
  --warn: #ff8a72;
  --good: #7ccf98;
  --shadow-1: 0 1px 1px rgba(0, 0, 0, 0.3), 0 3px 10px -2px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 2px 4px rgba(0, 0, 0, 0.3), 0 16px 40px -8px rgba(0, 0, 0, 0.55);
  --wood-1: #5b3d27;
  --wood-2: #6f4b31;
  --wood-3: #36241a;
  --grain: rgba(0, 0, 0, 0.32);
  --brass-0: #fff3c9;
  --brass-1: #e8c46e;
  --brass-2: #c39a45;
  --brass-3: #7a5420;
  --brass-edge: rgba(30, 18, 6, 0.7);
  --chain: #b18c4b;
  --shade-0: rgba(0, 0, 0, 0.5);
  --shade-1: rgba(0, 0, 0, 0);
  --it-A: #f39484;
  --it-B: #74cfab;
  --it-C: #86b2e8;
  --it-D: #eabd52;
  --it-E: #cc9cc5;
  --it-F: #5fcad2;
}

/* the first paint, before the script sets data-theme: follow the system */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { color-scheme: dark; --bg: #1e2530; --surface: #28313e; --ink: #ece6dc; --ink-2: #c9c0b3; --line: rgba(236, 230, 220, 0.1); --brass: #d4ae5c; }
}

.it-A, .note-row[data-id="A"] { --c: var(--it-A); }
.it-B, .note-row[data-id="B"] { --c: var(--it-B); }
.it-C, .note-row[data-id="C"] { --c: var(--it-C); }
.it-D, .note-row[data-id="D"] { --c: var(--it-D); }
.it-E, .note-row[data-id="E"] { --c: var(--it-E); }
.it-F, .note-row[data-id="F"] { --c: var(--it-F); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(110% 70% at 10% -10%, rgba(255, 214, 150, 0.38), transparent 60%), radial-gradient(80% 60% at 100% 0%, rgba(184, 137, 58, 0.12), transparent 60%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}
:root[data-theme="dark"] body { background-image: radial-gradient(110% 70% at 10% -10%, rgba(212, 174, 92, 0.12), transparent 60%), radial-gradient(80% 50% at 100% 0%, rgba(90, 120, 170, 0.12), transparent 60%); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brass-ink); }
h1, h2, h3, h4 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.main:focus { outline: none; }

/* ---- shell ------------------------------------------------------------------------------ */
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding-left: var(--safe-l); padding-right: var(--safe-r); }
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 4px;
  min-height: calc(var(--bar-h) + var(--safe-t));
  padding: var(--safe-t) 8px 0 8px;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--line);
  transition: background-color 0.2s ease;
}
body[data-screen="landing"] .bar, body[data-screen="boot"] .bar { display: none; }
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; text-decoration: none; color: inherit; border-radius: 12px; padding: 4px 4px 4px 2px; }
.brand-icon { width: 32px; height: 32px; border-radius: 9px; flex: none; box-shadow: var(--shadow-1); }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-weight: 800; font-size: 17px; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.brand-sub { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-slot { display: none; flex: 1; min-width: 0; }
body.has-slot .bar-slot { display: flex; }
body.has-slot .brand { display: none; }
.bar-tools { display: flex; align-items: center; gap: 2px; flex: none; }
.chip-slot { display: flex; align-items: center; min-width: 44px; justify-content: center; }
.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 14px; border: 0;
  background: transparent; color: var(--ink-2);
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.12s var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.boot { flex: 1; display: grid; place-items: center; min-height: 60vh; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--brass); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.screen { width: 100%; max-width: 1180px; margin: 0 auto; padding: 18px 16px calc(28px + var(--safe-b)); animation: screen-in 0.24s var(--ease) both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(12px); } }
.screen-title { font-size: 26px; font-weight: 800; margin: 4px 0 16px; }
.kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brass-ink); }
.fine { font-size: 13px; color: var(--ink-3); margin-top: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); transition: background-color 0.2s ease, border-color 0.2s ease; }
.center-screen { display: grid; place-items: center; min-height: 60vh; }
.error-card { padding: 28px 24px; display: grid; gap: 12px; justify-items: center; text-align: center; max-width: 420px; color: var(--ink-2); }
.error-card h2 { color: var(--ink); }

/* ---- buttons ---------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px; border-radius: 14px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-weight: 700; text-decoration: none; text-align: center; line-height: 1.2;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, var(--shadow-1);
  transition: transform 0.12s var(--ease), background-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px) scale(0.985); }
.btn.primary { background: linear-gradient(180deg, var(--primary), var(--primary-2)); color: var(--primary-ink); border-color: transparent; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 6px 16px -6px color-mix(in srgb, var(--primary) 70%, transparent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.big { min-height: 52px; padding: 12px 22px; font-size: 17px; }
.btn.small { min-height: 44px; padding: 8px 14px; font-size: 15px; }
.btn[aria-disabled="true"], .btn.off { opacity: 0.5; box-shadow: none; }
.btn[aria-disabled="true"]:active { transform: none; }
.link-btn { background: none; border: 0; color: var(--brass-ink); font-weight: 700; padding: 10px 6px; min-height: 44px; text-decoration: underline; text-underline-offset: 3px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: 14px; background: var(--surface-3); }
.seg-btn { min-height: 40px; min-width: 44px; padding: 6px 12px; border: 0; border-radius: 11px; background: transparent; color: var(--ink-2); font-weight: 700; font-size: 14px; }
.seg-btn[aria-checked="true"], .seg-btn[aria-pressed="true"], .seg-btn[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* ---- stars, dots, seals ----------------------------------------------------------------- */
.stars { display: inline-flex; gap: 2px; vertical-align: middle; }
.stars .st { color: var(--line-2); display: inline-grid; }
.stars .st.on { color: var(--gold); }
.play-head { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; }
.ph-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.ph-title { font-weight: 800; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ph-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ph-tools { display: flex; align-items: center; gap: 4px; }
.dots { display: inline-flex; flex-wrap: wrap; gap: 3px; max-width: 170px; }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--brass); background: transparent; }
.dot.used { background: radial-gradient(circle at 35% 30%, var(--brass-0), var(--brass-2) 60%, var(--brass-3)); border-color: var(--brass-3); }
.dot.penalty { background: var(--warn); border-color: color-mix(in srgb, var(--warn) 70%, black); }
.dot.fresh { animation: dot-in 0.3s var(--spring); }
@keyframes dot-in { from { transform: scale(0.3); } }
.seals { display: inline-flex; gap: 3px; }
.seal { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--brass-0), var(--brass-1) 45%, var(--brass-3)); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--brass-3) 60%, transparent); position: relative; }
.seal::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; border: 1px solid rgba(80, 50, 10, 0.45); }
.seal.spent { background: var(--surface-3); box-shadow: inset 0 0 0 2px var(--line-2); }
.seal.spent::after { border-color: var(--line-2); }
.seal.fresh { animation: seal-out 0.45s ease; }
@keyframes seal-out { 0% { transform: scale(1.3); filter: brightness(1.4); } }
.timer { font-weight: 700; font-size: 16px; min-width: 52px; text-align: right; color: var(--ink-2); }

/* ---- the play screen -------------------------------------------------------------------- */
body[data-screen="play"] { overflow: hidden; }
body[data-screen="play"] .main { overflow: hidden; }
.screen.play { max-width: none; padding: 0; position: relative; height: calc(100dvh - var(--bar-h) - var(--safe-t)); display: flex; flex-direction: column; overflow: hidden; }
.play-body { flex: 1; min-height: 0; display: grid; }
.play-main { display: flex; flex-direction: column; align-items: center; min-width: 0; min-height: 0; }
.board { position: relative; width: 100%; display: flex; flex-direction: column; align-items: center; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.stage { position: relative; width: 100%; }
.balance { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; }
.balance.back { z-index: 0; }
.balance.front { z-index: 3; pointer-events: none; }
.piece-layer { position: absolute; inset: 0; pointer-events: none; }
.tray { position: relative; width: 100%; height: calc(var(--s, 52px) + 24px); overflow: hidden; border-radius: 16px; background: linear-gradient(180deg, var(--wood-2), var(--wood-1) 55%, var(--wood-3)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), inset 0 -2px 4px rgba(0, 0, 0, 0.3), 0 8px 16px -10px rgba(40, 20, 5, 0.6); }
.tray::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: repeating-linear-gradient(178deg, transparent 0 9px, var(--grain) 9px 10px, transparent 10px 23px); opacity: 0.5; pointer-events: none; }
.tray.scrolls::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; background: linear-gradient(90deg, rgba(0, 0, 0, calc(var(--fade-l, 0) * 0.35)), transparent 28px, transparent calc(100% - 28px), rgba(0, 0, 0, calc(var(--fade-r, 0) * 0.35))); }
.tray-strip { position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; height: 100%; padding: 0 14px; width: max-content; min-width: 100%; }
.tray-group { display: flex; gap: 8px; }
.tray-sep { width: 2px; align-self: stretch; margin: 14px 2px; border-radius: 1px; background: rgba(0, 0, 0, 0.22); box-shadow: 1px 0 0 rgba(255, 255, 255, 0.12); }
.tray-slot { width: var(--s, 52px); height: var(--s, 52px); border-radius: 50%; background: rgba(0, 0, 0, 0.16); box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.4), 0 1px 0 rgba(255, 255, 255, 0.14); flex: none; }
.tray-slot.et { border-radius: 30% / 26%; }

/* the pieces: domed weights and brass cylinders (positions come from scale.js) */
.piece {
  position: absolute; left: 0; top: 0; z-index: 2;
  width: var(--s, 52px); height: var(--s, 52px); padding: 0; border: 0; border-radius: 50%;
  background: none; color: var(--piece-ink); pointer-events: auto; cursor: grab;
  touch-action: none; will-change: transform; --lift: 0;
}
.piece:focus-visible { outline-offset: 4px; border-radius: 50%; }
.piece.dragging, .piece.held { z-index: 6; cursor: grabbing; }
/* contact + diffuse shadow as one soft ellipse under the piece (a box-shadow never fills its own box) */
.pc-shadow { position: absolute; left: 4%; right: 4%; bottom: -9%; height: 42%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(30, 15, 5, 0.5), rgba(30, 15, 5, 0.22) 55%, rgba(30, 15, 5, 0));
  transform: translate(calc(var(--lift) * 4px), calc(var(--lift) * 12px)) scale(calc(1 + var(--lift) * 0.3)); opacity: calc(1 - var(--lift) * 0.4); }
.piece.etalon .pc-shadow { border-radius: 50%; }
.pc-body { position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(circle at 34% 28%, color-mix(in srgb, var(--c, #ccc) 45%, white) 0%, var(--c, #ccc) 42%, color-mix(in srgb, var(--c, #ccc) 72%, #3a2010) 100%);
  box-shadow: inset 0 -3px 6px rgba(40, 20, 5, 0.25), inset 0 2px 3px rgba(255, 255, 255, 0.55), 0 0 0 1px rgba(40, 20, 5, 0.18);
}
.pc-l { font-weight: 800; font-size: calc(var(--s, 52px) * 0.42); line-height: 1; margin-top: -10%; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35); transition: transform 0.3s var(--ease), opacity 0.2s ease; }
.pc-sym { position: absolute; left: 50%; bottom: 11%; width: 22%; height: 22%; transform: translateX(-50%); fill: rgba(36, 26, 18, 0.78); stroke: rgba(36, 26, 18, 0.78); transition: opacity 0.2s ease; }
.pc-val { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: calc(var(--s, 52px) * 0.4); opacity: 0; transform: rotateX(90deg); font-variant-numeric: tabular-nums; }
.piece.revealed .pc-l { transform: translateY(-34%) scale(0.5); opacity: 0.7; transition-delay: var(--d, 0ms); }
.piece.revealed .pc-sym { opacity: 0; }
.piece.revealed .pc-val { animation: dial 0.42s var(--ease) var(--d, 0ms) both; padding-top: 18%; }
.piece.revealed.muted .pc-body { filter: saturate(0.35) brightness(0.92); }
@keyframes dial { 0% { opacity: 0; transform: rotateX(90deg) translateY(-30%); } 60% { opacity: 1; transform: rotateX(-12deg); } 100% { opacity: 1; transform: none; } }
.piece.etalon .pc-body {
  border-radius: 30% / 26%;
  background: linear-gradient(90deg, var(--brass-3) 0%, var(--brass-1) 22%, var(--brass-0) 34%, var(--brass-2) 60%, var(--brass-3) 100%);
  box-shadow: inset 0 -4px 5px rgba(60, 35, 5, 0.35), 0 0 0 1px var(--brass-edge);
  align-items: start;
}
.et-top { position: absolute; left: 6%; right: 6%; top: 5%; height: 54%; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(ellipse at 40% 35%, var(--brass-0), var(--brass-1) 55%, var(--brass-2)); box-shadow: inset 0 -2px 3px rgba(80, 50, 10, 0.4), 0 2px 2px rgba(60, 35, 5, 0.35); }
.et-n { font-weight: 800; font-size: calc(var(--s, 52px) * 0.3); color: #4a3008; text-shadow: 0 1px 0 rgba(255, 245, 210, 0.85), 0 -1px 0 rgba(60, 35, 5, 0.35); font-variant-numeric: tabular-nums; }
.piece.certain::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 3px solid var(--gold); box-shadow: 0 0 12px color-mix(in srgb, var(--gold) 60%, transparent); pointer-events: none; }
.piece.certain.pulse::after { animation: gold-pulse 0.3s ease-in-out 2; }
@keyframes gold-pulse { 50% { transform: scale(1.15); } }
.piece.flash .pc-body { animation: flash 1s ease; }
@keyframes flash { 15%, 60% { box-shadow: 0 0 0 4px var(--brass), 0 0 18px var(--brass); } }
.piece.coach-target::before { content: ""; position: absolute; inset: -8px; border-radius: 50%; border: 2px dashed var(--brass); animation: coach-ring 1.4s ease-in-out infinite; }
@keyframes coach-ring { 50% { transform: scale(1.12); opacity: 0.5; } }

/* the balance's colours (SVG, from CSS so themes cost nothing) */
.g-wood1 { stop-color: var(--wood-1); }
.g-wood2 { stop-color: var(--wood-2); }
.g-wood3 { stop-color: var(--wood-3); }
.g-brass0 { stop-color: var(--brass-0); }
.g-brass1 { stop-color: var(--brass-1); }
.g-brass2 { stop-color: var(--brass-2); }
.g-brass3 { stop-color: var(--brass-3); }
.g-sh0 { stop-color: var(--shade-0); }
.g-sh1 { stop-color: var(--shade-1); }
.balance .wood-edge { stroke: rgba(30, 15, 5, 0.35); stroke-width: 1; }
.balance .wood-hi { fill: rgba(255, 230, 200, 0.18); }
.balance .grain { fill: none; stroke: var(--grain); stroke-width: 1; stroke-linecap: round; }
.balance .brass-edge { stroke: var(--brass-edge); stroke-width: 1; }
.balance .beam-hi { fill: none; stroke: rgba(255, 248, 220, 0.75); stroke-width: 1.3; stroke-linecap: round; }
.balance .hook { fill: none; stroke: var(--chain); stroke-width: 2; }
.balance .arc-plate { stroke: var(--brass-edge); stroke-width: 1; opacity: 0.95; }
.balance .tick { stroke: #4a3008; stroke-width: 1.2; stroke-linecap: round; opacity: 0.7; }
.balance .tick.zero { stroke-width: 2; opacity: 0.9; }
.balance .needle-p { fill: #3a2410; }
:root[data-theme="dark"] .balance .needle-p { fill: #f6e3b5; }
.balance .pivot-pin { fill: var(--brass-3); }
.balance .chains path { fill: none; stroke: var(--chain); stroke-width: 1.6; stroke-dasharray: 3.2 1.6; stroke-linecap: round; }
.balance .bowl-in { fill: color-mix(in srgb, var(--brass-3) 80%, black); stroke: var(--brass-edge); }
.balance .bowl-contact { fill: rgba(0, 0, 0, 0.2); }
.balance .bowl-sel { fill: none; stroke: var(--gold); stroke-width: 3; opacity: 0; transition: opacity 0.2s ease; }
.balance .pan-back.selected .bowl-sel { opacity: 0.9; }
.balance .pan-back.magnet .bowl-sel { opacity: 1; stroke-width: 5; filter: drop-shadow(0 0 4px var(--gold)); }
.balance .bowl-lip { fill: none; stroke: rgba(255, 245, 210, 0.85); stroke-width: 1.4; }
.balance .bowl-shine { fill: none; stroke: rgba(255, 250, 230, 0.7); stroke-width: 2; stroke-linecap: round; }
.balance .bowl-foot { fill: var(--brass-3); }
.balance .lockpin { transition: transform 0.15s var(--spring), opacity 0.15s ease; }
.balance .lockpin.released { transform: translateY(-5px); opacity: 0.55; }
.pan-hit { position: absolute; left: 0; top: 0; z-index: 1; width: var(--w); height: var(--h); border: 0; border-radius: 18px; background: transparent; cursor: pointer; }
.pan-label {
  position: absolute; left: 0; top: 0; z-index: 4; display: inline-flex; align-items: center; gap: 4px;
  min-height: 26px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line-2);
  background: color-mix(in srgb, var(--surface) 86%, transparent); color: var(--ink-2);
  font-size: 12px; font-weight: 700; white-space: nowrap; cursor: pointer;
}
.pan-label::before { content: ""; position: absolute; inset: -9px -4px; }
.pan-label.on { color: var(--brass-ink); border-color: var(--brass); background: var(--brass-soft); }
.pl-arrow { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid currentColor; opacity: 0; transition: opacity 0.2s ease; }
.pan-label.on .pl-arrow { opacity: 1; }
.locked .pan-label { opacity: 0.6; }
.scale-badge { position: absolute; left: var(--bx); top: var(--by); z-index: 4; transform: translate(-50%, -50%) scale(0.6); opacity: 0; pointer-events: none; transition: transform 0.22s var(--spring), opacity 0.16s ease; }
.scale-badge.show { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.scale-badge.instant { transition: none; }
.sb-coin { display: grid; place-items: center; width: calc(var(--s, 52px) * 0.95); height: calc(var(--s, 52px) * 0.95); border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--brass-0), var(--brass-1) 45%, var(--brass-3)); box-shadow: 0 0 0 2px rgba(255, 245, 210, 0.6) inset, 0 3px 6px rgba(40, 20, 5, 0.35), 0 10px 18px -8px rgba(40, 20, 5, 0.5); }
.sb-sym { font-size: 34px; font-weight: 800; line-height: 1; color: #3d2706; text-shadow: 0 1px 0 rgba(255, 245, 210, 0.85); margin-top: -3px; }

/* actions */
.actions { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 12px; }
.act-row { display: flex; gap: 10px; justify-content: center; width: 100%; max-width: 520px; }
.act-row .btn { flex: 1 1 0; min-height: 52px; font-size: 17px; }
.act-measure .lbl, .act-submit .lbl { white-space: normal; }
.act-measure.long { font-size: 14px; }
.act-submit.ready { animation: ready 1.6s ease-in-out infinite; border-color: var(--gold); }
.act-submit.ready-static { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
@keyframes ready { 50% { transform: scale(1.04); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 55%, transparent), var(--shadow-1); } }
.act-hint { min-height: 18px; font-size: 13px; font-weight: 600; color: var(--ink-2); text-align: center; opacity: 0; transition: opacity 0.2s ease; }
.act-hint.show { opacity: 1; }

/* the side: weight set, notes, log */
.side { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--line); transition: background-color 0.2s ease; }
.sheet-grip { display: none; }
.tabs { display: flex; gap: 4px; padding: 8px 10px 0; }
.tab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--ink-2); font-weight: 700; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brass); }
.tab-count { min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--surface-3); font-size: 12px; }
.tab-count:empty { display: none; }
.panel { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 10px 12px 16px; }
.side[data-tab="notes"] .log-panel, .side[data-tab="log"] .notes-panel { display: none; }
.panel-h { font-size: 13px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin: 4px 0 8px; }
.desk-only { display: none; }
.set-strip { display: grid; gap: 6px; padding: 10px 12px; margin-bottom: 10px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.ss-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 10px; }
.ss-title { font-size: 13px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--brass-ink); }
.ss-meta { font-size: 13px; color: var(--ink-2); }
.ss-values { display: flex; flex-wrap: wrap; gap: 5px; }
.coin { display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 6px; border-radius: 16px; font-weight: 800; font-size: 15px; color: #3d2706; background: radial-gradient(circle at 35% 30%, var(--brass-0), var(--brass-1) 50%, var(--brass-2)); box-shadow: inset 0 -1px 2px rgba(80, 50, 10, 0.4), 0 1px 2px rgba(60, 35, 5, 0.3); }
.ss-et { display: flex; align-items: center; gap: 8px; }
.notes-grid { display: grid; gap: 6px; --cols: 6; }
.notes-panel.shake { animation: shake 0.4s ease; }
@keyframes shake { 16% { transform: translateX(-8px); } 33% { transform: translateX(8px); } 50% { transform: translateX(-8px); } 66% { transform: translateX(8px); } 83% { transform: translateX(-4px); } }
.note-row { display: grid; grid-template-columns: 46px minmax(0, 1fr); align-items: center; gap: 6px; padding: 4px; border-radius: 14px; transition: background-color 0.2s ease; }
.note-row.flash { animation: row-flash 1s ease; }
@keyframes row-flash { 15%, 60% { background: var(--brass-soft); } }
.note-row.missing .nr-item { animation: missing 0.65s ease-in-out 2; }
@keyframes missing { 50% { transform: scale(1.12); } }
.nr-item { position: relative; display: grid; justify-items: center; gap: 1px; }
.nr-ans { font-size: 12px; font-weight: 800; color: var(--ink-2); min-height: 15px; line-height: 1.2; }
.note-row.certain .chipface { box-shadow: 0 0 0 3px var(--gold), 0 0 10px color-mix(in srgb, var(--gold) 60%, transparent); }
.note-row.certain.pulse .chipface { animation: gold-pulse 0.3s ease-in-out 2; }
.nr-chips { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 4px; }
.vchip {
  position: relative; display: grid; place-items: center; min-height: 44px; min-width: 0; padding: 0;
  border-radius: 11px; border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-weight: 800; font-size: 16px; overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  transition: opacity 0.2s ease, background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
@media (pointer: fine) { .vchip { min-height: 38px; } }
.vchip:active { transform: scale(0.95); }
.vc-line { position: absolute; left: 14%; right: 14%; top: 50%; height: 2px; border-radius: 1px; background: currentColor; transform: scaleX(0); transform-origin: left center; pointer-events: none; }
.vchip[data-state="struck"] { opacity: 0.55; }
.vchip[data-state="struck"] .vc-line { transform: rotate(-24deg) scaleX(1); background: var(--ink-2); height: 2px; border-radius: 2px; box-shadow: 0 0 0 0.4px var(--ink-2); }
.vchip[data-state="auto"] { opacity: 0.35; background: transparent; cursor: default; }
.vchip[data-state="auto"] .vc-line { transform: scaleX(1); }
.vchip.elim { animation: elim-fade 0.2s ease var(--d, 0ms) both; }
.vchip.elim .vc-line { animation: elim-line 0.2s ease-out var(--d, 0ms) both; }
@keyframes elim-fade { from { opacity: 1; } to { opacity: 0.35; } }
@keyframes elim-line { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.vchip[data-state="answer"] { background: var(--c, var(--brass)); border-color: color-mix(in srgb, var(--c, var(--brass)) 70%, black); color: var(--piece-ink); box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.4); }
.vchip.dupe { border-color: var(--warn); box-shadow: 0 0 0 2px var(--warn); }
.vchip.coach-target, .notes-grid.coach-target { outline: 2px dashed var(--brass); outline-offset: 3px; }

/* chip faces: an object or a reference weight, small */
.chipface { display: inline-grid; place-items: center; position: relative; width: 40px; height: 40px; border-radius: 50%; flex: none; color: var(--piece-ink);
  background: radial-gradient(circle at 34% 28%, color-mix(in srgb, var(--c, #ccc) 45%, white), var(--c, #ccc) 45%, color-mix(in srgb, var(--c, #ccc) 72%, #3a2010));
  box-shadow: inset 0 -2px 3px rgba(40, 20, 5, 0.25), 0 1px 2px rgba(40, 20, 5, 0.3); transition: box-shadow 0.2s ease; }
.chipface .cf-l { font-weight: 800; font-size: 18px; line-height: 1; margin-top: -6px; }
.chipface .cf-sym { position: absolute; bottom: 4px; left: 50%; width: 9px; height: 9px; transform: translateX(-50%); fill: rgba(36, 26, 18, 0.78); stroke: rgba(36, 26, 18, 0.78); }
.chipface.small { width: 30px; height: 30px; }
.chipface.small .cf-l { font-size: 14px; margin-top: -5px; }
.chipface.small .cf-sym { width: 7px; height: 7px; bottom: 3px; }
.chipface.etalon { border-radius: 30% / 26%; background: linear-gradient(90deg, var(--brass-3), var(--brass-1) 25%, var(--brass-0) 38%, var(--brass-2) 65%, var(--brass-3)); }
.chipface .cf-n { font-weight: 800; font-size: 14px; color: #4a3008; text-shadow: 0 1px 0 rgba(255, 245, 210, 0.8); }
.chipface.small .cf-n { font-size: 13px; }

/* the log */
.log-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.log-empty { color: var(--ink-3); font-size: 14px; padding: 6px 4px; }
.log-entry { display: flex; align-items: center; gap: 4px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); transition: background-color 0.2s ease; }
.log-entry.fresh { animation: slide-in 0.22s var(--ease) both; }
@keyframes slide-in { from { opacity: 0; transform: translateY(-10px); } }
.log-entry.hl { animation: row-flash 1.6s ease; }
.le-main { flex: 1; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-height: 48px; padding: 6px 8px; border: 0; background: none; text-align: left; border-radius: 14px; }
.le-n { font-size: 13px; font-weight: 800; color: var(--ink-3); min-width: 26px; }
.le-side { display: inline-flex; align-items: center; gap: 3px; }
.le-plus { font-weight: 800; color: var(--ink-3); font-size: 13px; }
.le-r { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 4px; border-radius: 9px; font-weight: 800; font-size: 20px; color: #3d2706; background: radial-gradient(circle at 35% 30%, var(--brass-0), var(--brass-1) 55%, var(--brass-2)); }
.le-rep { flex: none; }
.help-ex { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 5px; padding: 8px 10px; margin: 8px 0 2px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.help-ex .sep { width: 12px; }

/* the coach */
.coach { position: absolute; left: 50%; top: 10px; z-index: 12; width: min(92%, 420px); transform: translateX(-50%); animation: coach-in 0.26s var(--spring) both; }
@keyframes coach-in { from { opacity: 0; transform: translate(-50%, -8px) scale(0.97); } }
.coach-card { padding: 12px 14px; border-radius: 16px; background: var(--surface); border: 1.5px solid var(--brass); box-shadow: var(--shadow-2); display: grid; gap: 6px; }
.coach-n { font-size: 12px; font-weight: 800; color: var(--brass-ink); text-transform: uppercase; letter-spacing: 0.05em; }
.coach-t { font-size: 15px; }
.coach-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.btn.coach-target, .act-submit.coach-target { outline: 2px dashed var(--brass); outline-offset: 3px; }

/* ---- phones: portrait < 600 px ----------------------------------------------------------- */
@media (max-width: 599px) {
  .bar .tool-help, .bar .tool-settings { display: none; }
  body:not(.has-slot) .bar .tool-help, body:not(.has-slot) .bar .tool-settings { display: inline-grid; }
  .brand-sub { display: none; }
  .play-body { position: relative; display: block; }
  .play-main { position: static; padding-top: 4px; }
  .play .stage { width: 92vw; height: clamp(206px, 38dvh, 330px); }
  .play .tray { width: 94vw; border-radius: 14px; }
  .actions { position: absolute; left: 0; right: 0; bottom: 0; z-index: 9; padding: 8px 12px calc(8px + var(--safe-b)); background: color-mix(in srgb, var(--bg) 92%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
  .act-row { flex-direction: row-reverse; max-width: none; }
  .left-handed .act-row { flex-direction: row; }
  .act-row .act-measure { flex-grow: 1.4; }
  .act-hint { position: absolute; left: 12px; right: 12px; bottom: calc(100% + 6px); padding: 6px 10px; border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-1); min-height: 0; }
  .act-hint:empty { display: none; }
  .side {
    --board-h: calc(clamp(206px, 38dvh, 330px) + var(--tray-h, 74px) + 6px);
    position: absolute; left: 0; right: 0; top: 8px; bottom: calc(68px + var(--safe-b)); z-index: 8;
    border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0;
    box-shadow: 0 -8px 24px -12px rgba(40, 25, 10, 0.35);
    transform: translateY(calc(var(--sheet-y) + var(--drag, 0px)));
    transition: transform 0.3s var(--ease);
    --sheet-y: calc(var(--board-h) - 8px);
  }
  .side.dragging { transition: none; }
  .side[data-sheet="up"] { --sheet-y: 0px; }
  .side[data-sheet="down"] { --sheet-y: calc(100% - 66px); }
  .sheet-grip { display: grid; place-items: center; width: 100%; height: 18px; border: 0; background: none; padding: 0; touch-action: none; }
  .sheet-grip span { width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); }
  .tabs { padding-top: 0; touch-action: none; }
  .panel { padding-bottom: calc(var(--board-h) + 12px); }
  .side[data-sheet="up"] .panel { padding-bottom: 16px; }
  .coach { top: auto; bottom: calc(76px + var(--safe-b)); }
  .coach[data-step="watch"], .coach[data-step="note"] { top: 6px; bottom: auto; }
}
@media (max-width: 359px) {
  .ph-title { font-size: 15px; }
  .ph-row { gap: 6px; }
  .dots { max-width: 110px; }
  .dot { width: 8px; height: 8px; }
  .seal { width: 12px; height: 12px; }
}

/* ---- tablets and phones lying down: 600–1023 px ---------------------------------------------- */
@media (min-width: 600px) and (max-width: 1023px) {
  .play-body { grid-template-columns: minmax(0, 1fr) minmax(300px, 42%); }
  .play-main { justify-content: center; padding: 8px 10px 0; overflow: hidden; }
  .play .stage { width: 100%; max-width: 560px; height: min(46vh, 340px); }
  .play .tray { max-width: 560px; }
  .side { border-left: 1px solid var(--line); }
}
/* phones lying down: the buttons move under the notes, the balance takes the whole left side */
@media (min-width: 600px) and (max-height: 520px) {
  .play-body { position: relative; }
  .play-main { justify-content: flex-start; padding-top: 4px; }
  .play .stage { height: calc(100dvh - var(--bar-h) - var(--safe-t) - var(--s, 44px) - 40px); min-height: 200px; }
  .actions { position: absolute; right: 0; bottom: 0; width: max(300px, 42%); padding: 6px 10px calc(6px + var(--safe-b)); background: var(--surface); border-top: 1px solid var(--line); border-left: 1px solid var(--line); z-index: 3; }
  .act-row .btn { min-height: 46px; font-size: 16px; }
  .act-hint { display: none; }
  .side .panel { padding-bottom: 76px; }
}

/* ---- desktop: ≥ 1024 px ------------------------------------------------------------------------ */
@media (min-width: 1024px) {
  .play-body { grid-template-columns: minmax(0, 1fr) 360px; }
  .play-main { justify-content: center; padding: 12px 20px 0; overflow: auto; }
  .play .stage { width: min(560px, 46vw); height: min(calc(min(560px, 46vw) * 0.66), calc(100dvh - var(--bar-h) - 230px)); min-height: 260px; }
  .play .tray { width: min(600px, 50vw); }
  .tabs { display: none; }
  .side { overflow-y: auto; }
  .side .panel { overflow: visible; }
  .side[data-tab] .log-panel, .side[data-tab] .notes-panel { display: block; }
  .desk-only { display: block; }
  .log-panel { border-top: 1px solid var(--line); padding-top: 12px; }
  .coach { left: auto; right: 16px; top: 14px; transform: none; width: min(300px, 26vw); animation-name: fade-only; }
}

/* ---- menu -------------------------------------------------------------------------------------- */
.menu-grid { display: grid; gap: 14px; }
@media (min-width: 760px) { .menu-grid { grid-template-columns: 1fr 1fr; } }
.daily-card, .camp-card { display: grid; grid-template-columns: 1fr; overflow: hidden; }
.dc-art, .cc-art { height: 128px; overflow: hidden; }
.band { background: linear-gradient(180deg, var(--sky0, #f8e7c8), var(--sky1, #efd5ac)); }
.band .art { width: 100%; height: 100%; display: block; overflow: visible; }
.dc-art .art, .cc-art .art { width: 100%; height: 100%; display: block; }
.dc-body, .cc-body { padding: 16px 18px 18px; display: grid; gap: 8px; align-content: start; }
.dc-body h2, .cc-body h2 { font-size: 22px; font-weight: 800; }
.dc-meta, .cc-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; color: var(--ink-2); font-size: 14px; }
.cc-meta .icon { color: var(--gold); }
.streak { display: inline-flex; align-items: center; gap: 4px; color: var(--brass-ink); font-weight: 700; }
.dc-res { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ink-2); font-size: 14px; }
.dc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.dc-next { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; color: var(--ink-2); font-size: 14px; }
.y-line { justify-self: start; padding-left: 0; }
.daily-card.st-won .dc-art .art, .daily-card.st-failed .dc-art .art { filter: saturate(0.75); }
.menu-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.tile-link { display: grid; justify-items: center; gap: 6px; min-height: 76px; padding: 14px 6px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 700; font-size: 14px; text-align: center; box-shadow: var(--shadow-1); transition: transform 0.12s var(--ease); }
.tile-link .icon { color: var(--brass-ink); }
.tile-link:active { transform: scale(0.97); }

/* art colours (the band behind a wide picture continues its sky) */
.band { --sky0: #f8e7c8; --sky1: #efd5ac; }
.band.k-market { --sky0: #f5e2c6; --sky1: #e9cfae; }
.band.k-mint { --sky0: #efe2c9; --sky1: #dfc9a2; }
.band.k-treasury { --sky0: #f0dcc0; --sky1: #d9b98c; }
.band.k-daily { --sky0: #f7e3bc; --sky1: #edc98d; }
:root[data-theme="dark"] .band { --sky0: #2b3646; --sky1: #222b38; }
:root[data-theme="dark"] .band:not(.k-workshop) { --sky0: #2e3848; --sky1: #1f2733; }
.a-sky0 { stop-color: #f8e7c8; }
.a-sky1 { stop-color: #efd5ac; }
:root[data-theme="dark"] .a-sky0 { stop-color: #2b3646; }
:root[data-theme="dark"] .a-sky1 { stop-color: #222b38; }
.art-market .a-sky0 { stop-color: #f5e2c6; } .art-market .a-sky1 { stop-color: #e9cfae; }
.art-mint .a-sky0 { stop-color: #efe2c9; } .art-mint .a-sky1 { stop-color: #dfc9a2; }
.art-treasury .a-sky0 { stop-color: #f0dcc0; } .art-treasury .a-sky1 { stop-color: #d9b98c; }
.art-daily .a-sky0 { stop-color: #f7e3bc; } .art-daily .a-sky1 { stop-color: #edc98d; }
:root[data-theme="dark"] .art-market .a-sky0, :root[data-theme="dark"] .art-mint .a-sky0, :root[data-theme="dark"] .art-treasury .a-sky0, :root[data-theme="dark"] .art-daily .a-sky0 { stop-color: #2e3848; }
:root[data-theme="dark"] .art-market .a-sky1, :root[data-theme="dark"] .art-mint .a-sky1, :root[data-theme="dark"] .art-treasury .a-sky1, :root[data-theme="dark"] .art-daily .a-sky1 { stop-color: #1f2733; }
.art .a-glow { fill: rgba(255, 250, 230, 0.55); }
:root[data-theme="dark"] .art .a-glow { fill: rgba(212, 174, 92, 0.12); }
.art .a-floor { fill: rgba(90, 55, 25, 0.16); }
.art .a-chain { stroke: var(--chain); stroke-width: 0.8; fill: none; }
.art .a-w { stroke: rgba(40, 20, 5, 0.35); stroke-width: 0.6; }
.art .c-coral { fill: var(--it-A); } .art .c-mint { fill: var(--it-B); } .art .c-blue { fill: var(--it-C); } .art .c-mustard { fill: var(--it-D); } .art .c-plum { fill: var(--it-E); }
.art .a-shine { fill: rgba(255, 255, 255, 0.5); }
.art .a-tool { stroke: var(--wood-3); stroke-width: 3; stroke-linecap: round; }
.art .a-awning { fill: #c2523f; }
:root[data-theme="dark"] .art .a-awning { fill: #9a4236; }
.art .a-stripe { stroke: rgba(255, 240, 220, 0.85); stroke-width: 6; }
.art .a-edge { stroke: rgba(90, 58, 18, 0.55); stroke-width: 0.6; }
.art .a-coin-in { fill: rgba(255, 245, 210, 0.35); }
.art .a-num { font: 800 9px var(--font); fill: #4a3008; }
.art .a-spark { fill: var(--gold); }
.art .a-ray { fill: var(--brass); opacity: 0.8; }

/* ---- chapters and levels ------------------------------------------------------------------------- */
.chapter-grid { display: grid; gap: 14px; }
@media (min-width: 700px) { .chapter-grid { grid-template-columns: 1fr 1fr; } }
.chapter-card { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 14px; align-items: center; padding: 12px; text-align: left; color: inherit; font: inherit; }
.chapter-card:active { transform: scale(0.985); }
.chapter-card.locked { opacity: 0.62; }
.chapter-card.locked .chc-art { filter: grayscale(0.7); }
.chc-art .art { width: 120px; height: 84px; display: block; border-radius: 14px; }
.chc-body { display: grid; gap: 3px; min-width: 0; }
.chc-title { font-size: 20px; font-weight: 800; }
.chc-desc { font-size: 14px; color: var(--ink-2); }
.chc-meta { display: flex; align-items: center; gap: 4px; font-size: 14px; color: var(--ink-2); font-weight: 700; margin-top: 2px; }
.chc-meta .icon-star { color: var(--gold); }
.levels-head { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 16px; align-items: center; margin-bottom: 18px; }
.lh-art .art { width: 132px; height: 92px; display: block; border-radius: 16px; box-shadow: var(--shadow-1); }
.levels-head .screen-title { margin: 2px 0 4px; }
.lh-desc { color: var(--ink-2); }
.lh-meta { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-weight: 700; color: var(--ink-2); }
.lh-meta .icon { color: var(--gold); }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.level-tile { position: relative; display: grid; align-content: center; justify-items: center; gap: 6px; min-height: 92px; padding: 10px 6px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); transition: transform 0.12s var(--ease); }
.level-tile:active { transform: scale(0.96); }
.lt-n { font-size: 20px; font-weight: 800; }
.lt-res { display: grid; justify-items: center; gap: 2px; min-height: 30px; }
.lt-pts { font-size: 13px; color: var(--ink-2); font-weight: 700; }
.lt-hint { font-size: 12px; color: var(--ink-3); font-weight: 700; }
.level-tile.current { border-color: var(--brass); box-shadow: 0 0 0 2px var(--brass), var(--shadow-1); }
.level-tile.locked { background: var(--surface-2); color: var(--ink-3); box-shadow: none; }
.lt-lock { color: var(--ink-3); }

/* ---- leaderboard --------------------------------------------------------------------------------- */
.board-tabs { margin-bottom: 12px; }
.board-tabs .seg-btn { min-width: 110px; min-height: 44px; }
.board-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.stepper { display: inline-flex; align-items: center; gap: 4px; padding: 2px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.st-date { min-width: 150px; text-align: center; font-weight: 700; }
.board-sub { color: var(--ink-2); font-size: 14px; max-width: 46ch; }
.board-body { min-height: 200px; transition: opacity 0.2s ease; }
.board-body.loading { opacity: 0.55; }
.board-cols, .b-row { display: grid; align-items: center; gap: 8px; padding: 0 12px; }
.board-cols { font-size: 12px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.board-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 60vh; overflow-y: auto; position: relative; }
.board-list.daily .b-row, .board-screen:has(.board-list.daily) .board-cols { grid-template-columns: 30px minmax(0, 1fr) 54px 56px 48px 50px; }
.board-list.campaign .b-row, .board-screen:has(.board-list.campaign) .board-cols { grid-template-columns: 30px minmax(0, 1fr) 70px 44px 54px; }
.b-row { min-height: 52px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.b-row.me { background: var(--brass-soft); border-color: var(--brass); position: sticky; top: 0; bottom: 0; z-index: 1; box-shadow: var(--shadow-1); }
.b-rank { font-weight: 800; color: var(--ink-2); }
.b-name { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 700; }
.b-name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-name .icon-heart { color: #d4566a; flex: none; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; flex: none; background: radial-gradient(circle at 35% 30%, var(--brass-0), var(--brass-1) 55%, var(--brass-2)); color: #3d2706; font-weight: 800; font-size: 14px; }
.b-fail { grid-column: 3 / -1; color: var(--ink-3); font-weight: 700; font-size: 14px; }
.b-pts { font-weight: 800; }
.b-used, .b-time { color: var(--ink-2); font-size: 14px; }
.note { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 14px; margin-bottom: 8px; }
.empty { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 22px 18px; margin-top: 12px; color: var(--ink-2); }
.empty .icon { color: var(--brass-ink); }
@media (max-width: 479px) {
  .board-list.daily .b-row, .board-screen:has(.board-list.daily) .board-cols { grid-template-columns: 22px minmax(0, 1fr) 58px 44px 46px; }
  .board-list.campaign .b-row, .board-screen:has(.board-list.campaign) .board-cols { grid-template-columns: 22px minmax(0, 1fr) 62px 36px 52px; }
  .board-cols { font-size: 11px; letter-spacing: 0.02em; }
  .board-screen:has(.board-list.daily) .board-cols span:nth-child(3), .board-list.daily .b-stars { display: none; }
  .b-row, .board-cols { padding: 0 8px; gap: 6px; }
}

/* ---- statistics -------------------------------------------------------------------------------------- */
.stats-screen { display: grid; gap: 14px; }
.stats-screen .screen-title { margin-bottom: 0; }
.stat-card { padding: 16px; }
.stat-card h2 { font-size: 18px; font-weight: 800; margin-bottom: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.stat { display: grid; gap: 2px; padding: 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.stat .icon { color: var(--brass-ink); }
.stat-v { font-size: 24px; font-weight: 800; }
.stat-l { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.badge-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge { display: grid; justify-items: center; text-align: center; gap: 4px; padding: 14px 10px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.bd-art .medal { width: 56px; height: 66px; }
.bd-t { font-weight: 800; font-size: 14px; }
.bd-d { font-size: 12px; color: var(--ink-2); }
.medal .md-ribbon { fill: #b9483a; }
.medal .md-edge { stroke: rgba(80, 50, 10, 0.5); stroke-width: 1; }
.medal .md-in { fill: none; stroke: rgba(255, 245, 210, 0.7); stroke-width: 1.2; }
.medal .md-em { fill: none; stroke: #4a3008; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.medal:not(.won) { filter: grayscale(1) opacity(0.4); }
.badge:not(:has(.won)) .bd-t { color: var(--ink-2); }

/* ---- sheets ------------------------------------------------------------------------------------- */
.sheet {
  width: min(560px, calc(100vw - 24px)); max-height: min(86dvh, 820px); padding: 0; border: 0; border-radius: 24px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); overflow: auto; overscroll-behavior: contain;
}
.sheet[open] { animation: sheet-in 0.26s var(--spring) both; }
.sheet.closing { animation: sheet-out 0.17s ease both; }
@keyframes sheet-in { from { opacity: 0; transform: scale(0.96) translateY(10px); } }
@keyframes sheet-out { to { opacity: 0; transform: scale(0.97) translateY(8px); } }
.sheet::backdrop { background: rgba(30, 20, 10, 0.45); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.sheet.sheet-wide { width: min(760px, calc(100vw - 24px)); }
.sheet.sheet-small { width: min(440px, calc(100vw - 24px)); }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 10px 10px 20px; background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 20px; font-weight: 800; }
.sheet-body { padding: 16px 20px calc(20px + var(--safe-b)); }
.sheet-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.sheet-small .sheet-body h2 { font-size: 20px; margin-bottom: 8px; }
.sheet-small .sheet-body p { color: var(--ink-2); }
.card-art { height: 130px; border-radius: 16px; overflow: hidden; margin-bottom: 14px; }
@media (max-width: 599px) {
  .sheet, .sheet.sheet-result, .sheet.sheet-wide, .sheet.sheet-small { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 24px 24px 0 0; max-height: 92dvh; }
  .sheet[open] { animation: sheet-up 0.3s var(--ease) both; }
  .sheet.closing { animation: sheet-down 0.17s ease both; }
  @keyframes sheet-up { from { transform: translateY(40%); opacity: 0.4; } }
  @keyframes sheet-down { to { transform: translateY(30%); opacity: 0; } }
}
.group { display: grid; gap: 2px; margin-bottom: 18px; }
.group h3, .about h3 { font-size: 13px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--brass-ink); margin-bottom: 4px; }
.row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; min-height: 52px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.row > span:first-child { font-weight: 600; }
.switch { appearance: none; -webkit-appearance: none; width: 52px; height: 32px; border-radius: 16px; background: var(--line-2); position: relative; cursor: pointer; transition: background-color 0.2s ease; flex: none; margin: 0; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.2s var(--spring); }
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(20px); }
.vol { display: inline-flex; align-items: center; gap: 10px; }
.range { width: 160px; accent-color: var(--primary); min-height: 44px; }
.vol-out { min-width: 42px; text-align: right; color: var(--ink-2); font-weight: 700; }
.about { display: grid; gap: 10px; justify-items: start; }
.about p { color: var(--ink-2); }
.version { font-size: 13px; color: var(--ink-3); }

/* help */
.help-sec { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.help-ic { display: grid; place-items: start center; color: var(--brass-ink); padding-top: 2px; }
.help-txt { display: grid; gap: 6px; }
.help-txt h3 { font-size: 17px; font-weight: 800; }
.help-txt h4 { font-size: 15px; font-weight: 800; margin-top: 6px; }
.help-txt p { color: var(--ink-2); }
.tips { margin: 4px 0 0; padding-left: 18px; display: grid; gap: 10px; }
.score-table, .keys { border-collapse: collapse; width: 100%; max-width: 440px; font-size: 14px; margin-top: 4px; }
.score-table th, .score-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.score-table th { color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.keys th { text-align: left; padding: 5px 10px 5px 0; white-space: nowrap; vertical-align: top; }
.keys td { padding: 5px 0; color: var(--ink-2); }
kbd { display: inline-block; min-width: 28px; padding: 2px 7px; border-radius: 7px; border: 1px solid var(--line-2); border-bottom-width: 2px; background: var(--surface-2); font: 700 13px var(--font); text-align: center; }
.help-foot { padding-top: 14px; }

/* the result */
.sheet-result { width: min(520px, calc(100vw - 24px)); }
.rs-head { position: relative; text-align: center; display: grid; gap: 4px; padding-top: 4px; }
.rs-kicker { font-size: 13px; font-weight: 700; color: var(--brass-ink); }
.rs-head h2 { font-size: 30px; font-weight: 800; }
.rs-head.fail h2 { color: var(--ink-2); }
.rs-sub { color: var(--ink-2); }
.rs-reveal { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 16px 0 6px; }
.rs-w { display: grid; justify-items: center; gap: 4px; animation: rs-pop 0.4s var(--spring) var(--d, 0ms) both; }
.rs-w .chipface { width: 46px; height: 46px; }
.rs-n { font-size: 24px; font-weight: 800; animation: dial 0.42s var(--ease) calc(var(--d, 0ms) + 150ms) both; }
.rs-reveal.muted .rs-w { opacity: 0.6; filter: saturate(0.4); }
@keyframes rs-pop { from { opacity: 0; transform: scale(0.7); } }
.rs-score { display: grid; justify-items: center; gap: 8px; margin-top: 8px; }
.rs-stars .st { animation: star-pop 0.4s var(--spring) var(--d, 0ms) both; }
.rs-stars .st:not(.on) { animation-name: star-dim; }
@keyframes star-pop { from { transform: scale(0) rotate(-30deg); } to { transform: scale(1); } }
@keyframes star-dim { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.rs-total-wrap { position: relative; display: flex; align-items: baseline; gap: 6px; }
.rs-total { font-size: 40px; font-weight: 800; line-height: 1; }
.rs-pts { font-size: 16px; color: var(--ink-2); font-weight: 700; }
.rs-flies { position: absolute; left: 50%; top: 100%; width: 0; height: 0; }
.fly { position: absolute; left: var(--x); top: 34px; transform: translateX(-50%); font-weight: 800; color: var(--brass-ink); opacity: 0; animation: fly-up 0.7s var(--ease) var(--d) both; white-space: nowrap; }
@keyframes fly-up { 0% { opacity: 0; transform: translate(-50%, 10px) scale(0.8); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(-50% - var(--x)), -52px) scale(1.1); } }
.rs-break { display: grid; grid-template-columns: auto auto; gap: 2px 14px; margin: 4px 0 0; font-size: 14px; }
.rs-break dt { color: var(--ink-2); }
.rs-break dd { margin: 0; text-align: right; font-weight: 700; }
.rs-used, .rs-time { color: var(--ink-2); font-size: 14px; text-align: center; display: flex; align-items: center; justify-content: center; gap: 4px; }
.rs-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 18px 0 6px; }
.rs-actions .btn { flex: 1 1 140px; }
.rs-friends { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.rs-friends h3 { font-size: 15px; font-weight: 800; margin-bottom: 8px; }
.friends-host { min-height: 80px; }
.sparks { position: absolute; left: 50%; top: 34px; width: 0; height: 0; pointer-events: none; }
.sparks span { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: radial-gradient(circle, var(--brass-0), var(--gold)); opacity: 0; animation: spark 1s ease-out var(--d) both; }
@keyframes spark { 0% { opacity: 1; transform: rotate(var(--a)) translateX(10px) scale(1); } 100% { opacity: 0; transform: rotate(var(--a)) translateX(var(--r)) scale(0.3); } }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); z-index: 60; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; max-width: min(92vw, 440px); padding: 12px 18px; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 700; box-shadow: var(--shadow-2); transition: opacity 0.2s ease, transform 0.25s var(--ease); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast[data-kind="warn"] { background: var(--warn); color: #fff; }
:root[data-theme="dark"] .toast[data-kind="warn"] { color: #2a1006; }
.toast[data-kind="gold"] { background: linear-gradient(180deg, var(--brass-1), var(--brass-2)); color: #2a1a06; }

/* ---- landing ------------------------------------------------------------------------------------ */
.landing { display: grid; gap: 22px; padding-top: calc(10px + var(--safe-t)); }
.landing-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.landing-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--ink-2); }
.landing-brand img { border-radius: 9px; box-shadow: var(--shadow-1); }
.landing-tools { display: flex; align-items: center; gap: 6px; }
.landing-tools .seg-btn { min-height: 38px; }
.hero { display: grid; gap: 18px; align-items: center; }
.hero > *, .hero-demo > *, .taste > *, .features > *, .menu-grid > * { min-width: 0; }
@media (max-width: 459px) { .landing-brand span { display: none; } }
@media (min-width: 900px) { .hero { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 28px; } }
.hero-text { display: grid; gap: 12px; align-content: center; }
.hero-text h1 { font-size: clamp(34px, 6vw, 58px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; }
.promise { font-size: clamp(18px, 2.4vw, 22px); color: var(--ink-2); font-weight: 600; }
.hero-cta { display: grid; gap: 10px; margin-top: 6px; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.notice { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 15px; }
.notice .icon { color: var(--brass-ink); flex: none; }
.hero-demo { display: grid; gap: 12px; padding: 14px; border-radius: 26px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-2); }
@media (min-width: 560px) { .hero-demo { grid-template-columns: minmax(0, 1fr) 180px; align-items: center; } }
.hero-board .stage { height: 250px; }
.hero-board .tray, .demo-board .tray { height: calc(var(--s, 48px) + 20px); }
.hero-side { display: grid; gap: 8px; }
.hero-cap { min-height: 24px; font-weight: 800; text-align: center; color: var(--brass-ink); }
.hero-notes { display: grid; gap: 4px; pointer-events: none; }
.hero-notes .note-row { grid-template-columns: 36px minmax(0, 1fr); padding: 2px; }
.hero-notes .chipface { width: 32px; height: 32px; }
.hero-notes .chipface .cf-l { font-size: 15px; margin-top: -5px; }
.hero-notes .chipface .cf-sym { width: 7px; height: 7px; bottom: 3px; }
.hero-notes .vchip { min-height: 32px; font-size: 15px; }
.hero-notes .nr-chips { grid-template-columns: repeat(3, 1fr); }
.taste { display: grid; gap: 14px; padding: 16px; }
@media (min-width: 760px) { .taste { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); align-items: center; } }
.taste-text { display: grid; gap: 8px; }
.taste-text h2 { font-size: 22px; font-weight: 800; }
.taste-text > p { color: var(--ink-2); }
.demo-msg { min-height: 44px; font-weight: 700; color: var(--brass-ink); }
.taste-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.demo-board .stage { height: 220px; }
.features { display: grid; gap: 14px; }
@media (min-width: 760px) { .features { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.feature { padding: 14px 16px 18px; display: grid; gap: 8px; align-content: start; }
.feature h3 { font-size: 18px; font-weight: 800; }
.feature p { color: var(--ink-2); }
.f-art { height: 116px; border-radius: 14px; overflow: hidden; }
.landing-foot { text-align: center; color: var(--ink-3); font-size: 13px; padding: 6px 0 10px; }

/* ---- reduced motion: crossfades, no travel, no pulse, no sparks ------------------------------------ */
/* transitions are instant (a duration on every element would animate every layout change);
   animations that remain become short crossfades */
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after { animation-duration: 0.15s !important; animation-iteration-count: 1 !important; transition: none !important; }
:root[data-motion="reduce"] .screen, :root[data-motion="reduce"] .sheet[open], :root[data-motion="reduce"] .log-entry.fresh, :root[data-motion="reduce"] .coach { animation-name: fade-only !important; }
:root[data-motion="reduce"] .notes-panel.shake, :root[data-motion="reduce"] .piece.certain.pulse::after, :root[data-motion="reduce"] .note-row.certain.pulse .chipface, :root[data-motion="reduce"] .act-submit.ready, :root[data-motion="reduce"] .note-row.missing .nr-item, :root[data-motion="reduce"] .sparks, :root[data-motion="reduce"] .fly, :root[data-motion="reduce"] .coach-target::before { animation: none !important; }
:root[data-motion="reduce"] .rs-stars .st, :root[data-motion="reduce"] .rs-w, :root[data-motion="reduce"] .rs-n, :root[data-motion="reduce"] .piece.revealed .pc-val { animation-name: fade-only !important; }
@keyframes fade-only { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) .sparks { display: none; }
}
