:root {
  --bg: #1d3557;
  --panel: #f1faee;
  --text: #1b1b1b;
  --muted: #5c677d;
  --accent: #e76f51;
  --sea: #457b9d;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  gap: 16px;
}

h1 {
  color: var(--panel);
  margin: 8px 0 0;
  letter-spacing: 0.08em;
}

.board {
  width: min(92vw, 520px);
  height: auto;
}

.panel {
  background: var(--panel);
  border-radius: 12px;
  padding: 16px;
  width: min(92vw, 420px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel h2 { margin: 0; font-size: 1.1rem; }

button, input {
  font: inherit;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #c9d1d9;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
}

button:disabled { opacity: 0.5; cursor: default; }

.row { display: flex; gap: 8px; }
.row > input { flex: 1; min-width: 0; }

.players { margin: 0; padding-left: 20px; }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: #b00020; }
.share { word-break: break-all; }

.watermark {
  position: fixed;
  right: 8px;
  bottom: 6px;
  color: rgba(241, 250, 238, 0.45);
  font-size: 11px;
  font-family: ui-monospace, monospace;
  pointer-events: none;
}

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

a.button {
  display: inline-block;
  text-align: center;
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
}

button.secondary, a.button.secondary { background: #5c677d; color: white; }
button.primary { background: #2a9d8f; font-weight: 600; }
button.active { background: #1d3557; outline: 3px solid #e9c46a; }
button.small { padding: 6px 10px; font-size: 0.9rem; }
button.link { background: none; color: var(--panel); text-decoration: underline; padding: 4px; }
.panel button.link { color: var(--muted); }

.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; align-items: center; }
.row { align-items: center; }
.small { font-size: 0.8rem; }

.game {
  width: 100%;
  max-width: 1320px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 16px;
  align-items: start;
}

.game .board { width: 100%; max-height: calc(100vh - 140px); }
.game .panel { width: 100%; }
.side { display: flex; flex-direction: column; gap: 12px; }
.board-wrap { position: sticky; top: 8px; }

.status {
  color: var(--panel);
  font-size: 1.15rem;
  font-weight: 600;
  text-align: center;
  padding: 4px 0 8px;
}

@media (max-width: 900px) {
  .game { grid-template-columns: minmax(0, 1fr); }
  .game .board { max-height: none; }
  .board-wrap { position: static; }
  #app { padding: 8px; }
}

.chips, .hand { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.35);
  font-size: 0.85rem;
  color: #1b1b1b;
}
.chip-label { font-weight: 600; }
.chip-count {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  min-width: 1.4em;
  text-align: center;
  font-weight: 700;
}
.hand .chip { font-size: 1rem; padding: 6px 10px; }

.swatch {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  border-radius: 3px;
  border: 1px solid #1b1b1b;
  margin-right: 6px;
  vertical-align: -1px;
}
.player-name { white-space: nowrap; }

.dice { display: inline-flex; gap: 4px; }
.die { width: 30px; height: 30px; }

.picker { display: flex; flex-direction: column; gap: 4px; }
.picker-row { display: grid; grid-template-columns: 1fr auto 2em auto; gap: 6px; align-items: center; }
.picker-count { text-align: center; font-weight: 700; }
button.step { padding: 2px 10px; background: #5c677d; }

.composer { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 8px 0; }
.composer h3, .devcards h3 { margin: 0 0 4px; font-size: 0.95rem; }
.bank-trade label { display: flex; flex-direction: column; font-size: 0.85rem; gap: 2px; }
.bank-trade select { padding: 6px; }
.offer { border: 1px dashed #5c677d; border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.offer p { margin: 0; }
.choice { background: #e9f5db; border-radius: 8px; padding: 8px; }
.choice p { margin: 0 0 6px; }
details summary { cursor: pointer; color: var(--muted); }
.costs div { margin: 4px 0; }

.players-panel table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.players-panel th, .players-panel td { text-align: center; padding: 3px 4px; }
.players-panel td:first-child { text-align: left; }
.players-panel tr.current { background: #fff3b0; }
.badge { color: #e76f51; margin-left: 2px; }

.log ol { margin: 0; padding-left: 0; list-style: none; max-height: 220px; overflow-y: auto; font-size: 0.85rem; }
.log li { padding: 2px 0; border-bottom: 1px solid #e0e6ea; }

.toast.error { background: #ffd6d6; color: #8a0000; border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.winner { background: #fff3b0; }

.target { cursor: pointer; }
.target-vertex { fill: rgba(255, 255, 255, 0.75); stroke: #1b1b1b; stroke-width: 3; animation: pulse 1.2s ease-in-out infinite; }
.target-edge { fill: rgba(255, 255, 255, 0.8); stroke: #1b1b1b; stroke-width: 2.5; animation: pulse 1.2s ease-in-out infinite; }
.target-hex { fill: rgba(255, 255, 255, 0.18); stroke: #fff; stroke-width: 3; stroke-dasharray: 8 6; }
.target-hex:hover { fill: rgba(255, 255, 255, 0.4); }
@keyframes pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .target { animation: none; } }

.setup label.row { gap: 8px; }
.setup input[type='checkbox'] { width: 1.2em; height: 1.2em; }
.pass { margin-top: 40px; text-align: center; }

.banner {
  background: #fff3b0;
  color: #1b1b1b;
  border-radius: 8px;
  padding: 6px 14px;
  font-weight: 600;
}
.offline { color: #b00020; font-size: 0.85em; }
.players li { display: flex; align-items: center; gap: 2px; padding: 2px 0; }
.share { flex-wrap: wrap; }

/* Animations. Everything is decorative, so reduced-motion turns it all off. */
.building, .road { transform-box: fill-box; transform-origin: center; animation: pop 0.35s ease-out; }
@keyframes pop { from { transform: scale(0.2); opacity: 0; } 70% { transform: scale(1.15); } to { transform: scale(1); opacity: 1; } }
.robber { transition: transform 0.45s ease-in-out; }
.dice .die { animation: tumble 0.5s ease-out; }
.dice .die:nth-child(2) { animation-delay: 0.06s; }
@keyframes tumble { from { transform: rotate(-200deg) scale(0.4); opacity: 0; } to { transform: none; opacity: 1; } }
.flash { fill: #fff3b0; pointer-events: none; animation: flash 1.6s ease-out forwards; }
@keyframes flash { 0% { opacity: 0.85; } 100% { opacity: 0; } }
.chip { position: relative; }
.gain {
  position: absolute;
  right: -4px;
  top: -10px;
  background: #2a9d8f;
  color: white;
  font-weight: 700;
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 0 5px;
  animation: gain 1.8s ease-out forwards;
  pointer-events: none;
}
@keyframes gain { 0% { transform: translateY(6px); opacity: 0; } 15% { transform: none; opacity: 1; } 80% { opacity: 1; } 100% { transform: translateY(-10px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .building, .road, .dice .die, .flash, .gain { animation: none; }
  .flash, .gain { display: none; }
  .robber { transition: none; }
}
.toast.info { background: #d8f3dc; color: #1b4332; border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.response { display: flex; flex-direction: column; gap: 6px; }
.counter .small { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; }

header.top { display: flex; align-items: center; gap: 16px; }
header.top h1 { margin: 0; }
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 35, 0.7);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 12px;
  overflow-y: auto;
  z-index: 10;
}
.rules { max-width: 640px; width: 100%; gap: 6px; }
.rules h3 { margin: 10px 0 2px; }
.rules p, .rules ul, .rules ol { margin: 2px 0; }
.rules li { margin: 2px 0; }

/* Phones held sideways: board left, scrolling panel right, no header. */
@media (orientation: landscape) and (max-height: 560px) {
  #app { padding: 6px; gap: 6px; }
  header.top { position: fixed; bottom: 6px; left: 8px; z-index: 5; }
  header.top h1 { display: none; }
  .game { grid-template-columns: minmax(0, 1fr) minmax(300px, 40%); gap: 8px; }
  .game .board { max-height: calc(100vh - 44px); }
  .board-wrap { position: sticky; top: 0; }
  .side { max-height: calc(100vh - 12px); overflow-y: auto; }
  .status { font-size: 0.95rem; padding: 0 0 4px; }
}
.status { display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; }
.clock { font-variant-numeric: tabular-nums; background: rgba(241, 250, 238, 0.15); border-radius: 6px; padding: 0 8px; }
.clock.soon { background: #e9c46a; color: #1b1b1b; }
.clock.late { background: #e63946; color: white; }
.seats-panel { width: min(100%, 1320px); }
