:root {
  color-scheme: dark;
  --bg: #312e2b;
  --ink: #f4f1ec;
  --muted: #b9b4ad;
  --line: oklch(1 0 0 / 0.08);
  --light: #ebecd0;
  --dark: #739552;
  --last-light: #f6f669;
  --last-dark: #baca44;
  --check: #e85d4c;
  --clock: #3c3936;
  --clock-live: #fff;
  --low: #c33;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  min-height: 100%;
}

body {
  padding: env(safe-area-inset-top) 12px calc(16px + env(safe-area-inset-bottom));
}

button, .tab {
  font: inherit;
  color: inherit;
}

#app { max-width: 520px; margin: 0 auto; }

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 12px 0;
}

.tab, .btn {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: #3c3936;
  cursor: pointer;
  transition-property: scale;
  transition-duration: 0.12s;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.tab[aria-selected="true"] { background: #5d9948; color: #fff; }

.tab:active, .btn:active { scale: 0.96; }

.tab:focus-visible, .btn:focus-visible, .sq:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.seat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
}

.name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.clock {
  min-width: 88px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--clock);
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 22px;
  letter-spacing: 0.02em;
}

.clock.live { background: var(--clock-live); color: #1a1a1a; }
.clock.low { background: var(--low); color: #fff; }

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: min(100%, 480px);
  margin: 8px auto;
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
  touch-action: none;
  box-shadow: 0 12px 32px oklch(0 0 0 / 0.28);
  position: relative;
}

.sq {
  position: relative;
  border: 0;
  padding: 0;
  background: var(--light);
}

.sq.dark { background: var(--dark); }
.sq.last { background: var(--last-light); }
.sq.dark.last { background: var(--last-dark); }
.sq.selected { box-shadow: inset 0 0 0 3px oklch(0 0 0 / 0.35); }
.sq.check { background: var(--check); }

.sq img {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  outline: 1px solid oklch(1 0 0 / 0.1);
  outline-offset: -1px;
}

.coord {
  position: absolute;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

.sq.light .coord { color: oklch(0 0 0 / 0.45); }
.sq.dark .coord { color: oklch(1 0 0 / 0.72); }
.coord.file { right: 3px; bottom: 2px; }
.coord.rank { left: 3px; top: 2px; }

.dot, .ring {
  position: absolute;
  inset: 0;
  margin: auto;
  pointer-events: none;
}

.dot {
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: oklch(0 0 0 / 0.22);
}

.ring {
  width: 86%;
  height: 86%;
  border-radius: 50%;
  border: 4px solid oklch(0 0 0 / 0.22);
}

.cover {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg);
  text-align: center;
  padding: 24px;
}

.cover h2 { margin: 0; font-size: 28px; }

.actions, .list { display: grid; gap: 8px; margin-top: 12px; }

.actions { grid-template-columns: repeat(3, 1fr); }

.note, .banner, .empty, .gate {
  color: var(--muted);
  text-align: center;
  margin: 10px 0;
}

.banner { color: var(--ink); font-weight: 650; }

.row, .stat {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.win { font-weight: 700; }
.loss { color: var(--muted); }

.promo {
  position: fixed;
  inset: 0;
  background: oklch(0 0 0 / 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

.promo div {
  display: flex;
  gap: 8px;
  background: var(--bg);
  padding: 12px;
  border-radius: 12px;
}

.promo button {
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 8px;
  background: var(--light);
}

.promo img { width: 100%; height: 100%; }

.ghost { grid-column: 1 / -1; background: transparent; }

@media (prefers-reduced-motion: reduce) {
  .tab, .btn { transition: none; }
  .tab:active, .btn:active { scale: 1; }
}
