:root {
  color-scheme: dark;
  --bg: #111715;
  --panel: #19211e;
  --line: #303b35;
  --text: #edf0e7;
  --muted: #a0afa5;
  --accent: #d3ee8c;
  --x: #356bce;
  --o: #c95443;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  cursor: pointer;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #a2c9ff;
  outline-offset: 3px;
}
.shell {
  width: min(1240px, 100%);
  margin: auto;
  padding: 0 40px;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 100px;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 32px;
  font-weight: 750;
  letter-spacing: -2px;
}
.brand-dot {
  color: var(--accent);
}
.brand-icon {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  font-size: 26px;
  font-weight: 400;
  color: var(--accent);
}
.brand-icon span {
  font-size: 34px;
}
.tag {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 1.6px;
  border-left: 1px solid var(--line);
  padding-left: 28px;
}
.connection {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.connection::before {
  content: "";
  width: 7px;
  height: 7px;
  background: #c5a46b;
  border-radius: 50%;
}
.connection.connected::before {
  background: var(--accent);
  box-shadow: 0 0 10px #d3ee8c30;
}
.heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  padding: 46px 0 30px;
  gap: 20px;
}
.eyebrow {
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 2px;
  font-weight: 700;
  margin: 0 0 12px;
}
h1 {
  font-size: clamp(30px, 4vw, 45px);
  letter-spacing: -1.8px;
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 12px;
}
.subtitle {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}
.room-label {
  text-align: right;
  padding-bottom: 5px;
}
.room-label span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 1.4px;
}
.room-label strong {
  display: block;
  font-family: monospace;
  font-size: 16px;
  margin-top: 6px;
  font-weight: 400;
}
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}
.board-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}
.board-toolbar,
.board-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
}
.board-toolbar {
  padding: 0 1px 17px;
}
#board-state {
  color: var(--text);
  font-weight: 600;
}
.board-scroll {
  overflow: auto;
  border-radius: 6px;
  background: #efe9d9;
}
.board {
  display: grid;
  grid-template-columns: repeat(15, minmax(28px, 1fr));
  min-width: 420px;
  padding: 8px;
  background: #efe9d9;
  gap: 1px;
}
.cell {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 0;
  padding: 0;
  border-radius: 0;
  aspect-ratio: 1;
  color: transparent;
  background:
    linear-gradient(#c8c0ac, #c8c0ac) center/1px 100% no-repeat,
    linear-gradient(#c8c0ac, #c8c0ac) center/100% 1px no-repeat;
  font-family: Arial, sans-serif;
  font-size: clamp(18px, 2.8vw, 30px);
  font-weight: 500;
  line-height: 1;
}
.cell:disabled {
  cursor: default;
  opacity: 1;
}
.cell.x {
  color: var(--x);
}
.cell.o {
  color: var(--o);
  font-size: clamp(24px, 3.4vw, 36px);
}
.cell:not(:disabled):hover {
  background-color: #d9d6c4;
}
.cell:focus-visible {
  outline: 2px solid var(--x);
  outline-offset: -2px;
  z-index: 1;
}
.cell.last::after {
  content: "";
  position: absolute;
  bottom: 2px;
  right: 2px;
  height: 4px;
  width: 4px;
  background: #252f29;
  border-radius: 50%;
}
.cell.winning {
  background-color: #bed186;
}
.board-footer {
  padding-top: 17px;
  font-size: 10px;
}
.board-footer > span:first-child {
  display: flex;
  gap: 7px;
  align-items: center;
}
.last-marker {
  display: inline-block;
  background: var(--muted);
  width: 4px;
  height: 4px;
  border-radius: 50%;
}
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.status-card {
  background: var(--accent);
  color: #1c2b20;
  border-radius: 12px;
  padding: 23px;
}
.status-card .eyebrow {
  color: #526a38;
}
h2 {
  font-size: 24px;
  letter-spacing: -0.7px;
  line-height: 1.25;
  font-weight: 650;
  margin: 0 0 12px;
}
.status-card p:not(.eyebrow) {
  color: #465638;
  font-size: 12px;
  margin: 0;
}
.timer-panel {
  margin-top: 24px;
}
.timer-panel > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.timer-panel span {
  font-size: 11px;
  color: #52623f;
}
.timer-panel strong {
  font-family: monospace;
  font-size: 27px;
  font-weight: 500;
}
progress {
  display: block;
  width: 100%;
  height: 4px;
  margin-top: 9px;
  appearance: none;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #b4ce82;
}
progress::-webkit-progress-bar {
  background: #b4ce82;
}
progress::-webkit-progress-value {
  background: #2d4127;
}
progress::-moz-progress-bar {
  background: #2d4127;
}
.timer-panel.urgent strong {
  color: #aa3e2f;
}
.players-card {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 18px;
  border-radius: 12px;
}
.player {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 6px;
  padding: 5px;
}
.player.active {
  background: #263229;
}
.piece {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  font:
    30px Arial,
    sans-serif;
  border-radius: 8px;
}
.piece.x {
  background: #213853;
  color: #8cb8ff;
}
.piece.o {
  background: #442f29;
  color: #f29d83;
  font-size: 38px;
}
.player > div {
  min-width: 0;
}
.player-label {
  display: block;
  font-size: 8px;
  letter-spacing: 1.5px;
  color: var(--muted);
}
.player strong {
  display: block;
  font-size: 12px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.you {
  margin-left: auto;
  font-size: 8px;
  color: var(--accent);
  flex-shrink: 0;
}
.versus {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 5px;
  color: #748579;
  font-size: 8px;
  letter-spacing: 1px;
}
.versus span {
  height: 1px;
  background: var(--line);
  flex: 1;
}
.leave-button {
  color: #c7cfc4;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 8px;
  padding: 11px;
  font-size: 12px;
}
.leave-button:hover {
  border-color: #ae7770;
  color: #f29d83;
}
.leave-button:disabled {
  opacity: 0.5;
  cursor: wait;
}
.notice {
  background: #402c27;
  color: #ffcead;
  padding: 12px 16px;
  font-size: 12px;
  border-radius: 8px;
  overflow-wrap: anywhere;
}
.rules {
  padding: 6px 5px;
}
.rules h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
}
.rules p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.8;
  margin: 0 0 10px;
}
.no-stakes {
  font-size: 8px;
  letter-spacing: 1.2px;
  color: #9cad82;
}
.page-footer {
  border-top: 1px solid var(--line);
  margin-top: 36px;
  padding: 23px 0;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: #829286;
  font-size: 10px;
}
.page-footer span:last-child {
  font-size: 8px;
  letter-spacing: 1.3px;
}
dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  max-width: min(420px, 90vw);
}
dialog::backdrop {
  background: #0009;
}
dialog p {
  font-size: 13px;
  color: var(--muted);
}
.dialog-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}
.dialog-actions button {
  padding: 10px 16px;
  color: var(--text);
  background: #2b3830;
  border: 0;
  border-radius: 7px;
  font-size: 12px;
}
.dialog-actions .danger {
  background: #b34d3c;
}
@media (min-width: 1500px) {
  .shell {
    padding-top: 15px;
  }
}
@media (max-width: 1000px) {
  .shell {
    padding: 0 24px;
  }
  .game-layout {
    grid-template-columns: minmax(0, 1fr) 250px;
    gap: 16px;
  }
  .board-panel {
    padding: 14px;
  }
  .status-card {
    padding: 20px;
  }
}
.zoom-button {
  display: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 10px;
}
@media (max-width: 900px) {
  .shell {
    padding: 0 16px;
  }
  .topbar {
    min-height: 76px;
    gap: 12px;
  }
  .tag {
    display: none;
  }
  .heading {
    padding: 28px 0 22px;
  }
  .subtitle {
    max-width: 280px;
    font-size: 12px;
  }
  .game-layout {
    display: flex;
    flex-direction: column;
  }
  .board-panel {
    width: 100%;
    padding: 12px;
    order: 1;
  }
  .board {
    grid-template-columns: repeat(15, minmax(18px, 1fr));
    min-width: 300px;
  }
  .board.enlarged {
    min-width: 600px;
  }
  .board.enlarged .cell {
    font-size: 30px;
  }
  .board.enlarged .cell.o {
    font-size: 36px;
  }
  .zoom-button {
    display: block;
  }
  .sidebar {
    display: contents;
  }
  .status-card {
    order: 0;
    width: 100%;
    padding: 16px 20px;
  }
  .status-card .eyebrow {
    margin-bottom: 5px;
  }
  .status-card h2 {
    font-size: 22px;
    margin-bottom: 6px;
  }
  .timer-panel {
    margin-top: 10px;
  }
  .timer-panel strong {
    font-size: 22px;
  }
  .players-card {
    order: 2;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
  }
  .player {
    flex: 1;
    min-width: 0;
    gap: 8px;
  }
  .player .piece {
    width: 30px;
    height: 30px;
    font-size: 24px;
  }
  .player .o {
    font-size: 30px;
  }
  .player strong {
    font-size: 11px;
  }
  .versus {
    margin: 0;
  }
  .versus span {
    display: none;
  }
  .you {
    font-size: 7px;
  }
  .notice {
    order: 3;
    width: 100%;
  }
  .leave-button {
    order: 4;
    width: 100%;
  }
  .rules {
    order: 5;
  }
  .room-label strong {
    font-size: 12px;
  }
  .board-toolbar {
    font-size: 10px;
    padding-bottom: 12px;
  }
  .board-footer {
    font-size: 9px;
    padding-top: 12px;
  }
  .cell {
    font-size: 20px;
  }
  .cell.o {
    font-size: 26px;
  }
  .page-footer {
    margin-top: 20px;
    flex-wrap: wrap;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .cell {
    transition: background-color 0.12s;
  }
}
