:root {
  --bg: #12100e;
  --bg-2: #1b1814;
  --ink: #f4ecdf;
  --muted: #b5a894;
  --dim: #7e7468;
  --gold: #e0c48a;
  --gold-2: #a8884e;
  --line: rgba(224, 196, 138, 0.28);
  --panel: rgba(20, 17, 14, 0.94);
  --danger: #d36a5c;
  --ok: #8fce9a;
  --serif: "Cinzel", Palatino, "Palatino Linotype", serif;
  --sans: "Outfit", "Segoe UI", sans-serif;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(1200px 500px at 20% -10%, rgba(224, 196, 138, 0.08), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  letter-spacing: 0.01em;
}

button, input, select { font: inherit; color: inherit; }

button { cursor: pointer; }

.top {
  height: 68px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 12, 10, 0.92);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand strong {
  display: block;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.mark { width: 34px; height: 34px; }
.mark path { fill: none; stroke: var(--gold); stroke-width: 1.6; }
.mark .crown { fill: var(--gold); stroke: none; }

#status-line {
  flex: 1;
  margin: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--gold);
  overflow: hidden;
  white-space: nowrap;
}

.status-meta {
  font-family: var(--serif);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--gold);
}

.turn-clock {
  min-width: 84px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: Stencil, "Black Ops One", Impact, sans-serif;
  font-size: 28px;
  letter-spacing: 0.08em;
  line-height: 1;
  text-align: center;
  color: var(--gold);
}

.turn-clock.late {
  color: #ff1f1f;
  border-color: #ff1f1f;
  animation: clock-pulse 1s steps(2, end) infinite;
}

@keyframes clock-pulse {
  50% { opacity: 0.45; }
}

