/* Frog Crossing — a painted village. Page colours live on [data-theme];
   the canvas side of each look lives in js/themes.js. */

:root {
  --bg-a: #f6efd9;
  --bg-m: #ede5c8;
  --bg-b: #dfe1bf;
  --blob1: rgba(255, 243, 200, 0.95);
  --blob2: rgba(170, 210, 135, 0.45);
  --blob3: rgba(242, 190, 115, 0.42);
  --ink: #33301f;
  --ink-soft: #77705a;
  --paper: #fcf8ee;
  --paper-2: #f2ecdb;
  --line: rgba(60, 50, 20, 0.12);
  --accent: #4f8c35;
  --accent-ink: #fbfff2;
  --btn-top: #82bf57;
  --btn-bot: #4b8b34;
  --btn-edge: #3a6f28;
  --glow: #f6d47a;
  --gold: #e7a92a;
  --hot: #c4552f;
  --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: #8cc35a;
  --meter-b: #e9b543;
  --frog: #5ca93f;
  --backdrop: rgba(45, 40, 15, 0.34);
  --sheet-shadow: rgba(45, 40, 15, 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="dusk"] {
  --bg-a: #2b2f55;
  --bg-m: #232846;
  --bg-b: #172031;
  --blob1: rgba(125, 110, 210, 0.3);
  --blob2: rgba(80, 160, 140, 0.2);
  --blob3: rgba(240, 150, 100, 0.17);
  --ink: #f2ecdc;
  --ink-soft: #abb0c7;
  --paper: #252a47;
  --paper-2: #30365a;
  --line: rgba(255, 255, 255, 0.11);
  --accent: #e2a65a;
  --accent-ink: #2a1d10;
  --btn-top: #f3c97f;
  --btn-bot: #cf8a3e;
  --btn-edge: #9a5f24;
  --glow: #f3c97f;
  --gold: #ffcf5c;
  --hot: #f0a35f;
  --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: #7fc39a;
  --meter-b: #f3c97f;
  --frog: #8fcf6a;
  --backdrop: rgba(5, 6, 20, 0.55);
  --sheet-shadow: rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}
:root[data-theme="autumn"] {
  --bg-a: #f5eadb;
  --bg-m: #eddcc3;
  --bg-b: #e2cdae;
  --blob1: rgba(255, 238, 205, 0.95);
  --blob2: rgba(225, 160, 90, 0.38);
  --blob3: rgba(190, 120, 70, 0.3);
  --ink: #3a2c1f;
  --ink-soft: #7d6a55;
  --paper: #fcf6ec;
  --paper-2: #f3e7d4;
  --line: rgba(70, 45, 20, 0.12);
  --accent: #b5582c;
  --accent-ink: #fff8f0;
  --btn-top: #dc8b4b;
  --btn-bot: #a9502a;
  --btn-edge: #85391b;
  --glow: #ffd3a0;
  --gold: #e09a2c;
  --hot: #b5452c;
  --btn-border: rgba(80, 50, 20, 0.15);
  --meter-a: #c9a24f;
  --meter-b: #dc7f3f;
  --frog: #5ca33f;
  --backdrop: rgba(50, 30, 15, 0.34);
  --sheet-shadow: rgba(50, 30, 15, 0.25);
}

* { 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="dusk"] .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: 560px; 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: center; gap: 4px; }
.stat b em { font-style: normal; }
.frog-ico { width: 19px; height: 19px; color: var(--frog); --eye: var(--paper); filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.15)); }
.bump { animation: bump 0.32s var(--spring); }
.stat.pulse { animation: pulse 0.7s var(--ease); }
.stat.gain { animation: gain 0.8s var(--ease); }
@keyframes bump { 40% { transform: scale(1.14); } }
@keyframes pulse { 30% { transform: scale(0.94); box-shadow: 0 0 0 3px color-mix(in oklab, var(--hot) 35%, transparent); } }
@keyframes gain { 30% { transform: scale(1.08); box-shadow: 0 0 0 3px color-mix(in oklab, var(--frog) 40%, transparent); } }

/* time for the current frog */
.meter { display: flex; align-items: center; gap: 6px; height: 14px; margin: 3px auto 1px; padding: 0 18px; }
.meter-ico { width: 13px; height: 13px; flex: 0 0 auto; fill: none; stroke: var(--ink-soft); stroke-width: 2; stroke-linecap: round; }
.meter-track {
  position: relative;
  flex: 1;
  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(1);
  background: linear-gradient(90deg, var(--meter-b), var(--meter-a));
  border-radius: inherit;
  transition: background 0.4s;
}
.meter.calm .meter-fill { opacity: 0.55; }
.meter.low .meter-fill { background: linear-gradient(90deg, var(--hot), color-mix(in oklab, var(--hot) 60%, var(--meter-b))); }

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

