:root {
  --bg: #151923; --panel: #242c3a; --cell: #303a4b; --grid: #6c7a90;
  --text: #eef3fb; --muted: #aeb9c9; --x: #ff6559; --o: #55a7ff;
  --ghost: #8f8f8f; --accent: #f2c94c; --ok: #75d69b; --danger: #e05656;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; justify-content: center;
}
#app { width: 100%; max-width: 480px; padding: 12px 16px 24px; }
#topbar { display: flex; justify-content: space-between; align-items: center; padding: 4px 0 12px; }
#game-title { font-weight: 800; letter-spacing: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.card { background: var(--panel); border-radius: 12px; padding: 20px; text-align: center; }
.stat { display: flex; justify-content: space-between; padding: 6px 2px; font-size: 18px; }
.label { color: var(--muted); }
.big { font-size: 28px; font-weight: 700; }
button {
  background: var(--cell); color: var(--text); border: 1px solid var(--grid);
  border-radius: 10px; padding: 12px 18px; font-size: 16px; margin-top: 12px;
  width: 100%; cursor: pointer;
}
button.primary { background: var(--accent); color: #151923; font-weight: 700; border: none; }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button:disabled { opacity: 0.45; cursor: default; }
#scorebar { display: flex; justify-content: space-between; align-items: center; margin: 4px 0; }
.side { display: flex; flex-direction: column; min-width: 90px; }
.side.right { text-align: right; }
.rating { color: var(--muted); font-size: 13px; }
.dots { color: var(--accent); font-size: 15px; letter-spacing: 2px; }
#board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0; }
.cell {
  aspect-ratio: 1; background: var(--cell); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 52px; font-weight: 800; cursor: pointer; user-select: none;
}
.cell.x { color: var(--x); }
.cell.o { color: var(--o); }
.cell.ghost { color: var(--ghost); opacity: 0.55; cursor: pointer; }
.cell.locked { cursor: default; }
.cell.win { outline: 3px solid var(--accent); background: #4a4430; }
.won-text { color: var(--ok); font-weight: 700; }
.lost-text { color: var(--danger); font-weight: 700; }
.miniboard {
  display: grid; grid-template-columns: repeat(3, 22px);
  gap: 2px; margin: 8px 0; justify-content: start;
}
.minicell {
  width: 22px; height: 22px; background: var(--cell); border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
.minicell.win { outline: 2px solid var(--accent); }
#game-status { min-height: 20px; }
.history-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--cell); border-radius: 10px; padding: 10px 12px;
  margin: 6px 0; cursor: pointer; font-size: 15px;
}
.history-item.won { border-left: 4px solid var(--ok); }
.history-item.lost { border-left: 4px solid var(--danger); }
.history-item.live { border-left: 4px solid var(--accent); }
.history-detail { text-align: left; font-size: 14px; }
.history-detail .row { display: flex; justify-content: space-between; padding: 3px 0; }
