/* Whack-a-Mole — a hand-painted garden. Page colours live on [data-theme];
   the canvas side of each garden lives in js/themes.js. */

:root {
  --bg-a: #f4f1df;
  --bg-m: #e7eed7;
  --bg-b: #d3e2cf;
  --blob1: rgba(255, 250, 225, 0.95);
  --blob2: rgba(190, 220, 150, 0.55);
  --blob3: rgba(255, 215, 170, 0.45);
  --ink: #2f3423;
  --ink-soft: #6f7560;
  --paper: #fbf9f1;
  --paper-2: #f0ede0;
  --line: rgba(60, 60, 30, 0.12);
  --accent: #9a5a33;
  --accent-2: #c58654;
  --accent-ink: #fffaf0;
  --btn-top: #d8a56f;
  --btn-bot: #91582f;
  --btn-edge: #6f4123;
  --glow: #f6d47a;
  --star: #efb02e;
  --hot: #c4682f;
  --stat-bg: rgba(255, 255, 255, 0.45);
  --stat-border: rgba(255, 255, 255, 0.75);
  --btn-bg: rgba(255, 255, 255, 0.55);
  --btn-hover: rgba(255, 255, 255, 0.85);
  --btn-border: rgba(70, 60, 30, 0.14);
  --meter-a: #8fc35a;
  --meter-b: #e9b543;
  --backdrop: rgba(40, 45, 20, 0.34);
  --sheet-shadow: rgba(40, 45, 20, 0.25);
  --ease: cubic-bezier(0.4, 0.1, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 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: light;
}
:root[data-theme="twilight"] {
  --bg-a: #2b2f55;
  --bg-m: #232846;
  --bg-b: #172133;
  --blob1: rgba(120, 110, 210, 0.32);
  --blob2: rgba(80, 160, 140, 0.2);
  --blob3: rgba(240, 160, 110, 0.16);
  --ink: #f1ecdf;
  --ink-soft: #aeb0c6;
  --paper: #262b48;
  --paper-2: #30365a;
  --line: rgba(255, 255, 255, 0.11);
  --accent: #e2a65a;
  --accent-2: #f1c27f;
  --accent-ink: #2a1d10;
  --btn-top: #f3c97f;
  --btn-bot: #cf8a3e;
  --btn-edge: #9a5f24;
  --glow: #f3c97f;
  --star: #ffcf5c;
  --hot: #f0b45f;
  --stat-bg: rgba(255, 255, 255, 0.065);
  --stat-border: rgba(255, 255, 255, 0.1);
  --btn-bg: rgba(255, 255, 255, 0.07);
  --btn-hover: rgba(255, 255, 255, 0.13);
  --btn-border: rgba(255, 255, 255, 0.13);
  --meter-a: #6fb59a;
  --meter-b: #f3c97f;
  --backdrop: rgba(5, 6, 20, 0.55);
  --sheet-shadow: rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}
:root[data-theme="winter"] {
  --bg-a: #eef3f8;
  --bg-m: #e2e9f2;
  --bg-b: #cfdbe8;
  --blob1: rgba(255, 255, 255, 0.95);
  --blob2: rgba(180, 205, 235, 0.55);
  --blob3: rgba(230, 200, 210, 0.35);
  --ink: #26303f;
  --ink-soft: #6a7689;
  --paper: #fbfcfe;
  --paper-2: #edf1f6;
  --line: rgba(40, 60, 90, 0.12);
  --accent: #b1433b;
  --accent-2: #d06a5d;
  --accent-ink: #fff8f6;
  --btn-top: #d9675a;
  --btn-bot: #9c3530;
  --btn-edge: #7a2723;
  --glow: #ffd1c7;
  --star: #e9a92c;
  --hot: #b1433b;
  --btn-border: rgba(40, 60, 90, 0.13);
  --meter-a: #8fb3d9;
  --meter-b: #e9a92c;
  --backdrop: rgba(30, 40, 60, 0.32);
  --sheet-shadow: rgba(30, 40, 60, 0.22);
}

* { 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(172deg, var(--bg-a) 0%, var(--bg-m) 50%, var(--bg-b) 100%);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  transition: background 0.8s, color 0.4s;
}

/* ---------------------------------------------------------- background */
.bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
.bg .blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.8;
  will-change: transform;
  transition: background 0.8s;
}
.bg .b1 { width: 62vmax; height: 62vmax; left: -22vmax; top: -26vmax; background: var(--blob1); animation: drift 54s ease-in-out infinite alternate; }
.bg .b2 { width: 52vmax; height: 52vmax; right: -22vmax; bottom: -20vmax; background: var(--blob2); animation: drift 66s ease-in-out infinite alternate-reverse; }
.bg .b3 { width: 42vmax; height: 42vmax; left: 28vw; bottom: -26vmax; background: var(--blob3); 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); }
}
.bg .stars {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.8s;
  background-image:
    radial-gradient(1.2px 1.2px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 27% 62%, #fff 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 41% 9%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 58% 33%, #fff 50%, transparent 51%),
    radial-gradient(1.3px 1.3px at 72% 14%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 86% 48%, #fff 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 93% 8%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 82%, #fff 50%, transparent 51%),
    radial-gradient(1.1px 1.1px at 35% 88%, #fff 50%, transparent 51%),
    radial-gradient(1.3px 1.3px at 80% 92%, #fff 50%, transparent 51%);
}
:root[data-theme="twilight"] .bg .stars { opacity: 0.5; animation: twinkle 7s ease-in-out infinite alternate; }
@keyframes twinkle { to { opacity: 0.28; } }

/* -------------------------------------------------------------- layout */
.app {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  max-width: 980px;
  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, .stats, .meter, .actions { width: 100%; max-width: 640px; margin-left: auto; margin-right: auto; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px 4px;
}
.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(50, 40, 20, 0.25)); }
.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: 22px; letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { font-size: 11.5px; color: var(--ink-soft); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px; 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(--ink);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.icon-btn:hover { background: color-mix(in oklab, var(--ink) 8%, transparent); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg, .btn 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 4px;
}
.stat {
  background: var(--stat-bg);
  border: 1px solid var(--stat-border);
  box-shadow: 0 1px 2px rgba(50, 45, 20, 0.06);
  border-radius: 12px;
  padding: 5px 6px;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
  min-width: 0;
  transition: background 0.3s, border-color 0.3s, color 0.3s;
}
.stat span { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stat b { font-family: var(--serif); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; display: inline-flex; align-items: baseline; gap: 4px; }
.stat b small { font-family: var(--sans); font-size: 11px; font-weight: 500; color: var(--ink-soft); }
.stat.hot { border-color: color-mix(in oklab, var(--hot) 45%, transparent); }
.stat.hot b { color: var(--hot); }
.stat.low b { color: var(--hot); }
#st-score.bump { animation: bump 0.28s var(--spring); }
.stat.pulse { animation: pulse 0.6s var(--ease); }
@keyframes bump { 40% { transform: scale(1.14); } }
@keyframes pulse { 30% { transform: scale(1.07); box-shadow: 0 0 0 3px color-mix(in oklab, var(--hot) 35%, transparent); } }

/* star meter */
.meter { --ml: 16px; --mr: 16px; position: relative; height: 20px; margin: 2px auto 0; }
.meter-track {
  position: absolute;
  left: var(--ml);
  right: var(--mr);
  top: 8px;
  height: 5px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--ink) 10%, transparent);
  overflow: hidden;
}
.meter-fill {
  position: absolute;
  inset: 0;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--meter-a), var(--meter-b));
  border-radius: inherit;
  transition: transform 0.35s var(--ease);
}
.meter-star {
  position: absolute;
  top: 1px;
  width: 18px;
  height: 18px;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
}
.meter-star svg { width: 15px; height: 15px; fill: var(--paper); stroke: color-mix(in oklab, var(--ink) 30%, transparent); stroke-width: 1.4; transition: fill 0.3s, transform 0.3s var(--spring); }
.meter-star.on svg { fill: var(--star); stroke: color-mix(in oklab, var(--star) 60%, #6b4300); transform: scale(1.22); filter: drop-shadow(0 0 4px color-mix(in oklab, var(--star) 60%, transparent)); }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0 4px;
}
#garden {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  touch-action: none;
  outline: none;
  cursor: pointer;
}

/* the card over the garden: stage intro, pause */
.card {
  position: absolute;
  left: 50%;
  top: var(--cy, 50%);
  transform: translate(-50%, -50%);
  width: min(calc(100% - 40px), 340px);
  background: color-mix(in oklab, var(--paper) 94%, transparent);
  border: 1px solid color-mix(in oklab, var(--ink) 8%, transparent);
  border-radius: 22px;
  padding: 16px 18px 14px;
  text-align: center;
  box-shadow: 0 18px 50px -12px rgba(30, 30, 10, 0.45), 0 2px 6px rgba(30, 30, 10, 0.12);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: card-in 0.38s var(--ease);
  z-index: 2;
}
@keyframes card-in { from { opacity: 0; transform: translate(-50%, -46%) scale(0.97); } }
.card-kicker { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.card h2 { font-family: var(--serif); font-weight: 600; font-size: 25px; margin: 2px 0 8px; line-height: 1.15; }
.card-intro { display: flex; align-items: center; gap: 12px; text-align: left; margin: 0 0 10px; }
.card[data-kind="paused"] .card-intro { justify-content: center; text-align: center; }
.card-intro p { margin: 0; font-size: 14.5px; line-height: 1.42; color: var(--ink); }
.card-art { display: flex; flex: 0 0 auto; }
.card-art canvas + canvas { margin-left: -16px; }
.portrait { display: block; flex: 0 0 auto; }
.goals { display: flex; justify-content: center; gap: 6px; margin-bottom: 12px; }
.goal {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px 4px 7px;
  border-radius: 999px;
  background: var(--paper-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}
.goal b { font-weight: 600; }
.goal-stars { display: inline-flex; }
.goal-stars svg { width: 12px; height: 12px; fill: color-mix(in oklab, var(--ink-soft) 45%, transparent); }
.goal.on { color: var(--ink); background: color-mix(in oklab, var(--star) 22%, var(--paper)); }
.goal.on .goal-stars svg { fill: var(--star); }
.card-go { width: 100%; font-size: 16px; padding: 12px; }
.card-hint { margin: 8px 0 0; font-size: 12px; color: var(--ink-soft); min-height: 0; }
.card-hint:empty { display: none; }

/* ---------------------------------------------------------- the actions */
.actions {
  display: flex;
  gap: 10px;
  padding: 6px 16px 14px;
}
.btn {
  appearance: none;
  flex: 1;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--ink);
  font: 500 15px var(--sans);
  padding: 11px 12px;
  min-height: 46px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(50, 45, 20, 0.08);
  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:hover { background: var(--btn-hover); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.btn.primary {
  background: linear-gradient(180deg, var(--btn-top), var(--btn-bot));
  color: var(--accent-ink);
  border-color: var(--btn-edge);
  box-shadow: 0 4px 12px -4px color-mix(in oklab, var(--btn-bot) 70%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.22);
}
:root[data-theme="twilight"] .btn.primary { text-shadow: none; }
.btn.primary:hover { filter: brightness(1.06); }
.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; }
.btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* -------------------------------------------------------- sheets, dialogs */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--backdrop);
  backdrop-filter: blur(3px);
  -webkit-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: 560px;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 40px var(--sheet-shadow);
  padding-bottom: env(safe-area-inset-bottom);
  animation: rise 0.32s var(--ease);
}
@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-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;
  -webkit-user-select: text;
  user-select: text;
}
.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: 5px 0; }
.muted { color: var(--ink-soft); }
.about { font-size: 13px; margin-top: 22px; text-align: center; }

