/* Tower Gears — inside the bell tower: an oak movement board in an iron
   frame, brass wheels, a sunbeam through the louvres, the painted dial.
   Colours that depend on the chosen look arrive as custom properties from
   themes.js. Game-specific classes carry the tg- prefix. */

:root {
  --page-a: #2b1d14;
  --page-b: #0e0906;
  --light: #ffcc7a;
  --accent: #b9842f;
  --accent-deep: #6d4712;
  --accent-text: #fff4dc;
  --frame-hi: #5d5853;
  --frame-lo: #1d1b19;
  --bolt: #8d8780;
  --board-base: #6f4a2c;
  --wall-a: #3a2a1f;
  --wall-b: #21170f;
  --tray-a: #4a2f1c;
  --tray-b: #2a190e;
  --dial-face: #f3e9d2;
  --dial-edge: #d9c7a0;
  --dial-ink: #1f1712;
  --dial-hand: #1a130e;
  --bezel-hi: #ffe39a;
  --bezel-lo: #8a6420;
  --bell-hi: #e7b964;
  --bell-lo: #6b4314;
  --ok: #79d27a;
  --bad: #ff6a4d;
  --text: #f6ead2;
  --text-dim: rgba(246, 234, 210, 0.62);
  --ink: #2b211a;
  --ink-soft: #6e5f4f;
  --paper: #f7f0e2;
  --paper-2: #ece2ce;
  --line: rgba(60, 45, 30, 0.14);
  --ease: cubic-bezier(0.4, 0.1, 0.2, 1);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background: radial-gradient(120% 90% at 15% 0%, color-mix(in oklab, var(--page-a) 80%, var(--light) 8%), var(--page-a) 42%, var(--page-b));
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* ---------------------------------------------------------- background */
.bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
.bg .blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.2;
  will-change: transform;
}
.bg .b1 { width: 60vmax; height: 60vmax; left: -28vmax; top: -32vmax; background: var(--light); animation: drift 52s ease-in-out infinite alternate; }
.bg .b2 { width: 48vmax; height: 48vmax; right: -24vmax; bottom: -22vmax; background: var(--accent); opacity: 0.14; animation: drift 66s ease-in-out infinite alternate-reverse; }
.bg .b3 { width: 34vmax; height: 34vmax; left: 38vw; bottom: -26vmax; background: var(--light); opacity: 0.08; animation: drift 78s ease-in-out infinite alternate; }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(8vmax, 6vmax) scale(1.12); }
}

