:root {
  --bg: #f4ede1;
  --bg-strong: #efe2cd;
  --card: rgba(255, 250, 242, 0.78);
  --card-strong: rgba(255, 247, 235, 0.95);
  --line: rgba(62, 39, 24, 0.16);
  --text: #22160f;
  --muted: #6d5545;
  --accent: #d85b38;
  --accent-2: #1b62c5;
  --good: #27845a;
  --shadow: 0 20px 50px rgba(62, 35, 14, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(216, 91, 56, 0.17), transparent 30%),
    radial-gradient(circle at bottom right, rgba(27, 98, 197, 0.16), transparent 28%),
    linear-gradient(135deg, var(--bg), #f8f4eb 55%, var(--bg-strong));
  color: var(--text);
}

body[data-theme="midnight"] {
  background:
    radial-gradient(circle at top left, rgba(240, 137, 87, 0.15), transparent 30%),
    radial-gradient(circle at bottom right, rgba(99, 164, 255, 0.14), transparent 28%),
    linear-gradient(135deg, #0b111b, var(--bg) 52%, var(--bg-strong));
}

body[data-theme="ocean"] {
  --bg: #dfeaf5;
  --bg-strong: #c8dbed;
  --card: rgba(247, 251, 255, 0.8);
  --card-strong: rgba(238, 246, 253, 0.95);
  --line: rgba(18, 56, 82, 0.15);
  --text: #112032;
  --muted: #46607b;
  --accent: #0f8c94;
  --accent-2: #2458cc;
  --good: #1c8a63;
  --shadow: 0 18px 45px rgba(17, 44, 76, 0.15);
}

body[data-theme="midnight"] {
  --bg: #0f1723;
  --bg-strong: #192334;
  --card: rgba(21, 31, 46, 0.84);
  --card-strong: rgba(28, 40, 58, 0.96);
  --line: rgba(162, 184, 210, 0.16);
  --text: #e8edf7;
  --muted: #97a9c2;
  --accent: #f08957;
  --accent-2: #63a4ff;
  --good: #38bb86;
  --shadow: 0 20px 50px rgba(4, 9, 18, 0.42);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 28px 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(16px);
}

body[data-theme="midnight"] .sidebar {
  background: rgba(8, 14, 24, 0.52);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: block;
  border-radius: 18px;
  object-fit: cover;
  object-position: center;
  box-shadow: var(--shadow);
}

.brand h1,
.section-head h2,
.hero-card h2,
.board-caption h3 {
  margin: 0;
  font-family: "Unbounded", sans-serif;
  letter-spacing: -0.03em;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  color: var(--muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-link,
.menu-card,
button.mode-card,
.secondary-button,
.primary-button {
  border: 1px solid var(--line);
  background: var(--card-strong);
  box-shadow: var(--shadow);
  color: var(--text);
}

.mode-card,
.setting-card,
.upload-card,
.stat-chip,
.player-card,
.dice-panel,
.table-card,
.profile-card,
.auth-card,
.board-panel {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.28);
  box-shadow: 0 8px 24px rgba(62, 35, 14, 0.06);
  color: var(--text);
}

body[data-theme="midnight"] .mode-card,
body[data-theme="midnight"] .setting-card,
body[data-theme="midnight"] .upload-card,
body[data-theme="midnight"] .stat-chip,
body[data-theme="midnight"] .player-card,
body[data-theme="midnight"] .dice-panel,
body[data-theme="midnight"] .table-card,
body[data-theme="midnight"] .profile-card,
body[data-theme="midnight"] .auth-card,
body[data-theme="midnight"] .board-panel {
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 8px 24px rgba(4, 9, 18, 0.18);
}

.nav-link {
  border-radius: 18px;
  padding: 14px 16px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, border-color 140ms ease;
}

.nav-link.active,
.nav-link:hover {
  background: var(--card-strong);
  border-color: rgba(216, 91, 56, 0.28);
  transform: translateY(-1px);
}

.content {
  padding: 28px;
}

.screen {
  display: none;
  animation: fadeUp 220ms ease;
}

.screen.active {
  display: block;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-card,
.menu-grid,
.mode-grid,
.game-layout,
.settings-grid,
.bots-grid,
.button-row,
.section-head,
.toolbar,
.control-row,
.dice-visuals,
.resource-list,
.legend,
.board-caption {
  display: flex;
  gap: 16px;
}

.hero-card,
.profile-card,
.auth-card,
.board-panel,
.table-card {
  border-radius: 28px;
  padding: 24px;
}

.hero-card {
  justify-content: space-between;
  align-items: center;
  min-height: 280px;
  background:
    linear-gradient(125deg, rgba(255, 255, 255, 0.78), rgba(255, 245, 233, 0.9)),
    linear-gradient(45deg, rgba(216, 91, 56, 0.15), transparent);
}

.hero-copy {
  max-width: 580px;
  color: var(--muted);
  line-height: 1.6;
}

.hero-actions {
  display: grid;
  gap: 12px;
  min-width: 250px;
}

.primary-button,
.secondary-button {
  border-radius: 18px;
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease, background 140ms ease;
}

.primary-button {
  background: linear-gradient(145deg, var(--accent), #f5a25f);
  color: white;
  border: none;
}

.primary-button.big {
  min-height: 74px;
  font-size: 24px;
  font-weight: 800;
}

.secondary-button {
  color: var(--text);
  border-color: rgba(216, 91, 56, 0.22);
}

.secondary-button:hover,
.primary-button:hover,
.menu-card:hover,
button.mode-card:hover {
  transform: translateY(-2px);
  border-color: rgba(216, 91, 56, 0.42);
  box-shadow: 0 16px 34px rgba(62, 35, 14, 0.16);
}

body[data-theme="midnight"] .secondary-button:hover,
body[data-theme="midnight"] .primary-button:hover,
body[data-theme="midnight"] .menu-card:hover,
body[data-theme="midnight"] button.mode-card:hover {
  box-shadow: 0 16px 34px rgba(4, 9, 18, 0.36);
}

.menu-grid,
.mode-grid,
.settings-grid,
.bots-grid {
  margin-top: 22px;
  flex-wrap: wrap;
}

.menu-card,
.mode-card,
.setting-card,
.upload-card {
  border-radius: 24px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 220px;
  flex: 1 1 240px;
}

.menu-card,
button.mode-card {
  cursor: pointer;
}

div.mode-card,
.setting-card,
.upload-card,
.stat-chip,
.player-card,
.dice-panel,
.table-card,
.profile-card,
.auth-card {
  cursor: default;
}

.leaderboard-filter,
.mode-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.section-head {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.game-layout {
  padding: 18px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
}

.game-panel {
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player-card,
.dice-panel {
  border-radius: 24px;
  padding: 18px;
}

.player-card.active-turn {
  border-color: rgba(216, 91, 56, 0.48);
  box-shadow: 0 0 0 3px rgba(216, 91, 56, 0.12), var(--shadow);
}

.player-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.player-name {
  font-size: 18px;
  font-weight: 800;
}

.timer {
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.meta-row {
  display: flex;
  gap: 12px;
  color: var(--muted);
}

.dice-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.die-card,
.resource-chip,
.pill {
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--card-strong);
}

.die-card {
  flex: 1;
  padding: 12px;
  display: grid;
  place-items: center;
}

.die-card.rolling {
  animation: diePulse 520ms ease;
}

@keyframes diePulse {
  0% {
    transform: translateY(0) scale(1);
    filter: saturate(1);
  }
  35% {
    transform: translateY(-4px) scale(1.06) rotate(-4deg);
    filter: saturate(1.25);
  }
  70% {
    transform: translateY(2px) scale(0.98) rotate(3deg);
  }
  100% {
    transform: translateY(0) scale(1) rotate(0deg);
    filter: saturate(1);
  }
}

.die-value {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 68px;
  height: 68px;
  padding: 10px;
  border-radius: 8px;
  background: #f2eadf;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    inset 0 -1px 0 rgba(77, 55, 37, 0.1);
}

body[data-theme="midnight"] .die-value {
  background: #efe7da;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    inset 0 -1px 0 rgba(39, 28, 16, 0.12);
}

.die-value.is-empty {
  opacity: 0.45;
}

.pip {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: transparent;
  justify-self: center;
  align-self: center;
}

.pip.active {
  background: #0f0f10;
}

.resource-list {
  flex-direction: column;
}

.resource-chip {
  padding: 14px;
  text-align: left;
  cursor: default;
  background: rgba(255, 255, 255, 0.52);
  box-shadow: none;
}

.resource-chip.active {
  border-color: rgba(216, 91, 56, 0.55);
  background: rgba(255, 255, 255, 0.95);
}

.resource-chip:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.pill {
  padding: 10px 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.38);
  box-shadow: none;
}

#online-status,
#auth-status {
  color: var(--muted);
  line-height: 1.5;
}

.auto-roll-note {
  background: rgba(255, 255, 255, 0.78);
}

.status-box {
  min-height: 80px;
  border-radius: 22px;
  padding: 14px;
  background: rgba(34, 22, 15, 0.04);
  line-height: 1.55;
}

body[data-theme="midnight"] .resource-chip {
  background: rgba(255, 255, 255, 0.06);
}

body[data-theme="midnight"] .pill {
  background: rgba(255, 255, 255, 0.05);
}

.board-panel {
  flex: 0 0 auto;
  width: max-content;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.board-caption {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.legend {
  flex-wrap: wrap;
  color: var(--muted);
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
  margin-right: 6px;
}

.dot.red { background: #e6473e; }
.dot.blue { background: #275cff; }
.dot.ghost { background: #ffc057; }

.board-wrap {
  position: relative;
  overflow: auto;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.18);
  padding: 10px 4px 10px 10px;
}

.board-labels {
  display: grid;
  --cols: 12;
  --cell-size: 34px;
  grid-template-columns: repeat(var(--cols), var(--cell-size));
  gap: 2px;
  width: max-content;
  padding: 0 12px;
  margin: 0 0 8px;
}

.board-labels.bottom {
  margin: 8px 0 0;
}

.board-label {
  width: var(--cell-size);
  height: 24px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.game-result-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(244, 237, 225, 0.88);
  backdrop-filter: blur(6px);
  border-radius: 24px;
}

.game-result-overlay[hidden] {
  display: none;
}

.game-result-card {
  min-width: 260px;
  padding: 28px 34px;
  border-radius: 28px;
  background: rgba(255, 251, 244, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  text-align: center;
}

.game-result-card strong {
  font-family: "Unbounded", sans-serif;
  font-size: 34px;
  letter-spacing: -0.04em;
}

.game-result-card p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.game-result-card.win strong {
  color: var(--good);
}

.game-result-card.loss strong {
  color: var(--accent);
}

.board {
  display: grid;
  --cols: 12;
  --cell-size: 34px;
  grid-template-columns: repeat(var(--cols), var(--cell-size));
  gap: 2px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.38);
  border-radius: 24px;
  width: max-content;
}

body[data-theme="midnight"] .board {
  background: rgba(255, 255, 255, 0.06);
}

body[data-theme="midnight"] .board-wrap {
  background: rgba(255, 255, 255, 0.04);
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.65);
  position: relative;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

body[data-theme="midnight"] .cell {
  border-color: rgba(255, 255, 255, 0.06);
  background: rgba(234, 241, 250, 0.08);
}

.cell.column-highlight {
  background: rgba(255, 208, 87, 0.26);
}

body[data-theme="midnight"] .cell.column-highlight {
  background: rgba(240, 137, 87, 0.16);
}

.cell.selectable {
  cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(216, 91, 56, 0.45);
}

.cell:hover.selectable {
  transform: translateY(-2px);
}

.cell.recent {
  box-shadow: 0 0 0 2px rgba(39, 132, 90, 0.45);
}

.piece {
  position: absolute;
  inset: 4px;
  border-radius: 12px;
}

.distance-marker {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
}

.piece.red {
  background: linear-gradient(160deg, #ff8b6f, #e64239);
}

.piece.blue {
  background: linear-gradient(160deg, #7db1ff, #275cff);
}

body[data-theme="midnight"] input,
body[data-theme="midnight"] select {
  color: var(--text);
  background: rgba(13, 21, 33, 0.88);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
}

tr.is-you {
  background: rgba(216, 91, 56, 0.09);
}

.stat-chip {
  border-radius: 18px;
  padding: 18px;
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}

.auth-card {
  display: grid;
  gap: 16px;
  max-width: 560px;
}

.auth-card label {
  display: grid;
  gap: 8px;
}

input,
select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
}

body[data-theme="midnight"] option {
  color: var(--text);
  background: #122031;
}

body[data-theme="midnight"] .hero-card {
  background:
    linear-gradient(125deg, rgba(23, 35, 52, 0.92), rgba(18, 28, 44, 0.96)),
    linear-gradient(45deg, rgba(240, 137, 87, 0.12), transparent);
}

body[data-theme="midnight"] .resource-chip.active,
body[data-theme="midnight"] .game-result-card {
  background: rgba(24, 36, 53, 0.96);
  color: var(--text);
}

body[data-theme="midnight"] .game-result-overlay {
  background: rgba(10, 16, 25, 0.84);
}

body[data-theme="midnight"] tr.is-you {
  background: rgba(240, 137, 87, 0.14);
}

.setting-toggle input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .game-layout {
    flex-direction: column;
  }

  .game-panel {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .content {
    padding: 18px;
  }

  .hero-card,
  .section-head,
  .board-caption {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-actions,
  .toolbar {
    width: 100%;
  }

  .board {
    padding: 8px;
    --cell-size: 26px;
  }

  .board-labels {
    --cell-size: 26px;
    padding: 0 8px;
  }

  .cell {
    border-radius: 7px;
  }
}
