@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 —— */
.play-online {
  display: grid; grid-template-columns: 64px 1fr; gap: 6px 14px; align-items: center;
  margin: 4px 0 18px; padding: 14px 16px; text-decoration: none; color: #fff;
  background: linear-gradient(135deg, var(--red) 0%, var(--orange) 100%);
  border: 3px solid var(--ink); border-radius: 22px; box-shadow: 0 6px 0 var(--ink);
}
.play-online:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--ink); }
.play-online:focus-visible { outline: 4px solid var(--sky); outline-offset: 3px; }
.po-art svg { width: 64px; height: 64px; display: block; }
.po-text strong { display: block; font-size: 1.45rem; line-height: 1.1; font-weight: 900; text-shadow: 0 2px 0 rgba(26,35,50,.25); }
.po-text small { display: block; margin-top: 4px; font-size: .95rem; font-weight: 700; line-height: 1.3; color: #fff8e7; }
.po-go {
  grid-column: 1 / -1; text-align: center; background: var(--sun); color: var(--ink); font-weight: 900; font-size: 1.2rem;
  padding: 10px; border: 2.5px solid var(--ink); border-radius: 14px; box-shadow: 0 3px 0 var(--ink);
}
.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 { grid-template-columns: 72px 1fr auto; }
  .po-go { grid-column: auto; padding: 12px 22px; }
}
