:root {
  --bg: #120e0b;
  --panel: #1c1612;
  --ink: #f6ead4;
  --muted: #b8a58a;
  --gold: #e0b56a;
  --line: #3d3228;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; min-height: 100%;
  background: radial-gradient(1200px 600px at 50% -10%, #2a2118, var(--bg));
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
}
button, select { font: inherit; color: inherit; }
#app { display: flex; flex-direction: column; min-height: 100dvh; }
header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px calc(8px + env(safe-area-inset-top));
}
header h1 {
  margin: 0; font-family: Georgia, serif; font-size: 1.2rem;
  color: var(--gold); letter-spacing: .06em;
}
header .sub { color: var(--muted); font-size: .78rem; margin-top: 2px; }
#turnBar {
  margin: 0 12px; padding: 10px 12px; border-radius: 14px;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, #2b2119, #1e1713);
  border: 1px solid #4a3b2c; box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
#turnBar .dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid #fff4d6; flex: 0 0 auto;
}
#turnBar b { display: block; font-size: .95rem; }
#turnBar small { color: var(--muted); font-size: .75rem; }
#steps { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.step {
  font-size: .68rem; letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
}
.step.on { background: var(--gold); color: #1a120a; border-color: var(--gold); font-weight: 700; }
#players {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  padding: 8px 12px 4px;
}
.seat {
  background: #1a1410; border: 1px solid var(--line); border-radius: 12px;
  padding: 6px 8px; font-size: .72rem; min-width: 0;
}
.seat.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.seat .name { display: flex; align-items: center; gap: 6px; font-weight: 700; white-space: nowrap; overflow: hidden; }
.seat .sw { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.seat .meta { color: var(--muted); margin-top: 2px; }
#boardWrap { flex: 1; display: flex; justify-content: center; align-items: center; padding: 4px 8px; }
canvas {
  width: min(100%, 720px); height: auto;
  touch-action: manipulation; border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0,0,0,.45);
}
#dock {
  padding: 8px 12px calc(14px + env(safe-area-inset-bottom));
  display: grid; gap: 8px;
  background: linear-gradient(180deg, transparent, #140f0c 18%);
}
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
#res { justify-content: space-between; }
.res {
  flex: 1 1 0; min-width: 56px; text-align: center;
  background: #1b1511; border: 1px solid var(--line);
  border-radius: 12px; padding: 6px 4px; font-size: .72rem;
}
.res .ic { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 4px; vertical-align: middle; }
.res b { display: block; color: var(--gold); font-size: 1rem; margin-top: 2px; }
.pill {
  border: 1px solid var(--line); background: #2a2118;
  border-radius: 12px; padding: 10px 12px; cursor: pointer;
}
.pill.primary { background: var(--gold); color: #1a120a; font-weight: 800; }
.pill:disabled { opacity: .38; cursor: not-allowed; }
#modes .pill { padding: 8px 10px; font-size: .82rem; }
#log {
  max-height: 56px; overflow: auto; font-size: .75rem; color: var(--muted);
  background: #16110e; border-radius: 10px; padding: 6px 8px;
}
.costs { width: 100%; color: var(--muted); font-size: .7rem; }
#modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none;
  align-items: center; justify-content: center; padding: 16px;
}
#modal.show { display: flex; }
#modal .box {
  background: var(--panel); border: 1px solid var(--gold); border-radius: 16px;
  padding: 16px; width: min(440px, 100%);
}
#modal h2 { margin: 0 0 8px; color: var(--gold); font-family: Georgia, serif; }
#modal p { margin: 0 0 10px; color: var(--muted); font-size: .92rem; }
@media (max-width: 520px) {
  #players { grid-template-columns: repeat(2, 1fr); }
  #steps { display: none; }
}

#lobby {
  position: fixed; inset: 0; background: rgba(8,6,4,.78);
  display: none; align-items: center; justify-content: center;
  padding: 16px; z-index: 20;
}
#lobby.show { display: flex; }
#lobby .box {
  width: min(520px, 100%); max-height: 92dvh; overflow: auto;
  background: #1c1612; border: 1px solid #e0b56a; border-radius: 18px; padding: 16px;
}
#lobby h2 { margin: 0 0 8px; font-family: Georgia, serif; color: #e0b56a; }
.maps { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.mapcard {
  text-align: left; background: #2a2118; border: 1px solid #3d3228;
  border-radius: 12px; padding: 10px; cursor: pointer; color: #f6ead4;
}
.mapcard.on { border-color: #e0b56a; box-shadow: 0 0 0 1px #e0b56a; }
.mapcard small { display: block; color: #b8a58a; margin-top: 4px; }
.seatrow { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.seatrow select, .seatrow input { flex: 1; }
