:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --ink: #202124;
  --muted: #6b665d;
  --line: #d8d1c2;
  --panel: #fffaf1;
  --accent: #0e766d;
  --accent-strong: #09544e;
  --danger: #b3261e;
  --light-square: #eee8cc;
  --dark-square: #6f9460;
  --select: #f1c84b;
  --move: rgba(32, 33, 36, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf8;
  color: var(--ink);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #ffffff;
  color: var(--ink);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
}

.profile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.auth-panel,
.lobby-panel {
  grid-column: 1;
}

.lobby-panel {
  margin-top: 16px;
}

.game-area {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: grid;
  grid-template-columns: minmax(360px, 680px) minmax(240px, 300px);
  gap: 16px;
  align-items: start;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.tab.active {
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 700;
}

.form,
.stack {
  display: grid;
  gap: 12px;
}

.hidden {
  display: none;
}

.copy-row {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 8px;
}

.copy-row button {
  font-size: 20px;
  line-height: 1;
}

.board-shell {
  width: 100%;
}

.board {
  display: grid;
  width: min(100%, 680px);
  aspect-ratio: 1;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  border: 1px solid #464138;
  box-shadow: 0 10px 26px rgba(36, 31, 24, 0.14);
}

.square {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  padding: 0;
  overflow: hidden;
}

.square.light {
  background: var(--light-square);
}

.square.dark {
  background: var(--dark-square);
}

.square.selected::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(241, 200, 75, 0.55);
}

.square.move::before {
  content: "";
  position: absolute;
  width: 28%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: var(--move);
  z-index: 2;
}

.square .coord {
  position: absolute;
  left: 5px;
  bottom: 4px;
  color: rgba(32, 33, 36, 0.58);
  font-size: 11px;
  font-weight: 700;
  z-index: 3;
}

.piece-img {
  width: 86%;
  height: 86%;
  object-fit: contain;
  z-index: 1;
  pointer-events: none;
}

.hidden-piece {
  width: 58%;
  aspect-ratio: 1;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.08), 0 3px 7px rgba(0, 0, 0, 0.18);
  z-index: 1;
}

.hidden-piece.w {
  background: #ffffff;
}

.hidden-piece.b {
  background: #111111;
}

.game-panel {
  display: grid;
  gap: 14px;
}

.players {
  display: grid;
  gap: 8px;
}

.player-row {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 28px;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid #8a8377;
}

.white .dot {
  background: #ffffff;
}

.black .dot {
  background: #111111;
}

.turn-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 46px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

#timer {
  font-size: 24px;
  letter-spacing: 0;
}

.status {
  min-height: 42px;
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.status.error {
  color: var(--danger);
}

.moves {
  display: grid;
  gap: 6px;
  max-height: 220px;
  margin: 0;
  padding-left: 22px;
  overflow: auto;
  color: var(--muted);
}

@media (max-width: 960px) {
  .layout,
  .game-area {
    grid-template-columns: 1fr;
  }

  .auth-panel,
  .lobby-panel,
  .game-area {
    grid-column: 1;
    grid-row: auto;
  }

  .game-area {
    gap: 12px;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100vw - 20px, 1180px);
    padding: 14px 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 30px;
  }

  .panel {
    padding: 12px;
  }

  .square .coord {
    display: none;
  }
}
