/* Mirror Target — an optics lab at night: graphite, glass and laser light.
   Theme colours arrive as custom properties from themes.js. */

:root {
  --bg-a: #0d1015;
  --bg-b: #161b23;
  --grid-line: rgba(120, 190, 255, 0.045);
  --bloom-1: rgba(56, 225, 255, 0.16);
  --bloom-2: rgba(255, 79, 216, 0.12);
  --ink: #e7edf5;
  --ink-soft: #8792a3;
  --paper: #151a22;
  --paper-2: #1d232d;
  --line: rgba(160, 200, 255, 0.11);
  --chip: rgba(22, 27, 35, 0.72);
  --chip-edge: rgba(140, 190, 255, 0.14);
  --accent: #38e1ff;
  --accent-2: #ff4fd8;
  --accent-ink: #04141a;
  --gold: #ffd166;
  --btn: rgba(24, 30, 39, 0.78);
  --btn-edge: rgba(150, 200, 255, 0.16);
  --btn-hover: rgba(36, 44, 56, 0.9);
  --toast: rgba(231, 237, 245, 0.95);
  --toast-ink: #0d1015;
  --shadow: rgba(0, 0, 0, 0.55);
  --backdrop: rgba(4, 6, 10, 0.6);
  --radius: 16px;
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
  --spring: cubic-bezier(0.3, 1.45, 0.45, 1);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { 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(--ink);
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(165deg, var(--bg-a), var(--bg-b));
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  -webkit-touch-callout: none;
}

/* ---------------------------------------------------------- background */
.bg { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.bloom { position: absolute; border-radius: 50%; filter: blur(70px); will-change: transform; }
.bloom.b1 { width: 70vmax; height: 50vmax; left: -25vmax; top: -22vmax; background: var(--bloom-1); animation: drift 40s ease-in-out infinite alternate; }
.bloom.b2 { width: 60vmax; height: 45vmax; right: -25vmax; bottom: -22vmax; background: var(--bloom-2); animation: drift 52s ease-in-out infinite alternate-reverse; }
@keyframes drift { to { transform: translate(7vmax, 5vmax) scale(1.1); } }

/* -------------------------------------------------------------- layout */
.app {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  max-width: 820px;
  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: 11px; min-width: 0; flex: 1 1 auto; margin-right: 10px; }
.brand img { width: 38px; height: 38px; filter: drop-shadow(0 0 8px color-mix(in oklab, var(--accent) 35%, transparent)); flex: 0 0 auto; }
.brand span { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; overflow: hidden; }
.brand b { font-weight: 650; font-size: 17px; letter-spacing: 0.16em; text-transform: uppercase; white-space: nowrap; }
@media (max-width: 400px) { .brand b { font-size: 15px; letter-spacing: 0.09em; } .brand { gap: 9px; } }
.brand small { font-family: var(--mono); font-size: 10.5px; color: var(--ink-soft); letter-spacing: 0.08em; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { display: flex; gap: 6px; flex: 0 0 auto; }

.icon-btn {
  appearance: none;
  border: 1px solid var(--chip-edge);
  background: var(--chip);
  color: var(--ink);
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s var(--ease), border-color 0.2s, color 0.2s;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.icon-btn:hover { border-color: color-mix(in oklab, var(--accent) 55%, transparent); color: var(--accent); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn:focus-visible, .btn:focus-visible, .opt:focus-visible, .lvl:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn svg, .btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* --------------------------------------------------------------- stats */
.stats { display: grid; grid-template-columns: 1.1fr 1fr 1fr 1.3fr; gap: 8px; padding: 6px 16px 4px; }
.stat {
  position: relative;
  background: var(--chip);
  border: 1px solid var(--chip-edge);
  border-radius: 10px;
  padding: 6px 8px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
/* HUD corner ticks */
.stat::before, .stat::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border: 1.5px solid color-mix(in oklab, var(--accent) 70%, transparent);
  pointer-events: none;
}
.stat::before { left: -1px; top: -1px; border-right: 0; border-bottom: 0; border-top-left-radius: 9px; }
.stat::after { right: -1px; bottom: -1px; border-left: 0; border-top: 0; border-bottom-right-radius: 9px; }
.stat span { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft); white-space: nowrap; }
.stat b { font-family: var(--mono); font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; min-height: 23px; display: flex; align-items: center; }
.stat b.bump { animation: bump 0.32s var(--spring); }
@keyframes bump { 40% { transform: scale(1.18); color: var(--accent); } }
#st-pips { display: flex; gap: 5px; font-style: normal; flex-wrap: wrap; justify-content: center; max-width: 100%; }
.pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--c);
  background: transparent;
  transition: background 0.3s, box-shadow 0.3s, transform 0.3s var(--spring);
}
.pip.on { background: var(--c); box-shadow: 0 0 8px var(--c), 0 0 2px var(--c); transform: scale(1.12); }

.stage {
  flex: 1;
  min-height: 0;
  position: relative;
  padding: 4px 8px;
}
.board {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  outline: none;
  cursor: default;
}
.board.grab { cursor: grabbing; }
.board.point { cursor: pointer; }

/* ------------------------------------------------------------- actions */
.actions { display: flex; gap: 8px; padding: 6px 16px 14px; }
.btn {
  appearance: none;
  flex: 1;
  border: 1px solid var(--btn-edge);
  background: var(--btn);
  color: var(--ink);
  font: 500 14.5px var(--sans);
  letter-spacing: 0.02em;
  padding: 11px 10px;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  min-height: 46px;
  transition: transform 0.15s var(--ease), background 0.2s, opacity 0.2s, border-color 0.2s, box-shadow 0.2s;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.btn svg { width: 19px; height: 19px; }
.btn:hover { background: var(--btn-hover); border-color: color-mix(in oklab, var(--accent) 40%, transparent); }
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.38; cursor: default; transform: none; }
.btn.primary {
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 88%, white), var(--accent));
  color: var(--accent-ink);
  border-color: color-mix(in oklab, var(--accent) 70%, white);
  font-weight: 600;
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--accent) 30%, transparent), 0 6px 22px -6px color-mix(in oklab, var(--accent) 70%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary.next { animation: beckon 2.4s ease-in-out infinite; }
@keyframes beckon { 50% { box-shadow: 0 0 0 1px color-mix(in oklab, var(--accent) 40%, transparent), 0 6px 30px -2px color-mix(in oklab, var(--accent) 90%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.45); } }
.btn.thinking { animation: breathe 0.8s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.6; } }
.btn.subtle { flex: 0 0 auto; background: transparent; box-shadow: none; border-color: transparent; color: var(--ink-soft); font-size: 13.5px; margin: 18px auto 0; display: flex; }