/* round messages and the countdown, over the board */
.banner {
  position: absolute;
  left: 50%;
  top: var(--by, 50%);
  transform: translate(-50%, -50%) scale(0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 22px 11px;
  border-radius: 18px;
  background: color-mix(in oklab, var(--paper) 90%, transparent);
  box-shadow: 0 14px 40px -12px rgba(30, 30, 10, 0.5), 0 2px 6px rgba(30, 30, 10, 0.12);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s var(--ease), transform 0.36s var(--spring);
  z-index: 2;
  white-space: nowrap;
  max-width: calc(100% - 24px);
}
.banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.banner b { font-family: var(--serif); font-weight: 600; font-size: 24px; line-height: 1.15; }
.banner small { font-size: 13px; color: var(--ink-soft); }
.banner small:empty { display: none; }
.banner.count { padding: 6px 26px 8px; border-radius: 999px; }
.banner.count b { font-size: 40px; font-variant-numeric: tabular-nums; }

/* the card over the board: start, pause */
.card {
  position: absolute;
  left: 50%;
  top: var(--cy, 50%);
  transform: translate(-50%, -50%);
  width: min(calc(100% - 36px), 340px);
  max-height: calc(100% - 16px);
  overflow: auto;
  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: 3;
}
@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 12px; }
.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); }
.portrait { display: block; flex: 0 0 auto; }
.card-extra:empty { display: none; }
.card-extra { margin: 0 0 12px; }
.chips { display: flex; gap: 4px; padding: 3px; border-radius: 999px; background: var(--paper-2); }
.chip {
  appearance: none;
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: 500 13.5px var(--sans);
  min-height: 36px;
  padding: 6px 6px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}
.chip[aria-checked="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(40, 30, 10, 0.18); }
.card-best { margin-top: 8px; font-size: 12.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.card-best:empty { display: none; }
.card-go { width: 100%; font-size: 16px; padding: 12px; }
.card-hint { margin: 9px 0 0; font-size: 12px; line-height: 1.4; color: var(--ink-soft); }
.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;
  min-width: 0;
}
.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="dusk"] .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);
  max-height: calc(100dvh - 24px);
  overflow: auto;
  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 auto; }
.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-tier="0"] .glow { opacity: 0.35; }
.result h2 { position: relative; font-size: 27px; line-height: 1.2; }
.result p { position: relative; margin-bottom: 14px; }
.result-art { position: relative; display: flex; justify-content: center; margin: -6px 0 4px; }
.result-art .portrait { animation: hop-in 0.7s var(--spring) both; }
@keyframes hop-in { 0% { opacity: 0; transform: translateY(18px) scale(0.7); } 60% { opacity: 1; transform: translateY(-6px) scale(1.04, 0.96); } }
.result-stats {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.result-stats span { white-space: normal; line-height: 1.25; min-height: 2.5em; display: flex; align-items: center; justify-content: center; text-align: center; }
.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 { position: relative; 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; }
.final-score small.new { color: var(--accent); font-weight: 600; }

/* --------------------------------------------------------------- pace */
.paces { display: grid; gap: 8px; margin-top: 4px; }
.pace-card {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 16px;
  padding: 11px 14px;
  cursor: pointer;
  font: inherit;
  transition: border-color 0.2s, background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.pace-card:active { transform: scale(0.985); }
.pace-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); }
.pace-dots { display: flex; gap: 3px; flex: 0 0 auto; }
.pace-dots i { width: 8px; height: 8px; border-radius: 50%; background: color-mix(in oklab, var(--ink-soft) 30%, transparent); }
.pace-dots i.on { background: var(--accent); }
.pace-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; flex: 1; }
.pace-text b { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.pace-text small { font-size: 12.5px; color: var(--ink-soft); }
.pace-best { font: 600 15px var(--serif); font-variant-numeric: tabular-nums; color: var(--ink-soft); flex: 0 0 auto; }

/* ------------------------------------------------------------- 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-homes, .results-table .col-round, .results-table .col-games, .results-table .col-rounds, .results-table .col-best { text-align: right; }
.results-table td.col-score { font-family: var(--serif); font-weight: 600; font-size: 15px; }
.tag { font-style: normal; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: color-mix(in oklab, var(--accent) 16%, transparent); color: color-mix(in oklab, var(--accent) 75%, var(--ink)); }
.tag.hasty { background: color-mix(in oklab, var(--hot) 16%, transparent); color: color-mix(in oklab, var(--hot) 75%, var(--ink)); }
.tag.normal { background: color-mix(in oklab, var(--gold) 20%, transparent); color: color-mix(in oklab, var(--gold) 55%, var(--ink)); }
@media (max-width: 420px) { .results-table .col-homes { 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, .opts.plain .opt { padding-left: 14px; min-width: 96px; justify-content: center; }
.swatch { display: inline-grid; place-items: center; width: 36px; height: 32px; border-radius: 10px; flex: 0 0 auto; overflow: hidden; position: relative; }
.swatch .portrait { position: relative; }
.sw-summer { background: linear-gradient(180deg, #9ac2b0 0 46%, #c9d283 46% 54%, #8e8a84 54% 100%); }
.sw-dusk { background: linear-gradient(180deg, #2e566a 0 46%, #4f6350 46% 54%, #474a5b 54% 100%); }
.sw-autumn { background: linear-gradient(180deg, #7f9e98 0 46%, #c4b472 46% 54%, #85827d 54% 100%); }
.sw-auto { background: linear-gradient(135deg, #9ac2b0 0 50%, #2e566a 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; }

/* -------------------------------------------------------------- rules */
.legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 6px; }
.legend div { 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; }
.legend b { font-size: 12.5px; font-weight: 600; margin-top: 4px; }
.legend small { font-size: 11.5px; color: var(--ink-soft); }
.legend canvas { display: block; }

/* ---------------------------------------------------------------- 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) {
  .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; }
  .meter { padding: 0 14px; }
  .actions { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .card-intro p { font-size: 13.5px; }
  .chip { font-size: 12.5px; }
}
@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 board 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; padding: 0 4px 0 12px; }
  .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, .stat, .bump, .result-art .portrait { animation: none !important; transition-duration: 0.01s; }
  .banner { transition-duration: 0.01s; }
}
