@font-face {
  font-family: Nunito;
  src: url("fonts/Nunito.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #fff8e7;
  --bg-deep: #ffe9a8;
  --ink: #1a2332;
  --ink-soft: #3f4a5a;
  --sun: #ffd100;
  --sun-soft: #fff3b0;
  --red: #e31c3d;
  --red-soft: #ffd6dc;
  --sky: #1ea7e1;
  --sky-soft: #d4f0fc;
  --grass: #2e9b3d;
  --grass-soft: #d8f5dc;
  --orange: #ff7a00;
  --orange-soft: #ffe0c2;
  --card: #ffffff;
  --card-edge: #f0d59a;
  --shadow: 0 8px 24px rgba(26, 35, 50, 0.08);
  --radius: 18px;
  --font: Nunito, ui-rounded, "Arial Rounded MT Bold", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: light; overflow-x: hidden; }

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% -10%, #fff3b0 0%, transparent 50%),
    radial-gradient(800px 360px at 100% 0%, #d4f0fc 0%, transparent 45%),
    var(--bg);
  min-height: 100vh;
  line-height: 1.45;
  overflow-x: hidden;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

.skip {
  position: absolute;
  left: -999px;
  top: 0;
}
.skip:focus {
  left: 12px;
  top: 12px;
  z-index: 80;
  background: var(--card);
  padding: 8px 12px;
  border-radius: 8px;
}

/* —— header / picker —— */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 90%, white);
  backdrop-filter: blur(12px);
  border-bottom: 3px solid var(--sun);
}

.top-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 12px 12px;
}

.brand {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  margin-bottom: 10px;
  min-width: 0;
}
.logo {
  font-weight: 800;
  font-size: clamp(1.2rem, 6vw, 1.85rem);
  letter-spacing: -0.03em;
  color: var(--ink);
  margin: 0;
  line-height: 1.1;
  min-width: 0;
}
.logo span { color: var(--red); }
.suits {
  display: inline-flex;
  gap: 5px;
  font-size: 0.95rem;
  line-height: 1;
  margin-left: 2px;
}
.suits .h { color: var(--red); }
.suits .d { color: var(--orange); }
.suits .c { color: var(--grass); }
.suits .s { color: var(--sky); }
.tagline {
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 700;
  margin: 0;
}

.pickers {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.picker {
  background: var(--card);
  border: 2px solid var(--card-edge);
  border-radius: 16px;
  padding: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}
.picker label {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
}
.stepper button {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--sky);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
  display: grid;
  place-items: center;
}
.stepper button:hover { background: #1689bd; }
.stepper button:disabled {
  background: #c9c1b3;
  color: #f4efe6;
  cursor: default;
}
.stepper button:focus-visible,
.search:focus-visible,
.chip:focus-visible,
.game-card:focus-visible,
.back:focus-visible,
.linkish:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}
.stepper .mid {
  min-width: 0;
  flex: 1;
  text-align: center;
  overflow: hidden;
}
.stepper .value {
  font-size: clamp(1.35rem, 5.4vw, 2rem);
  font-weight: 800;
  line-height: 1;
}
.stepper .hint {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
  min-width: 0;
}
.search {
  flex: 1 1 180px;
  min-width: 0;
  min-height: 44px;
  border: 2px solid var(--card-edge);
  border-radius: 999px;
  padding: 8px 14px;
  background: var(--card);
}
.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 100%;
}
.chip {
  border: 2px solid var(--card-edge);
  background: var(--card);
  border-radius: 999px;
  padding: 7px 12px;
  min-height: 40px;
  font-weight: 800;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.chip[aria-pressed="true"] {
  background: #23802f;
  border-color: #23802f;
  color: #fff;
}
.chip-play {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  background: var(--red-soft);
  border-color: var(--red);
  color: var(--ink);
}
.chip-play .chip-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  display: block;
}
.chip-play:active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
@media (max-width: 380px) {
  .chip { padding: 7px 10px; font-size: 0.82rem; }
}

