[hidden] { display: none !important; }
:root {
  --bg: #262421; --panel: #302e2b; --panel2: #3a3733; --text: #e8e6e3; --muted: #9a958e;
  --accent: #7fa650; --accent2: #5d8a3a; --danger: #c0392b; --warn: #d6a33a; --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: hidden; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: #9ec1ff; text-decoration: none; }
button, input, select { font: inherit; }
button { background: var(--panel2); color: var(--text); border: 1px solid #4a4640; border-radius: var(--radius);
  padding: 8px 14px; cursor: pointer; }
button:hover { background: #45413c; }
button.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
button.primary:hover { background: var(--accent); }
button.danger { background: #6e2a22; border-color: #6e2a22; }
button:disabled { opacity: .45; cursor: default; }
input, select { background: #1f1d1b; color: var(--text); border: 1px solid #4a4640; border-radius: var(--radius);
  padding: 8px 10px; width: 100%; }

header#top { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px;
  background: var(--panel); position: sticky; top: 0; z-index: 10; }
header .logo { color: var(--text); font-weight: 700; font-size: 18px; }
header nav a { margin-left: 14px; }

main { max-width: 980px; margin: 0 auto; padding: 12px; }
.card { background: var(--panel); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card h2 { margin: 0 0 10px; font-size: 17px; }
.narrow { max-width: 380px; margin: 40px auto; }
.narrow label { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 14px; }
.narrow button { width: 100%; margin-top: 14px; }
.err { color: #ff8a7a; min-height: 1.4em; margin-top: 8px; }
.muted { color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid #3d3a36; }
.list li:first-child { border-top: none; }
.list li .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.list a.game { color: var(--text); display: block; }
.badge { font-size: 12px; padding: 2px 7px; border-radius: 10px; background: var(--panel2); color: var(--muted); white-space: nowrap; }
.badge.turn { background: var(--accent2); color: #fff; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #555; display: inline-block; margin-right: 6px; }
.dot.on { background: var(--accent); }

.seg { display: inline-flex; border: 1px solid #4a4640; border-radius: var(--radius); overflow: hidden; }
.seg button { border: none; border-radius: 0; padding: 7px 12px; }
.seg button.on { background: var(--accent2); color: #fff; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.presets button { padding: 6px 10px; }
.presets button.on { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.form-grid label { font-size: 13px; color: var(--muted); }

/* --- партия --- */
.game { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 14px; align-items: start; }
.board-col { width: 100%; max-width: min(100%, calc(100vh - 190px)); margin: 0 auto; }
.board-wrap { position: relative; width: 100%; aspect-ratio: 1 / 1; }
.board-wrap > .cg-wrap { position: absolute; inset: 0; width: 100%; height: 100%; }
.player { display: flex; justify-content: space-between; align-items: center; padding: 6px 2px; gap: 8px; }
.player .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clock { font: 600 22px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: #1f1d1b;
  padding: 6px 10px; border-radius: 6px; min-width: 92px; text-align: right; color: var(--muted); }
.clock.run { background: #e8e6e3; color: #1f1d1b; }
.clock.low { background: var(--danger); color: #fff; }
.clock.corr { font-size: 14px; min-width: 0; }
.side .card { margin-bottom: 10px; }
.status { font-weight: 600; }
.moves { max-height: 260px; overflow-y: auto; font: 14px/1.6 ui-monospace, Menlo, Consolas, monospace;
  display: grid; grid-template-columns: 34px 1fr 1fr; }
.moves .n { color: var(--muted); }
.moves .last { background: var(--panel2); border-radius: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions button { flex: 1 1 auto; }
.offer { background: #4a3f1e; border-radius: var(--radius); padding: 10px; margin-bottom: 10px; }

.promo.cg-wrap { position: absolute; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center;
  justify-content: center; z-index: 20; }
.promo.cg-wrap div { display: flex; gap: 6px; background: var(--panel); padding: 10px; border-radius: var(--radius); }
.promo.cg-wrap piece { pointer-events: auto; position: static; display: block; width: 64px; height: 64px; cursor: pointer;
  background-size: cover; border-radius: 6px; background-color: #f0d9b5; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #111; color: #fff;
  padding: 10px 16px; border-radius: var(--radius); z-index: 50; max-width: 90vw; }
.conn { position: fixed; top: 0; left: 0; right: 0; background: var(--warn); color: #111; text-align: center;
  font-size: 13px; padding: 3px; z-index: 40; }
code.link { display: block; background: #1f1d1b; padding: 8px; border-radius: 6px; word-break: break-all; margin: 8px 0; }

@media (max-width: 760px) {
  main { padding: 6px; }
  .game { grid-template-columns: 1fr; gap: 8px; }
  .board-col { max-width: 100%; }
  .moves { max-height: 120px; grid-template-columns: 30px 1fr 1fr; }
  .clock { font-size: 20px; min-width: 80px; }
}