/* ---------------------------------------------------------------- intro */
.intro {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 3;
  background: color-mix(in oklab, var(--bg-a) 55%, transparent);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fade 0.3s;
}
.intro-card {
  width: min(100%, 360px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px 20px 18px;
  text-align: center;
  box-shadow: 0 24px 60px var(--shadow), 0 0 0 1px color-mix(in oklab, var(--accent) 12%, transparent);
  animation: popc2 0.36s var(--ease);
}
@keyframes popc2 { from { opacity: 0; transform: translateY(10px) scale(0.97); } }
.kicker { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); margin: 0 0 6px; }
.intro-card h2 { margin: 0 0 12px; font-size: 22px; font-weight: 650; letter-spacing: 0.04em; }
.intro-card p:not(.kicker) { margin: 12px 0 16px; color: var(--ink-soft); font-size: 15px; line-height: 1.5; }
.intro-art { display: flex; justify-content: center; gap: 10px; }
.intro-art canvas, .legend canvas { width: 58px; height: 58px; display: block; flex: 0 0 auto; }
.intro-card .btn { width: 100%; flex-direction: row; gap: 8px; font-size: 15px; min-height: 48px; }

/* -------------------------------------------------------- sheets, dialogs */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--backdrop);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  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: 560px;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -12px 50px var(--shadow);
  padding-bottom: env(safe-area-inset-bottom);
  animation: rise 0.34s var(--ease);
}
.sheet::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 120px;
  height: 2px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.7;
}
@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 h2, .dialog h2 { font-weight: 650; font-size: 20px; margin: 0; letter-spacing: 0.05em; }
.sheet-body {
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px 22px 26px;
  font-size: 15px;
  line-height: 1.55;
  -webkit-user-select: text;
  user-select: text;
}
.sheet-body h3 { font-family: var(--mono); font-weight: 600; font-size: 11.5px; letter-spacing: 0.16em; text-transform: uppercase; margin: 22px 0 10px; color: var(--accent); }
.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; }
.keys { font-family: var(--mono); font-size: 12.5px; color: var(--ink-soft); line-height: 1.7; }