/* —— main —— */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 12px 80px;
  min-width: 0;
}

.summary {
  margin: 0 0 14px;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--ink-soft);
}
.summary strong { color: var(--ink); }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 24px 0 12px;
}
.section-head h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.02em;
}
.section-head .count {
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top-inner, main, footer { padding-left: 20px; padding-right: 20px; }
  .stepper button { width: 48px; height: 48px; flex-basis: 48px; }
}

.game-card {
  display: flex;
  color: inherit;
  text-decoration: none;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  background: var(--card);
  border: 2px solid var(--card-edge);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
  width: 100%;
  min-width: 0;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.game-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(26, 35, 50, 0.12);
}
.thumb {
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--sun-soft);
}
.thumb svg {
  display: block;
  width: 72px;
  height: 72px;
}
.card-body {
  min-width: 0;
  flex: 1;
}
.game-card h3 {
  font-size: 1.08rem;
  font-weight: 800;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.game-card p {
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.pill {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--sun-soft);
  color: #6a5200;
  max-width: 100%;
}
.pill.players { background: var(--sky-soft); color: #0a5a7a; }
.pill.decks { background: var(--grass-soft); color: #145a1e; }
.pill.time { background: var(--sun-soft); color: #6a5200; }
.pill.ease { background: var(--orange-soft); color: #8a3d00; }
.pill.extra { background: var(--red-soft); color: #8a1024; }

.empty {
  background: var(--card);
  border: 2px dashed var(--card-edge);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--ink-soft);
  font-weight: 700;
}

footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 12px 40px;
  color: var(--ink-soft);
  font-size: 0.86rem;
  font-weight: 600;
}

/* —— detail pane —— */
.pane {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--bg);
  overflow: auto;
}
.pane.open { display: block; }
.pane-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 16px 80px;
  min-width: 0;
}
.back {
  border: 0;
  background: transparent;
  color: var(--sky);
  font-weight: 800;
  padding: 8px 0 12px;
  font-size: 1rem;
}
.hero-art {
  width: 148px;
  height: 148px;
  border-radius: 28px;
  overflow: hidden;
  margin: 0 auto 14px;
  box-shadow: var(--shadow);
  background: var(--sun-soft);
}
.hero-art svg {
  display: block;
  width: 148px;
  height: 148px;
}
.kicker {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--orange);
  margin: 0 0 6px;
  text-align: center;
}
.pane h1, .rules h1 {
  font-size: clamp(1.8rem, 7vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
  line-height: 1.15;
  text-align: center;
}
.aka { color: var(--ink-soft); margin: 0 0 12px; text-align: center; font-weight: 700; }
.lede {
  font-size: 1.08rem;
  font-weight: 700;
  margin: 0 0 14px;
}
.pane .meta, .rules .meta { margin-bottom: 16px; justify-content: center; }
.need, .block {
  background: var(--card);
  border: 2px solid var(--card-edge);
  border-radius: 16px;
  padding: 14px 16px;
  margin: 0 0 12px;
}
.need strong, .block h2 {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0 0 8px;
}
.block ol, .block ul {
  margin: 0;
  padding-left: 1.2rem;
}
.block li { margin: 0 0 8px; font-weight: 600; }
.block li:last-child { margin-bottom: 0; }
.house {
  border-color: #f0c36a;
  background: #fff8e0;
}
.see-also { margin-top: 8px; font-weight: 700; }
.linkish {
  background: none;
  border: 0;
  padding: 0;
  color: var(--sky);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

body.locked { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .game-card { transition: none; }
}

/* —— how-to-play diagrams —— */
.fig {
  margin: 10px 0 14px;
  padding: 6px 6px 10px;
  background: #fffaf0;
  border: 2px solid var(--card-edge);
  border-radius: 14px;
  min-width: 0;
}
.diagram { display: block; width: 100%; height: auto; max-width: 100%; }
.diagram text { font-family: var(--font); font-weight: 800; }
.fig figcaption {
  margin: 6px 6px 0;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink-soft);
  text-align: center;
}
.block .fig + ol, .block .fig + ul { margin-top: 4px; }

/* —— links that look like buttons / text —— */
a.linkish { cursor: pointer; }
.page-link { font-size: 0.9rem; color: var(--ink-soft); }

/* —— Surprise me —— */
.surprise-wrap { margin: 0 0 18px; }
.surprise-wrap[hidden], .surprise[hidden] { display: none; }
.surprise {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  min-height: 72px;
  padding: 10px 18px;
  border: 3px solid var(--ink);
  border-radius: 22px;
  background: linear-gradient(135deg, var(--orange) 0%, var(--red) 100%);
  color: #fff;
  box-shadow: 0 6px 0 var(--ink);
  text-align: left;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.surprise:hover { transform: translateY(-1px); box-shadow: 0 7px 0 var(--ink); }
.surprise:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.surprise:focus-visible { outline: 4px solid var(--sky); outline-offset: 3px; }
.surprise .dice { flex: 0 0 46px; width: 46px; height: 46px; }
.surprise:hover .dice { animation: dice-wiggle 0.5s ease; }
.surprise .s-text { display: flex; flex-direction: column; min-width: 0; }
.surprise strong { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; text-shadow: 0 2px 0 rgba(26, 35, 50, 0.35); }
.surprise small { font-size: 0.86rem; font-weight: 700; opacity: 0.95; }
@keyframes dice-wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-14deg); } 75% { transform: rotate(14deg); } }
@media (min-width: 700px) { .surprise { max-width: 460px; margin: 0 auto; } }
@media (prefers-reduced-motion: reduce) { .surprise, .surprise:hover .dice { transition: none; animation: none; } }

