/* ============ Mister X — noir London theme ============ */
:root {
  --bg: #14161d;
  --bg2: #1c1f29;
  --panel: #21242f;
  --panel-edge: #2f3342;
  --ink: #e8e2d2;
  --ink-dim: #9a94a8;
  --gold: #c9a227;
  --gold-hi: #e6c453;
  --taxi: #e5a91e;
  --bus: #1f8a5d;
  --tube: #c8403c;
  --black-ticket: #16151a;
  --danger: #d05555;
  font-size: 15px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 800px at 70% -10%, #232839 0%, var(--bg) 55%);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
}
h1, h2, h3 { font-weight: 700; letter-spacing: .04em; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }

.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

/* ============ Buttons & inputs ============ */
.btn {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  padding: 10px 18px;
  transition: all .15s;
}
.btn:hover { border-color: var(--gold); color: var(--gold-hi); }
.btn.gold {
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
  color: #191405;
  border-color: #8a6f16;
  font-weight: bold;
}
.btn.gold:hover { filter: brightness(1.08); color: #191405; }
.btn.big { width: 100%; padding: 13px; font-size: 1.1rem; }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-dim); }
.btn.ghost:hover { color: var(--danger); border-color: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }

input, select {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--panel-edge);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 4px 0 14px;
}
input:focus, select:focus { outline: none; border-color: var(--gold); }
label { color: var(--ink-dim); font-size: .85rem; letter-spacing: .06em; text-transform: uppercase; }
.code-input { text-transform: uppercase; letter-spacing: .5em; font-size: 1.3rem; text-align: center; }

/* ============ Home ============ */
.home-wrap { max-width: 860px; margin: 0 auto; padding: 48px 20px 30px; }
.brand { text-align: center; margin-bottom: 36px; }
.brand-mark { width: 110px; height: 110px; filter: drop-shadow(0 6px 24px rgba(201,162,39,.25)); }
.brand h1 {
  margin: 14px 0 6px;
  font-size: 3rem;
  letter-spacing: .28em;
  color: var(--ink);
  text-shadow: 0 2px 0 #000, 0 0 40px rgba(201,162,39,.35);
}
.tagline { color: var(--ink-dim); font-style: italic; margin: 0; }

.home-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 700px) { .home-cards { grid-template-columns: 1fr; } }
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
.card h2 { margin: 0 0 16px; font-size: 1.15rem; color: var(--gold-hi); letter-spacing: .1em; }

