:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #5d6a65;
  --panel: #f7f4ee;
  --surface: rgba(255, 252, 246, 0.88);
  --card: #fffaf1;
  --button: #fffdf8;
  --line: #d8d0c3;
  --blue: #1d6f8f;
  --red: #b54635;
  --green: #3f7f4d;
  --yellow: #d5a93b;
  --board: #26352f;
  --tile: #fbfaf6;
  --focus: #e9b44c;
  --shadow: rgba(42, 35, 24, 0.14);
  --page:
    linear-gradient(135deg, rgba(29, 111, 143, 0.14), transparent 34%),
    linear-gradient(315deg, rgba(181, 70, 53, 0.13), transparent 30%),
    #ebe4d8;
}

html.dark-theme {
  color-scheme: dark;
  --ink: #f1eee7;
  --muted: #c2bbb0;
  --panel: #1f2926;
  --surface: rgba(28, 35, 32, 0.9);
  --card: #26312d;
  --button: #202a27;
  --line: #48524d;
  --blue: #6fb4d4;
  --red: #d47c6a;
  --green: #7fa876;
  --yellow: #e8b34c;
  --board: #111a18;
  --tile: #f4efe4;
  --focus: #f0bc55;
  --shadow: rgba(0, 0, 0, 0.32);
  --page:
    linear-gradient(135deg, rgba(29, 111, 143, 0.2), transparent 34%),
    linear-gradient(315deg, rgba(181, 70, 53, 0.16), transparent 30%),
    #141917;
}

* {
  box-sizing: border-box;
}

a {
  color: inherit;
  text-decoration: none;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.64);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: max-content;
  font-size: 1.1rem;
  font-weight: 950;
}
.brand-mark img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.nav-links a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #bfb5a4;
  border-radius: 8px;
  background: var(--button);
  padding: 0 12px;
  font-weight: 800;
}

.nav-links a:hover {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(233, 180, 76, 0.22), 0 22px 52px var(--shadow);
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.62rem 0.82rem;
  color: var(--ink);
  background: var(--button);
  cursor: pointer;
}

button:hover {
  border-color: var(--focus);
}

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

.primary {
  border-color: #c7a84a;
  background: linear-gradient(180deg, #e9b44c, #d5a93b);
  color: #15120c;
  font-weight: 800;
}

.hidden {
  display: none !important;
}

.setup-screen {
  position: relative;
  display: grid;
  min-height: 100vh;
  place-items: center;
  overflow: hidden;
  padding: 2rem;
}

.setup-art {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(235, 228, 216, 0.12), rgba(235, 228, 216, 0.32)),
    linear-gradient(135deg, rgba(29, 111, 143, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(181, 70, 53, 0.06), transparent 30%),
    #f5ede8;
}

.rift {
  position: absolute;
  width: 14rem;
  height: 60rem;
  transform: rotate(28deg);
  border: 2px solid rgba(29, 111, 143, 0.22);
  background: linear-gradient(90deg, transparent, rgba(181, 70, 53, 0.12), transparent);
  box-shadow: 0 0 90px rgba(217, 180, 95, 0.12);
}

.rift-a {
  left: 14%;
  top: -12rem;
}

.rift-b {
  right: 10%;
  bottom: -20rem;
}

.mana-grid {
  position: absolute;
  inset: 8% 5%;
  border: 1px solid rgba(215, 183, 106, 0.18);
  clip-path: polygon(7% 12%, 88% 0, 100% 78%, 18% 100%);
}

.setup-content {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.setup-content h1 {
  margin-bottom: 0.75rem;
  font-size: clamp(3rem, 12vw, 7.4rem);
  line-height: 0.9;
}

.lede {
  max-width: 42rem;
  color: var(--muted);
  font-size: 1.12rem;
  line-height: 1.55;
}

.setup-controls {
  display: grid;
  grid-template-columns: 1fr 11rem auto;
  gap: 0.8rem;
  align-items: end;
  margin-top: 2rem;
}

label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

input[type="number"] {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.58rem 0.68rem;
  color: var(--ink);
  background: var(--button);
}

.game-screen {
  min-height: 100vh;
  padding: 1rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.75rem 1rem;
}

.topbar h1 {
  margin: 0;
  font-size: 1.55rem;
}

.topbar-actions {
  display: flex;
  gap: 0.55rem;
}

.table {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(420px, 1fr) minmax(260px, 330px);
  gap: 1rem;
  min-height: calc(100vh - 12rem);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 22px 52px var(--shadow);
  overflow: hidden;
}

.left-panel,
.right-panel {
  display: grid;
  align-content: start;
  gap: 1rem;
  padding: 1rem;
}

.turn-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.8rem;
  background: var(--card);
}

.turn-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.turn-card strong {
  display: block;
  margin: 0.2rem 0 0.35rem;
  font-size: 1.12rem;
}

.turn-card p,
.player-row p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.4;
}

