:root {
  color-scheme: light;
  --bg: #f6f1e7;
  --bg-2: #f0e7d6;
  --ink: #1b1b1b;
  --accent: #d95d39;
  --accent-2: #0f6b6b;
  --panel: #fff9ef;
  --panel-border: #e5d4b9;
  --muted: #6d5f4c;
  --shadow: rgba(25, 17, 7, 0.12);
  --radius: 18px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Space Grotesk", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

[hidden] {
  display: none !important;
}

.countdown-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(18, 12, 6, 0.45);
  backdrop-filter: blur(4px);
  z-index: 10;
}

.countdown-number {
  font-family: "Spectral", serif;
  font-size: clamp(4rem, 12vw, 10rem);
  color: #fff5e5;
  text-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  padding: 24px 48px;
  border-radius: 30px;
  background: radial-gradient(circle at 30% 30%, rgba(255, 200, 140, 0.35), transparent 45%),
    linear-gradient(140deg, #7a1f12, #d0492f 60%, #ff8a4c);
}

.bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top left, rgba(217, 93, 57, 0.2), transparent 55%),
    radial-gradient(circle at 20% 80%, rgba(15, 107, 107, 0.18), transparent 60%),
    linear-gradient(120deg, var(--bg), var(--bg-2));
  z-index: -1;
}

.shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 20px 80px;
  display: grid;
  gap: 24px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 20px;
  align-items: center;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.8rem;
  color: var(--muted);
}

h1 {
  font-family: "Spectral", serif;
  font-size: clamp(2rem, 3vw, 3.2rem);
  margin: 8px 0 12px;
}

h2 {
  font-family: "Spectral", serif;
  font-size: 1.3rem;
  margin-bottom: 12px;
}

.lead {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 540px;
}

.status-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 10px 24px var(--shadow);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 10px 24px var(--shadow);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

input, select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: #fff;
  font-size: 0.95rem;
  flex: 1 1 200px;
}

button {
  border: none;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(217, 93, 57, 0.25);
}

button.secondary {
  background: var(--accent-2);
}

.muted {
  color: var(--muted);
}

.warning {
  color: #a73f2d;
  margin-top: 10px;
}

.board {
  display: grid;
  gap: 14px;
  margin-top: 14px;
  padding: 16px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 10% 20%, rgba(15, 107, 107, 0.12), transparent 40%),
    radial-gradient(circle at 80% 10%, rgba(217, 93, 57, 0.2), transparent 45%),
    linear-gradient(140deg, #f2e1c8, #f9f3e9);
  border: 1px solid var(--panel-border);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.board-category {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(185, 150, 120, 0.35);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 12px 24px rgba(62, 39, 28, 0.08), inset 0 0 0 1px rgba(255, 255, 255, 0.7);
  min-width: 0;
}

.board-category-title {
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 6px 10px;
  background: linear-gradient(135deg, #fff8ee, #f1ddc2);
  border-radius: 999px;
  border: 1px solid rgba(185, 150, 120, 0.4);
  display: inline-flex;
  align-self: flex-start;
}

.board-subgrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(60px, 1fr));
  gap: 10px;
  min-width: 0;
}