.rules { margin-top: 30px; color: var(--ink-dim); }
.rules summary { cursor: pointer; color: var(--gold); letter-spacing: .08em; }
.rules-body { padding: 10px 6px; line-height: 1.55; }
.rules-body strong { color: var(--ink); }
.credits { text-align: center; color: #565163; margin-top: 34px; font-size: .8rem; }

/* ============ Lobby ============ */
.lobby-wrap { max-width: 560px; margin: 0 auto; padding: 60px 20px; }
.lobby-card h3 { color: var(--ink-dim); font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; margin: 22px 0 8px; }
.invite-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.invite-code {
  font-size: 2rem; letter-spacing: .35em; font-weight: bold; color: var(--gold-hi);
  background: var(--bg); border: 1px dashed var(--gold); border-radius: 10px; padding: 8px 10px 8px 20px;
}
.player-list { list-style: none; margin: 0; padding: 0; }
.player-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-bottom: 1px solid var(--panel-edge);
}
.player-list .dot { width: 9px; height: 9px; border-radius: 50%; background: #4caf50; }
.player-list .dot.off { background: #666; }
.player-list .tag { font-size: .72rem; color: var(--bg); background: var(--gold); border-radius: 4px; padding: 2px 7px; letter-spacing: .06em; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 12px 0; }
.setting-row span { color: var(--ink-dim); }
.setting-row select { width: auto; margin: 0; }
.seg { display: flex; border: 1px solid var(--panel-edge); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--bg2); color: var(--ink-dim); border: none; padding: 8px 16px; }
.seg button.on { background: var(--gold); color: #191405; font-weight: bold; }
.hint { color: var(--ink-dim); font-size: .85rem; font-style: italic; }
#btn-start { margin-top: 14px; }
#btn-leave-lobby { margin-top: 18px; }

/* ============ Game layout ============ */
#screen-game { height: 100vh; overflow: hidden; }
#game-layout { display: flex; height: 100vh; }
#map-pane { position: relative; flex: 1; min-width: 0; background: #0f1116; }
#map-container { position: absolute; inset: 0; cursor: grab; }
#map-container.dragging { cursor: grabbing; }
#map-container svg { display: block; width: 100%; height: 100%; touch-action: none; }

#side-pane {
  width: 320px; flex: none; display: flex; flex-direction: column; gap: 14px;
  padding: 14px; overflow-y: auto;
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border-left: 1px solid var(--panel-edge);
}
@media (max-width: 900px) {
  #game-layout { flex-direction: column; }
  #side-pane { width: 100%; border-left: none; border-top: 1px solid var(--panel-edge); max-height: 42vh; }
}

#turn-banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(20,22,29,.92); border: 1px solid var(--panel-edge); border-radius: 999px;
  padding: 8px 22px; font-size: 1rem; letter-spacing: .04em; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0,0,0,.5); pointer-events: none; z-index: 5;
}
#turn-banner .who { color: var(--gold-hi); font-weight: bold; }
#turn-banner.mine { border-color: var(--gold); box-shadow: 0 0 24px rgba(201,162,39,.35); }

#map-controls {
  position: absolute; right: 14px; bottom: 70px; display: flex; flex-direction: column; gap: 6px; z-index: 5;
}
#map-controls button {
  width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--panel-edge);
  background: rgba(20,22,29,.92); color: var(--ink); font-size: 1.15rem;
}
#map-controls button:hover { border-color: var(--gold); color: var(--gold-hi); }