/* -------------------------------------------------------------- layout */
.app {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  max-width: 1240px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 4px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 40px; height: 40px; flex: 0 0 auto; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5)); }
.brand span { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand b { font-family: var(--serif); font-weight: 600; font-size: 21px; letter-spacing: 0.01em; color: #f9e8c4; text-shadow: 0 1px 10px color-mix(in oklab, var(--light) 30%, transparent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { font-size: 11px; color: var(--text-dim); letter-spacing: 0.1em; text-transform: uppercase; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { display: flex; gap: 2px; flex: 0 0 auto; }

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.icon-btn:hover { background: rgba(255, 235, 210, 0.1); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn:focus-visible, .btn:focus-visible, .tg-chip:focus-visible, .tg-plane:focus-visible { outline: 2px solid #ffd27a; outline-offset: 2px; }
.icon-btn svg, .btn svg, .tg-plane svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 4px 16px 6px;
}
.stat {
  background: rgba(255, 236, 210, 0.06);
  border: 1px solid rgba(255, 236, 210, 0.1);
  border-radius: 12px;
  padding: 5px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
  min-width: 0;
}
.stat span { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stat b { font-family: var(--serif); font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; color: #f9e8c4; white-space: nowrap; }
.stat b small { font-size: 0.72em; color: var(--text-dim); font-weight: 500; }
.stat b.tg-at-par { color: #c8f0b8; }

.stage {
  flex: 1;
  min-height: 0;
  container: stage / size;
  padding: 4px 12px;
}

.actions {
  display: flex;
  gap: 8px;
  padding: 6px 12px 14px;
}

.btn {
  appearance: none;
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(255, 235, 210, 0.16);
  background: rgba(255, 235, 210, 0.08);
  color: var(--text);
  font: 500 15px var(--sans);
  padding: 11px 10px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s, background 0.2s, opacity 0.2s, box-shadow 0.2s;
}
.btn svg { width: 19px; height: 19px; flex: 0 0 auto; }
.btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn:hover { background: rgba(255, 235, 210, 0.14); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.38; cursor: default; transform: none; }
.btn.primary {
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 88%, #fff 12%), var(--accent-deep));
  color: var(--accent-text);
  border-color: color-mix(in oklab, var(--accent-deep) 70%, #000);
  box-shadow: 0 4px 14px -4px color-mix(in oklab, var(--accent) 70%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.subtle { flex: 0 0 auto; background: transparent; box-shadow: none; color: var(--ink-soft); border-color: transparent; font-size: 13.5px; margin: 18px auto 0; display: flex; }
.btn.tg-busy { opacity: 0.7; cursor: progress; }

/* --------------------------------------------------------------- scene */
.tg-scene {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
}

/* The tower panel: belfry, goal and dial on a plastered wall. */
.tg-tower {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 8px;
  border-radius: 16px;
  background:
    radial-gradient(70% 140% at 10% 30%, color-mix(in oklab, var(--light) 16%, transparent), transparent 70%),
    linear-gradient(180deg, var(--wall-a), var(--wall-b));
  box-shadow: inset 0 1px 0 rgba(255, 240, 210, 0.08), inset 0 -18px 30px -18px rgba(0, 0, 0, 0.6), 0 10px 24px -14px rgba(0, 0, 0, 0.8);
}
.tg-tower::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 236, 210, 0.07);
}
.tg-belfry { width: 64px; align-self: center; }
.tg-belfry svg { display: block; width: 100%; height: auto; overflow: visible; }
.tg-dial { width: 86px; height: 86px; }
.tg-dial-svg { display: block; width: 100%; height: 100%; overflow: visible; }

.tg-goal { min-width: 0; align-self: center; }
.tg-chapter { margin: 0; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.tg-chapter b { font: 600 16.5px var(--serif); color: #f9e8c4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tg-chapter small { flex: 0 0 auto; font-size: 11px; letter-spacing: 0.1em; color: var(--text-dim); text-transform: uppercase; }
.tg-targets { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 5px; }
.tg-target {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 2px 9px 2px 3px;
  border-radius: 999px;
  background: rgba(10, 6, 3, 0.32);
  border: 1px solid rgba(255, 235, 210, 0.14);
  font-size: 13px;
  white-space: nowrap;
  transition: border-color 0.3s, box-shadow 0.3s, background 0.3s;
}
.tg-target .tg-ico { width: 22px; height: 22px; padding: 2px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fbf3df, #cdb88c); fill: #2a1b0c; flex: 0 0 auto; }
.tg-target .tg-dir { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.tg-need { display: inline-flex; align-items: center; gap: 2px; font: 600 15px var(--serif); color: #fbe9c6; }
.tg-now { font-size: 11.5px; color: var(--text-dim); margin-left: 2px; }
.tg-target[data-state="ok"] { border-color: color-mix(in oklab, var(--ok) 70%, transparent); background: color-mix(in oklab, var(--ok) 14%, rgba(10, 6, 3, 0.4)); box-shadow: 0 0 12px -2px color-mix(in oklab, var(--ok) 60%, transparent); }
.tg-target[data-state="ok"] .tg-now { color: #c8f0b8; }
.tg-target[data-state="bad"] { border-color: color-mix(in oklab, var(--bad) 75%, transparent); background: color-mix(in oklab, var(--bad) 12%, rgba(10, 6, 3, 0.4)); }
.tg-target[data-state="bad"] .tg-now { color: #ffc2b2; }

/* stacked fraction: ×1⁄4 */
.tg-frac { display: inline-grid; grid-template-rows: auto auto; line-height: 0.95; text-align: center; font-size: 0.72em; vertical-align: middle; margin: 0 1px; }
.tg-frac b { font-weight: 600; border-bottom: 1px solid currentColor; padding: 0 1px; }
.tg-frac i { font-style: normal; font-weight: 600; }
.tg-times { font-size: 0.8em; opacity: 0.8; margin-right: 1px; }

/* ---------------------------------------------------------------- board */
.tg-board-host {
  position: relative;
  min-height: 0;
  min-width: 0;
  display: grid;
  place-items: center;
}
.tg-board {
  --frame-w: 12px;
  position: relative;
  width: var(--board-w, 300px);
  height: var(--board-h, 300px);
  box-sizing: content-box;
  border: var(--frame-w) solid transparent;
  border-radius: 16px;
  background:
    linear-gradient(160deg, rgba(255, 236, 200, 0.08), rgba(0, 0, 0, 0.18)) padding-box,
    var(--board-img) center / var(--board-size) repeat padding-box,
    linear-gradient(var(--board-base), var(--board-base)) padding-box,
    linear-gradient(150deg, var(--frame-hi), var(--frame-lo) 60%, color-mix(in oklab, var(--frame-lo) 70%, var(--frame-hi))) border-box;
  box-shadow:
    0 22px 44px -18px rgba(0, 0, 0, 0.95),
    0 0 0 1px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(0, 0, 0, 0.5);
}
/* bolts in the iron frame */
.tg-board::before {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--frame-w));
  border-radius: inherit;
  pointer-events: none;
  z-index: 4;
  --b: radial-gradient(circle at 42% 38%, #fff6 0 1px, var(--bolt) 1.6px 2.6px, rgba(0, 0, 0, 0.75) 3.4px, transparent 4.2px);
  background: var(--b), var(--b), var(--b), var(--b), var(--b), var(--b), var(--b), var(--b);
  background-size: var(--frame-w) var(--frame-w);
  background-repeat: no-repeat;
  background-position: 0 0, 100% 0, 0 100%, 100% 100%, 50% 0, 50% 100%, 0 50%, 100% 50%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), inset 0 -1px 0 rgba(0, 0, 0, 0.5);
}
/* the board's own light: brighter where the sun comes in, darker at the edges */
.tg-board::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 6px;
  pointer-events: none;
  z-index: 3;
  background:
    radial-gradient(90% 70% at 18% 8%, color-mix(in oklab, var(--light) 14%, transparent), transparent 60%),
    radial-gradient(130% 110% at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.42) 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 10px 18px -10px rgba(0, 0, 0, 0.7);
}
.tg-bg, .tg-fg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 6px;
}
.tg-bg { z-index: 1; }
.tg-fg { z-index: 2; touch-action: none; cursor: pointer; outline: none; }

/* A sunbeam through the louvres, with slow dust. */
.tg-beam {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 6px;
  pointer-events: none;
  z-index: 3;
}
.tg-beam::before {
  content: "";
  position: absolute;
  left: 4%;
  top: -60%;
  width: 34%;
  height: 230%;
  transform: rotate(-34deg);
  transform-origin: 50% 0;
  background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--light) 12%, transparent) 25%, color-mix(in oklab, var(--light) 20%, transparent) 50%, color-mix(in oklab, var(--light) 10%, transparent) 75%, transparent);
  animation: tg-beam 11s ease-in-out infinite alternate;
}
@keyframes tg-beam { from { opacity: 0.75; } to { opacity: 1; } }
.tg-beam i {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in oklab, var(--light) 80%, #fff) 0 30%, transparent 70%);
  opacity: 0;
  animation: tg-mote 18s linear infinite;
}
.tg-beam i:nth-child(1) { left: 12%; top: 8%; animation-duration: 21s; }
.tg-beam i:nth-child(2) { left: 22%; top: 22%; animation-delay: -4s; width: 2px; height: 2px; }
.tg-beam i:nth-child(3) { left: 30%; top: 38%; animation-duration: 25s; animation-delay: -9s; }
.tg-beam i:nth-child(4) { left: 40%; top: 52%; animation-delay: -13s; width: 4px; height: 4px; }
.tg-beam i:nth-child(5) { left: 50%; top: 66%; animation-duration: 23s; animation-delay: -6s; width: 2px; height: 2px; }
.tg-beam i:nth-child(6) { left: 58%; top: 80%; animation-delay: -16s; }
.tg-beam i:nth-child(7) { left: 18%; top: 30%; animation-duration: 27s; animation-delay: -20s; width: 2px; height: 2px; }
.tg-beam i:nth-child(8) { left: 34%; top: 60%; animation-duration: 20s; animation-delay: -2s; }
.tg-beam i:nth-child(9) { left: 46%; top: 30%; animation-duration: 29s; animation-delay: -11s; width: 2px; height: 2px; }
.tg-beam i:nth-child(10) { left: 26%; top: 74%; animation-duration: 24s; animation-delay: -17s; }
@keyframes tg-mote {
  0% { transform: translate(0, 0); opacity: 0; }
  12% { opacity: 0.9; }
  50% { transform: translate(18px, 26px); opacity: 0.55; }
  85% { opacity: 0.85; }
  100% { transform: translate(-6px, 52px); opacity: 0; }
}
/* the golden sweep when the clock starts */
.tg-shine {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 6px;
  pointer-events: none;
  z-index: 3;
}
.tg-shine::before {
  content: "";
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: -60%;
  width: 45%;
  transform: skewX(-18deg) translateX(0);
  background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--light) 30%, transparent), transparent);
  opacity: 0;
}
.tg-board.tg-win .tg-shine::before { animation: tg-sweep 1.6s var(--ease) 0.2s; }
@keyframes tg-sweep {
  0% { transform: skewX(-18deg) translateX(0); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: skewX(-18deg) translateX(420%); opacity: 0; }
}

/* the gear that follows a dragging finger */
.tg-drag {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 30;
  pointer-events: none;
  filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.55));
  opacity: 0.92;
}

/* ----------------------------------------------------------------- tray */
.tg-tray {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--tray-a), var(--tray-b));
  box-shadow: inset 0 1px 0 rgba(255, 240, 210, 0.12), inset 0 -10px 18px -10px rgba(0, 0, 0, 0.6), 0 8px 20px -12px rgba(0, 0, 0, 0.85);
  min-width: 0;
}
.tg-planes {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 0 0 auto;
}
.tg-plane {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px 4px 6px;
  border-radius: 9px;
  border: 1px solid rgba(255, 235, 210, 0.14);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-dim);
  font: 600 12px var(--sans);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.tg-plane svg { width: 17px; height: 17px; stroke-width: 1.6; }
