:root {
  color-scheme: light dark;
  --bg: #f6f5ee; --card: #fffefa; --ink: #292a23; --muted: #6b6c63; --line: #e4e2d6;
  --lime: #d8fd71; --on-lime: #292a23; --danger: #c0392b; --ok: #2e7d32;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #292a23; --card: #33342c; --ink: #f6f5ee; --muted: #b0b1a6; --line: #4a4b41; --danger: #ff8a7d; --ok: #7fd884; }
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font: 16px/1.4 "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif; }
#app { max-width: 460px; margin: 0 auto; padding: 56px 16px 64px; display: grid; gap: 14px; justify-items: center; text-align: center; }
h1 { margin: 0; font-size: clamp(2rem, 8vw, 2.8rem); letter-spacing: -.045em; }
section { width: 100%; display: grid; gap: 14px; justify-items: center; }
.lead { margin: 0; color: var(--muted); font-size: 1.05rem; }
.note { margin: 0; color: var(--muted); font-size: .85rem; }
.problem { margin: 0; color: var(--danger); font-weight: 600; }
.invite { margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--lime); color: var(--on-lime); font-weight: 700; }
[hidden] { display: none !important; }
.buttons { display: grid; gap: 8px; width: 100%; }
button { font: inherit; font-weight: 700; padding: 13px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--ink); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
button.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
button.link { border: 0; background: none; color: var(--muted); font-weight: 600; text-decoration: underline; padding: 6px; }
button:disabled { opacity: .55; cursor: default; }
.count { font-family: var(--mono); font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: var(--lime); color: var(--on-lime); margin-left: 6px; }
.join { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; width: 100%; }
.join label { color: var(--muted); font-size: .9rem; }
.join input { min-width: 0; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 700 1rem var(--mono); letter-spacing: .2em; text-transform: uppercase; text-align: center; }
.code-box { display: grid; gap: 10px; justify-items: center; padding: 18px; width: 100%; border: 1.5px solid var(--ink); border-radius: 20px; background: var(--card); box-shadow: 6px 6px 0 var(--lime); }
.code { font: 800 2.4rem var(--mono); letter-spacing: .25em; padding-left: .25em; }
.players { display: flex; justify-content: space-between; gap: 10px; width: 100%; font-weight: 700; }
.players span { flex: 1; padding: 8px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players span.turn { background: var(--lime); color: var(--on-lime); border-color: var(--lime); }
.players span.away { opacity: .6; border-style: dashed; }
.status { margin: 0; font-size: 1.2rem; font-weight: 700; min-height: 1.5em; }
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: min(100%, 360px); }
.cell { aspect-ratio: 1; padding: 0; font-size: clamp(2.4rem, 14vw, 4rem); line-height: 1; border-radius: 16px; display: grid; place-items: center; }
.cell.x { color: var(--ink); }
.cell.o { color: var(--ok); }
.cell.win { background: var(--lime); color: var(--on-lime); border-color: var(--lime); }
.cell:disabled { opacity: 1; }

/* draughts */
#app.wide { max-width: 560px; }
.dr { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); width: min(100%, 520px); aspect-ratio: 1; border: 2px solid var(--ink); border-radius: 12px; overflow: hidden; touch-action: manipulation; }
.sq { position: relative; min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 0; display: grid; place-items: center; background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq:hover:not(:disabled) { border: 0; filter: brightness(1.08); }
.sq:disabled { opacity: 1; cursor: default; }
.sq.last { box-shadow: inset 0 0 0 100px rgba(216, 253, 113, .4); }
.sq.selected { box-shadow: inset 0 0 0 100px var(--lime); }
.sq.target::after { content: ""; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgba(41, 42, 35, .4); }
.disc { width: 78%; height: 78%; border-radius: 50%; display: grid; place-items: center; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .3), 0 2px 3px rgba(0, 0, 0, .4); font-size: clamp(1rem, 5vw, 1.8rem); line-height: 1; }
.disc.p0 { background: #f1ead7; color: #8a6d00; }
.disc.p1 { background: #5a2a22; color: #f2c94c; }
.disc.king::after { content: "♛"; }
.sq .coord { position: absolute; left: 3px; bottom: 1px; font: 600 .6rem var(--mono); color: rgba(255, 255, 255, .65); pointer-events: none; }
:root { --sq-light: #ebecd0; --sq-dark: #6e5a46; }
@media (prefers-color-scheme: dark) { :root { --sq-light: #c9cba8; --sq-dark: #55453a; } }
.players span .dot { display: inline-block; width: .8em; height: .8em; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.dot.p0 { background: #f1ead7; box-shadow: inset 0 0 0 1px var(--line); }
.dot.p1 { background: #5a2a22; }