/* Travel log strip */
#log-strip {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px;
  display: flex; gap: 4px; padding: 8px 12px; border-radius: 12px;
  background: rgba(20,22,29,.92); border: 1px solid var(--panel-edge);
  box-shadow: 0 6px 18px rgba(0,0,0,.5); z-index: 5; max-width: calc(100% - 40px); overflow-x: auto;
}
.log-slot {
  width: 26px; height: 34px; flex: none; border-radius: 5px;
  border: 1px solid var(--panel-edge); background: var(--bg2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: .62rem; color: var(--ink-dim); position: relative;
}
.log-slot .n { font-size: .6rem; opacity: .8; }
.log-slot.reveal { border-color: var(--gold); box-shadow: inset 0 0 0 1px rgba(201,162,39,.5); }
.log-slot.used { color: #f4efe4; }
.log-slot.used .st { font-weight: bold; font-size: .68rem; }
.log-slot.t-taxi { background: var(--taxi); color: #221a04; }
.log-slot.t-bus { background: var(--bus); }
.log-slot.t-underground { background: var(--tube); }
.log-slot.t-black { background: var(--black-ticket); }
.log-slot.current { outline: 2px solid var(--gold-hi); }

/* Side panels */
#side-pane h3 { margin: 0 0 8px; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-dim); }
.panel { background: var(--bg); border: 1px solid var(--panel-edge); border-radius: 12px; padding: 12px 14px; }

.you-role { font-size: 1.05rem; margin-bottom: 8px; }
.you-role .r { color: var(--gold-hi); font-weight: bold; }
.tickets-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tk {
  display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 8px;
  background: var(--bg2); border: 1px solid var(--panel-edge); font-size: .95rem;
}
.tk svg { width: 20px; height: 20px; }
.tk.taxi svg { color: var(--taxi); } .tk.bus svg { color: var(--bus); }
.tk.underground svg { color: var(--tube); } .tk.black svg { color: #cfc9da; }
.tk.double svg { color: var(--gold-hi); }
.tk b { min-width: 14px; text-align: right; }

.det-row {
  display: flex; align-items: center; gap: 9px; padding: 7px 4px;
  border-bottom: 1px solid rgba(255,255,255,.05); font-size: .92rem;
}
.det-row:last-child { border-bottom: none; }
.det-row .pawn { width: 20px; height: 20px; flex: none; }
.det-row .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.det-row .who small { color: var(--ink-dim); }
.det-row .mini { display: flex; gap: 7px; font-size: .8rem; color: var(--ink-dim); }
.det-row .mini i { font-style: normal; display: inline-flex; align-items: center; gap: 2px; }
.det-row .mini svg { width: 13px; height: 13px; }
.det-row.acting { background: rgba(201,162,39,.1); border-radius: 8px; }
.det-row .st { font-weight: bold; color: var(--ink); min-width: 30px; text-align: right; }

#side-actions .btn { width: 100%; margin-bottom: 8px; }
#btn-double.armed { background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: #191405; font-weight: bold; }

#side-events { flex: 1; min-height: 120px; display: flex; flex-direction: column; }
#event-list {
  list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1;
  font-size: .85rem; line-height: 1.45; color: var(--ink-dim);
}
#event-list li { padding: 4px 2px; border-bottom: 1px dashed rgba(255,255,255,.06); }
#event-list li.hot { color: var(--gold-hi); }

/* Ticket chooser */
#ticket-chooser {
  position: fixed; z-index: 40; background: var(--panel);
  border: 1px solid var(--gold); border-radius: 12px; padding: 10px;
  box-shadow: 0 14px 40px rgba(0,0,0,.6);
  display: flex; gap: 8px;
}
#ticket-chooser button {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--bg2); border: 1px solid var(--panel-edge); border-radius: 9px;
  color: var(--ink); padding: 9px 13px; font-size: .78rem;
}
#ticket-chooser button:hover { border-color: var(--gold); }
#ticket-chooser svg { width: 26px; height: 26px; }
#ticket-chooser .taxi svg { color: var(--taxi); } #ticket-chooser .bus svg { color: var(--bus); }
#ticket-chooser .underground svg { color: var(--tube); } #ticket-chooser .black svg { color: #cfc9da; }

/* Game over */
#gameover {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(10,11,15,.82); backdrop-filter: blur(3px);
}
.go-card {
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--gold); border-radius: 16px; padding: 34px 44px; text-align: center;
  box-shadow: 0 0 80px rgba(201,162,39,.2); max-width: 480px;
}
.go-card h2 { font-size: 1.9rem; margin: 0 0 6px; color: var(--gold-hi); letter-spacing: .1em; }
.go-card p { color: var(--ink-dim); margin: 0 0 20px; }
.go-card .btn { margin: 4px; }

/* Toasts */
#toasts { position: fixed; top: 18px; right: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--panel); border: 1px solid var(--danger); color: var(--ink);
  border-radius: 10px; padding: 10px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
  animation: toast-in .2s ease-out; max-width: 320px; font-size: .9rem;
}
.toast.info { border-color: var(--gold); }
@keyframes toast-in { from { transform: translateX(30px); opacity: 0; } }

/* ============ Map artwork (SVG classes) ============ */
.st-halo { pointer-events: none; }
.station { cursor: default; }
.station text { font-family: Georgia, serif; font-weight: bold; user-select: none; pointer-events: none; }
.station.clickable { cursor: pointer; }
.station.clickable .st-ring { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { stroke-opacity: .95; } 50% { stroke-opacity: .25; } }
.piece { transition: transform .55s cubic-bezier(.5,0,.3,1); pointer-events: none; }
.ghostx { transition: transform .55s cubic-bezier(.5,0,.3,1); pointer-events: none; }
