:root {
  color-scheme: dark;
  --ink: #241910;
  --paper: #f4ead8;
  --paper-deep: #e7d8bf;
  --sea: #1c4c58;
  --night: #221c16;
  --night-2: #2c241c;
  --brass: #c9893a;
  --brass-deep: #8a5a22;
  --wax: #8d2f2a;
  --foam: #f7f1e6;
  --line: rgba(244, 234, 216, 0.16);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--night); color: var(--foam); }
body { min-height: 100dvh; }
button, input, select { font: inherit; color: inherit; touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.boot { padding: 2rem 1.2rem; color: var(--paper); }

.home, .table { min-height: 100dvh; }
.home {
  display: grid;
  align-content: start;
  gap: 1.2rem;
  padding: calc(1.2rem + env(safe-area-inset-top)) 1rem 2rem;
  background:
    radial-gradient(circle at 20% -10%, rgba(201, 137, 58, 0.35), transparent 42%),
    linear-gradient(180deg, #3a2b20 0%, var(--night) 46%);
}
.brand {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--brass);
}
h1, h2 { font-family: Palatino, "Iowan Old Style", Georgia, serif; font-weight: 600; }
h1 { margin: 0.2rem 0; font-size: clamp(2.4rem, 10vw, 4.4rem); line-height: 0.92; }
.lede { max-width: 38rem; margin: 0; color: #f0e2cc; line-height: 1.45; }
.panel, .sheet, .card {
  background: var(--night-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.panel, .card { padding: 1rem; }
form { display: grid; gap: 0.8rem; }
label { display: grid; gap: 0.35rem; font-size: 0.92rem; }
input, select {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(244, 234, 216, 0.2);
  background: #16120e;
  padding: 0.55rem 0.75rem;
  font-size: 16px;
}
.row { display: flex; gap: 0.7rem; }
.row > * { flex: 1; }
.check { display: flex; align-items: center; gap: 0.6rem; min-height: 44px; }
.check input { width: 1.2rem; height: 1.2rem; }
.primary, .ghost, .choice {
  min-height: 44px;
  border-radius: 999px;
  border: 0;
  padding: 0.65rem 1rem;
}
.primary { background: var(--brass); color: #24160b; font-weight: 700; }
.ghost, .choice { background: transparent; border: 1px solid rgba(244, 234, 216, 0.28); }
.choice.on, .tile-hot { outline: 2px solid var(--brass); }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.alert {
  background: rgba(141, 47, 42, 0.25);
  border: 1px solid rgba(232, 148, 138, 0.5);
  color: #ffd7d1;
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
}
.muted { color: #d9cbb6; }
.tiny { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: #cbbba6; }

.table {
  display: grid;
  grid-template-rows: auto minmax(240px, 1fr) auto;
  height: 100dvh;
}
.top {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  padding: calc(0.7rem + env(safe-area-inset-top)) 0.8rem 0.6rem;
  align-items: end;
}
.top h1 { font-size: 1.55rem; }
.clock { margin: 0; font-variant-numeric: tabular-nums; color: var(--brass); white-space: nowrap; }
.stage {
  overflow: auto;
  background:
    radial-gradient(circle at 50% 20%, #2a6d78, var(--sea) 70%);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
svg { width: 100%; height: auto; display: block; min-width: 320px; touch-action: manipulation; }
.sea { fill: transparent; }
.land { stroke-linejoin: round; cursor: pointer; }
.land.mine { stroke: #f6e27a; stroke-width: 4; }
.badge { fill: #1b140f; stroke: rgba(255, 244, 220, 0.7); stroke-width: 1; }
.army {
  fill: var(--foam);
  font-size: 16px;
  font-weight: 750;
  text-anchor: middle;
  dominant-baseline: central;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  pointer-events: none;
}
.tname {
  fill: #1b140f;
  font-size: 11px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
  font-family: Palatino, Georgia, serif;
}
.land.picked { stroke: #f2c14e; stroke-width: 4; }
.land.hot { stroke: #fff6d8; stroke-width: 3; }

.sheet {
  max-height: 46dvh;
  overflow: auto;
  padding: 0.75rem 0.8rem calc(0.8rem + env(safe-area-inset-bottom));
  border-radius: 18px 18px 0 0;
  background: #2a231c;
}
.versus {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.4rem;
  align-items: center;
  text-align: center;
}
.huge {
  display: block;
  font-size: 3rem;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}
.vs { color: var(--brass); font-family: Palatino, Georgia, serif; }
.versus .who, .versus .tiny { display: block; margin-top: 0.15rem; }
.roster, .realms, .cards, .dice-row { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.seat, .realm, .playing-card, .die {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #16120e;
}
.seat, .realm, .playing-card { padding: 0.35rem 0.55rem; min-height: 44px; }
.seat { display: flex; align-items: center; gap: 0.4rem; }
.swatch { width: 0.7rem; height: 0.7rem; border-radius: 99px; display: inline-block; }
.playing-card { text-align: left; }
.playing-card.on { border-color: var(--brass); background: #3a2c1d; }
.ai {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--brass);
  color: var(--brass);
  border-radius: 99px;
  padding: 0.1rem 0.35rem;
}
.die {
  width: 44px;
  height: 44px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 6px;
  background: var(--paper);
}
.pip { width: 7px; height: 7px; border-radius: 99px; background: transparent; justify-self: center; align-self: center; }
.pip.on { background: var(--ink); }
.log { margin: 0.4rem 0 0; padding: 0; list-style: none; display: grid; gap: 0.25rem; }
.log li { color: #efe4d4; font-size: 0.92rem; }
.winner {
  background: #3d311c;
  border: 1px solid var(--brass);
  border-radius: 14px;
  padding: 0.8rem;
}

@media (min-width: 960px) {
  .home { padding: 3rem 8vw; }
  .table {
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100dvh;
  }
  .top { grid-column: 1 / -1; }
  .sheet {
    max-height: none;
    grid-row: 2;
    grid-column: 2;
    border-radius: 0;
  }
  .stage { grid-row: 2; grid-column: 1; }
  svg { max-height: calc(100dvh - 92px); margin: 0 auto; }
}
