:root {
  --bg: #f3f4ee;
  --text: #17201c;
  --muted: #65716b;
  --line: #d8ded4;
  --panel: #ffffff;
  --dark: #6b7f57;
  --light: #eef2df;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.app {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar,
.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: start;
}

.topbar {
  align-items: end;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.4rem, 7vw, 5.2rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.05rem;
}

.room-form,
.side,
.status,
.moves {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.room-form {
  display: grid;
  grid-template-columns: 1fr 110px auto;
  gap: 10px;
  padding: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

input,
select,
button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
}

button {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

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

.board-wrap {
  width: min(100%, 720px);
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  overflow: hidden;
  border: 1px solid #9ba88d;
  border-radius: 8px;
  aspect-ratio: 1;
  background: var(--line);
}

.square {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: var(--text);
  font-size: clamp(1.9rem, 7vw, 4rem);
  line-height: 1;
}

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

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

.square.selected {
  outline: 4px solid #facc15;
  outline-offset: -4px;
}

.square.legal::after {
  content: "";
  width: 22%;
  height: 22%;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.55);
}

.square.legal.has-piece::after {
  width: 76%;
  height: 76%;
  border: 4px solid rgba(180, 35, 24, 0.58);
  background: transparent;
}

.side {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.status,
.moves {
  padding: 18px;
}

.status p,
.moves {
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

#resetGame {
  background: transparent;
  color: var(--danger);
  border-color: #f1b9b5;
}

.moves {
  min-height: 240px;
}

.moves ol {
  margin: 0;
  padding-left: 22px;
  line-height: 1.8;
}

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

  .room-form {
    grid-template-columns: 1fr;
  }

  .board-wrap {
    width: 100%;
  }
}
