:root {
  --bg: #e8e7e3;
  --bg-2: #d9d8d4;
  --panel: #ffffff;
  --ink: #21201c;
  --muted: #6d6c6a;
  --line: #d4d3d0;
  --accent: #81b64c;
  --accent-ink: #ffffff;
  --light: #eeeed2;
  --dark: #769656;
  --sel: #bbca44;
  --hint: rgba(0, 0, 0, 0.22);
  --last: rgba(246, 246, 105, 0.72);
  --check: rgba(235, 97, 80, 0.55);
  --shadow: 0 12px 32px rgba(33, 32, 28, 0.1);
  --nav: rgba(255, 255, 255, 0.94);
  --ok: #81b64c;
  --danger: #df5536;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body {
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  font-weight: 600;
  line-height: 1.5;
}
h1, h2, h3, .logo, .hero h1 {
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  font-weight: 800;
  letter-spacing: -0.03em;
}
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
button, input { font: inherit; }
button {
  appearance: none; border: 0; cursor: pointer;
  border-radius: 8px; padding: 12px 18px; font-weight: 800;
  background: var(--accent); color: var(--accent-ink);
}
button.ghost {
  background: transparent; color: var(--ink);
  border: 1.5px solid var(--line);
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
.wrap { width: min(1120px, calc(100% - 28px)); margin: 0 auto; }
.site-header {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(16px);
  background: var(--nav);
  border-bottom: 1px solid var(--line);
}
.nav {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 1.25rem; }
.logo img { width: 34px; height: 34px; }
.nav-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.icon-btn {
  width: 42px; height: 42px; padding: 0; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
}
.hero {
  display: grid; gap: 28px; padding: 42px 0 28px;
  grid-template-columns: 1fr;
}
.kicker { color: var(--accent); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.16em; margin: 0 0 10px; }
.hero h1 { font-size: clamp(2.4rem, 6vw, 4.4rem); line-height: 0.95; margin: 0 0 14px; }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 38rem; font-weight: 500; }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.mini-board {
  background: var(--panel); border: 1px solid var(--line); border-radius: 24px;
  padding: 16px; box-shadow: var(--shadow);
}
.mini-grid {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 0;
  overflow: hidden; border-radius: 12px;
}
.mini-grid span { aspect-ratio: 1; display: grid; place-items: center; }
.mini-grid span svg { width: 78%; height: 78%; }
.section { padding: 42px 0; }
.section h2 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0 0 8px; }
.muted { color: var(--muted); font-weight: 500; }
.cards { display: grid; gap: 14px; grid-template-columns: 1fr; margin-top: 18px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 18px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 6px; font-size: 1.2rem; }
.setup { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  background: var(--bg-2); border-radius: 999px; padding: 8px 12px; font-size: 0.92rem;
}
.faq details {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 16px; margin-top: 10px;
}
.faq summary { cursor: pointer; font-weight: 700; }
.credit-bar {
  text-align: center;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 8px 0;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.credit-bar a, .site-footer a, .faq a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.site-footer .credit-bar { border-bottom: 0; border-top: 0; padding: 0 0 10px; }
.prose { max-width: 42rem; }
.prose p { color: var(--muted); font-weight: 500; margin: 0 0 12px; }
.faq p { margin: 8px 0 0; }
.game-shell {
  padding: 16px 0 48px;
}
.table-bg {
  background:
    radial-gradient(1200px 400px at 50% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent),
    var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 16px;
}
.topbar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.22em; color: var(--accent); font-size: 1.15rem;
}
.status { color: var(--muted); font-weight: 500; }
.players { display: grid; gap: 10px; grid-template-columns: 1fr; margin: 14px 0; }
.time-groups { display: grid; gap: 12px; margin: 12px 0 16px; }
.time-group h4 { margin: 0 0 8px; font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.time-picks { display: flex; flex-wrap: wrap; gap: 8px; }
.time-picks button {
  background: var(--bg-2); color: var(--ink); border: 1px solid var(--line);
  padding: 8px 12px; font-size: 0.9rem;
}
.time-picks button.on { background: var(--accent); color: #fff; border-color: transparent; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.choice-row button {
  background: var(--bg-2); color: var(--ink); border: 1px solid var(--line);
  padding: 8px 12px; font-size: 0.9rem;
}
.choice-row button.on { background: var(--accent); color: #fff; border-color: transparent; }
.draw-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 0 0 12px; padding: 12px 14px; border-radius: 14px;
  background: #fff6d8; border: 1px solid #e6c56e; color: var(--ink);
}
.draw-bar .hero-cta { margin-top: 0; }
.toast {
  position: fixed; top: 78px; left: 50%; transform: translateX(-50%);
  z-index: 50; background: var(--accent); color: #fff;
  padding: 12px 18px; border-radius: 12px; font-weight: 800;
  box-shadow: var(--shadow); max-width: calc(100% - 32px);
}
.custom-time { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.custom-time input {
  width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink);
}
.player {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel);
  flex-wrap: wrap;
}
.caps { display: flex; gap: 2px; flex-wrap: wrap; justify-content: flex-end; min-height: 28px; width: 100%; }
.clock {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 1.35rem;
  font-weight: 800;
  min-width: 5.2rem;
  text-align: right;
  padding: 4px 8px;
  border-radius: 10px;
}
.clock.ticking { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.clock.low { color: var(--danger); }
.clock-label { color: var(--muted); font-weight: 600; font-size: 0.88rem; }
.player.on { outline: 2px solid var(--accent); }
.player .who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.net {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  border-radius: 999px;
  padding: 4px 8px 4px 6px;
}
.net .wifi { width: 20px; height: 20px; flex: 0 0 20px; fill: currentColor; }
.net.ok { color: #2f9e44; background: color-mix(in srgb, #2f9e44 12%, white); }
.net.bad { color: #c43c22; background: #fde8e4; }
.net.ok .net-label { display: none; }
.net.bad .net-label { display: inline; }
.mat-score {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  min-width: 2.4rem;
  text-align: right;
  color: var(--muted);
}
.mat-score.up { color: #3d7c22; }
.caps svg { width: 22px; height: 22px; }
.board-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.board {
  display: grid;
  grid-template-columns: 18px repeat(12, minmax(0, 1fr)) 18px;
  width: min(100%, 920px);
  min-width: 320px;
  margin: 0 auto;
  user-select: none;
  touch-action: manipulation;
}
.file, .rank {
  display: grid; place-items: center; color: var(--muted);
  font-size: 0.68rem; font-family: ui-monospace, Menlo, monospace; font-weight: 700;
}
.sq {
  position: relative; display: grid; place-items: center;
  cursor: pointer; aspect-ratio: 1; width: 100%; border: 0; padding: 0;
  border-radius: 0; background: none;
}
.sq.light { background: var(--light); }
.sq.dark { background: var(--dark); }
.sq.last { box-shadow: inset 0 0 0 100px var(--last); }
.sq.sel { box-shadow: inset 0 0 0 4px var(--sel); }
.sq.check { box-shadow: inset 0 0 0 100px var(--check); }
.sq svg, .sq img { width: 92%; height: 92%; pointer-events: none; object-fit: contain; }
.mini-grid span img { width: 86%; height: 86%; object-fit: contain; }
.caps img { width: 22px; height: 22px; object-fit: contain; }
.promo img { width: 56px; height: 56px; margin: 0 auto; object-fit: contain; }
.sq .dot { width: 26%; height: 26%; border-radius: 50%; background: var(--hint); }
.sq .ring { position: absolute; inset: 7%; border: 3px solid var(--hint); border-radius: 50%; }
.side {
  display: grid; gap: 12px; margin-top: 14px;
}
.moves {
  max-height: 160px; overflow: auto; font-weight: 500; color: var(--muted);
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px;
}
.wait {
  margin-top: 12px; padding: 12px 14px; border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  border: 1px dashed var(--accent);
}
.err { color: var(--danger); min-height: 1.2em; }
.modal {
  position: fixed; inset: 0; background: rgba(12, 10, 8, 0.55);
  display: grid; place-items: center; padding: 16px; z-index: 40;
}
.modal .card { width: min(520px, 100%); max-height: 90vh; overflow: auto; }
.promo { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.promo button { background: var(--bg-2); color: var(--ink); padding: 8px; }
.promo svg { width: 100%; height: 64px; }
.result h2 { margin-top: 0; }
.result .big { font-size: 2.2rem; margin: 0 0 8px; }
[hidden] { display: none !important; }
.skip {
  position: absolute; left: -999px;
}
.skip:focus { left: 8px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; z-index: 50; }
@media (min-width: 720px) {
  .hero { grid-template-columns: 1.1fr 0.9fr; align-items: center; }
  .cards { grid-template-columns: repeat(3, 1fr); }
  .players { grid-template-columns: 1fr 1fr; }
  .game-grid { display: grid; grid-template-columns: 1fr 220px; gap: 16px; align-items: start; }
}
@media (max-width: 719px) {
  .nav-actions button:not(.icon-btn) { padding: 10px 12px; font-size: 0.86rem; }
  .hero { padding-top: 22px; }
  .table-bg { padding: 10px; border-radius: 16px; }
}