/* —— "Add to home screen" hint —— */
.install-hint {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 12px;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 6px 0 var(--ink), 0 14px 30px rgba(26, 35, 50, 0.2);
  font-size: 0.9rem;
  line-height: 1.3;
  animation: hint-in 0.35s ease both;
}
.install-hint .ih-icon { width: 44px; height: 44px; border-radius: 11px; flex: 0 0 44px; }
.install-hint .ih-text { flex: 1; min-width: 0; font-weight: 600; color: var(--ink-soft); }
.install-hint .ih-text strong { color: var(--ink); font-weight: 800; }
.install-hint .ih-share { display: inline-block; padding: 0 7px; border-radius: 8px; background: var(--sky-soft); color: #0a5a7a; font-weight: 800; }
.install-hint .ih-btn {
  flex: 0 0 auto;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--sun);
  color: var(--ink);
  font-weight: 800;
  font-size: 1rem;
  padding: 10px 16px;
  min-height: 44px;
  box-shadow: 0 3px 0 var(--ink);
}
.install-hint .ih-close {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: #f3ecd9;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
}
.install-hint button:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
@keyframes hint-in { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .install-hint { animation: none; } }

/* —— all-games link list (homepage) —— */
.all-games { max-width: 1100px; margin: 8px auto 0; padding: 0 12px; }
.all-games h2 { font-size: 1.15rem; font-weight: 800; margin: 18px 0 4px; }
.all-games h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--orange); margin: 12px 0 6px; }
.all-games ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.all-games a, .mini-link {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--card);
  border: 2px solid var(--card-edge);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none;
}
.all-games a:hover, .mini-link:hover { background: var(--sun-soft); }
.noscript { max-width: 1100px; margin: 8px auto; padding: 0 12px; font-weight: 700; color: var(--ink-soft); }