.legend, .prose .legend { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.legend li { display: flex; align-items: center; gap: 14px; font-size: 14.5px; line-height: 1.4; }
.legend canvas { width: 50px; height: 50px; }

@media (min-width: 700px) and (min-height: 560px) {
  .sheet {
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 22px;
    border-bottom: 1px solid var(--line);
    max-height: 82dvh;
    animation: pop 0.3s var(--ease);
  }
  .sheet.wide { max-width: 640px; }
}
@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, 400px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 24px 22px 20px;
  box-shadow: 0 24px 70px var(--shadow);
  text-align: center;
  animation: popc 0.32s var(--ease);
  overflow: hidden;
}
@keyframes popc { from { opacity: 0; transform: translate(-50%, -46%) scale(0.95); } }
.dialog p { margin: 6px 0 16px; color: var(--ink-soft); font-size: 15px; line-height: 1.5; }
.dialog .row { display: flex; gap: 10px; }
.dialog .row .btn { flex-direction: row; gap: 8px; font-size: 14.5px; min-height: 48px; }
.result .glow {
  position: absolute;
  inset: -50% -20% auto;
  height: 80%;
  background: radial-gradient(ellipse at 50% 55%, color-mix(in oklab, var(--accent) 30%, transparent), transparent 62%);
  pointer-events: none;
}
.result h2 { position: relative; font-size: 24px; }
.result .kicker { position: relative; margin-top: 4px; }
.stars { position: relative; display: flex; justify-content: center; gap: 6px; margin: 2px 0 10px; }
.stars svg { width: 40px; height: 40px; fill: color-mix(in oklab, var(--ink-soft) 25%, transparent); stroke: color-mix(in oklab, var(--ink-soft) 60%, transparent); stroke-width: 1; stroke-linejoin: round; transition: transform 0.2s; }
.stars svg:nth-child(2) { width: 48px; height: 48px; margin-top: -6px; }
.stars svg.on { fill: var(--gold); stroke: color-mix(in oklab, var(--gold) 70%, white); filter: drop-shadow(0 0 10px color-mix(in oklab, var(--gold) 70%, transparent)); animation: star 0.5s var(--spring) backwards; }
.stars svg.on:nth-child(2) { animation-delay: 0.14s; }
.stars svg.on:nth-child(3) { animation-delay: 0.28s; }
@keyframes star { from { transform: scale(0.2) rotate(-40deg); opacity: 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: 1px solid var(--line); border-radius: 12px; padding: 8px 4px; line-height: 1.2; }
.result-stats span, .summary span { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); }
.result-stats b, .summary b { font-family: var(--mono); font-size: 18px; font-weight: 600; }
.score { display: flex; flex-direction: column; align-items: center; margin: 4px 0 16px; position: relative; }
.score span { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-soft); }
.score b { font-family: var(--mono); font-size: 40px; font-weight: 600; line-height: 1.1; color: var(--ink); text-shadow: 0 0 22px color-mix(in oklab, var(--accent) 45%, transparent); }
.score em { font-style: normal; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }

