:root {
  --bg: #e9e5dc;
  --card: #fbf9f4;
  --ink: #1f2a24;
  --muted: #6b716c;
  --line: #d6d1c5;
  --green: #2e7047;
  --green-hi: #4d9a63;
  --water: #255781;
  --red: #e0282e;
  --gold: #efb434;
  --hi: #ffd84d;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
button {
  font: inherit; cursor: pointer; border-radius: 10px; padding: 10px 14px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
button:hover:not(:disabled) { border-color: var(--green); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--green); color: #fff; border-color: var(--green); font-weight: 600; }
button.primary:hover:not(:disabled) { background: #245c39; }
input {
  font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; width: 100%;
}
input:focus-visible, button:focus-visible { outline: 3px solid var(--hi); outline-offset: 1px; }

/* Lobby */
.lobby { max-width: 420px; margin: 0 auto; padding: 40px 16px; display: grid; gap: 16px; }
.lobby h1 { margin: 0; text-align: center; font-size: 30px; letter-spacing: .02em; }
.sub { margin: -10px 0 4px; text-align: center; color: var(--muted); }
.logo { display: flex; justify-content: center; gap: 0; }
.dot { width: 34px; height: 34px; border-radius: 50%; border: 4px solid #1a1a1a; margin: 0 -3px; }
.dot.chicken { background: #f1ece1; }
.dot.fox { background: var(--red); }
.dot.corn { background: var(--gold); }
.field { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 10px; }
.card h2 { margin: 0; font-size: 15px; }
.or { text-align: center; color: var(--muted); font-size: 13px; }
.join { display: flex; gap: 8px; }
.join input { text-transform: uppercase; letter-spacing: .2em; font-weight: 700; text-align: center; }

/* Game layout */
.game { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; padding: 16px; max-width: 1180px; margin: 0 auto; align-items: start; }
.board-wrap { position: sticky; top: 16px; }
#board { width: 100%; height: auto; max-height: calc(100vh - 32px); display: block; border-radius: var(--radius); box-shadow: 0 2px 12px rgba(0,0,0,.15); touch-action: manipulation; user-select: none; }
@media (max-width: 820px) {
  .game { grid-template-columns: 1fr; padding: 8px; gap: 10px; }
  .board-wrap { position: static; }
  #board { max-height: none; }
}

/* Board SVG */
.pad { fill: var(--green); cursor: pointer; transition: fill .15s; }
.pad.last { fill: #3a7d52; }
.pad.dest { fill: var(--green-hi); stroke: var(--hi); stroke-width: 3; stroke-dasharray: 6 4; animation: march 1s linear infinite; }
.shore.dest { fill: var(--green-hi); stroke: var(--hi); stroke-width: 3; stroke-dasharray: 6 4; cursor: pointer; animation: march 1s linear infinite; }
@keyframes march { to { stroke-dashoffset: -20; } }
.piece { cursor: pointer; }
.sel-ring { fill: none; stroke: var(--hi); stroke-width: 4; pointer-events: none; }
.count { font: 700 14px system-ui, sans-serif; fill: #2b2b2b; cursor: pointer; }
.empty { font: italic 12px system-ui, sans-serif; fill: #7a766d; text-anchor: middle; }
.sand-label { font: 600 12px system-ui, sans-serif; fill: #5c584f; }
.shore-label { font: 700 14px system-ui, sans-serif; fill: #fff; text-anchor: middle; cursor: pointer; }
.banner { font: 700 15px system-ui, sans-serif; fill: #fff; text-anchor: middle; paint-order: stroke; stroke: rgba(0,0,0,.55); stroke-width: 4px; pointer-events: none; }

/* Panel */
.panel { display: grid; gap: 12px; }
.panel section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.panel h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.room { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.room .code { font: 800 20px ui-monospace, Menlo, monospace; letter-spacing: .15em; }
.room button { padding: 6px 10px; font-size: 13px; }
.conn { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.conn i { width: 9px; height: 9px; border-radius: 50%; background: #bbb; display: inline-block; }
.conn.ok i { background: #2fa35a; }
.conn.warn i { background: #e4a11b; }
.turn { font-size: 18px; font-weight: 700; margin: 0 0 8px; }
.turn.mine { color: var(--green); }
.checklist { list-style: none; margin: 0 0 10px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.checklist li { display: flex; align-items: center; gap: 6px; font-size: 14px; padding: 4px 6px; border-radius: 8px; background: #f0ede5; }
.checklist li.done { background: #dcebdf; color: #245c39; }
.checklist li.na { opacity: .5; }
.checklist li svg { flex: none; }
.checklist .st { margin-left: auto; font-size: 12px; font-weight: 700; }
.actions { display: flex; gap: 8px; }
.actions button { flex: 1; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.hint button { padding: 4px 10px; font-size: 13px; margin-left: 6px; }
.player { display: grid; gap: 6px; }
.player + .player { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.player .name { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.player .name .rim { width: 14px; height: 14px; border-radius: 50%; border: 3px solid; }
.player .name .you { font-size: 11px; font-weight: 700; background: var(--ink); color: #fff; border-radius: 6px; padding: 1px 6px; }
.player .name .token { font-size: 11px; font-weight: 700; background: #6b3f22; color: #fff; border-radius: 6px; padding: 1px 6px; }
.markers { display: flex; gap: 6px; flex-wrap: wrap; }
.marker { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.marker.won { background: #1f2a24; color: #ffd84d; border-color: #1f2a24; font-weight: 700; }
.marker.lost { text-decoration: line-through; opacity: .5; }
.statline { font-size: 13px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }
.statline b { color: var(--ink); }
.log { max-height: 200px; overflow: auto; font-size: 13px; margin: 0; padding-left: 18px; }
.log li { margin: 2px 0; }
.log li:last-child { font-weight: 600; }
details.rules summary { cursor: pointer; font-weight: 600; }
details.rules ul { padding-left: 18px; font-size: 13px; margin: 8px 0 0; }
.footer-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.footer-actions button { font-size: 13px; padding: 6px 10px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px); background: #1f2a24; color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; max-width: calc(100vw - 32px); z-index: 10; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

dialog { border: none; border-radius: 16px; padding: 24px; max-width: 360px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(20, 30, 25, .45); }
dialog h2 { margin: 0 0 8px; font-size: 26px; }
dialog .row { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }

/* v2.0: games list */
.games { display: grid; gap: 8px; }
.game-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }
.game-row:hover, .game-row:focus-visible { border-color: var(--green); outline: none; }
.game-row .who { flex: 1; min-width: 0; font-size: 14px; }
.game-row .when { font-size: 12px; color: var(--muted); }
.code-sm { font: 700 13px ui-monospace, Menlo, monospace; letter-spacing: .08em; }
.status { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: #eee; color: var(--muted); white-space: nowrap; }
.status.mine { background: var(--green); color: #fff; }
.status.won { background: #1f2a24; color: var(--hi); }
.status.draw { background: #dfe6f0; color: #2c4a6e; }
.status.wait { background: #f6e7bf; color: #7a5a00; }
button.small { padding: 4px 9px; font-size: 12px; }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.muted { color: var(--muted); font-size: 14px; margin: 0; }
.error { color: #b3261e; font-size: 14px; margin: 0; }
.version-foot { text-align: center; color: var(--muted); font-size: 12px; margin: 0; }
.version-foot a { color: inherit; }
.version-tag { margin-left: auto; align-self: center; font-size: 12px; color: var(--muted); }
.invite { margin-top: 8px; font-size: 13px; color: var(--muted); }

/* v2.4: optional Google sign-in */
.account { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; color: var(--muted); margin-top: -6px; }
.account:empty { display: none; }
.account b { color: var(--ink); }
.acct-note { flex-basis: 100%; font-size: 12px; }