/* —— standalone game pages (/games/<id>/) —— */
.top.simple { position: sticky; }
.simple-inner { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.logo-link { text-decoration: none; color: inherit; min-width: 0; }
.logo-link .logo { display: block; }
.home-btn, .cta-btn {
  display: inline-block;
  text-decoration: none;
  font-weight: 800;
  color: var(--ink);
  background: var(--sun);
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 9px 14px;
  box-shadow: 0 3px 0 var(--ink);
  white-space: nowrap;
}
.cta-btn { font-size: 1.1rem; padding: 12px 20px; }
.home-btn:active, .cta-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.crumbs { font-weight: 700; font-size: 0.9rem; color: var(--ink-soft); padding: 6px 0 10px; }
.crumbs a { color: var(--sky); }
.rules { padding-top: 8px; }
.cta { text-align: center; background: var(--sky-soft); border: 2px solid var(--sky); border-radius: 18px; padding: 18px 16px; margin: 18px 0 0; }
.cta h2 { margin: 0 0 6px; font-size: 1.25rem; }
.cta p { margin: 0 0 12px; font-weight: 600; color: var(--ink-soft); }
.cta .more-links { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 14px 0 0; }
body.gamepage footer { padding-top: 24px; }
body.gamepage { padding-bottom: 8px; }

/* hide the below-the-fold chrome until the game list has rendered (avoids a layout jump) */
.js body:not(.ready) footer, .js body:not(.ready) .all-games { visibility: hidden; }
.simple-inner { flex-wrap: nowrap; }
.simple-inner .logo { font-size: clamp(1.1rem, 5.2vw, 1.6rem); }
.home-btn { font-size: 0.92rem; padding: 8px 12px; flex: 0 0 auto; }

/* —— Share button, fallback menu, copied toast —— */
.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  margin: 0 auto 16px;
  min-height: 52px;
  padding: 10px 18px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: #0e6f9c;
  color: #fff;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  box-shadow: 0 4px 0 var(--ink);
  text-decoration: none;
}
.share-btn:hover { background: #0c628a; }
.share-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.share-btn:focus-visible { outline: 4px solid var(--orange); outline-offset: 3px; }
.share-btn svg { width: 26px; height: 26px; flex: 0 0 26px; }
.share-menu {
  position: fixed;
  z-index: 100;
  min-width: 220px;
  padding: 8px;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 6px 0 var(--ink), 0 14px 28px rgba(26, 35, 50, 0.18);
}
.share-opt {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.share-opt:hover, .share-opt:focus-visible { background: var(--sky-soft); outline: none; }
.share-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 110;
  padding: 12px 22px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  font-size: 1.05rem;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(26, 35, 50, 0.25);
  animation: hint-in 0.2s ease both;
}
.share-toast.out { opacity: 0; transition: opacity 0.3s ease; }
@media (prefers-reduced-motion: reduce) {
  .share-btn, .share-toast { transition: none; animation: none; }
}

/* —— Play online call-to-action (slim bar) —— */
.play-online {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 6px 6px 6px 10px;
  min-height: 56px;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(135deg, var(--red) 0%, var(--orange) 100%);
  border: 2px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 3px 0 var(--ink);
}
.play-online:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.play-online:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.po-art { flex: 0 0 auto; }
.po-art svg { width: 28px; height: 28px; display: block; }
.po-text { flex: 1 1 auto; min-width: 0; }
.po-text strong {
  display: block;
  font-size: 0.92rem;
  line-height: 1.15;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.po-text small {
  display: block;
  margin-top: 1px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.2;
  color: #fff8e7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.po-go {
  flex: 0 0 auto;
  background: var(--sun);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.82rem;
  line-height: 1;
  padding: 7px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 2px 0 var(--ink);
  white-space: nowrap;
}
.online-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; margin: 12px 0 0; padding: 12px 16px; text-decoration: none; font-weight: 900; font-size: 1.05rem;
  color: #fff; background: var(--red); border: 2.5px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 var(--ink);
}
.online-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }
.online-link { margin: 12px 0 0 !important; font-weight: 700; }
.online-link a { color: var(--red); font-weight: 900; }
@media (min-width: 700px) {
  .play-online { padding: 6px 8px 6px 12px; }
  .po-text strong { font-size: 1rem; }
  .po-go { padding: 7px 14px; font-size: 0.88rem; }
}
@media (max-width: 380px) {
  .po-text strong { font-size: 0.85rem; }
  .po-go { padding: 7px 8px; font-size: 0.78rem; }
}