.tg-plane[aria-checked="true"] { color: #fff3da; border-color: color-mix(in oklab, var(--accent) 80%, #fff 10%); background: color-mix(in oklab, var(--accent) 38%, rgba(0, 0, 0, 0.3)); }
.tg-chips {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
}
.tg-chip {
  appearance: none;
  position: relative;
  flex: 0 1 58px;
  min-width: 44px;
  height: 58px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(255, 235, 210, 0.12);
  background: radial-gradient(circle at 50% 40%, rgba(255, 236, 200, 0.08), rgba(0, 0, 0, 0.18));
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: grab;
  touch-action: none;
  transition: transform 0.18s var(--ease), border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.tg-chip canvas { width: 44px; height: 44px; pointer-events: none; }
.tg-chip .tg-z {
  position: absolute;
  left: 50%;
  bottom: 2px;
  transform: translateX(-50%);
  font: 700 11px var(--serif);
  color: #f9e8c4;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}
.tg-chip .tg-n {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 18px;
  padding: 1px 4px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.5);
  font: 600 10.5px var(--sans);
  color: #f3e3c2;
}
.tg-chip[aria-pressed="true"] {
  border-color: #ffd98a;
  transform: translateY(-3px);
  box-shadow: 0 0 0 2px color-mix(in oklab, #ffd98a 45%, transparent), 0 8px 16px -6px rgba(0, 0, 0, 0.7), 0 0 18px -4px color-mix(in oklab, var(--light) 70%, transparent);
}
.tg-chip:disabled { opacity: 0.3; cursor: default; }
.tg-chip:active:not(:disabled) { cursor: grabbing; }
.tg-tray.tg-nudge { animation: tg-nudge 0.5s var(--ease); }
@keyframes tg-nudge { 30% { transform: translateY(-4px); } 60% { transform: translateY(1px); } }

/* --------------------------------------------------------------- belfry */
.tg-st-sky0 { stop-color: color-mix(in oklab, var(--light) 55%, #fff); }
.tg-st-sky1 { stop-color: color-mix(in oklab, var(--light) 85%, #c06a20); }
.tg-st-bell-hi { stop-color: var(--bell-hi); }
.tg-st-bell-mid { stop-color: color-mix(in oklab, var(--bell-hi) 55%, var(--bell-lo)); }
.tg-st-bell-lo { stop-color: var(--bell-lo); }
.tg-st-bezel-hi { stop-color: var(--bezel-hi); }
.tg-st-bezel-mid { stop-color: color-mix(in oklab, var(--bezel-hi) 45%, var(--bezel-lo)); }
.tg-st-bezel-lo { stop-color: var(--bezel-lo); }
.tg-st-face0 { stop-color: color-mix(in oklab, var(--dial-face) 85%, #fff); }
.tg-st-face1 { stop-color: var(--dial-edge); }

.tg-stone { fill: url(#tg-g-stone); stroke: rgba(38, 28, 18, 0.7); stroke-width: 0.9; stroke-linejoin: round; }
.tg-stone.b { fill: #a99c84; }
.tg-stone.c { fill: #bdb19a; }
.tg-stone.k { fill: #c9bea6; }
.tg-sky { fill: url(#tg-g-sky); }
.tg-slat { fill: url(#tg-g-slat); }
.tg-slat-lit { stroke: color-mix(in oklab, var(--light) 70%, #fff); stroke-width: 0.8; opacity: 0.6; fill: none; }
.tg-stile { stroke: #2a190e; stroke-width: 2.2; opacity: 0.8; }
.tg-headstock { fill: url(#tg-g-beam); stroke: rgba(0, 0, 0, 0.5); stroke-width: 0.5; }
.tg-headstock-bolts { stroke: #1a120b; stroke-width: 2.6; stroke-linecap: round; }
.tg-bell { transform-box: view-box; transform-origin: 60px 35px; }
.tg-bell-crown { fill: var(--bell-lo); }
.tg-bell-body { fill: url(#tg-g-bell); stroke: rgba(40, 20, 4, 0.5); stroke-width: 0.6; }
.tg-bell-lip { fill: color-mix(in oklab, var(--bell-lo) 75%, #000); }
.tg-bell-shine { fill: none; stroke: rgba(255, 250, 230, 0.5); stroke-width: 1.4; stroke-linecap: round; }
.tg-bell-band { fill: none; stroke: rgba(50, 26, 6, 0.4); stroke-width: 0.8; }
.tg-waves path { fill: none; stroke: color-mix(in oklab, var(--light) 80%, #fff); stroke-width: 1.4; stroke-linecap: round; opacity: 0; transform-box: fill-box; transform-origin: center; }
.tg-waves.go path { animation: tg-wave 1.15s ease-out; }
.tg-waves.go path:nth-child(2) { animation-delay: 0.12s; }
@keyframes tg-wave { 0% { opacity: 0.9; transform: scale(0.85); } 100% { opacity: 0; transform: scale(1.25); } }
.tg-bracket { fill: url(#tg-g-iron); }
.tg-hammer { transform-box: view-box; transform-origin: 110.5px 72.5px; }
.tg-hammer-arm { stroke: #2b2b2e; stroke-width: 2.4; stroke-linecap: round; }
.tg-hammer-head { fill: url(#tg-g-iron); stroke: #151516; stroke-width: 0.5; }
.tg-hammer-pivot { fill: #9a9aa0; stroke: #222; stroke-width: 0.6; }
.tg-hammer.strike { animation: tg-strike 0.62s ease-in; }
.tg-hammer.ready { animation: tg-ready 2.8s ease-in-out infinite; }
@keyframes tg-strike { 0% { transform: rotate(0); } 48% { transform: rotate(-28deg); } 60% { transform: rotate(3deg); } 72% { transform: rotate(-2deg); } 100% { transform: rotate(0); } }
@keyframes tg-ready { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-10deg); } }
.tg-bell.ring { animation: tg-ring 1.3s ease-out; }
@keyframes tg-ring { 0% { transform: rotate(0); } 15% { transform: rotate(-3deg); } 35% { transform: rotate(2.2deg); } 55% { transform: rotate(-1.4deg); } 75% { transform: rotate(0.7deg); } 100% { transform: rotate(0); } }
.tg-sill { fill: url(#tg-g-stone); }

.tg-pigeon { transform-box: fill-box; transform-origin: 50% 100%; animation: tg-peck 7s ease-in-out infinite; }
.tg-pigeon.p2 { animation-duration: 9s; animation-delay: -3s; }
.tg-pg-body { fill: url(#tg-g-pigeon); }
.tg-pg-tail { fill: #5d606c; }
.tg-pg-wing { fill: #8a8d99; stroke: #555865; stroke-width: 0.4; transform-box: fill-box; transform-origin: 30% 20%; }
.tg-pg-neck { fill: url(#tg-g-neck); opacity: 0.9; }
.tg-pg-eye { fill: #e0702a; }
.tg-pg-beak { fill: #2d2622; }
.tg-pg-feet { stroke: #d07b78; stroke-width: 0.9; stroke-linecap: round; }
@keyframes tg-peck { 0%, 70%, 100% { transform: rotate(0); } 76% { transform: rotate(6deg) translateY(0.5px); } 82% { transform: rotate(0); } 86% { transform: rotate(5deg) translateY(0.5px); } 90% { transform: rotate(0); } }
.tg-flown .tg-pigeon.p1 { animation: tg-fly1 1.7s cubic-bezier(0.3, 0.1, 0.6, 1) forwards; }
.tg-flown .tg-pigeon.p2 { animation: tg-fly2 1.9s cubic-bezier(0.3, 0.1, 0.6, 1) 0.15s forwards; }
.tg-flown .tg-pg-wing { animation: tg-flap 0.11s ease-in-out infinite alternate; }
@keyframes tg-fly1 { 0% { transform: translate(0, 0); opacity: 1; } 18% { transform: translate(4px, -10px) rotate(-12deg); } 100% { transform: translate(-60px, -150px) rotate(-20deg); opacity: 0; } }
@keyframes tg-fly2 { 0% { transform: translate(0, 0); opacity: 1; } 18% { transform: translate(5px, -9px) rotate(-14deg); } 100% { transform: translate(-70px, -120px) rotate(-18deg); opacity: 0; } }
@keyframes tg-flap { from { transform: scaleY(1); } to { transform: scaleY(-1.3); } }
.tg-landing .tg-pigeon { animation: tg-land 1.3s cubic-bezier(0.2, 0.6, 0.3, 1); }
@keyframes tg-land { 0% { transform: translate(-40px, -60px); opacity: 0; } 70% { opacity: 1; } 100% { transform: translate(0, 0); opacity: 1; } }

/* ----------------------------------------------------------------- dial */
.tg-dial-shadow { fill: rgba(0, 0, 0, 0.45); }
.tg-bezel { fill: url(#tg-g-bezel); }
.tg-bezel-in { fill: none; stroke: rgba(0, 0, 0, 0.35); stroke-width: 1.2; }
.tg-face { fill: url(#tg-g-face); }
.tg-face-glow { fill: url(#tg-g-faceglow); }
.tg-ring { fill: none; stroke: var(--dial-ink); stroke-width: 0.9; opacity: 0.75; }
.tg-ring.thin { stroke-width: 0.6; opacity: 0.35; }
.tg-ticks { stroke: var(--dial-ink); stroke-width: 1; opacity: 0.85; }
.tg-numeral { font: 600 17px var(--serif); fill: var(--dial-ink); letter-spacing: -0.02em; }
.tg-dot { fill: var(--dial-ink); opacity: 0.6; }
.tg-rosette ellipse { fill: none; stroke: var(--dial-ink); stroke-width: 0.6; opacity: 0.28; }
.tg-hand path { fill: var(--dial-hand); stroke: color-mix(in oklab, var(--dial-hand) 60%, #000); stroke-width: 0.6; }
.tg-counter { fill: var(--dial-hand); }
.tg-cap { fill: url(#tg-g-bezel); stroke: rgba(0, 0, 0, 0.5); stroke-width: 0.6; }
.tg-cap-pin { fill: rgba(0, 0, 0, 0.55); }

/* -------------------------------------------------------- sheets, dialogs */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(8, 5, 3, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fade 0.25s;
}
@keyframes fade { from { opacity: 0; } }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  z-index: 21;
  max-width: 580px;
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  color-scheme: light;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.45);
  padding-bottom: env(safe-area-inset-bottom);
  animation: rise 0.32s var(--ease);
  -webkit-user-select: text;
  user-select: text;
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 6px 22px;
  flex: 0 0 auto;
}
.sheet .icon-btn, .dialog .icon-btn { color: var(--ink); }
.sheet .icon-btn:hover, .dialog .icon-btn:hover { background: rgba(60, 45, 30, 0.08); }
.sheet h2, .dialog h2 { font-family: var(--serif); font-weight: 600; font-size: 24px; margin: 0; letter-spacing: 0.01em; }
.sheet-body {
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px 22px 26px;
  font-size: 15px;
  line-height: 1.55;
}
.sheet-body h3 { font-family: var(--serif); font-weight: 600; font-size: 17px; margin: 20px 0 8px; color: var(--ink); }
.prose p { margin: 0 0 12px; }
.prose ul { margin: 0; padding-left: 20px; }
.prose li { margin: 4px 0; }
.muted { color: var(--ink-soft); }
.about { font-size: 13px; margin-top: 22px; text-align: center; }
.tg-rule-art { display: flex; justify-content: center; gap: 14px; margin: 4px 0 14px; flex-wrap: wrap; }
.tg-rule-art figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; font: 600 13px var(--serif); color: var(--ink-soft); }
.tg-rule-art canvas { width: 112px; height: 80px; }

@media (min-width: 700px) and (min-height: 560px) {
  .sheet {
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 24px;
    max-height: 80dvh;
    animation: pop 0.28s var(--ease);
  }
}
@keyframes pop { from { opacity: 0; transform: translateY(-50%) scale(0.96); } }

.dialog {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 22;
  width: min(92vw, 420px);
  max-height: 94dvh;
  overflow: auto;
  background: var(--paper);
  color: var(--ink);
  color-scheme: light;
  border-radius: 24px;
  padding: 24px 22px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  text-align: center;
  animation: popc 0.3s var(--ease);
}
@keyframes popc { from { opacity: 0; transform: translate(-50%, -50%) scale(0.94); } }
.dialog p { margin: 8px 0 18px; color: var(--ink-soft); font-size: 15.5px; line-height: 1.5; }
.dialog .row { display: flex; gap: 10px; }
.dialog .btn { color: var(--ink); background: rgba(255, 255, 255, 0.6); border-color: rgba(60, 45, 30, 0.16); box-shadow: 0 1px 2px rgba(60, 45, 30, 0.1); }
.dialog .btn:hover { background: #fff; }
.dialog .btn.primary { color: var(--accent-text); background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 88%, #fff 12%), var(--accent-deep)); border-color: color-mix(in oklab, var(--accent-deep) 70%, #000); }

/* Levels */
.tg-levels-dialog {
  width: min(94vw, 560px);
  max-height: min(88dvh, 760px);
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 14px 8px 8px 18px;
  overflow: hidden;
}
.tg-levels-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 6px 2px; }
.tg-level-list { overflow: auto; overscroll-behavior: contain; padding: 0 10px 10px 0; }
.tg-ch { margin: 10px 0 4px; }
.tg-ch h3 { margin: 0 0 7px; display: flex; align-items: baseline; gap: 8px; font: 600 16px var(--serif); color: var(--ink); }
.tg-ch h3 small { font: 600 11px var(--sans); letter-spacing: 0.12em; color: var(--ink-soft); text-transform: uppercase; }
.tg-ch-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.tg-lv {
  appearance: none;
  position: relative;
  min-height: 62px;
  padding: 6px 4px 5px;
  border-radius: 13px;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  font: inherit;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.tg-lv:hover:not(:disabled) { background: #fff; }
.tg-lv:active:not(:disabled) { transform: scale(0.96); }
.tg-lv b { font: 600 19px var(--serif); line-height: 1; }
.tg-lv[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent); }
.tg-lv:disabled { opacity: 0.42; cursor: default; }
.tg-lv .tg-lock { width: 15px; height: 15px; fill: none; stroke: var(--ink-soft); stroke-width: 1.8; }
.tg-stars { display: inline-flex; gap: 1px; }
.tg-stars svg { width: 13px; height: 13px; fill: rgba(60, 45, 30, 0.18); }
.tg-stars svg.on { fill: #d9a32a; filter: drop-shadow(0 0.5px 0 rgba(120, 70, 0, 0.6)); }

/* Result */
.result .glow {
  position: absolute;
  inset: -30% -20% auto;
  height: 70%;
  background: radial-gradient(ellipse at 50% 40%, color-mix(in oklab, var(--light) 50%, transparent), transparent 65%);
  pointer-events: none;
  opacity: 0.7;
}
.result { overflow-x: hidden; }
.result h2 { position: relative; font-size: clamp(25px, 7vw, 30px); animation: shimmer 2.4s ease-in-out infinite; }
@keyframes shimmer { 50% { text-shadow: 0 0 18px color-mix(in oklab, var(--light) 80%, white); } }
.tg-result-stars { position: relative; display: flex; justify-content: center; gap: 10px; margin: 0 0 10px; }
.tg-result-stars figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; width: 92px; }
.tg-result-stars svg { width: 46px; height: 46px; fill: rgba(60, 45, 30, 0.15); }
.tg-result-stars svg.on { fill: #e2a92c; filter: drop-shadow(0 2px 3px rgba(140, 80, 0, 0.45)); animation: tg-star 0.6s var(--ease) backwards; }
.tg-result-stars figure:nth-child(2) svg.on { animation-delay: 0.25s; }
.tg-result-stars figure:nth-child(3) svg.on { animation-delay: 0.5s; }
.tg-result-stars figcaption { font-size: 11px; letter-spacing: 0.04em; color: var(--ink-soft); line-height: 1.2; }
@keyframes tg-star { 0% { transform: scale(0.2) rotate(-40deg); opacity: 0; } 70% { transform: scale(1.18) rotate(6deg); opacity: 1; } 100% { transform: scale(1) rotate(0); } }
.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.result-stats div, .summary div { display: flex; flex-direction: column; align-items: center; background: var(--paper-2); border-radius: 12px; padding: 8px 4px; line-height: 1.2; min-width: 0; }
.result-stats span, .summary span { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.result-stats b, .summary b { font-family: var(--serif); font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.result .score { display: flex; flex-direction: column; align-items: center; margin: 4px 0 18px; }
.result .score span { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.result .score b { font-family: var(--serif); font-size: 44px; font-weight: 600; line-height: 1.05; color: color-mix(in oklab, var(--accent-deep) 80%, #000); }

/* ------------------------------------------------------------- results */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
th { text-align: left; vertical-align: bottom; font-weight: 500; color: var(--ink-soft); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; padding: 4px; border-bottom: 1px solid var(--line); }
td { padding: 7px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th.time, th.gears, th.hints, th.score, td.time, td.gears, td.hints, td.score { text-align: right; }
td.score { font-family: var(--serif); font-weight: 600; font-size: 15px; }
td.level { font-family: var(--serif); font-weight: 600; }
td.stars { color: #c08a1a; letter-spacing: 1px; font-size: 12px; }
@media (max-width: 440px) { th.gears, td.gears, th.hints, td.hints { display: none; } td { padding: 7px 3px; } }

/* ------------------------------------------------------------- settings */
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt {
  appearance: none;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  font: 500 14px var(--sans);
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.opt:active { transform: scale(0.97); }
.opt[aria-checked="true"] { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent); }
.opts.lang .opt { padding-left: 14px; min-width: 96px; justify-content: center; }
.tg-swatch {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--sw-board);
  box-shadow: inset 0 0 0 2.5px var(--sw-frame), inset 0 0 0 3.5px rgba(0, 0, 0, 0.35);
}
.tg-swatch::after {
  content: "";
  position: absolute;
  inset: 4px;
  background: radial-gradient(circle at 38% 34%, color-mix(in oklab, var(--sw-gear) 55%, #fff), var(--sw-gear) 55%, color-mix(in oklab, var(--sw-gear) 70%, #000));
  -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%27-12%20-12%2024%2024%27%3E%3Cpath%20fill-rule%3D%27evenodd%27%20d%3D%27M7.67%20-3.25L7.45%20-2.37L7.63%20-1.67L8.26%20-1.02L8.72%20-1.08L9.19%20-1.14L9.65%20-1.19L9.97%20-1.18L10.28%20-1.14L10.57%20-1.06L10.82%20-0.96L11.04%20-0.83L11.20%20-0.66L11.30%20-0.43L11.34%200.00L11.30%200.43L11.20%200.66L11.04%200.83L10.82%200.96L10.57%201.06L10.28%201.14L9.97%201.18L9.65%201.19L9.19%201.14L8.72%201.08L8.26%201.02L7.63%201.67L7.45%202.37L7.67%203.25L8.10%203.43L8.52%203.61L8.95%203.79L9.22%203.96L9.47%204.15L9.68%204.36L9.85%204.58L9.97%204.80L10.03%205.03L10.00%205.27L9.82%205.67L9.57%206.03L9.37%206.17L9.14%206.24L8.89%206.25L8.62%206.21L8.33%206.12L8.04%206.00L7.76%205.86L7.39%205.58L7.02%205.30L6.65%205.02L5.78%205.26L5.26%205.78L5.02%206.65L5.30%207.02L5.58%207.39L5.86%207.76L6.00%208.04L6.12%208.33L6.21%208.62L6.25%208.89L6.24%209.14L6.17%209.37L6.03%209.57L5.67%209.82L5.27%2010.00L5.03%2010.03L4.80%209.97L4.58%209.85L4.36%209.68L4.15%209.47L3.96%209.22L3.79%208.95L3.61%208.52L3.43%208.10L3.25%207.67L2.37%207.45L1.67%207.63L1.02%208.26L1.08%208.72L1.14%209.19L1.19%209.65L1.18%209.97L1.14%2010.28L1.06%2010.57L0.96%2010.82L0.83%2011.04L0.66%2011.20L0.43%2011.30L0.00%2011.34L-0.43%2011.30L-0.66%2011.20L-0.83%2011.04L-0.96%2010.82L-1.06%2010.57L-1.14%2010.28L-1.18%209.97L-1.19%209.65L-1.14%209.19L-1.08%208.72L-1.02%208.26L-1.67%207.63L-2.37%207.45L-3.25%207.67L-3.43%208.10L-3.61%208.52L-3.79%208.95L-3.96%209.22L-4.15%209.47L-4.36%209.68L-4.58%209.85L-4.80%209.97L-5.03%2010.03L-5.27%2010.00L-5.67%209.82L-6.03%209.57L-6.17%209.37L-6.24%209.14L-6.25%208.89L-6.21%208.62L-6.12%208.33L-6.00%208.04L-5.86%207.76L-5.58%207.39L-5.30%207.02L-5.02%206.65L-5.26%205.78L-5.78%205.26L-6.65%205.02L-7.02%205.30L-7.39%205.58L-7.76%205.86L-8.04%206.00L-8.33%206.12L-8.62%206.21L-8.89%206.25L-9.14%206.24L-9.37%206.17L-9.57%206.03L-9.82%205.67L-10.00%205.27L-10.03%205.03L-9.97%204.80L-9.85%204.58L-9.68%204.36L-9.47%204.15L-9.22%203.96L-8.95%203.79L-8.52%203.61L-8.10%203.43L-7.67%203.25L-7.45%202.37L-7.63%201.67L-8.26%201.02L-8.72%201.08L-9.19%201.14L-9.65%201.19L-9.97%201.18L-10.28%201.14L-10.57%201.06L-10.82%200.96L-11.04%200.83L-11.20%200.66L-11.30%200.43L-11.34%200.00L-11.30%20-0.43L-11.20%20-0.66L-11.04%20-0.83L-10.82%20-0.96L-10.57%20-1.06L-10.28%20-1.14L-9.97%20-1.18L-9.65%20-1.19L-9.19%20-1.14L-8.72%20-1.08L-8.26%20-1.02L-7.63%20-1.67L-7.45%20-2.37L-7.67%20-3.25L-8.10%20-3.43L-8.52%20-3.61L-8.95%20-3.79L-9.22%20-3.96L-9.47%20-4.15L-9.68%20-4.36L-9.85%20-4.58L-9.97%20-4.80L-10.03%20-5.03L-10.00%20-5.27L-9.82%20-5.67L-9.57%20-6.03L-9.37%20-6.17L-9.14%20-6.24L-8.89%20-6.25L-8.62%20-6.21L-8.33%20-6.12L-8.04%20-6.00L-7.76%20-5.86L-7.39%20-5.58L-7.02%20-5.30L-6.65%20-5.02L-5.78%20-5.26L-5.26%20-5.78L-5.02%20-6.65L-5.30%20-7.02L-5.58%20-7.39L-5.86%20-7.76L-6.00%20-8.04L-6.12%20-8.33L-6.21%20-8.62L-6.25%20-8.89L-6.24%20-9.14L-6.17%20-9.37L-6.03%20-9.57L-5.67%20-9.82L-5.27%20-10.00L-5.03%20-10.03L-4.80%20-9.97L-4.58%20-9.85L-4.36%20-9.68L-4.15%20-9.47L-3.96%20-9.22L-3.79%20-8.95L-3.61%20-8.52L-3.43%20-8.10L-3.25%20-7.67L-2.37%20-7.45L-1.67%20-7.63L-1.02%20-8.26L-1.08%20-8.72L-1.14%20-9.19L-1.19%20-9.65L-1.18%20-9.97L-1.14%20-10.28L-1.06%20-10.57L-0.96%20-10.82L-0.83%20-11.04L-0.66%20-11.20L-0.43%20-11.30L-0.00%20-11.34L0.43%20-11.30L0.66%20-11.20L0.83%20-11.04L0.96%20-10.82L1.06%20-10.57L1.14%20-10.28L1.18%20-9.97L1.19%20-9.65L1.14%20-9.19L1.08%20-8.72L1.02%20-8.26L1.67%20-7.63L2.37%20-7.45L3.25%20-7.67L3.43%20-8.10L3.61%20-8.52L3.79%20-8.95L3.96%20-9.22L4.15%20-9.47L4.36%20-9.68L4.58%20-9.85L4.80%20-9.97L5.03%20-10.03L5.27%20-10.00L5.67%20-9.82L6.03%20-9.57L6.17%20-9.37L6.24%20-9.14L6.25%20-8.89L6.21%20-8.62L6.12%20-8.33L6.00%20-8.04L5.86%20-7.76L5.58%20-7.39L5.30%20-7.02L5.02%20-6.65L5.26%20-5.78L5.78%20-5.26L6.65%20-5.02L7.02%20-5.30L7.39%20-5.58L7.76%20-5.86L8.04%20-6.00L8.33%20-6.12L8.62%20-6.21L8.89%20-6.25L9.14%20-6.24L9.37%20-6.17L9.57%20-6.03L9.82%20-5.67L10.00%20-5.27L10.03%20-5.03L9.97%20-4.80L9.85%20-4.58L9.68%20-4.36L9.47%20-4.15L9.22%20-3.96L8.95%20-3.79L8.52%20-3.61L8.10%20-3.43ZM5.13%203.59A1.54%201.54%200%201%200%202.05%203.59A1.54%201.54%200%201%200%205.13%203.59ZM-2.05%203.59A1.54%201.54%200%201%200%20-5.13%203.59A1.54%201.54%200%201%200%20-2.05%203.59ZM-2.05%20-3.59A1.54%201.54%200%201%200%20-5.13%20-3.59A1.54%201.54%200%201%200%20-2.05%20-3.59ZM5.13%20-3.59A1.54%201.54%200%201%200%202.05%20-3.59A1.54%201.54%200%201%200%205.13%20-3.59Z%27%2F%3E%3C%2Fsvg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%27-12%20-12%2024%2024%27%3E%3Cpath%20fill-rule%3D%27evenodd%27%20d%3D%27M7.67%20-3.25L7.45%20-2.37L7.63%20-1.67L8.26%20-1.02L8.72%20-1.08L9.19%20-1.14L9.65%20-1.19L9.97%20-1.18L10.28%20-1.14L10.57%20-1.06L10.82%20-0.96L11.04%20-0.83L11.20%20-0.66L11.30%20-0.43L11.34%200.00L11.30%200.43L11.20%200.66L11.04%200.83L10.82%200.96L10.57%201.06L10.28%201.14L9.97%201.18L9.65%201.19L9.19%201.14L8.72%201.08L8.26%201.02L7.63%201.67L7.45%202.37L7.67%203.25L8.10%203.43L8.52%203.61L8.95%203.79L9.22%203.96L9.47%204.15L9.68%204.36L9.85%204.58L9.97%204.80L10.03%205.03L10.00%205.27L9.82%205.67L9.57%206.03L9.37%206.17L9.14%206.24L8.89%206.25L8.62%206.21L8.33%206.12L8.04%206.00L7.76%205.86L7.39%205.58L7.02%205.30L6.65%205.02L5.78%205.26L5.26%205.78L5.02%206.65L5.30%207.02L5.58%207.39L5.86%207.76L6.00%208.04L6.12%208.33L6.21%208.62L6.25%208.89L6.24%209.14L6.17%209.37L6.03%209.57L5.67%209.82L5.27%2010.00L5.03%2010.03L4.80%209.97L4.58%209.85L4.36%209.68L4.15%209.47L3.96%209.22L3.79%208.95L3.61%208.52L3.43%208.10L3.25%207.67L2.37%207.45L1.67%207.63L1.02%208.26L1.08%208.72L1.14%209.19L1.19%209.65L1.18%209.97L1.14%2010.28L1.06%2010.57L0.96%2010.82L0.83%2011.04L0.66%2011.20L0.43%2011.30L0.00%2011.34L-0.43%2011.30L-0.66%2011.20L-0.83%2011.04L-0.96%2010.82L-1.06%2010.57L-1.14%2010.28L-1.18%209.97L-1.19%209.65L-1.14%209.19L-1.08%208.72L-1.02%208.26L-1.67%207.63L-2.37%207.45L-3.25%207.67L-3.43%208.10L-3.61%208.52L-3.79%208.95L-3.96%209.22L-4.15%209.47L-4.36%209.68L-4.58%209.85L-4.80%209.97L-5.03%2010.03L-5.27%2010.00L-5.67%209.82L-6.03%209.57L-6.17%209.37L-6.24%209.14L-6.25%208.89L-6.21%208.62L-6.12%208.33L-6.00%208.04L-5.86%207.76L-5.58%207.39L-5.30%207.02L-5.02%206.65L-5.26%205.78L-5.78%205.26L-6.65%205.02L-7.02%205.30L-7.39%205.58L-7.76%205.86L-8.04%206.00L-8.33%206.12L-8.62%206.21L-8.89%206.25L-9.14%206.24L-9.37%206.17L-9.57%206.03L-9.82%205.67L-10.00%205.27L-10.03%205.03L-9.97%204.80L-9.85%204.58L-9.68%204.36L-9.47%204.15L-9.22%203.96L-8.95%203.79L-8.52%203.61L-8.10%203.43L-7.67%203.25L-7.45%202.37L-7.63%201.67L-8.26%201.02L-8.72%201.08L-9.19%201.14L-9.65%201.19L-9.97%201.18L-10.28%201.14L-10.57%201.06L-10.82%200.96L-11.04%200.83L-11.20%200.66L-11.30%200.43L-11.34%200.00L-11.30%20-0.43L-11.20%20-0.66L-11.04%20-0.83L-10.82%20-0.96L-10.57%20-1.06L-10.28%20-1.14L-9.97%20-1.18L-9.65%20-1.19L-9.19%20-1.14L-8.72%20-1.08L-8.26%20-1.02L-7.63%20-1.67L-7.45%20-2.37L-7.67%20-3.25L-8.10%20-3.43L-8.52%20-3.61L-8.95%20-3.79L-9.22%20-3.96L-9.47%20-4.15L-9.68%20-4.36L-9.85%20-4.58L-9.97%20-4.80L-10.03%20-5.03L-10.00%20-5.27L-9.82%20-5.67L-9.57%20-6.03L-9.37%20-6.17L-9.14%20-6.24L-8.89%20-6.25L-8.62%20-6.21L-8.33%20-6.12L-8.04%20-6.00L-7.76%20-5.86L-7.39%20-5.58L-7.02%20-5.30L-6.65%20-5.02L-5.78%20-5.26L-5.26%20-5.78L-5.02%20-6.65L-5.30%20-7.02L-5.58%20-7.39L-5.86%20-7.76L-6.00%20-8.04L-6.12%20-8.33L-6.21%20-8.62L-6.25%20-8.89L-6.24%20-9.14L-6.17%20-9.37L-6.03%20-9.57L-5.67%20-9.82L-5.27%20-10.00L-5.03%20-10.03L-4.80%20-9.97L-4.58%20-9.85L-4.36%20-9.68L-4.15%20-9.47L-3.96%20-9.22L-3.79%20-8.95L-3.61%20-8.52L-3.43%20-8.10L-3.25%20-7.67L-2.37%20-7.45L-1.67%20-7.63L-1.02%20-8.26L-1.08%20-8.72L-1.14%20-9.19L-1.19%20-9.65L-1.18%20-9.97L-1.14%20-10.28L-1.06%20-10.57L-0.96%20-10.82L-0.83%20-11.04L-0.66%20-11.20L-0.43%20-11.30L-0.00%20-11.34L0.43%20-11.30L0.66%20-11.20L0.83%20-11.04L0.96%20-10.82L1.06%20-10.57L1.14%20-10.28L1.18%20-9.97L1.19%20-9.65L1.14%20-9.19L1.08%20-8.72L1.02%20-8.26L1.67%20-7.63L2.37%20-7.45L3.25%20-7.67L3.43%20-8.10L3.61%20-8.52L3.79%20-8.95L3.96%20-9.22L4.15%20-9.47L4.36%20-9.68L4.58%20-9.85L4.80%20-9.97L5.03%20-10.03L5.27%20-10.00L5.67%20-9.82L6.03%20-9.57L6.17%20-9.37L6.24%20-9.14L6.25%20-8.89L6.21%20-8.62L6.12%20-8.33L6.00%20-8.04L5.86%20-7.76L5.58%20-7.39L5.30%20-7.02L5.02%20-6.65L5.26%20-5.78L5.78%20-5.26L6.65%20-5.02L7.02%20-5.30L7.39%20-5.58L7.76%20-5.86L8.04%20-6.00L8.33%20-6.12L8.62%20-6.21L8.89%20-6.25L9.14%20-6.24L9.37%20-6.17L9.57%20-6.03L9.82%20-5.67L10.00%20-5.27L10.03%20-5.03L9.97%20-4.80L9.85%20-4.58L9.68%20-4.36L9.47%20-4.15L9.22%20-3.96L8.95%20-3.79L8.52%20-3.61L8.10%20-3.43ZM5.13%203.59A1.54%201.54%200%201%200%202.05%203.59A1.54%201.54%200%201%200%205.13%203.59ZM-2.05%203.59A1.54%201.54%200%201%200%20-5.13%203.59A1.54%201.54%200%201%200%20-2.05%203.59ZM-2.05%20-3.59A1.54%201.54%200%201%200%20-5.13%20-3.59A1.54%201.54%200%201%200%20-2.05%20-3.59ZM5.13%20-3.59A1.54%201.54%200%201%200%202.05%20-3.59A1.54%201.54%200%201%200%205.13%20-3.59Z%27%2F%3E%3C%2Fsvg%3E") center / contain no-repeat;
}
.toggle { display: flex; align-items: center; gap: 12px; margin-top: 18px; cursor: pointer; font-size: 15px; line-height: 1.35; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track { flex: 0 0 auto; width: 46px; height: 28px; border-radius: 999px; background: #cfc6b8; position: relative; transition: background 0.25s; }
.toggle .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.25s var(--ease); }
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(18px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(10px);
  z-index: 15;
  background: rgba(250, 238, 214, 0.97);
  color: #2b1d12;
  padding: 10px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.35;
  width: max-content;
  max-width: min(92vw, 460px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (max-width: 760px) {
  .toast { bottom: calc(158px + env(safe-area-inset-bottom)); }
}
@media (max-width: 760px) and (max-height: 700px) {
  .toast { bottom: calc(142px + env(safe-area-inset-bottom)); }
}
.tg-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ------------------------------------------------------- wide layouts */
@container stage (min-width: 760px) and (min-aspect-ratio: 6 / 5) {
  .tg-scene {
    grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "tower board" "tray board";
    gap: 12px 18px;
  }
  .tg-tower {
    grid-area: tower;
    grid-template-columns: auto 1fr;
    grid-template-areas: "belfry dial" "goal goal";
    align-items: end;
    gap: 12px 6px;
    padding: 16px 16px 16px 14px;
  }
  .tg-belfry { grid-area: belfry; width: 100px; margin-bottom: 0; }
  .tg-dial { grid-area: dial; width: 136px; height: 136px; justify-self: end; align-self: center; }
  .tg-goal { grid-area: goal; }
  .tg-chapter { flex-direction: column; gap: 2px; }
  .tg-chapter b { font-size: 20px; white-space: normal; }
  .tg-targets { flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 10px; }
  .tg-target { font-size: 14px; min-height: 32px; }
  .tg-board-host { grid-area: board; }
  .tg-tray {
    grid-area: tray;
    flex-direction: column;
    align-items: stretch;
    align-self: start;
    padding: 12px;
    gap: 10px;
  }
  .tg-planes { flex-direction: row; }
  .tg-plane { flex: 1; justify-content: center; }
  .tg-chips { flex-wrap: wrap; justify-content: flex-start; }
  .tg-chip { flex: 0 0 auto; width: 74px; height: 74px; }
  .tg-chip canvas { width: 58px; height: 58px; }
}
@container stage (min-width: 1000px) and (min-aspect-ratio: 6 / 5) {
  .tg-scene { grid-template-columns: 320px minmax(0, 1fr); }
}

/* ------------------------------------------------------- small screens */
@media (max-height: 700px) {
  .top { padding-top: 6px; }
  .brand small { display: none; }
  .brand b { font-size: 19px; }
  .stat b { font-size: 16px; }
  .stat { padding: 3px 6px; }
  .actions { padding-bottom: 10px; }
  .btn { padding: 9px 8px; }
  .tg-dial { width: 70px; height: 70px; }
  .tg-belfry { width: 52px; }
  .tg-chip { height: 50px; }
  .tg-chip canvas { width: 38px; height: 38px; }
  .tg-target { min-height: 24px; font-size: 12px; }
  .tg-target .tg-ico { width: 19px; height: 19px; }
}
@media (max-width: 560px) {
  .tg-chapter small { display: none; }
  .tg-target[data-state="idle"] .tg-now { display: none; }
  .tg-target[data-state="idle"] { padding-right: 7px; }
  .tg-target[data-state="ok"] .tg-now { font-size: 0; }
  .tg-target[data-state="ok"] .tg-now::after { content: "✓"; font-size: 14px; font-weight: 700; }
  .btn { flex-direction: column; gap: 3px; padding: 8px 4px 7px; font-size: 12.5px; }
  .btn svg { width: 21px; height: 21px; }
  .brand b { font-size: 18px; }
  .brand img { width: 36px; height: 36px; }
  .stage { padding: 2px 10px 4px; }
}
@media (max-width: 420px) {
  .top { padding-left: 12px; padding-right: 8px; }
  .brand { gap: 8px; }
  .brand img { width: 32px; height: 32px; }
  .brand b { font-size: 16.5px; letter-spacing: 0; }
  .icon-btn { width: 38px; height: 38px; }
  .stats { padding: 4px 10px 6px; gap: 6px; }
  .tg-tower { gap: 8px; padding: 5px 8px 5px 6px; }
  .tg-chapter b { font-size: 15px; }
  .tg-tray { gap: 6px; padding: 5px 6px; }
  .tg-plane { padding: 4px 7px 4px 5px; font-size: 11px; letter-spacing: 0.02em; gap: 4px; }
  .tg-plane svg { width: 15px; height: 15px; }
  .brand small { font-size: 10px; letter-spacing: 0.06em; }
  .tg-chips { gap: 4px; }
  .tg-board { --frame-w: 10px; }
}
@media (min-width: 900px) and (min-height: 700px) {
  .brand b { font-size: 25px; }
  .stage { padding: 8px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .bg .blob, .tg-beam::before, .tg-beam i, .tg-pigeon, .tg-hammer.ready { animation: none !important; }
  .tg-beam i { opacity: 0.5; }
  .sheet, .dialog, .backdrop, .tg-result-stars svg.on, .tg-board.tg-win .tg-shine::before { animation: none !important; }
  .tg-flown .tg-pigeon { animation: none !important; opacity: 0; transition: opacity 0.4s; }
}

/* The symbol sprite must stay rendered (not display:none), or its gradients vanish. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
