:root {
  --ink: #1c2430;
  --muted: #687386;
  --paper: #fbf7ec;
  --panel: #fffdf8;
  --line: #d7c9a9;
  --room: #e9d8ad;
  --room-dark: #c39a5b;
  --hall: #7f9488;
  --accent: #0f766e;
  --danger: #b42318;
  --shadow: rgba(28, 36, 48, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.11), transparent 36%),
    linear-gradient(315deg, rgba(195, 154, 91, 0.18), transparent 34%),
    #f4efe4;
  font-family: Arial, Helvetica, sans-serif;
}

button,
select {
  min-height: 40px;
  border-radius: 8px;
  font: inherit;
}

button {
  border: 0;
  padding: 10px 14px;
  color: white;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

button.danger {
  background: var(--danger);
}

button:disabled {
  background: #9aa4b2;
  cursor: not-allowed;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  padding: 8px 10px;
  color: var(--ink);
  background: white;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1;
}

.game {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 18px;
  min-height: 100vh;
  padding: 20px;
}

.topbar,
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar {
  justify-content: space-between;
}

.header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

#contextLabel {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.table {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(260px, 320px) minmax(250px, 320px);
  gap: 16px;
  min-height: 0;
}

.board-panel {
  align-self: center;
  justify-self: center;
  width: min(72vh, 62vw, 720px);
  min-width: 330px;
}

.board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 8px;
  aspect-ratio: 1;
  padding: 12px;
  border: 4px solid #4c3a26;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(76, 58, 38, 0.16) 1px, transparent 1px),
    linear-gradient(180deg, rgba(76, 58, 38, 0.16) 1px, transparent 1px),
    #bfa779;
  background-size: 20% 20%;
  box-shadow: 0 24px 56px var(--shadow);
}

.space {
  position: relative;
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  min-height: 0;
  border: 2px solid rgba(76, 58, 38, 0.3);
  border-radius: 8px;
  padding: 10px;
  color: #241b12;
  background: rgba(127, 148, 136, 0.55);
  text-align: left;
}

.space.room {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 45%),
    var(--room);
}

.space.hall {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent 50%),
    var(--hall);
}

.space.current {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 3px rgba(15, 118, 110, 0.26);
}

.space.legal {
  outline: 4px solid rgba(15, 118, 110, 0.66);
  outline-offset: -6px;
  cursor: pointer;
}

.space-name {
  font-size: clamp(12px, 1.8vmin, 17px);
  font-weight: 900;
  line-height: 1.1;
}

.space.hall .space-name {
  display: none;
}

.tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: auto;
}

.token {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid white;
  border-radius: 50%;
  color: white;
  background: #475569;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 3px 8px rgba(28, 36, 48, 0.28);
}

.play-panel,
.notes-panel {
  display: grid;
  gap: 12px;
  min-height: 0;
}

.status-card,
.action-card,
.hand-card,
.players-card,
.log-card {
  border: 1px solid rgba(76, 58, 38, 0.16);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 10px 24px rgba(28, 36, 48, 0.08);
}

.status-card,
.action-card,
.hand-card,
.players-card,
.log-card {
  padding: 14px;
}

.action-card {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hint {
  margin: -4px 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.status {
  font-size: 18px;
  font-weight: 900;
  line-height: 1.25;
}

.player-side {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.hand {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card-pill,
.reveal-option {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  color: #2d2418;
  background: #f6ecd6;
  font-size: 12px;
  font-weight: 800;
}

.reveal-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.reveal-option {
  color: white;
  background: var(--accent);
}

.players-card ol,
.log-card ol {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
}

.players-card li.eliminated {
  color: var(--muted);
  text-decoration: line-through;
}

.log-card {
  min-height: 180px;
  overflow: auto;
}

.result-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 20;
  display: grid;
  min-width: min(78vw, 420px);
  padding: 26px 32px;
  border: 2px solid #facc15;
  border-radius: 8px;
  color: #111827;
  background: rgba(255, 253, 248, 0.97);
  box-shadow: 0 24px 60px rgba(28, 36, 48, 0.3);
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.hidden {
  display: none !important;
}

.result-overlay.hidden {
  display: none;
}

.result-message {
  color: var(--accent);
  font-size: clamp(38px, 9vmin, 76px);
  font-weight: 900;
  line-height: 1;
}

@media (max-width: 1120px) {
  .table {
    grid-template-columns: 1fr 1fr;
  }

  .board-panel {
    grid-column: 1 / -1;
    width: min(82vw, 650px);
  }
}

@media (max-width: 720px) {
  .game {
    padding: 14px;
  }

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

  .table {
    grid-template-columns: 1fr;
  }

  .board-panel {
    width: 100%;
    min-width: 0;
  }

  .board {
    gap: 5px;
    padding: 8px;
  }

  .space {
    padding: 6px;
  }
}