/* —— Keep score button + scorecard —— */
.score-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  margin: 0 auto 16px;
  min-height: 52px;
  padding: 10px 18px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--grass);
  color: #fff;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  box-shadow: 0 4px 0 var(--ink);
}
.score-btn:hover { background: #257a32; }
.score-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.score-btn:focus-visible { outline: 4px solid var(--orange); outline-offset: 3px; }
.score-btn svg { width: 26px; height: 26px; flex: 0 0 26px; }

body.score-open { overflow: hidden; }

.score-root[hidden] { display: none !important; }
.score-root {
  position: fixed;
  inset: 0;
  z-index: 120;
}
.score-backdrop, .score-pad-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 35, 50, 0.45);
}
.score-pad-backdrop { z-index: 2; background: rgba(26, 35, 50, 0.35); }
.score-sheet {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px calc(16px + env(safe-area-inset-bottom, 0px));
}
.score-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}
.score-head-text { flex: 1; min-width: 0; }
.score-head h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.score-note {
  margin: 4px 0 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink-soft);
  line-height: 1.3;
}
.score-close {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--card);
  font-size: 1.6rem;
  line-height: 1;
  font-weight: 800;
  box-shadow: 0 2px 0 var(--ink);
}
.score-close:active { transform: translateY(2px); box-shadow: 0 0 0 var(--ink); }
.score-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
}
.score-chip {
  border: 2px solid var(--card-edge);
  background: var(--card);
  border-radius: 999px;
  padding: 7px 12px;
  min-height: 40px;
  font-weight: 800;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.score-chip[aria-pressed="true"] {
  background: #23802f;
  border-color: #23802f;
  color: #fff;
}
.score-banner {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 12px;
  padding: 12px 14px;
  background: var(--grass-soft);
  border: 2.5px solid var(--grass);
  border-radius: 16px;
  font-weight: 700;
}
.score-banner strong { font-size: 1.2rem; font-weight: 900; color: #14661f; }
.score-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 6px;
  margin: 0 0 12px;
}
.score-total {
  background: var(--card);
  border: 2px solid var(--card-edge);
  border-radius: 14px;
  padding: 8px 8px 6px;
  text-align: center;
  min-width: 0;
}
.score-total-name {
  display: block;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.score-total-name em { font-style: normal; color: var(--grass); }
.score-total-num { display: block; font-size: 1.35rem; font-weight: 900; line-height: 1.1; }
.score-total-tag {
  display: block;
  font-style: normal;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.score-total.is-winner .score-total-tag { color: #14661f; }
.score-total.is-leader, .score-table th.is-leader, .score-table td.is-leader,
.score-table tfoot td.is-leader {
  background: var(--sun);
  border-color: var(--ink);
}
.score-total.is-winner, .score-table th.is-winner, .score-table td.is-winner,
.score-table tfoot td.is-winner, .score-life.is-winner {
  background: var(--grass-soft);
  border-color: var(--grass);
}
.score-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 8px;
  max-width: 100%;
  border: 2px solid var(--card-edge);
  border-radius: 14px;
  background: var(--card);
}
.score-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: max-content;
  font-weight: 800;
}
.score-table th, .score-table td {
  padding: 0;
  text-align: center;
  border-bottom: 1px solid var(--card-edge);
  border-right: 1px solid var(--card-edge);
  font-size: 0.85rem;
}
.score-table th:last-child, .score-table td:last-child { border-right: 0; }
.score-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--sun-soft);
  padding: 8px 6px;
  min-width: 64px;
  max-width: 88px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.score-table .score-corner, .score-table tbody th, .score-table tfoot th {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--sky-soft);
  padding: 8px 8px;
  min-width: 72px;
  text-align: left;
  white-space: nowrap;
}
.score-table thead .score-corner { z-index: 3; background: var(--sky-soft); }
.score-table tfoot th, .score-table tfoot td {
  background: var(--bg-deep);
  border-bottom: 0;
  font-size: 1rem;
  padding: 8px 6px;
}
.score-cell {
  width: 100%;
  min-height: 44px;
  min-width: 56px;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--ink);
  padding: 8px 4px;
}
.score-cell:focus-visible { outline: 3px solid var(--orange); outline-offset: -3px; }
.score-text-btn, .score-new, .score-pad-save, .score-pad-moon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 14px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--card);
  font-weight: 800;
  box-shadow: 0 2px 0 var(--ink);
}
.score-text-btn:active, .score-new:active, .score-pad-save:active, .score-pad-moon:active,
.score-life-btn:active, .score-key:active, .score-icon-btn:active, .score-chip:active {
  transform: translateY(2px); box-shadow: 0 0 0 var(--ink);
}
.score-new { background: var(--orange-soft); }
.score-pad-save { background: var(--sun); font-size: 1.05rem; flex: 1; }
.score-pad-moon {
  width: 100%;
  margin: 8px 0 0;
  background: var(--sky-soft);
}
.score-footer { margin-top: 8px; }
.score-edit { margin-top: 14px; }
.score-edit summary {
  cursor: pointer;
  font-weight: 800;
  font-size: 1rem;
  padding: 10px 0;
  list-style: none;
}
.score-edit summary::-webkit-details-marker { display: none; }
.score-edit summary::after { content: " ▾"; color: var(--ink-soft); }
.score-edit[open] summary { margin-bottom: 8px; }
.score-edit-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.score-edit-row { display: flex; gap: 6px; align-items: center; }
.score-name {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border: 2px solid var(--card-edge);
  border-radius: 12px;
  padding: 8px 12px;
  background: var(--card);
  font: inherit;
  font-weight: 800;
}
.score-icon-btn {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--red-soft);
  font-size: 1.3rem;
  font-weight: 800;
  box-shadow: 0 2px 0 var(--ink);
}
.score-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.score-lives {
  display: grid;
  gap: 8px;
  margin: 4px 0 8px;
}
.score-life {
  background: var(--card);
  border: 2px solid var(--card-edge);
  border-radius: 16px;
  padding: 12px;
}
.score-life.is-out { opacity: 0.55; background: var(--red-soft); }
.score-life-name { font-weight: 800; font-size: 1.05rem; }
.score-life-name em { font-style: normal; color: var(--grass); }
.score-life.is-out .score-life-name em { color: var(--red); }
.score-life-letters { font-weight: 800; color: var(--ink-soft); margin-top: 2px; letter-spacing: 0.08em; }
.score-life-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 8px;
}
.score-life-btn {
  width: 52px;
  height: 52px;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  background: var(--sun);
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 3px 0 var(--ink);
}
.score-life-btn:disabled { background: #c9c1b3; color: #f4efe6; box-shadow: none; }
.score-life-num { font-size: 2.2rem; font-weight: 900; min-width: 1.4em; text-align: center; }
.score-pad {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  background: var(--card);
  border-top: 3px solid var(--ink);
  border-radius: 20px 20px 0 0;
  padding: 14px 14px calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 24px rgba(26, 35, 50, 0.12);
}
.score-pad-label { font-weight: 800; text-align: center; color: var(--ink-soft); }
.score-pad-value {
  font-size: 2.6rem;
  font-weight: 900;
  text-align: center;
  line-height: 1.1;
  margin: 4px 0 8px;
}
.score-pad-step { display: flex; justify-content: center; gap: 16px; margin-bottom: 8px; }
.score-keys {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.score-key {
  min-height: 48px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--bg);
  font-weight: 800;
  font-size: 1.3rem;
  box-shadow: 0 2px 0 var(--ink);
}
.score-pad-actions { display: flex; gap: 8px; margin-top: 10px; }

@media (min-width: 700px) {
  .score-sheet {
    inset: 24px auto 24px 50%;
    transform: translateX(-50%);
    width: min(720px, calc(100% - 48px));
    border: 3px solid var(--ink);
    border-radius: 22px;
    box-shadow: 0 8px 0 var(--ink);
  }
  .score-pad {
    left: 50%;
    transform: translateX(-50%);
    width: min(420px, 100%);
    border: 3px solid var(--ink);
    border-radius: 20px 20px 0 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .score-btn, .score-close, .score-text-btn, .score-new, .score-pad-save,
  .score-life-btn, .score-key, .score-icon-btn { transition: none; }
}

/* —— Tool row (Keep score + Timer side by side) and the timer —— */
.tool-row { display: flex; gap: 10px; max-width: 320px; margin: 0 auto 16px; }
.tool-row > .score-btn, .tool-row > .timer-btn {
  flex: 1 1 0; min-width: 0; width: auto; max-width: none; margin: 0;
  padding: 10px 8px; gap: 8px; font-size: 1.05rem;
}
.tool-row > .score-btn svg, .tool-row > .timer-btn svg { width: 24px; height: 24px; flex: 0 0 24px; }
.tool-row > :only-child { flex: 0 1 320px; margin: 0 auto; font-size: 1.15rem; }
.timer-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; max-width: 320px; margin: 0 auto 16px; min-height: 52px; padding: 10px 18px;
  border: 3px solid var(--ink); border-radius: 16px; background: var(--sun); color: var(--ink);
  font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; box-shadow: 0 4px 0 var(--ink);
  font-variant-numeric: tabular-nums;
}
.timer-btn:hover { background: #f2c400; }
.timer-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.timer-btn:focus-visible { outline: 4px solid var(--orange); outline-offset: 3px; }
.timer-btn svg { width: 26px; height: 26px; flex: 0 0 26px; }
.timer-btn.is-active { background: var(--grass-soft); }
.timer-btn.is-finished { background: var(--red-soft); }
.timer-btn-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

body.timer-open { overflow: hidden; }
.timer-root[hidden] { display: none !important; }
.timer-root { position: fixed; inset: 0; z-index: 130; }
.timer-backdrop { position: absolute; inset: 0; background: rgba(26, 35, 50, 0.5); }
.timer-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 520px; margin: 0 auto;
  max-height: 100%; overflow: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg); border: 3px solid var(--ink); border-bottom: 0; border-radius: 24px 24px 0 0;
  padding: 14px 14px calc(16px + env(safe-area-inset-bottom, 0px));
}
.timer-card { color: var(--ink); }
.timer-head { display: flex; align-items: flex-start; gap: 10px; }
.timer-head-text { flex: 1; min-width: 0; }
.timer-head h2 { margin: 0; font-size: 1.25rem; font-weight: 900; letter-spacing: -0.02em; }
.timer-note { margin: 2px 0 0; font-size: 0.92rem; color: var(--ink-soft); font-weight: 600; }
.timer-close {
  flex: 0 0 44px; width: 44px; height: 44px; border: 2.5px solid var(--ink); border-radius: 12px;
  background: var(--card); font-size: 1.7rem; line-height: 1; font-weight: 800; box-shadow: 0 2px 0 var(--ink);
}
.timer-close:active { transform: translateY(2px); box-shadow: none; }
.timer-display {
  margin: 12px 0 8px; padding: 14px 8px 10px; text-align: center;
  background: var(--card); border: 3px solid var(--ink); border-radius: 22px; box-shadow: 0 4px 0 var(--ink);
}
.timer-time {
  display: block; font-size: clamp(4.2rem, 24vw, 6.8rem); line-height: 1; font-weight: 900;
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--ink);
}
.timer-status { display: block; margin-top: 4px; font-weight: 800; font-size: 1rem; color: var(--ink-soft); }
.timer-card.is-running .timer-display { background: var(--grass-soft); }
.timer-card.is-running .timer-time { color: #14661f; }
.timer-card.is-low .timer-display { background: var(--orange-soft); }
.timer-card.is-low .timer-time { color: #b34700; }
.timer-card.is-finished .timer-display { background: var(--red-soft); animation: timer-pulse 0.7s ease-in-out 6; }
.timer-card.is-finished .timer-time, .timer-card.is-finished .timer-status { color: var(--red); }
.timer-card.is-finished .timer-status { font-size: 1.35rem; font-weight: 900; }
@keyframes timer-pulse { 50% { transform: scale(1.03); } }
.timer-bar { height: 12px; margin: 0 4px 12px; background: var(--card); border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; }
.timer-bar i { display: block; height: 100%; width: 100%; background: var(--grass); transition: width 0.25s linear; }
.timer-card.is-low .timer-bar i { background: var(--orange); }
.timer-card.is-finished .timer-bar i { background: var(--red); }
.timer-modes, .timer-presets, .timer-opts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.timer-chip {
  flex: 1 1 auto; min-height: 48px; padding: 8px 14px; border: 2.5px solid var(--ink); border-radius: 14px;
  background: var(--card); font-weight: 800; font-size: 1rem; box-shadow: 0 3px 0 var(--ink);
}
.timer-chip[aria-pressed="true"] { background: var(--sun); }
.timer-opts .timer-chip[aria-pressed="false"] { background: var(--red-soft); }
.timer-chip:active, .timer-small:active, .timer-go:active, .timer-reset:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.timer-adjust { display: flex; gap: 8px; margin: 0 0 12px; }
.timer-small {
  flex: 1; min-height: 44px; border: 2.5px solid var(--ink); border-radius: 12px; background: var(--sky-soft);
  font-weight: 800; font-size: 1rem; box-shadow: 0 3px 0 var(--ink);
}
.timer-small:disabled { opacity: 0.45; box-shadow: none; }
.timer-actions { display: flex; gap: 10px; margin: 0 0 12px; }
.timer-go {
  flex: 2 1 0; min-height: 68px; border: 3px solid var(--ink); border-radius: 18px; background: var(--grass); color: #fff;
  font-weight: 900; font-size: 1.6rem; letter-spacing: -0.02em; box-shadow: 0 5px 0 var(--ink);
}
.timer-card.is-running .timer-go { background: var(--orange); color: var(--ink); }
.timer-card.is-finished .timer-go { background: var(--red); }
.timer-reset {
  flex: 1 1 0; min-height: 68px; border: 3px solid var(--ink); border-radius: 18px; background: var(--card);
  font-weight: 900; font-size: 1.2rem; box-shadow: 0 5px 0 var(--ink);
}
.timer-chip:focus-visible, .timer-small:focus-visible, .timer-go:focus-visible, .timer-reset:focus-visible, .timer-close:focus-visible { outline: 4px solid var(--orange); outline-offset: 2px; }
.timer-foot { margin: 4px 0 0; text-align: center; font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); }
.timer-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.timer-toast {
  position: fixed; z-index: 140; left: 12px; right: 12px; top: calc(10px + env(safe-area-inset-top, 0px)); max-width: 420px; margin: 0 auto;
  padding: 14px 16px; border: 3px solid var(--ink); border-radius: 16px; background: var(--red); color: #fff;
  font-weight: 900; font-size: 1.1rem; box-shadow: 0 5px 0 var(--ink);
}
/* the standalone /timer/ page */
.timer-page { max-width: 520px; margin: 8px auto 0; }
.timer-page .timer-sheet-inline { background: transparent; }
@media (max-width: 380px) {
  .timer-chip { padding: 8px 10px; font-size: 0.95rem; }
}
@media (prefers-reduced-motion: reduce) {
  .timer-card.is-finished .timer-display { animation: none; }
  .timer-bar i { transition: none; }
}
.timer-link { margin: 14px 0 4px; text-align: center; font-weight: 800; }
.timer-link a { color: #0e6f9c; text-decoration: underline; text-underline-offset: 3px; }
