:root {
  /* HUD (dark glass over the bright board) */
  --hud: rgba(20, 25, 34, .88);
  --hud-2: rgba(36, 43, 56, .92);
  --hud-line: rgba(255, 255, 255, .1);
  --hud-ink: #f4efe6;
  --hud-muted: #a9b2bf;
  /* Paper (dialogs, cards) */
  --paper: #fbf6ea;
  --paper-2: #efe4cc;
  --paper-line: #d9c8a4;
  --ink: #241d14;
  --ink-muted: #6b5d45;
  /* Accents */
  --gold: #f2b544;
  --gold-2: #ffd27a;
  --gold-ink: #2a1d05;
  --good: #3fa356;
  --bad: #d2483a;
  --shadow: 0 12px 32px rgba(5, 10, 20, .38), 0 2px 6px rgba(5, 10, 20, .25);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font-family: Nunito, ui-rounded, system-ui, -apple-system, sans-serif; color: var(--hud-ink); background: #2f6f9f; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.center { text-align: center; }
.muted { color: var(--ink-muted); }
svg.ui { width: 18px; height: 18px; flex: none; display: block; }
[data-icon] { display: inline-flex; }

/* ---------- Buttons ---------- */
.btn, button {
  font: inherit; font-weight: 800; cursor: pointer; border: 0; border-radius: 12px; padding: 9px 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  color: var(--hud-ink); background: var(--hud-2); box-shadow: inset 0 0 0 1px var(--hud-line);
  transition: transform .08s, filter .15s, background .15s;
}
button:hover:not(:disabled) { filter: brightness(1.12); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .38; cursor: default; }
.btn.primary { color: var(--gold-ink); background: linear-gradient(var(--gold-2), var(--gold)); box-shadow: 0 3px 0 #b07a17, 0 6px 16px rgba(242,181,68,.3); }
.btn.dark { color: #fff; background: #2b3343; box-shadow: 0 3px 0 #141922; }
.btn.good { color: #fff; background: linear-gradient(#55b86a, var(--good)); box-shadow: 0 3px 0 #276b36; }
.btn.bad { color: #fff; background: linear-gradient(#e0604f, var(--bad)); box-shadow: 0 3px 0 #8a2a1f; }
.btn.ghost { background: transparent; color: var(--ink-muted); box-shadow: inset 0 0 0 2px var(--paper-line); width: 100%; }
.btn.big { padding: 13px 18px; font-size: 17px; }
.btn.wide { width: 100%; }
.btn.icon { width: 44px; height: 44px; padding: 0; }
.btn.icon svg.ui { width: 20px; height: 20px; }
input, select {
  font: inherit; font-weight: 800; padding: 10px 12px; border-radius: 12px; outline: none; min-width: 0;
  border: 2px solid var(--paper-line); background: #fff; color: var(--ink);
}
input:focus, select:focus { border-color: var(--gold); }

.glass { background: var(--hud); border-radius: 16px; box-shadow: var(--shadow), inset 0 0 0 1px var(--hud-line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.panel-light { background: var(--paper); color: var(--ink); border-radius: 22px; padding: 26px; box-shadow: 0 24px 60px rgba(5,10,20,.45), inset 0 0 0 1px rgba(255,255,255,.6); }
.panel-light button:not(.btn) { color: var(--ink); background: #fff; box-shadow: inset 0 0 0 1.5px var(--paper-line), 0 2px 0 var(--paper-line); }
.panel-light button.on, .panel-light button.active { background: var(--ink); color: #fff; box-shadow: none; }

/* ---------- Scene ---------- */
#scene { position: fixed; inset: 0; }
#scene canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#flat { position: fixed; inset: 0; background: #2a77ab; }
svg.board2d { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; user-select: none; }
svg.board2d.dragging { cursor: grabbing; }
.b2-tile.robber-target { cursor: pointer; }
.b2-tile.robber-target > polygon:first-child { animation: b2pulse 1s infinite alternate; }
.b2-tile.robber-target:hover > polygon:first-child { filter: brightness(1.25); stroke: #fff; stroke-width: 5; }
@keyframes b2pulse { from { filter: brightness(1); } to { filter: brightness(1.18); } }
.b2-edge-hint { stroke: #fff; stroke-width: 9; stroke-linecap: round; cursor: pointer; opacity: .8; animation: b2blink 1s infinite alternate; }
.b2-edge-hint:hover { stroke: var(--gold); opacity: 1; }
.b2-vert-hint { fill: #fff; stroke: #c27a12; stroke-width: 3; cursor: pointer; animation: b2blink 1s infinite alternate; }
.b2-vert-hint:hover { fill: var(--gold); }
@keyframes b2blink { from { opacity: .55; } to { opacity: 1; } }
.b2-new { transform-box: fill-box; transform-origin: center; animation: b2pop .45s cubic-bezier(.3,1.6,.5,1); }
@keyframes b2pop { from { transform: scale(0); } to { transform: scale(1); } }
.b2-token.hot { animation: b2hot 1.6s; }
.b2-token.hot circle:first-child { animation: b2hotc 1.6s; }
@keyframes b2hot { 0%, 100% { transform: none; } 30% { transform: scale(1.35); } }
@keyframes b2hotc { 0%, 100% { fill: #f8efdb; } 30% { fill: #ffe08a; } }
.b2-token { transform-box: fill-box; transform-origin: center; }

/* ---------- Splash screens (over the turning island) ---------- */
.splash {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto;
  background: radial-gradient(ellipse at center, rgba(10,18,30,.15), rgba(10,18,30,.6));
}
.logo { font-family: Fraunces, Georgia, serif; font-weight: 900; font-size: 46px; color: var(--ink); letter-spacing: -1px; display: flex; align-items: center; gap: 12px; }
.logo-mark { width: 40px; height: 46px; background: linear-gradient(var(--gold-2), #e0861f); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); flex: none; }
.logo-mark.sm { width: 20px; height: 23px; }
.home-card { width: 400px; max-width: 100%; display: flex; flex-direction: column; gap: 14px; }
.tag { margin: -6px 0 6px; color: var(--ink-muted); font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 900; font-size: 14px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--ink-muted); font-size: 13px; font-weight: 800; }
.or::before, .or::after { content: ''; flex: 1; height: 2px; background: var(--paper-line); }
.row { display: flex; gap: 8px; }
.row input { flex: 1; text-transform: uppercase; letter-spacing: 6px; text-align: center; font-size: 18px; }

.lobby-card { width: 800px; max-width: 100%; }
.lobby-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.eyebrow { font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: 2px; color: var(--ink-muted); }
.code { font-family: Fraunces, Georgia, serif; font-size: 48px; font-weight: 900; letter-spacing: 8px; color: #b8650f; line-height: 1.05; }
.lobby-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin: 6px 0 18px; }
.lobby-card h3 { font-family: Fraunces, Georgia, serif; margin: 18px 0 10px; font-size: 20px; }
#members { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 8px; }
#members li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: #fff; border-radius: 14px; font-weight: 900; box-shadow: inset 0 0 0 1.5px var(--paper-line); }
#members li .picon { width: 34px; height: 34px; }
#members li .tagline { color: var(--ink-muted); font-size: 12px; display: inline-flex; gap: 4px; align-items: center; }
#members li .tagline svg { width: 14px; height: 14px; }
#members li button { padding: 5px 10px; font-size: 12px; }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors button { width: 54px; height: 54px; padding: 4px; border-radius: 14px; }
.colors button .picon { width: 44px; height: 44px; }
.colors button.mine { box-shadow: inset 0 0 0 3px var(--ink) !important; }
.settings { display: grid; grid-template-columns: 1fr auto; gap: 10px 12px; align-items: center; font-size: 14px; font-weight: 800; }
.settings input[type=number] { width: 84px; }
.settings select { min-width: 150px; }
.settings input[type=checkbox] { width: 22px; height: 22px; accent-color: #b8650f; }

/* ---------- Game HUD ---------- */
#game { position: fixed; inset: 0; pointer-events: none; }
#game > * { pointer-events: auto; }
#game > #bottom, #game > #topbar, #game > #offer { pointer-events: none; }
#topbar > *, #bottom > *, #offer > * { pointer-events: auto; }

#topbar { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; align-items: flex-start; gap: 12px; }
.left-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.brand { align-self: flex-start; }
.brand { font-family: Fraunces, Georgia, serif; font-weight: 900; font-size: 21px; padding: 10px 14px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.chip { font-family: Nunito, sans-serif; font-size: 12px; font-weight: 900; background: rgba(255,255,255,.1); color: var(--gold-2); padding: 3px 8px; border-radius: 8px; letter-spacing: 2px; }
#status-wrap { position: absolute; left: 50%; transform: translateX(-50%); top: 0; min-width: 300px; max-width: 560px; overflow: hidden; text-align: center; }
#status { padding: 11px 20px; font-weight: 900; font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 8px; }
#status-wrap.mine { background: linear-gradient(var(--gold-2), var(--gold)); color: var(--gold-ink); }
#timer { height: 4px; background: rgba(255,255,255,.12); }
#timer-fill { height: 100%; width: 0; background: var(--gold-2); transition: width .25s linear; }
#status-wrap.mine #timer-fill { background: var(--gold-ink); }
#timer-fill.low { background: #ff5b4a !important; }
.tools { display: flex; gap: 8px; }
.seg { display: flex; padding: 4px; height: 44px; gap: 2px; }
.seg button { background: transparent; box-shadow: none; padding: 0 12px; font-size: 13px; border-radius: 11px; gap: 6px; }
.seg button.on { background: var(--gold); color: var(--gold-ink); }

#players { display: flex; flex-direction: column; gap: 6px; flex: none; max-height: 46%; overflow-y: auto; padding: 2px; }
.player { position: relative; padding: 10px 12px 10px 16px; border-radius: 14px; background: var(--hud); box-shadow: var(--shadow), inset 0 0 0 1px var(--hud-line); overflow: hidden; transition: transform .2s, box-shadow .2s; }
.player::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--pc); }
.player.current { box-shadow: var(--shadow), inset 0 0 0 2px var(--gold); }
.player { padding: 8px 12px 8px 16px; }
.player .stats { margin-top: 5px; }
.player .top { display: flex; align-items: center; gap: 8px; }
.player .picon { width: 30px; height: 30px; flex: none; }
.player .pname { font-weight: 900; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.player .pname svg { width: 14px; height: 14px; color: var(--hud-muted); }
.player .you { color: var(--hud-muted); font-weight: 800; font-size: 12px; }
.player .vp { font-family: Fraunces, Georgia, serif; font-weight: 900; font-size: 24px; line-height: 1; color: var(--gold-2); }
.player .vp small { font-family: Nunito; font-size: 11px; color: var(--hud-muted); margin-left: 2px; }
.player .stats { display: flex; gap: 12px; margin-top: 8px; font-size: 13px; font-weight: 900; color: var(--hud-ink); }
.player .stats span { display: inline-flex; align-items: center; gap: 4px; }
.player .stats svg { width: 15px; height: 15px; color: var(--hud-muted); }
.player .badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 7px; }
.player .badges:empty { display: none; }
.pbadge { font-size: 11px; font-weight: 900; padding: 3px 7px; border-radius: 7px; background: var(--gold); color: var(--gold-ink); display: inline-flex; align-items: center; gap: 4px; }
.pbadge svg { width: 12px; height: 12px; }
.pbadge.grey { background: rgba(255,255,255,.14); color: var(--hud-ink); }
.player.offline { opacity: .55; }

#side { position: absolute; right: 12px; top: 12px; width: 320px; display: flex; flex-direction: column; gap: 8px; bottom: 214px; }
#bank-panel { padding: 10px 12px 12px; }
#bank-panel .lbl { color: var(--hud-muted); font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: 1.5px; display: flex; justify-content: space-between; margin-bottom: 12px; }
#bank-panel .lbl b { color: var(--gold-2); }
.bank-row { display: flex; gap: 9px; align-items: flex-end; padding: 0 10px 0 4px; }
.bank-row .gcard { --w: 38px; padding: 2px 2px 0; border-radius: 6px; }
.bank-row .gc-art { border-radius: 4px; }
.bank-row .gc-name { display: none; }
.bank-row .gcard .gc-art { margin-bottom: 2px; }
.bank-row .gc-count { min-width: 22px; height: 20px; font-size: 12px; top: -8px; right: -10px; padding: 0 5px; }
.bank-row .gcard.low .gc-count { box-shadow: 0 0 0 2.5px var(--bad), 0 3px 6px rgba(0,0,0,.4); }
.bank-row .gcard.empty { opacity: .35; }
.spectators { margin-top: 10px; color: var(--hud-muted); font-size: 12px; font-weight: 800; display: flex; gap: 6px; align-items: center; }
.log-panel { flex: 1; display: flex; flex-direction: column; min-height: 130px; padding: 10px; }
.tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.tabs button { flex: 1; padding: 7px; font-size: 13px; background: rgba(255,255,255,.06); box-shadow: none; }
.tabs button.on { background: rgba(255,255,255,.16); }
.tabs svg.ui { width: 15px; height: 15px; }
.badge { background: var(--bad); color: #fff; border-radius: 8px; font-size: 11px; padding: 0 6px; }
#log, #chat { flex: 1; overflow-y: auto; font-size: 13px; line-height: 1.55; font-weight: 700; min-height: 0; padding-right: 4px; color: #dfe4ea; }
#log div, #chat div { padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
#log b, #chat b { font-weight: 900; }
#chat-form input { width: 100%; margin-top: 8px; padding: 9px 11px; background: rgba(255,255,255,.08); border-color: transparent; color: var(--hud-ink); }
#chat-form input::placeholder { color: var(--hud-muted); }
#chat-form input:focus { border-color: var(--gold); }

/* Inline resource chips */
.rchip { display: inline-flex; align-items: center; gap: 2px; padding: 1px 6px 1px 2px; border-radius: 8px; background: rgba(255,255,255,.1); vertical-align: middle; font-weight: 900; }
.rchip-ic { width: 20px; height: 20px; }
.panel-light .rchip, .offer-card .rchip { background: rgba(0,0,0,.06); }

/* ---------- Cards ---------- */
.gcard {
  --w: 70px; width: var(--w); height: calc(var(--w) * 1.42); border-radius: 10px; padding: 4px 4px 0; position: relative; flex: none;
  display: flex; flex-direction: column; background: linear-gradient(#fffdf6, #efe2c4);
  box-shadow: 0 8px 18px rgba(0,0,0,.35), inset 0 0 0 1.5px #c9b083, inset 0 0 0 3px #fffaf0;
  transition: transform .18s, box-shadow .18s; color: var(--ink);
}
.gc-art { flex: 1; border-radius: 7px; overflow: hidden; box-shadow: inset 0 0 0 1.5px var(--cb, #a58a5c); position: relative; }
.gc-art svg { width: 100%; height: 100%; display: block; }
.gc-name { font-family: Fraunces, Georgia, serif; font-weight: 900; font-size: 9.5px; text-transform: uppercase; letter-spacing: .6px; text-align: center; padding: 3px 0 4px; white-space: nowrap; overflow: hidden; }
.gc-count {
  position: absolute; top: -9px; right: -9px; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 13px;
  background: #1b2029; color: #fff; font-weight: 900; font-size: 14px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2.5px var(--gold), 0 3px 6px rgba(0,0,0,.4);
}
.gc-ribbon { position: absolute; bottom: 20px; left: -4px; right: -4px; background: var(--bad); color: #fff; font-size: 9px; font-weight: 900; text-align: center; letter-spacing: 1px; padding: 2px 0; box-shadow: 0 2px 4px rgba(0,0,0,.3); }
.gcard.dev { background: linear-gradient(#3e3275, #221a49); color: var(--gold-2); box-shadow: 0 8px 18px rgba(0,0,0,.35), inset 0 0 0 1.5px #f0cf73, inset 0 0 0 3px #2b2257; }
.gcard.dev .gc-art { --cb: #f0cf73; }
.gcard.back .gc-art { margin-bottom: 4px; }
.gcard.stack2 { box-shadow: 4px -4px 0 -1px #f6eedb, 4px -4px 0 0 #c9b083, 0 8px 18px rgba(0,0,0,.35), inset 0 0 0 1.5px #c9b083, inset 0 0 0 3px #fffaf0; }
.gcard.stack3 { box-shadow: 4px -4px 0 -1px #f6eedb, 4px -4px 0 0 #c9b083, 8px -8px 0 -1px #f1e7d0, 8px -8px 0 0 #c9b083, 0 8px 18px rgba(0,0,0,.35), inset 0 0 0 1.5px #c9b083, inset 0 0 0 3px #fffaf0; }
.slot { --w: 70px; width: var(--w); height: calc(var(--w) * 1.42); border-radius: 10px; flex: none; display: flex; align-items: center; justify-content: center; background: rgba(20,25,34,.82); box-shadow: inset 0 0 0 2px rgba(255,255,255,.16), 0 6px 14px rgba(0,0,0,.25); }
.slot svg { width: 34px; height: 34px; opacity: .45; filter: grayscale(.3); }
.gcard.gain { animation: gain .75s; }
@keyframes gain { 0% { transform: none; } 35% { transform: translateY(-20px) scale(1.1); box-shadow: 0 0 0 4px var(--gold-2), 0 14px 26px rgba(0,0,0,.4); } 100% { transform: none; } }

/* ---------- Bottom: hand & action bar ---------- */
#bottom { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: calc(100vw - 24px); }
#hand { display: flex; gap: 10px; align-items: flex-end; padding: 10px 8px 0; }
#hand .gcard:hover { transform: translateY(-8px); }
#hand .gcard.dev.ready { cursor: pointer; }
#hand .gcard.dev.ready:hover { transform: translateY(-12px) rotate(-2deg); box-shadow: 0 0 0 3px var(--gold-2), 0 14px 26px rgba(0,0,0,.45); }
#hand .gcard.dev.locked { filter: saturate(.55) brightness(.8); }
.hand-sep { width: 2px; height: 70px; background: rgba(255,255,255,.35); margin: 0 4px; border-radius: 2px; align-self: center; }

#actions { display: flex; gap: 6px; padding: 8px; flex-wrap: wrap; justify-content: center; align-items: stretch; }
.act { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 84px; padding: 6px 10px; background: rgba(255,255,255,.05); box-shadow: inset 0 0 0 1px var(--hud-line); }
.act .picon { width: 36px; height: 36px; }
.act .lb { font-size: 12px; font-weight: 900; }
.act .cost { display: flex; gap: 1px; }
.act .cost .rchip { padding: 0; background: none; }
.act .cost .rchip b { display: none; }
.act .cost .rchip-ic { width: 16px; height: 16px; }
.act .left { font-size: 10px; color: var(--hud-muted); font-weight: 800; }
.act.active { background: rgba(242,181,68,.2); box-shadow: inset 0 0 0 2px var(--gold); }
.act-sep { width: 1px; background: var(--hud-line); margin: 4px 2px; }
#roll-btn { min-width: 128px; font-size: 18px; }
#roll-btn svg.ui { width: 24px; height: 24px; }
#end-btn { min-width: 116px; }

/* ---------- Trade offer (panel left of the chat column) ---------- */
#offer { position: absolute; right: 344px; top: 132px; width: 420px; z-index: 5; }
.tpanel { background: var(--paper); color: var(--ink); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.tpanel.enter { animation: slideIn .28s cubic-bezier(.2,.9,.3,1.1); }
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.thead { position: relative; display: flex; align-items: center; justify-content: center; padding: 8px 10px; background: linear-gradient(#fffaf0, var(--paper-2)); border-bottom: 1px solid var(--paper-line); min-height: 60px; }
.tcollapse { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; padding: 0 !important; background: transparent !important; box-shadow: none !important; color: var(--ink) !important; }
.tcollapse svg.ui { width: 22px; height: 22px; }
.tbody { padding: 10px 12px 12px; }
.tmain { display: flex; gap: 10px; }
.trows { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.trow { display: flex; align-items: center; gap: 8px; }
.tcards { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 8px; }
.tcards .gcard { --w: 40px; padding: 2px 2px 0; border-radius: 6px; }
.tcards .gc-name { display: none; }
.tcards .gc-art { margin-bottom: 2px; border-radius: 4px; }
.tcards .gc-count { min-width: 20px; height: 20px; font-size: 12px; top: -8px; right: -8px; padding: 0 5px; }
.tarrow { display: inline-flex; flex: none; }
.tarrow svg.ui { width: 26px; height: 26px; stroke-width: 3; }
.tarrow.sm svg.ui { width: 18px; height: 18px; }
.tarrow.in { color: var(--good); }
.tarrow.out { color: var(--bad); }
.avatar { position: relative; width: 44px; height: 44px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; background: #fff; box-shadow: 0 0 0 3px var(--pc, #9b917f), 0 3px 8px rgba(0,0,0,.2); }
.avatar .picon { width: 32px; height: 32px; }
.avatar.any { --pc: #b9ab8d; color: var(--ink-muted); }
.avatar.any svg.ui { width: 24px; height: 24px; }
.sbadge { position: absolute; right: -6px; bottom: -6px; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; box-shadow: 0 0 0 2px #fff; }
.sbadge svg.ui { width: 12px; height: 12px; stroke-width: 3; }
.sbadge.pending { background: #5b7fa6; } .sbadge.ok { background: var(--good); } .sbadge.no { background: var(--bad); } .sbadge.ctr { background: #c98a14; }
.tside { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 10px; }
.tresp { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; padding: 4px 6px 0 0; }
.tresp .avatar { width: 36px; height: 36px; }
.tresp .avatar .picon { width: 26px; height: 26px; }
.tactions { display: flex; gap: 8px; }
.tbtn { width: 48px; height: 44px; padding: 0 !important; border-radius: 12px !important; background: linear-gradient(#ffffff, #e9dfc9) !important; color: var(--ink) !important; box-shadow: inset 0 0 0 1.5px var(--paper-line), 0 3px 0 var(--paper-line) !important; }
.tbtn svg.ui { width: 24px; height: 24px; stroke-width: 2.6; }
.tbtn.ok { color: var(--good) !important; }
.tbtn.no { color: var(--bad) !important; }
.tbtn.ok.chosen, .tbtn.ok:hover:not(:disabled) { background: linear-gradient(#5cc272, var(--good)) !important; color: #fff !important; box-shadow: 0 3px 0 #276b36 !important; }
.tbtn.no.chosen, .tbtn.no:hover:not(:disabled) { background: linear-gradient(#e0604f, var(--bad)) !important; color: #fff !important; box-shadow: 0 3px 0 #8a2a1f !important; }
.deals { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--paper-line); display: flex; flex-direction: column; gap: 10px; }
.deal { display: flex; align-items: center; gap: 8px; }
.deal .tcards { padding-top: 6px; }
.deal .avatar { width: 36px; height: 36px; } .deal .avatar .picon { width: 26px; height: 26px; }
/* Trade builder (docked bottom, replaces the hand + action bar while open) */
#tradebox { position: absolute; left: 12px; right: 344px; bottom: 12px; z-index: 6; }
#game.composing #bottom, #game.composing #dice3d { display: none; }
.tbox { display: flex; gap: 10px; align-items: stretch; }
.tbox.enter { animation: rise .28s cubic-bezier(.2,.9,.3,1.1); }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.tb-main { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.tb-panel { background: var(--paper); color: var(--ink); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.tb-panel .gcard { --w: 50px; padding: 2px 2px 0; border-radius: 7px; }
.tb-panel .gc-name { display: none; }
.tb-panel .gc-art { margin-bottom: 2px; border-radius: 5px; }
.tb-panel .gc-count { min-width: 22px; height: 22px; font-size: 12px; top: -8px; right: -8px; padding: 0 5px; }
.tb-pick .gcard { cursor: pointer; }
.tb-pick .gcard:hover { transform: translateY(-4px); box-shadow: 0 0 0 3px var(--good), 0 8px 14px rgba(0,0,0,.3); }
.tb-pick .gcard.dim { opacity: .35; }
.tb-pick .rate { position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 10px; font-weight: 900; border-radius: 6px; padding: 0 5px; white-space: nowrap; }
.tb-hint { margin-left: auto; color: var(--ink-muted); }
.tb-hint svg.ui { width: 30px; height: 30px; }
.tb-rows { flex-direction: column; align-items: stretch; gap: 12px; }
.tb-rows .trow { min-height: 62px; }
.tb-rows .tcards .gcard { --w: 42px; }
.tb-hand .gcard { cursor: pointer; }
.tb-hand .gcard:hover { transform: translateY(-4px); box-shadow: 0 0 0 3px var(--bad), 0 8px 14px rgba(0,0,0,.3); }
.tb-hand .gcard.spent { opacity: .3; cursor: default; transform: none; box-shadow: none; }
.tb-btns { display: flex; flex-direction: column; gap: 8px; width: 96px; }
.bigbtn { flex: 1; position: relative; border-radius: 14px !important; background: var(--paper) !important; color: var(--ink) !important; box-shadow: var(--shadow), inset 0 0 0 2px var(--paper-line) !important; min-height: 72px; }
.bigbtn svg.ui { width: 38px; height: 38px; stroke-width: 1.8; }
.bigbtn .vmark { position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%; display: none; align-items: center; justify-content: center; background: var(--good); color: #fff; }
.bigbtn .vmark svg.ui { width: 12px; height: 12px; stroke-width: 3.5; }
.bigbtn.valid { background: linear-gradient(#e8f6ea, #cfe9d4) !important; box-shadow: var(--shadow), inset 0 0 0 2px var(--good) !important; }
.bigbtn.valid .vmark { display: flex; }
.bigbtn.close svg.ui { stroke-width: 2.6; }
/* Disabled stays solid (it often sits over the board), just greyed */
.bigbtn:disabled { opacity: 1; color: var(--ink-muted) !important; }
.bigbtn:disabled svg.ui { opacity: .4; }
.bigbtn.close:hover { background: linear-gradient(#fde7e3, #f6cfc8) !important; }
.tslot { min-width: 40px; height: 57px; border-radius: 6px; padding: 0 14px; display: flex; align-items: center; font-size: 13px; font-weight: 800; color: var(--ink-muted); box-shadow: inset 0 0 0 2px var(--paper-line); background: repeating-linear-gradient(45deg, transparent 0 5px, rgba(0,0,0,.03) 5px 10px); }
.tbtn.pulse { animation: ready 1s infinite alternate; --pc: var(--good); }
.tcards .gcard.removable { cursor: pointer; }
.tcards .gcard.removable:hover { transform: translateY(-3px); box-shadow: 0 0 0 2px var(--bad), 0 6px 12px rgba(0,0,0,.25); }
.gcard.bump { animation: bump .32s cubic-bezier(.3,1.6,.5,1); }
@keyframes bump { from { transform: scale(.6) translateY(10px); opacity: .3; } to { transform: none; opacity: 1; } }
.avatar.go { cursor: pointer; animation: ready 1s infinite alternate; }
.avatar.go:hover { transform: scale(1.08); }
@keyframes ready { from { box-shadow: 0 0 0 3px var(--pc), 0 0 0 5px rgba(63,163,86,0); } to { box-shadow: 0 0 0 3px var(--pc), 0 0 0 7px rgba(63,163,86,.55); } }

.deal .tbtn { width: 40px; height: 36px; }
@keyframes pop { from { transform: scale(.88); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 3D dice ---------- */
#dice3d { position: absolute; right: 40px; bottom: 44px; display: flex; gap: 14px; perspective: 600px; pointer-events: none; }
.die { width: 56px; height: 56px; position: relative; transform-style: preserve-3d; transition: transform 1.1s cubic-bezier(.2,.9,.25,1.05); }
.face { position: absolute; inset: 0; border-radius: 12px; background: radial-gradient(circle at 35% 30%, #fffef9, #efe6d2); display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 9px; box-shadow: inset 0 0 0 1.5px #d9cba9, inset 0 -4px 8px rgba(0,0,0,.08); }
.die.red .face { background: radial-gradient(circle at 35% 30%, #ef6a57, #b8301f); box-shadow: inset 0 0 0 1.5px #8e2416, inset 0 -4px 8px rgba(0,0,0,.15); }
.face i { width: 10px; height: 10px; border-radius: 50%; background: #241d14; place-self: center; box-shadow: inset 0 1px 2px rgba(0,0,0,.5); }
.die.red .face i { background: #fff6e8; }
.face.f1 { transform: translateZ(28px); } .face.f6 { transform: rotateY(180deg) translateZ(28px); }
.face.f3 { transform: rotateY(90deg) translateZ(28px); } .face.f4 { transform: rotateY(-90deg) translateZ(28px); }
.face.f5 { transform: rotateX(90deg) translateZ(28px); } .face.f2 { transform: rotateX(-90deg) translateZ(28px); }
.dice-sum { position: absolute; top: -34px; left: 0; right: 0; text-align: center; }
.dice-sum span { display: inline-block; font-family: Fraunces, Georgia, serif; font-weight: 900; font-size: 20px; color: var(--gold-ink); background: var(--gold); border-radius: 10px; padding: 0 10px; box-shadow: var(--shadow); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(8,12,20,.55); display: flex; align-items: center; justify-content: center; z-index: 30; padding: 16px; backdrop-filter: blur(4px); }
.modal .panel-light { width: 500px; max-width: 100%; max-height: calc(100vh - 32px); overflow-y: auto; animation: pop .2s; }
.modal .panel-light.wide { width: 760px; }
.modal h3 { font-family: Fraunces, Georgia, serif; margin: 0 0 6px; font-size: 26px; display: flex; align-items: center; gap: 10px; }
.modal h3 .gcard { --w: 44px; }
.modal p { margin: 4px 0 10px; }
.picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 12px 0; justify-items: center; }
.picker .col { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.picker .gcard { --w: 64px; cursor: pointer; }
.picker .gcard:hover { transform: translateY(-4px); }
.picker .gcard.off { opacity: .35; cursor: default; transform: none; }
.picker .ctr { display: flex; align-items: center; gap: 6px; }
.picker .ctr button { width: 28px; height: 28px; padding: 0; border-radius: 9px; font-size: 16px; }
.picker .ctr b { min-width: 18px; text-align: center; font-size: 16px; }
.picker .have { font-size: 11px; color: var(--ink-muted); font-weight: 800; }
.sect { font-weight: 900; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ink-muted); margin-top: 10px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.choice { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.choice .gcard { --w: 64px; cursor: pointer; }
.choice .gcard:hover { transform: translateY(-4px); }
.choice .gcard.active { box-shadow: 0 0 0 3px var(--gold), 0 8px 18px rgba(0,0,0,.35); transform: translateY(-4px); }
.choice .gcard.off { opacity: .3; cursor: default; }
.choice .gcard .rate { position: absolute; left: 50%; bottom: -10px; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 11px; font-weight: 900; border-radius: 7px; padding: 1px 7px; white-space: nowrap; }
.victims { display: flex; gap: 10px; flex-wrap: wrap; }
.victims button { padding: 10px 14px !important; gap: 10px; }
.victims .picon { width: 30px; height: 30px; }
.dev-hero { display: flex; gap: 18px; align-items: center; }
.dev-hero .gcard { --w: 110px; }

#toasts { position: fixed; bottom: 236px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 40; align-items: center; pointer-events: none; }
.toast { background: var(--hud); color: var(--hud-ink); padding: 10px 18px; border-radius: 12px; font-weight: 900; box-shadow: var(--shadow), inset 0 0 0 1px var(--hud-line); animation: pop .2s; display: flex; gap: 8px; align-items: center; }
.toast.err { background: var(--bad); color: #fff; }

/* Stats */
.hist { display: flex; align-items: flex-end; gap: 6px; height: 160px; margin: 14px 0 6px; padding: 0 4px; border-bottom: 2px solid var(--paper-line); }
.hist .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; }
.hist .fill { width: 100%; background: linear-gradient(#f6c25a, #d9831e); border-radius: 6px 6px 0 0; min-height: 2px; }
.hist .exp { position: absolute; left: -2px; right: -2px; border-top: 2px dashed var(--ink); opacity: .45; }
.hist .cnt { font-size: 11px; font-weight: 900; margin-bottom: 2px; }
.hist-lbl { display: flex; gap: 6px; padding: 0 4px; }
.hist-lbl span { flex: 1; text-align: center; font-weight: 900; font-size: 13px; }
table.stats { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 16px; font-weight: 700; }
table.stats th, table.stats td { padding: 7px 8px; text-align: right; border-bottom: 1px solid var(--paper-line); }
table.stats th:first-child, table.stats td:first-child { text-align: left; }
table.stats th { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-muted); }
.winner { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.winner .picon { width: 84px; height: 84px; }
.winner h2 { font-family: Fraunces, Georgia, serif; font-size: 34px; margin: 0; }
.rank { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 6px; }
.rank li { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 12px; padding: 6px 12px; font-weight: 900; box-shadow: inset 0 0 0 1.5px var(--paper-line); }
.rank li .picon { width: 26px; height: 26px; }
.rank li .vp { margin-left: auto; font-family: Fraunces, Georgia, serif; font-size: 18px; }
.confetti { position: fixed; top: -20px; width: 10px; height: 14px; z-index: 50; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
.help ul { padding-left: 18px; line-height: 1.6; }
.kbd { display: inline-block; padding: 0 6px; border-radius: 5px; background: var(--paper-2); box-shadow: inset 0 -2px 0 var(--paper-line); font-weight: 900; font-size: 12px; }

/* ---------- Narrow screens ---------- */
@media (max-width: 1100px) {
  #side { width: 250px; }
  .gcard, .slot { --w: 60px; }
}
@media (max-width: 860px) {
  .lobby-grid { grid-template-columns: 1fr; gap: 0; }
  .brand { display: none; }
  #topbar { flex-wrap: wrap; top: 8px; left: 8px; right: 8px; gap: 6px; }
  .left-stack { flex: 1 1 100%; }
  .tools { width: 100%; }
  .tools #btn-help { margin-left: auto; }
  #status-wrap { position: static; transform: none; min-width: 0; max-width: none; flex: 1 1 100%; order: 2; }
  #status { font-size: 14px; padding: 7px 10px; }
  .seg button { padding: 0 9px; font-size: 0; gap: 0; }
  .seg button svg.ui { width: 18px; height: 18px; }
  .tools { gap: 5px; }
  .btn.icon { width: 40px; height: 40px; }
  .seg { height: 40px; }
  #side { top: 104px; left: 8px; right: 8px; bottom: auto; width: auto; gap: 6px; }
  #players { flex-direction: row; overflow-x: auto; max-height: none; order: -1; scrollbar-width: none; }
  .player { min-width: 150px; }
  .log-panel { min-height: 0; flex: none; padding: 6px 8px; }
  .log-panel .tabs { margin-bottom: 4px; }
  .log-panel .tabs button { padding: 4px; font-size: 12px; }
  #log, #chat { height: 40px; flex: none; }
  .log-panel:not(.chatting) #chat-form { display: none; }
  #chat-form input { margin-top: 4px; padding: 6px 9px; }
  #bank-panel { display: none; }
  #dice3d { right: auto; left: 16px; bottom: 262px; }
  .die { width: 42px; height: 42px; }
  .face { padding: 6px; } .face i { width: 7px; height: 7px; }
  .face.f1 { transform: translateZ(21px); } .face.f6 { transform: rotateY(180deg) translateZ(21px); }
  .face.f3 { transform: rotateY(90deg) translateZ(21px); } .face.f4 { transform: rotateY(-90deg) translateZ(21px); }
  .face.f5 { transform: rotateX(90deg) translateZ(21px); } .face.f2 { transform: rotateX(-90deg) translateZ(21px); }
  .gcard, .slot { --w: 48px; }
  .gc-name { display: none; }
  .act { min-width: 60px; padding: 5px; }
  .act .cost, .act .left { display: none; }
  #offer { right: 8px; left: 8px; top: auto; bottom: 250px; width: auto; }
  #tradebox { left: 8px; right: 8px; bottom: 8px; }
  .tb-btns { width: 64px; }
  .picker .gcard, .choice .gcard { --w: 52px; }
}

/* Lobby: name field, leave button; in-game seat swap */
.lobby-actions { display: flex; gap: 8px; align-items: center; }
.lobby-actions .btn { white-space: nowrap; }
#lobby-name { width: 100%; }
.pswap { padding: 0; width: 26px; height: 26px; display: inline-grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,.08); box-shadow: none; color: var(--hud-muted); flex: none; }
.pswap svg { width: 15px; height: 15px; }
.pswap:hover { background: rgba(255,255,255,.18); color: var(--hud-ink); }
.pswap.on { background: var(--gold); color: var(--gold-ink); }
.lobby-chat { margin: 14px 0 12px; border-radius: 14px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--paper-line); padding: 8px 10px; }
#lobby-chat-log { max-height: 96px; min-height: 40px; overflow-y: auto; font-size: 13px; font-weight: 700; line-height: 1.5; }
#lobby-chat-form input { width: 100%; margin-top: 6px; padding: 7px 10px; }
#rejoin { display: flex; align-items: center; justify-content: center; gap: 8px; }
#rejoin svg { width: 18px; height: 18px; }