.players-list {
  display: grid;
  gap: 0.58rem;
}

.player-row {
  display: grid;
  grid-template-columns: 0.7rem 1fr auto;
  gap: 0.55rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.64rem;
  background: var(--card);
}

.player-row.active {
  border-color: var(--focus);
}

.player-color {
  width: 0.7rem;
  height: 2.4rem;
  border-radius: 99px;
}

.status-pill {
  border-radius: 999px;
  padding: 0.16rem 0.42rem;
  color: white;
  background: var(--yellow);
  font-size: 0.72rem;
  font-weight: 800;
}

.status-pill.vassal {
  background: var(--blue);
}

.status-pill.out {
  background: var(--red);
}

.board-wrap {
  position: relative;
  display: grid;
  min-height: 39rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(235, 228, 216, 0.22), rgba(235, 228, 216, 0.18)),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(29, 111, 143, 0.03) 31px 32px),
    #f5ede8;
  box-shadow: 0 22px 52px var(--shadow);
  overflow: hidden;
}

.dice-display {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  z-index: 2;
  display: grid;
  gap: 0.12rem;
  min-width: 8.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  background: var(--card);
  box-shadow: 0 8px 28px rgba(42, 35, 24, 0.12);
}

.dice-display span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.dice-display strong {
  color: var(--yellow);
  font-size: 1.08rem;
}

#board {
  width: min(100%, 880px);
  height: min(72vh, 760px);
  min-height: 32rem;
}

.hex {
  stroke: rgba(38, 53, 47, 0.28);
  stroke-width: 1.4;
  cursor: pointer;
  transition: filter 120ms ease, stroke-width 120ms ease;
}

.hex:hover {
  filter: brightness(0.95);
  stroke-width: 2.4;
}

.hex.selected {
  stroke: var(--yellow);
  stroke-width: 4;
}

.hex.setup-target {
  stroke: #f0e0a6;
  stroke-width: 4;
  filter: brightness(1.08);
}

.hex.chart-target {
  stroke: #1d6f8f;
  stroke-width: 3.5;
  filter: brightness(0.92);
}

.hex.unrevealed {
  fill: #d8d0c3;
  stroke-dasharray: 4 5;
}

.hex.forest {
  fill: #6aa36f;
}

.hex.mine {
  fill: #8a8a8a;
}

.hex.pasture {
  fill: #9fa676;
}

.hex.market {
  fill: #a68c6a;
}

.hex.mixed {
  fill: #7a9a8a;
}

.hex.center {
  fill: #9a7a8a;
}

.piece-text,
.flag-text,
.coord-text {
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: middle;
  font-weight: 900;
}

.piece-text {
  fill: white;
  font-size: 17px;
}

.flag-text {
  fill: #17201d;
  font-size: 12px;
}

.coord-text {
  fill: rgba(38, 53, 47, 0.5);
  font-size: 9px;
  font-weight: 700;
}

.resources h2,
.selected h2,
.actions h2,
.cards h2 {
  margin-bottom: 0.65rem;
  font-size: 0.92rem;
}

.resource-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.45rem;
}

.resource {
  display: flex;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem;
  background: var(--card);
}

.selected-info {
  color: var(--muted);
  line-height: 1.5;
}

.action-buttons,
.hand-list {
  display: grid;
  gap: 0.45rem;
}

.action-buttons button,
.hand-list button {
  width: 100%;
  text-align: left;
}

.hand-list button {
  background: var(--button);
}

.log-wrap {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.game-log {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding: 0.7rem;
  color: var(--muted);
  font-size: 0.83rem;
}

.game-log span {
  flex: 0 0 auto;
  max-width: 28rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.34rem 0.6rem;
  background: var(--panel);
}

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

  .left-panel,
  .right-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .players-list,
  .actions,
  .cards {
    grid-column: span 2;
  }

  .setup-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .game-screen {
    padding: 0.5rem;
  }

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

  .left-panel,
  .right-panel {
    grid-template-columns: 1fr;
  }

  .players-list,
  .actions,
  .cards {
    grid-column: span 1;
  }

  #board {
    min-height: 28rem;
  }
}