/* --------------------------------------------------------------- levels */
.chapters { display: grid; gap: 12px; margin-top: 4px; }
.chap {
  border: 1px solid var(--line);
  background: var(--paper-2);
  border-radius: 16px;
  padding: 12px 14px 14px;
  position: relative;
}
.chap.current { border-color: color-mix(in oklab, var(--accent) 45%, transparent); box-shadow: 0 0 0 1px color-mix(in oklab, var(--accent) 18%, transparent); }
.chap.locked { opacity: 0.6; }
.chap-head { display: flex; align-items: baseline; gap: 10px; }
.chap-num { font-family: var(--mono); font-size: 12px; color: var(--accent); letter-spacing: 0.1em; }
.chap-name { font-weight: 650; font-size: 16px; letter-spacing: 0.04em; flex: 1; }
.chap-stars { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 4px; }
.chap-stars svg, .lvl-stars svg { width: 12px; height: 12px; fill: var(--gold); stroke: none; }
.chap p { margin: 4px 0 10px; font-size: 13.5px; color: var(--ink-soft); line-height: 1.4; }
.chap .lock-note { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--ink-soft); margin: 6px 0 0; }
.chap .lock-note svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; flex: 0 0 auto; }
.lvls { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.lvl {
  appearance: none;
  border: 1px solid var(--chip-edge);
  background: var(--chip);
  color: var(--ink);
  border-radius: 10px;
  min-height: 48px;
  padding: 5px 0 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  font: 600 15px var(--mono);
  transition: transform 0.15s var(--ease), border-color 0.2s, background 0.2s;
}
.lvl:hover:not(:disabled) { border-color: color-mix(in oklab, var(--accent) 60%, transparent); }
.lvl:active:not(:disabled) { transform: scale(0.94); }
.lvl:disabled { cursor: default; }
.lvl.done { background: color-mix(in oklab, var(--accent) 9%, var(--chip)); }
.lvl.here { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 14px -2px color-mix(in oklab, var(--accent) 60%, transparent); }
.lvl-stars { display: flex; gap: 1px; height: 10px; }
.lvl-stars svg { width: 9px; height: 9px; }
.lvl-stars svg.off { fill: color-mix(in oklab, var(--ink-soft) 30%, transparent); }
.endless-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.endless-grid .lvl { font: 600 13.5px var(--sans); min-height: 56px; letter-spacing: 0.02em; }
.endless-grid .lvl small { font: 500 10.5px var(--mono); color: var(--ink-soft); letter-spacing: 0.04em; }
@media (max-width: 440px) {
  .lvls { grid-template-columns: repeat(4, 1fr); }
  .endless-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ------------------------------------------------------------- results */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.bars { display: grid; gap: 7px; }
.bar { display: grid; grid-template-columns: 1.6fr 3fr auto; gap: 10px; align-items: center; font-size: 13.5px; }
.bar i { height: 6px; border-radius: 6px; background: var(--paper-2); overflow: hidden; position: relative; border: 1px solid var(--line); }
.bar i::after { content: ""; position: absolute; inset: 0; width: var(--w); background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 6px; }
.bar b { font-family: var(--mono); font-weight: 500; font-size: 12px; color: var(--ink-soft); }
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-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; 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.col-moves, th.col-score, td.col-moves, td.col-score { text-align: right; }
td.col-score { font-family: var(--mono); font-weight: 600; }
td.col-level, td.col-moves { font-family: var(--mono); }
td.col-stars .lvl-stars { height: auto; }
td.col-stars svg { width: 12px; height: 12px; }

/* ------------------------------------------------------------- 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;
  min-height: 44px;
  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); 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; }
.swatch { display: inline-block; width: 26px; height: 26px; border-radius: 8px; flex: 0 0 auto; position: relative; overflow: hidden; background: var(--sw-bg); box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.3); }
.swatch::before { content: ""; position: absolute; left: -10%; right: -10%; top: 52%; height: 3px; transform: rotate(-28deg); background: var(--sw-a); box-shadow: 0 0 6px var(--sw-a); }
.swatch::after { content: ""; position: absolute; left: -10%; right: -10%; top: 30%; height: 2px; transform: rotate(32deg); background: var(--sw-b); box-shadow: 0 0 5px var(--sw-b); }
.toggle { display: flex; align-items: center; gap: 12px; margin-top: 16px; 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: color-mix(in oklab, var(--ink-soft) 40%, transparent); 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(86px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(10px);
  z-index: 15;
  background: var(--toast);
  color: var(--toast-ink);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  max-width: min(88vw, 420px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.3s var(--ease);
  box-shadow: 0 10px 28px var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------------- small screens */
@media (max-height: 680px) {
  .top { padding-top: 6px; }
  .brand small { display: none; }
  .brand img { width: 32px; height: 32px; }
  .stat { padding: 4px 6px 3px; }
  .stat b { font-size: 16px; min-height: 20px; }
  .actions { padding-bottom: 10px; }
  .btn { min-height: 44px; padding: 8px 8px; }
}
@media (max-width: 520px) {
  .actions { gap: 7px; padding-left: 12px; padding-right: 12px; }
  .btn { flex-direction: column; gap: 3px; padding: 7px 4px 6px; font-size: 12px; min-height: 52px; }
  .btn span { white-space: nowrap; }
  .btn svg { width: 21px; height: 21px; }
  .stats { padding-left: 12px; padding-right: 12px; gap: 6px; }
  .top { padding-left: 12px; padding-right: 10px; }
}
@media (max-width: 370px) {
  .brand b { font-size: 15px; letter-spacing: 0.12em; }
  .icon-btn { width: 40px; height: 40px; }
}
/* landscape phones: stats and actions move to the sides */
@media (orientation: landscape) and (max-height: 520px) {
  .app { max-width: none; display: grid; grid-template-columns: 200px 1fr 150px; grid-template-rows: auto 1fr; }
  .top { grid-column: 1 / 2; grid-row: 1; flex-direction: column; align-items: flex-start; gap: 8px; }
  .stats { grid-column: 1 / 2; grid-row: 2; grid-template-columns: 1fr 1fr; align-content: start; }
  .stage { grid-column: 2; grid-row: 1 / 3; }
  .actions { grid-column: 3; grid-row: 1 / 3; flex-direction: column; justify-content: center; padding: 10px 12px; }
  .btn { flex: 0 0 auto; flex-direction: row; }
}
@media (min-width: 900px) and (min-height: 720px) {
  .brand b { font-size: 19px; }
  .stage { padding: 10px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .bloom { animation: none; }
  .sheet, .dialog, .backdrop, .intro, .intro-card, .stars svg.on, .stat b.bump, .btn.primary.next { animation: none !important; }
  * { transition-duration: 0.01s !important; }
}