.board-cell {
  padding: 12px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(180, 150, 120, 0.45);
  min-height: 66px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.board-cell span {
  font-size: 0.85rem;
  color: var(--muted);
}

.board-cell.tile {
  background: linear-gradient(135deg, #f8efe2, #ecd5bc);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.board-cell.tile.empty {
  background: linear-gradient(135deg, #f9f3ea, #f1dfc8);
  border-style: solid;
  color: #704a2e;
}

.board-cell.tile.selectable {
  cursor: pointer;
  border-color: rgba(35, 130, 142, 0.7);
  box-shadow: 0 0 0 3px rgba(35, 130, 142, 0.2);
}

.board-cell.tile.selected {
  border-color: rgba(38, 120, 54, 0.7);
  box-shadow: 0 0 0 3px rgba(38, 120, 54, 0.3);
}

.board-cell.tile.claimed {
  opacity: 0.7;
}

.board-cell.tile.attackable {
  cursor: pointer;
  border-color: rgba(217, 93, 57, 0.75);
  box-shadow: 0 0 0 3px rgba(217, 93, 57, 0.2);
}

.board-cell.tile.owned::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: var(--tile-color, rgba(15, 107, 107, 0.2));
  opacity: 0.25;
}

.board-cell.tile.in-duel {
  outline: 3px solid rgba(35, 130, 142, 0.45);
  box-shadow: 0 0 0 2px rgba(35, 130, 142, 0.25);
}

.board-cell.tile.active {
  outline: 3px solid rgba(217, 93, 57, 0.6);
  box-shadow: 0 0 0 3px rgba(217, 93, 57, 0.25);
}

.board-cell.tile.lava {
  color: #fff;
  border-color: rgba(180, 85, 66, 0.8);
  background: radial-gradient(circle at 20% 30%, rgba(255, 160, 80, 0.9), transparent 45%),
    radial-gradient(circle at 70% 60%, rgba(220, 60, 30, 0.9), transparent 50%),
    linear-gradient(140deg, #7a1f12, #d0492f 60%, #ff8a4c);
  animation: lavaPulse 2.8s ease-in-out infinite;
}

.board-cell.tile.lava::after {
  content: "";
  position: absolute;
  inset: -20%;
  background: radial-gradient(circle at 30% 40%, rgba(255, 230, 150, 0.8), transparent 40%);
  opacity: 0.6;
  mix-blend-mode: screen;
  animation: lavaFlow 4.5s linear infinite;
}

@keyframes lavaPulse {
  0%, 100% {
    transform: translateY(0);
    filter: brightness(1);
  }
  50% {
    transform: translateY(-2px);
    filter: brightness(1.15);
  }
}

@keyframes lavaFlow {
  0% {
    transform: translateX(-5%) translateY(0);
  }
  100% {
    transform: translateX(5%) translateY(-5%);
  }
}

.player-list {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.player-card {
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--panel-border);
}

.duel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.timer {
  padding: 16px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--panel-border);
  font-size: 1.2rem;
  font-weight: 700;
}

.last-answer {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--panel-border);
  font-weight: 600;
}

.last-answer.good {
  border-color: #4a8c4a;
  color: #2f6b2f;
}

.last-answer.bad {
  border-color: #b45542;
  color: #8c3b2f;
}

.answer-log {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--panel-border);
}

.answer-log h3 {
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.answer-log-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9rem;
  padding: 6px 0;
  border-bottom: 1px dashed var(--panel-border);
}

.answer-log-item:last-child {
  border-bottom: none;
}

.answer-log-item .badge {
  font-weight: 700;
}

.answer-log-item .badge.good {
  color: #2f6b2f;
}

.answer-log-item .badge.bad {
  color: #8c3b2f;
}

.winner-banner {
  padding: 14px;
  border-radius: 14px;
  background: linear-gradient(140deg, #2f6b2f, #6aa84f);
  color: #fff;
  font-weight: 700;
  text-align: center;
}

.split-view {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.split-card {
  border-radius: 14px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--panel-border);
}

.split-card h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.split-card .small {
  font-size: 0.9rem;
  color: var(--muted);
}

.spectator-grid {
  display: grid;
  gap: 12px;
}

.spectator-card {
  background: #fff;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px;
}

.spectator-card.in-duel {
  border-color: rgba(15, 107, 107, 0.55);
  box-shadow: 0 0 0 2px rgba(15, 107, 107, 0.2);
}

.spectator-card.active {
  border-color: rgba(217, 93, 57, 0.9);
  box-shadow: 0 0 0 3px rgba(217, 93, 57, 0.3);
  background: linear-gradient(160deg, #fff7ea, #fff);
}

.spectator-card.empty {
  opacity: 0.6;
  text-align: center;
  color: var(--muted);
}

.spectator-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.pill {
  background: #f3e6d2;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.75rem;
}

.duel-mini .small {
  margin-top: 6px;
}

button.active {
  box-shadow: 0 8px 18px rgba(217, 93, 57, 0.25);
  transform: translateY(-1px);
}
.category-btn.taken {
  opacity: 0.65;
}

.ready-btn {
  width: 100%;
  padding: 18px 24px;
  font-size: 1.2rem;
  font-weight: 700;
  border-radius: 14px;
  background: #b45542;
  color: #fff;
  margin-top: 12px;
}

.ready-btn.ready {
  background: #2f6b2f;
}

.question-box {
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--panel-border);
}

.question {
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.option-btn {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  font-weight: 600;
  color: var(--ink);
}

.option-btn.correct {
  border-color: #4a8c4a;
  background: rgba(74, 140, 74, 0.12);
  color: #2f6b2f;
}

.option-btn.wrong {
  border-color: #b45542;
  background: rgba(180, 85, 66, 0.12);
  color: #8c3b2f;
}

.option-btn.selected {
  border-color: #5b4a2b;
  background: rgba(91, 74, 43, 0.12);
  color: #4a3a20;
}

.category-btn.selected {
  border-color: #0f6b6b;
  background: rgba(15, 107, 107, 0.14);
  color: #0b4f4f;
}

.category-btn.taken {
  opacity: 0.75;
}

.option-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.admin button {
  background: #333;
}

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

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

  .board-subgrid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}