.status-army {
  font-family: Stencil, "Black Ops One", Impact, sans-serif;
  font-size: 28px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1;
  paint-order: stroke fill;
  max-width: 52%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-admin {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.room-admin[hidden],
.room-admin label[hidden],
.room-admin button[hidden] { display: none !important; }
.room-admin span { color: var(--gold); white-space: nowrap; }
.room-admin label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}
.room-admin select {
  background: #1a1612;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
  max-width: 140px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions button,
.speed {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 4px;
  padding: 7px 10px;
  font-size: 13px;
}

.speed { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.speed select {
  background: #211c17;
  border: 0;
  color: var(--ink);
  outline: none;
}

main {
  height: calc(100vh - 68px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
}

#map-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #0a4ea8;
}

svg.board-art .hex .body {
  fill: transparent;
  stroke: transparent;
  stroke-width: 10;
  pointer-events: none;
}
svg.board-art .hex .tname,
svg.board-art .hex .owner-edge { display: none; }
svg.board-art .hex .badge { pointer-events: auto; cursor: pointer; }
svg.board-art .hex .badge text { pointer-events: none; font-size: 12px; font-weight: 600; }
svg.board-art .hex.playable .badge circle,
svg.board-art .hex.selected .badge circle {
  stroke: #fff4cc;
  stroke-width: 2.6;
}
svg.board-art .hex.hostile .badge circle,
svg.board-art .hex.falling .badge circle {
  stroke: #ffb4a8;
  stroke-width: 2.6;
}
svg.board-art .hex.reach .badge circle {
  stroke: #b7f0c4;
  stroke-width: 2.6;
}
svg.board-art .hex:hover .badge circle {
  stroke: #fff4cc;
  stroke-width: 3.2;
}
svg.board-art .badge circle { stroke-width: 1.2; }

#board {
  width: 100%;
  height: 100%;
  display: block;
}
#board.board-art {
  width: 100%;
  height: 100%;
}

.map-title {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.22em;
  fill: #f0e2c4;
  text-anchor: middle;
}

.world-photo { pointer-events: none; }

.map-sub, .sea-label, .sea-name {
  font-family: var(--sans);
  fill: rgba(240, 226, 196, 0.9);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  stroke: rgba(6, 14, 18, 0.82);
  stroke-width: 3px;
  paint-order: stroke;
}

.sea-name { font-size: 9px; letter-spacing: 0.08em; }

.sea-route {
  fill: none;
  stroke: #f0e2c4;
  stroke-width: 1.6;
  stroke-dasharray: 2 7;
  stroke-linecap: round;
  opacity: 0.8;
}

.shores polygon, .shores path { fill: #07181d; }

.frame { fill: none; stroke: rgba(224, 196, 138, 0.38); stroke-width: 1.4; }
.frame.inner { stroke: rgba(224, 196, 138, 0.16); }
.frame, .map-title, .map-sub, .sea-label, .sea-name, .sea-route, .compass, .shores { pointer-events: none; }

.compass { stroke: #e0c48a; fill: #e0c48a; stroke-width: 1.2; }
.compass .east { opacity: 0.45; }
.compass text {
  fill: #e0c48a;
  stroke: none;
  font-family: var(--serif);
  font-size: 11px;
  text-anchor: middle;
}

.hex .body {
  stroke: rgba(12, 8, 6, 0.92);
  stroke-width: 1.45;
  stroke-linejoin: round;
  transition: filter 0.15s ease, stroke 0.15s ease;
}

.hex .tname {
  font-family: var(--sans);
  font-size: 8.5px;
  font-weight: 600;
  fill: #f7f1e7;
  stroke: rgba(18, 10, 8, 0.9);
  stroke-width: 2px;
  paint-order: stroke;
  text-anchor: middle;
  pointer-events: none;
}

.hex .badge { pointer-events: none; }
.hex .badge circle { stroke: #f7f1e7; stroke-width: 1.6; }
.hex .badge text {
  font-size: 11px;
  font-weight: 700;
  text-anchor: middle;
  font-family: var(--sans);
}
.hex .owner-edge { fill: none; stroke-linejoin: round; pointer-events: none; }
.hex.selected .owner-edge { stroke: #f6e7c4; stroke-width: 3.4; }
.hex.hostile .owner-edge { stroke: #ffd0c8; stroke-width: 3.2; }
.hex.reach .owner-edge { stroke: #d7ffe0; stroke-width: 3.2; }

.hex .pip { stroke: rgba(0, 0, 0, 0.45); stroke-width: 1; pointer-events: none; }
.hex.playable, .hex.hostile, .hex.reach, .hex.selected { cursor: pointer; }
.hex:hover .body { filter: brightness(1.14); }
.hex.current .body { stroke: rgba(255, 244, 220, 0.55); }
.hex.selected .body { stroke: #f6e7c4; stroke-width: 3.5; }
.hex.hostile .body { stroke: #e07a6a; stroke-width: 3.2; }
.hex.reach .body { stroke: #8fce9a; stroke-width: 3.2; }
.hex.falling .body { stroke: #e07060; stroke-width: 3.4; stroke-dasharray: 5 4; }

#tip {
  position: absolute;
  z-index: 3;
  min-width: 140px;
  max-width: 220px;
  padding: 8px 10px;
  background: rgba(18, 14, 11, 0.94);
  border: 1px solid var(--line);
  border-radius: 6px;
  pointer-events: none;
  box-shadow: var(--shadow);
}

#tip strong, #tip span { display: block; }
#tip span { color: var(--muted); font-size: 12px; margin-top: 2px; }

#toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: #241c16;
  color: var(--ink);
  border: 1px solid var(--gold);
  padding: 10px 14px;
  border-radius: 4px;
  z-index: 4;
  max-width: min(520px, 90%);
}

aside {
  overflow: auto;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kicker {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 30px;
  line-height: 1.15;
  margin: 0 0 8px;
}

h3 {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 500;
  margin: 16px 0 6px;
}

p { margin: 0 0 8px; line-height: 1.45; }

.muted, .hint { color: var(--muted); }
.hint { font-size: 12px; }

.card {
  background: rgba(255, 248, 236, 0.03);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.turn-banner {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--banner) 72%, #120e0c);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.turn-banner span {
  font-family: var(--serif);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 12px;
}

.turn-banner strong { font-size: 18px; }

.big {
  font-family: var(--serif);
  font-size: 42px;
  margin: 4px 0 8px;
  line-height: 1;
}

.big small {
  display: block;
  margin-top: 4px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0;
}

.progress { color: var(--gold); font-size: 13px; }

.row, .row-between, .actions, .swatches, .stepper, .header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.row-between, .actions, .stepper { justify-content: space-between; }
.actions { flex-wrap: wrap; margin-top: 8px; }
.actions .btn { flex: 1 1 auto; }

.btn, .setup button, .sheet button, .veil button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 4px;
  padding: 10px 12px;
  min-height: 40px;
}

.btn.primary, .sheet .primary, .veil .primary {
  background: linear-gradient(180deg, #f0d7a6, #c6a15c);
  color: #2a2116;
  border-color: #f3e4c2;
  font-weight: 600;
}

.btn.tiny { min-height: 32px; padding: 6px 10px; flex: 0 0 auto; }
.place-batch { flex-wrap: wrap; margin-top: 8px; }
.place-batch span { color: var(--muted); font-size: 12px; }
.place-batch input {
  width: 68px;
  background: #1a1612;
  border: 1px solid rgba(224, 196, 138, 0.2);
  border-radius: 8px;
  padding: 6px 8px;
}
.btn.on { border-color: var(--gold); color: var(--gold); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

input[type="range"] {
  width: 100%;
  accent-color: #e0c48a;
  margin: 8px 0;
}

.setup h2 { font-size: 28px; letter-spacing: -0.02em; margin-bottom: 4px; }
.setup-lead { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.count-pills {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 12px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(255, 248, 236, 0.04);
}
.setup .count-pill {
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}
.setup .count-pill.on {
  background: var(--ink);
  color: #1a140f;
}
.seat {
  margin-bottom: 8px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 248, 236, 0.035);
  border: 1px solid rgba(224, 196, 138, 0.16);
}
.seat-top { display: grid; grid-template-columns: 28px 1fr 108px; gap: 8px; align-items: center; }
.seat-index {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(224, 196, 138, 0.14);
  color: var(--gold);
  font-size: 13px;
  font-weight: 600;
}
.seat input, .seat select, .speed select {
  background: #1a1612;
  border: 1px solid rgba(224, 196, 138, 0.2);
  border-radius: 10px;
  padding: 8px 10px;
  width: 100%;
}
.seat select[data-field="difficulty"] { margin-top: 8px; }
.swatches { margin-top: 8px; gap: 6px; }
.setup .swatch {
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
  border: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.setup .swatch.on { outline: 2px solid var(--ink); outline-offset: 2px; }
.setup .swatch:disabled { opacity: 0.22; }
.setup-start { width: 100%; margin-top: 8px; border-radius: 12px; min-height: 44px; }
.setup-links { display: flex; justify-content: center; gap: 16px; margin-top: 8px; }
.setup .linkish {
  min-height: 0;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.setup .linkish:hover { color: var(--ink); }

.players, .regions, .log, .reveal { list-style: none; margin: 0; padding: 0; }

.player, .regions li {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-top: 1px solid rgba(224, 196, 138, 0.12);
}

.regions li { grid-template-columns: 12px 1fr auto auto; }
.player i, .regions li i { width: 12px; height: 12px; border-radius: 50%; display: block; }
.player i { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55); }
.player strong, .regions strong { display: block; font-weight: 600; }
.player em, .regions em { display: block; color: var(--dim); font-style: normal; font-size: 12px; }
.player.active { background: rgba(224, 196, 138, 0.06); margin: 0 -6px; padding: 6px; border-radius: 6px; }
.player.dead { opacity: 0.45; }
.player span, .bonus { color: var(--muted); font-size: 13px; }
.bonus { color: var(--gold); }

.cards { display: flex; flex-direction: column; gap: 6px; }
.card-token {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
}
.card-token.owned { outline: 1px solid rgba(224, 196, 138, 0.45); }
.card-token strong, .card-token span { display: block; }
.card-token span { color: var(--muted); font-size: 12px; }
.mark-svg { width: 26px; height: 26px; stroke: var(--gold); fill: none; stroke-width: 1.6; flex: none; }

.log-card { min-height: 120px; }
.log { max-height: 180px; overflow: auto; }
.log li { padding: 5px 0 5px 8px; border-left: 2px solid rgba(224, 196, 138, 0.3); margin: 0 0 6px; color: var(--muted); }
.log em { color: var(--gold); font-style: normal; margin-right: 6px; }

.mini-dice, .dice-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.mini-dice .die { width: 28px; height: 28px; padding: 3px; }
.mini-dice .die i { width: 4px; height: 4px; }
.vs { color: var(--dim); }

.die {
  width: 58px;
  height: 58px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 7px;
  border-radius: 8px;
  background: #f4efe4;
  animation: die-in 0.35s ease both;
}
.die i { width: 8px; height: 8px; border-radius: 50%; background: transparent; margin: auto; }
.die i.on { background: #2a2118; }
.die-atk { background: #f6d4cc; }
.die-atk i.on { background: #7c2430; }
.die:nth-child(2) { animation-delay: 0.06s; }
.die:nth-child(3) { animation-delay: 0.12s; }

@keyframes die-in {
  from { transform: rotate(-16deg) scale(0.7); opacity: 0; }
  to { transform: none; opacity: 1; }
}

#handoff, #modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 6, 5, 0.62);
}

#dice {
  position: absolute;
  left: 63%;
  top: 2.2%;
  z-index: 5;
  transform: translateX(-50%);
  pointer-events: none;
  background: none;
  border: 0;
  margin: 0;
  padding: 0;
}
.sea-dice { display: flex; align-items: flex-end; gap: 22px; }
.sea-col { display: flex; gap: 8px; }
.die-num {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-family: Stencil, Impact, sans-serif;
  font-size: 34px;
  line-height: 1;
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.35);
}
.die-num.die-atk { background: #ff1f1f; color: #fff; }
.die-num.die-def { background: #ffe14a; color: #1a1404; }
.die-num.spinning { animation: die-tumble 0.12s linear infinite; }
@keyframes die-tumble {
  from { transform: rotateX(0deg) rotate(-10deg); }
  to { transform: rotateX(360deg) rotate(10deg); }
}
.sea-note {
  margin: 8px 0 0;
  color: #fff8e8;
  font-family: Stencil, Impact, sans-serif;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 0 #10284a;
}

#handoff { z-index: 30; background: rgba(8, 6, 5, 0.94); }
#modal { z-index: 40; }

.dice-panel, .sheet, .veil {
  width: min(560px, 100%);
  background: #1a1612;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.dice-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 8px; }
.pairs { display: flex; gap: 10px; list-style: none; padding: 0; margin: 8px 0; }
.pairs .win { color: var(--ok); }
.pairs .lose { color: var(--danger); }
.dice-headline { font-family: var(--serif); font-size: 22px; margin: 0; }

.sheet blockquote, .objective p { font-size: 16px; }
.reveal li { padding: 6px 0; border-top: 1px solid rgba(224, 196, 138, 0.12); }
.reveal em { color: var(--gold); font-style: normal; }

.hidden { display: none !important; }

button:focus-visible, input:focus-visible, select:focus-visible, .hex:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

#hall {
  position: fixed;
  top: 68px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #100e0c;
  color: var(--ink);
}
.hall-enter { overflow: auto; }
.hall-live { flex: 1; min-height: 0; height: auto; }
.hall-enter {
  max-width: 440px;
  margin: 0 auto;
  padding: 48px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hall-enter h2 { font-family: var(--serif); margin: 0; }
.hall-enter label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}
.hall-enter input, .hall-enter select, .hall-say input {
  background: #1a1612;
  color: var(--ink);
  border: 1px solid rgba(224, 196, 138, 0.2);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
.hall-live {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.85fr;
  gap: 12px;
  padding: 16px;
}
.hall-col {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(255, 248, 236, 0.03);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.hall-chat {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hall-line { margin: 0; }
.hall-line strong { color: var(--gold); }
.hall-say { display: flex; gap: 8px; flex: 0 0 auto; }
.hall-say input { flex: 1; width: auto; }
.hall-room {
  border: 1px solid rgba(224, 196, 138, 0.16);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
}
.hall-room p { margin: 0 0 6px; }
.hall-room select, .hall-admin {
  background: #1a1612;
  color: var(--ink);
  border: 1px solid rgba(224, 196, 138, 0.2);
  border-radius: 10px;
  padding: 8px 10px;
  width: 100%;
  margin-bottom: 8px;
}
.hall-room .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.hall-rank { margin: 0; padding-left: 22px; }
.hall-rank li { margin: 6px 0; }
@media (max-width: 980px) {
  html, body { height: auto; overflow: auto; }
  .top { height: auto; flex-wrap: wrap; padding: 12px; }
  #status-line { order: 3; flex: 1 1 100%; text-align: left; }
  main { height: auto; grid-template-columns: 1fr; }
  #map-wrap { height: 72vh; }
  aside { border-left: 0; border-top: 1px solid var(--line); }
  .hall-live { grid-template-columns: 1fr; overflow: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