@media (min-width: 700px) and (min-height: 560px) {
  .sheet {
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 24px;
    max-height: 82dvh;
    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(calc(100vw - 28px), 400px);
  background: var(--paper);
  color: var(--ink);
  border-radius: 24px;
  padding: 24px 22px 20px;
  box-shadow: 0 20px 60px var(--sheet-shadow);
  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; }
.result { overflow: hidden; }
.result .glow {
  position: absolute;
  inset: -40% -20% auto;
  height: 70%;
  background: radial-gradient(ellipse at 50% 40%, color-mix(in oklab, var(--glow) 55%, transparent), transparent 65%);
  pointer-events: none;
  opacity: 0.85;
}
.result[data-stars="0"] .glow { opacity: 0.3; }
.result h2 { position: relative; font-size: 27px; line-height: 1.2; }
.result p { position: relative; margin-bottom: 14px; }
.result-stars { position: relative; display: flex; justify-content: center; gap: 6px; margin: -4px 0 8px; }
.result-stars svg {
  width: 44px;
  height: 44px;
  fill: color-mix(in oklab, var(--ink-soft) 22%, transparent);
  animation: star-in 0.5s var(--spring) both;
}
.result-stars svg:nth-child(2) { width: 54px; height: 54px; margin-top: -8px; }
.result-stars svg.on {
  fill: var(--star);
  filter: drop-shadow(0 2px 3px rgba(160, 100, 0, 0.3)) drop-shadow(0 0 10px color-mix(in oklab, var(--star) 55%, transparent));
}
@keyframes star-in { from { opacity: 0; transform: scale(0.3) rotate(-25deg); } }
.result-stats {
  position: relative;
  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: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.final-score { display: flex; flex-direction: column; align-items: center; margin: 2px 0 16px; }
.final-score span { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.final-score b { font-family: var(--serif); font-size: 44px; font-weight: 600; line-height: 1.05; font-variant-numeric: tabular-nums; }
.final-score small { font-size: 13px; color: var(--ink-soft); min-height: 1em; margin-top: 2px; }

/* -------------------------------------------------------------- stages */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.mode-card {
  appearance: none;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 16px;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  transition: border-color 0.2s, background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.mode-card:active { transform: scale(0.985); }
.mode-card[aria-checked="true"] { border-color: var(--accent); background: var(--paper); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 20%, transparent); }
.mode-dot { flex: 0 0 auto; width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; background: #8fc35a; box-shadow: 0 0 0 3px color-mix(in oklab, #8fc35a 25%, transparent); }
.mode-dot.frenzy { background: #e0763a; box-shadow: 0 0 0 3px color-mix(in oklab, #e0763a 25%, transparent); }
.mode-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.mode-text b { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.mode-text small { font-size: 12.5px; color: var(--ink-soft); }
.mode-text em { font-style: normal; font-size: 12px; color: var(--accent); margin-top: 3px; font-weight: 600; }
.stage-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stage-tile {
  appearance: none;
  position: relative;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 16px;
  padding: 10px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  font: inherit;
  min-height: 112px;
  transition: transform 0.15s, border-color 0.2s, background 0.2s;
}
.stage-tile:active { transform: scale(0.97); }
.stage-tile .num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 600 17px var(--serif);
  color: var(--accent-ink);
  background: radial-gradient(circle at 35% 30%, var(--btn-top), var(--btn-bot));
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(40, 30, 10, 0.3);
}
.stage-tile .name { font-size: 12.5px; line-height: 1.25; text-align: center; min-height: 2.5em; display: flex; align-items: center; color: var(--ink); }
.stage-tile .best { font-size: 11.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; min-height: 1.2em; }
.stage-tile.current { border-color: var(--accent); background: var(--paper); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent); }
.stage-tile:disabled { cursor: default; opacity: 0.55; }
.stage-tile:disabled .num { background: color-mix(in oklab, var(--ink-soft) 25%, var(--paper-2)); box-shadow: none; }
.stage-tile .lock { width: 17px; height: 17px; fill: none; stroke: var(--ink-soft); stroke-width: 1.8; stroke-linecap: round; }
.mini-stars { display: inline-flex; gap: 1px; }
.mini-stars svg { width: 13px; height: 13px; fill: color-mix(in oklab, var(--ink-soft) 28%, transparent); }
.mini-stars svg.on { fill: var(--star); }

/* -------------------------------------------------------------- rules */
.who { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.who.spare { grid-template-columns: repeat(3, 1fr); }
.who-item { display: flex; flex-direction: column; align-items: center; text-align: center; background: var(--paper-2); border-radius: 14px; padding: 8px 4px 9px; line-height: 1.25; }
.who.spare .who-item { background: color-mix(in oklab, #8fc35a 14%, var(--paper-2)); }
.who-item b { font-size: 13px; font-weight: 600; margin-top: 2px; }
.who-item small { font-size: 11.5px; color: var(--ink-soft); }

/* ------------------------------------------------------------- results */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.results-table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.results-table 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); }
.results-table td { padding: 7px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.results-table .col-score, .results-table .col-moles { text-align: right; }
.results-table td.col-score { font-family: var(--serif); font-weight: 600; font-size: 15px; }
.results-table .tag { font-style: normal; font-size: 10.5px; margin-left: 6px; padding: 1px 6px; border-radius: 999px; background: color-mix(in oklab, #e0763a 18%, transparent); color: color-mix(in oklab, #e0763a 70%, var(--ink)); }
.per-stage td.col-stage { white-space: normal; }
.per-stage td.col-stage b { font-family: var(--serif); margin-right: 2px; }
.per-stage td.col-mode { white-space: nowrap; }
.per-stage td.col-mode .num { margin-left: 6px; font-family: var(--serif); font-weight: 600; }
@media (max-width: 420px) { .results-table .col-moles { display: none; } .results-table 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: 6px 14px 6px 6px;
  min-height: 44px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  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: var(--paper); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 20%, transparent); }
.opts.lang .opt { padding-left: 14px; min-width: 96px; justify-content: center; }
.swatch { display: inline-grid; place-items: end center; width: 36px; height: 32px; border-radius: 10px; flex: 0 0 auto; overflow: hidden; }
.swatch canvas { display: block; margin-bottom: -3px; }
.sw-meadow { background: linear-gradient(170deg, #c8e08e, #79b04b); }
.sw-twilight { background: linear-gradient(170deg, #557f6a, #24433d); }
.sw-winter { background: linear-gradient(170deg, #ffffff, #d3dfeb); }
.sw-auto { background: linear-gradient(135deg, #c8e08e 0 50%, #2f5246 50% 100%); }
.toggle { display: flex; align-items: center; gap: 12px; margin-top: 16px; cursor: pointer; font-size: 15px; line-height: 1.35; min-height: 44px; }
.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%, var(--paper-2)); 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: color-mix(in oklab, var(--ink) 90%, transparent);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  max-width: min(90vw, 440px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s var(--ease);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------------- small screens */
@media (max-height: 700px) {
  .top { padding-top: 6px; padding-bottom: 2px; }
  .brand small { display: none; }
  .brand b { font-size: 20px; }
  .brand img { width: 34px; height: 34px; }
  .stat { min-height: 42px; padding: 3px 6px; }
  .stat b { font-size: 18px; }
  .actions { padding-bottom: 10px; }
  .btn { padding: 8px 10px; min-height: 44px; }
  .card { padding: 12px 14px 12px; }
  .card h2 { font-size: 22px; margin-bottom: 6px; }
}
@media (max-width: 520px) {
  .btn { font-size: 14px; padding: 9px 8px; gap: 6px; }
}
@media (max-width: 400px) {
  .meter { --ml: 12px; --mr: 12px; }
  .brand { gap: 8px; }
  .brand img { width: 34px; height: 34px; }
  .brand b { font-size: 19px; }
  .brand small { font-size: 10.5px; letter-spacing: 0.06em; }
  .menu .icon-btn { width: 42px; }
  .stats { gap: 6px; padding-left: 12px; padding-right: 12px; }
  .stat span { letter-spacing: 0.03em; font-size: 10px; }
  .actions { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .card-intro p { font-size: 13.5px; }
  .who { grid-template-columns: repeat(2, 1fr); }
  .who.spare { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 360px) {
  .top { padding-left: 12px; padding-right: 8px; }
  .btn svg { display: none; }
}
@media (min-width: 900px) and (min-height: 760px) {
  .brand b { font-size: 26px; }
}

/* Landscape phones: the garden takes the height, the rest moves to a side column. */
@media (orientation: landscape) and (max-height: 560px) {
  .app {
    max-width: none;
    display: grid;
    grid-template-columns: minmax(250px, 330px) minmax(0, 1fr);
    grid-template-rows: auto auto auto 1fr auto;
    column-gap: 4px;
  }
  .brand { gap: 7px; }
  .brand b { font-size: 17px; }
  .brand img { width: 30px; height: 30px; }
  .brand small { display: none; }
  .menu .icon-btn { width: 40px; height: 40px; }
  .top { grid-column: 1; grid-row: 1; padding: 8px 2px 2px 10px; }
  .stats { grid-column: 1; grid-row: 2; grid-template-columns: repeat(2, 1fr); padding: 4px 4px 4px 10px; }
  .meter { grid-column: 1; grid-row: 3; --ml: 10px; --mr: 4px; }
  .stage { grid-column: 2; grid-row: 1 / 6; margin: 0; }
  .actions { grid-column: 1; grid-row: 5; padding: 4px 4px 10px 10px; flex-wrap: wrap; }
  .actions .btn { flex: 1 1 40%; }
  .actions .btn.primary { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .bg .blob, .bg .stars { animation: none; }
  .sheet, .dialog, .backdrop, .card, .result-stars svg, .stat, #st-score { animation: none !important; transition-duration: 0.01s; }
  .meter-fill { transition: none; }
}
