:root {
  --bg: #0b1220;
  --panel: #131c2e;
  --panel2: #1a2540;
  --line: #2a3a5c;
  --text: #dbe4f5;
  --dim: #8fa3c8;
  --accent: #38bdf8;
  --good: #4ade80;
  --bad: #f87171;
  --blue: #3b82f6;
  --yellow: #eab308;
  --black: #64748b;
  --red: #ef4444;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
button {
  font: inherit;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); background: #21305a; }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: #0e4f7a; border-color: #2392d0; font-weight: 600; }
button.primary:hover:not(:disabled) { background: #136094; }
button.danger { border-color: #7a2e2e; }
select, input[type="text"] {
  font: inherit;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
}

#app { display: flex; flex-direction: column; height: 100vh; }
main { display: flex; flex: 1; min-height: 0; }

/* ---------- Top bar ---------- */
#topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
#topbar .title { font-weight: 700; font-size: 16px; letter-spacing: 0.5px; }
.stat { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--dim); }
.stat b { color: var(--text); }
.statbtn { cursor: pointer; border: 1px solid transparent; border-radius: 6px; padding: 2px 6px; }
.statbtn:hover { border-color: var(--accent); background: #1a2540; }
.statbtn .peek { font-size: 11px; }
.ratetrack { display: flex; gap: 3px; }
.ratetrack span {
  width: 20px; height: 20px; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; background: var(--panel2); border: 1px solid var(--line); color: var(--dim);
}
.ratetrack span.cur { background: #7a3030; border-color: #c05050; color: #fff; font-weight: 700; }
.cure { width: 20px; height: 20px; border-radius: 50%; border: 2px solid; opacity: 0.35; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: #fff; }
.cure.cured { opacity: 1; }
.outbreakmeter b.warn { color: var(--bad); }
.spacer { flex: 1; }

/* ---------- Map ---------- */
#mapwrap {
  position: relative; flex: 1; min-width: 0;
  background: radial-gradient(ellipse at 50% 38%, #142440 0%, #0c1629 55%, #060b16 100%);
}
#map { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#mapwrap.panning, #mapwrap.panning #map, #mapwrap.panning .cityNode { cursor: grabbing; }
.world .grat { stroke: rgba(80, 115, 180, 0.08); stroke-width: 1; }
.world .landlayer { filter: drop-shadow(0 5px 16px rgba(0, 0, 0, 0.55)); }
.world .land { fill: url(#landg); stroke: #41598a; stroke-width: 1.1; stroke-linejoin: round; }
.infglow { pointer-events: none; }
.infglow.hot { animation: hotpulse 1.7s ease-in-out infinite; }
@keyframes hotpulse { 0%, 100% { opacity: 0.95; } 50% { opacity: 0.55; } }
#mapcontrols { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 20; }
#mapcontrols button { width: 36px; height: 36px; font-size: 18px; line-height: 1; padding: 0; box-shadow: 0 2px 10px rgba(0,0,0,0.45); }
.cityNode { cursor: pointer; }
.cityNode:hover .cityCircle { stroke-width: 3; }
.citylabel { font-size: 12px; fill: #cdd9ef; pointer-events: none; font-weight: 700; paint-order: stroke; stroke: rgba(4, 8, 16, 0.9); stroke-width: 3.5px; }
.edge { stroke: rgba(205, 225, 255, 0.30); stroke-width: 1.6; }
.edge.wrap { stroke-dasharray: 5 5; }
.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 0.9; } 50% { opacity: 0.25; } }

/* ---------- Pawns & research stations ---------- */
.pawnicon { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.7)); }
.pawnicon.me { filter: drop-shadow(0 0 7px #38bdf8) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.7)); }
.pawnhalo { pointer-events: none; animation: pulse 1.6s infinite; }
.station .stationglow { pointer-events: none; animation: stationpulse 2.8s ease-in-out infinite; }
@keyframes stationpulse { 0%, 100% { opacity: 0.9; } 50% { opacity: 0.45; } }
.stationicon { filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.8)); }

/* ---------- Infection flip animation ---------- */
.infectflip {
  position: absolute; top: 54px; left: 50%; z-index: 28; pointer-events: none;
  padding: 12px 26px; border-radius: 12px; text-align: center; color: #fff;
  border: 2px solid rgba(255,255,255,0.35); box-shadow: 0 14px 50px rgba(0,0,0,0.7);
  animation: flipin 3.1s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.infectflip .ifname { font-size: 22px; font-weight: 800; white-space: nowrap; }
.infectflip .ifsub { font-size: 11px; text-transform: uppercase; letter-spacing: 2px; opacity: 0.85; }
.infectflip.blue { background: #1d4ed8; }
.infectflip.yellow { background: #a16207; }
.infectflip.black { background: #334155; }
.infectflip.red { background: #b91c1c; }
@keyframes flipin {
  0%   { opacity: 0; transform: translateX(-50%) perspective(700px) rotateY(95deg) scale(0.8); }
  14%  { opacity: 1; transform: translateX(-50%) perspective(700px) rotateY(0deg) scale(1.07); }
  22%  { opacity: 1; transform: translateX(-50%) perspective(700px) rotateY(0deg) scale(1); }
  80%  { opacity: 1; transform: translateX(-50%) perspective(700px) rotateY(0deg) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) perspective(700px) rotateY(0deg) scale(0.94) translateY(-14px); }
}
.ping { animation: ping 2.1s ease-out both; pointer-events: none; stroke-width: 5; }
@keyframes ping { 0% { r: 10; opacity: 1; stroke-width: 6; } 100% { r: 78; opacity: 0; stroke-width: 1.5; } }
.cityflash { animation: cityflash 2.2s ease-out both; pointer-events: none; }
@keyframes cityflash { 0% { opacity: 0.55; } 60% { opacity: 0.22; } 100% { opacity: 0; } }

/* ---------- Epidemic ground zero ---------- */
.shockwave { fill: none; stroke: #f87171; animation: shockwave 1.9s ease-out both; pointer-events: none; }
@keyframes shockwave { 0% { r: 12; opacity: 1; stroke-width: 6; } 100% { r: 170; opacity: 0; stroke-width: 1; } }
.shockwave.mega { animation: shockmega 2.5s ease-out both; }
@keyframes shockmega { 0% { r: 14; opacity: 1; stroke-width: 8; } 100% { r: 300; opacity: 0; stroke-width: 1; } }
.traveldot { pointer-events: none; filter: drop-shadow(0 0 6px currentColor); }
.epiflash { fill: #ef4444; animation: epiflash 2.4s ease-out both; pointer-events: none; }
@keyframes epiflash { 0% { opacity: 0.6; } 100% { opacity: 0; } }
.epilabel {
  font-size: 24px; font-weight: 900; fill: #fecaca; pointer-events: none;
  paint-order: stroke; stroke: #450a0a; stroke-width: 6px;
  animation: epilabel 2.7s ease-out both;
}
@keyframes epilabel {
  0% { opacity: 0; transform: translateY(10px) scale(0.8); }
  14% { opacity: 1; transform: none; }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-8px); }
}
#stateModal.docked .dialog.epidlg { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad), 0 12px 48px rgba(0,0,0,0.7); }

/* ---------- Action feedback ---------- */
.actionring { fill: none; animation: actionring 1.1s ease-out both; pointer-events: none; }
@keyframes actionring { 0% { r: 10; opacity: 1; stroke-width: 4; } 100% { r: 48; opacity: 0; stroke-width: 1; } }
.floatup {
  font-size: 16px; font-weight: 800; pointer-events: none;
  paint-order: stroke; stroke: rgba(4, 8, 16, 0.85); stroke-width: 4px;
  animation: floatup 1.5s ease-out both;
}
@keyframes floatup {
  0% { opacity: 0; transform: translateY(8px); }
  18% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-30px); }
}
.spreadline { stroke-width: 3.5; stroke-dasharray: 7 7; animation: spreadline 1.6s ease-out both; pointer-events: none; }
@keyframes spreadline {
  0% { opacity: 0; stroke-dashoffset: 56; }
  20% { opacity: 0.95; }
  100% { opacity: 0; stroke-dashoffset: -56; }
}
.planetrail {
  fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round;
  stroke-dasharray: 5 9; opacity: 0.8; pointer-events: none;
  filter: drop-shadow(0 0 4px var(--accent));
}
.planetrail.fade { transition: opacity 0.6s ease-out; opacity: 0; }
.drivetrail {
  stroke: #cbd5e1; stroke-width: 2; stroke-linecap: round;
  stroke-dasharray: 1 7; opacity: 0.55; pointer-events: none;
}
.drivetrail.fade { transition: opacity 0.6s ease-out; opacity: 0; }
.caricon {
  fill: #fcd34d; pointer-events: none;
  filter: drop-shadow(0 0 4px rgba(252, 211, 77, 0.7)) drop-shadow(0 1px 1px rgba(0,0,0,0.6));
}
.drivetrail.wake { stroke: #7dd3fc; stroke-dasharray: 6 6; opacity: 0.5; }
.boaticon {
  fill: #e2e8f0; pointer-events: none;
  filter: drop-shadow(0 0 4px rgba(125, 211, 252, 0.8)) drop-shadow(0 1px 1px rgba(0,0,0,0.6));
}
.planeicon {
  fill: #f1f6ff; pointer-events: none;
  filter: drop-shadow(0 0 5px var(--accent)) drop-shadow(0 1px 1px rgba(0,0,0,0.6));
}
#mapwrap.shake { animation: mapshake 0.55s; }
@keyframes mapshake {
  15% { transform: translate(-7px, 4px); }
  30% { transform: translate(6px, -5px); }
  45% { transform: translate(-5px, -3px); }
  60% { transform: translate(4px, 3px); }
  75% { transform: translate(-2px, 1px); }
  100% { transform: none; }
}
.curebanner {
  position: absolute; top: 26%; left: 50%; transform: translateX(-50%); z-index: 33;
  pointer-events: none; text-align: center; color: #fff;
  background: linear-gradient(135deg, #14213c, #103252);
  border: 2px solid; border-radius: 16px; padding: 18px 38px;
  box-shadow: 0 18px 70px rgba(0,0,0,0.8);
  animation: curebanner 3.3s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
.curebanner .ifname { font-size: 28px; font-weight: 900; letter-spacing: 1px; white-space: nowrap; }
.curebanner .ifsub { font-size: 13px; text-transform: uppercase; letter-spacing: 3px; opacity: 0.9; margin-top: 4px; }
@keyframes curebanner {
  0% { opacity: 0; transform: translateX(-50%) scale(2.4); }
  12% { opacity: 1; transform: translateX(-50%) scale(1); }
  82% { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) scale(0.95) translateY(-16px); }
}
.cureflash { position: absolute; inset: 0; z-index: 26; pointer-events: none; animation: cureflash 1.3s ease-out both; }
@keyframes cureflash { 0% { opacity: 0.35; } 100% { opacity: 0; } }

/* ---------- Click feel ---------- */
button:not(:disabled) { transition: transform 0.06s ease, border-color 0.12s ease, background 0.12s ease; }
button:active:not(:disabled) { transform: scale(0.94); }
#actionsbox button:hover:not(:disabled), #citymenu button:hover:not(:disabled) { transform: translateY(-1px); }
.playercard.active { animation: activebreathe 2.6s ease-in-out infinite; }
@keyframes activebreathe {
  0%, 100% { box-shadow: 0 0 0 1px var(--accent); }
  50% { box-shadow: 0 0 12px 1px rgba(56, 189, 248, 0.55); }
}
#log .entry:last-child { animation: logfade 0.4s ease-out; }
@keyframes logfade { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
.overlimit { color: var(--bad); font-weight: 700; }

/* ---------- Forecast drag rows ---------- */
.fcrow { cursor: grab; border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; background: var(--panel2); user-select: none; }
.fcrow:active { cursor: grabbing; }
.fcrow .grip { color: var(--dim); font-size: 14px; }
.fcrow .fchint { margin-left: auto; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); }
.fcrow.dragging { opacity: 0.45; border-color: var(--accent); }

/* ---------- Drawn player card reveal ---------- */
.drawflip {
  position: absolute; top: 54px; left: 32%; z-index: 28; pointer-events: none;
  padding: 12px 26px; border-radius: 12px; text-align: center; color: #fff;
  border: 2px solid rgba(255,255,255,0.35); box-shadow: 0 14px 50px rgba(0,0,0,0.7);
  animation: flipin 2s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.drawflip .ifname { font-size: 20px; font-weight: 800; white-space: nowrap; }
.drawflip .ifsub { font-size: 11px; text-transform: uppercase; letter-spacing: 2px; opacity: 0.85; }
.drawflip.blue { background: #1d4ed8; }
.drawflip.yellow { background: #a16207; }
.drawflip.black { background: #334155; }
.drawflip.red { background: #b91c1c; }
.drawflip.event { background: #166534; }
.drawflip.epidemic {
  background: #7a1d1d; border-color: #f87171; left: 50%; top: 44px;
  animation: epislam 2.6s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.drawflip.epidemic .ifname { font-size: 30px; letter-spacing: 3px; text-shadow: 0 0 18px rgba(248,113,113,0.8); }
@keyframes epislam {
  0%   { opacity: 0; transform: translateX(-50%) scale(3); }
  12%  { opacity: 1; transform: translateX(-50%) scale(1); }
  16%  { transform: translateX(-50%) translateX(-7px) scale(1); }
  20%  { transform: translateX(-50%) translateX(6px) scale(1); }
  24%  { transform: translateX(-50%) translateX(-4px) scale(1); }
  28%  { transform: translateX(-50%) scale(1); }
  82%  { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) scale(0.94) translateY(-14px); }
}

/* ---------- City postcard (drawn city cards) ---------- */
.postcard {
  position: absolute; top: 54px; left: 50%; transform: translateX(-50%); z-index: 29;
  width: 300px; cursor: pointer; overflow: hidden;
  background: var(--panel); border: 2px solid rgba(255,255,255,0.35); border-radius: 14px;
  box-shadow: 0 16px 60px rgba(0,0,0,0.75);
  animation: pcin 5.6s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
.postcard.blue { border-color: #3b82f6; }
.postcard.yellow { border-color: #eab308; }
.postcard.black { border-color: #94a3b8; }
.postcard.red { border-color: #ef4444; }
.pcimg {
  height: 130px; background: linear-gradient(160deg, #1c2c4f, #0e1730) center/cover no-repeat;
  display: flex; align-items: center; justify-content: center;
}
.pcemoji { font-size: 58px; filter: drop-shadow(0 6px 14px rgba(0,0,0,0.6)); }
.pcbody { padding: 10px 14px 12px; }
.pcname { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.pcfact { font-size: 12px; color: var(--text); opacity: 0.92; line-height: 1.45; margin-bottom: 3px; }
.pcsub { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--dim); margin-top: 6px; }
@keyframes pcin {
  0% { opacity: 0; transform: translateX(-50%) perspective(800px) rotateY(80deg) scale(0.85); }
  7% { opacity: 1; transform: translateX(-50%) perspective(800px) rotateY(0deg) scale(1.03); }
  11% { transform: translateX(-50%) scale(1); }
  90% { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) scale(0.95) translateY(-14px); }
}
.tipfact { margin-top: 6px; opacity: 0.85; font-style: italic; }

/* ---------- Turn banner ---------- */
.turnbanner {
  position: absolute; top: 34%; left: 50%; z-index: 32; pointer-events: none;
  display: flex; align-items: center; gap: 12px;
  font-size: 26px; font-weight: 800; letter-spacing: 0.5px; color: #fff;
  background: linear-gradient(135deg, #14213c, #0e4f7a);
  border: 1px solid #2392d0; border-radius: 14px; padding: 14px 30px;
  box-shadow: 0 16px 60px rgba(0,0,0,0.75);
  animation: turnsweep 2.1s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
.turnbanner .rolechip { font-size: 13px; }
@keyframes turnsweep {
  0%   { opacity: 0; transform: translate(-50%, 0) translateX(-70px); }
  14%  { opacity: 1; transform: translate(-50%, 0); }
  78%  { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, 0) translateX(60px); }
}

/* ---------- Game over ---------- */
#stateModal.winlay { background: radial-gradient(ellipse at center, rgba(18, 64, 38, 0.55), rgba(5, 9, 18, 0.88)); overflow: hidden; }
#stateModal.losslay { background: radial-gradient(ellipse at center, rgba(76, 16, 16, 0.55), rgba(5, 9, 18, 0.9)); overflow: hidden; }
#stateModal.losslay::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(190, 30, 30, 0.22) 100%);
  animation: vignpulse 2.4s ease-in-out infinite;
}
@keyframes vignpulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
.dialog.gameover { text-align: center; width: min(640px, 92vw); overflow: visible; }
.gameover .gobig { font-size: 70px; line-height: 1.1; animation: goicon 0.9s cubic-bezier(0.2, 1.5, 0.4, 1) both; }
.gameover h2 { font-size: 34px; letter-spacing: 3px; margin: 6px 0 10px; }
.gameover h2.win { color: var(--good); text-shadow: 0 0 28px rgba(74, 222, 128, 0.55); animation: gotitle 0.7s 0.2s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
.gameover h2.loss { color: var(--bad); text-shadow: 0 0 28px rgba(248, 113, 113, 0.55); animation: goshake 1s 0.2s both; }
.gameover .goreason { font-size: 15px; }
.gostats { display: flex; gap: 12px; justify-content: center; margin: 16px 0 4px; }
.gostat { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 18px; font-size: 12px; color: var(--dim); animation: dlgpop 0.4s 0.45s both; }
.gostat b { display: block; font-size: 22px; color: var(--text); }
@keyframes goicon { 0% { transform: scale(0) rotate(-30deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes gotitle { 0% { transform: scale(2.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes goshake {
  0% { transform: scale(2.8); opacity: 0; }
  40% { transform: scale(1); opacity: 1; }
  50% { transform: translateX(-8px); }
  60% { transform: translateX(7px); }
  70% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
  100% { transform: none; opacity: 1; }
}
.confetti {
  position: absolute; top: -24px; border-radius: 2px; pointer-events: none;
  animation-name: confettifall; animation-timing-function: linear; animation-iteration-count: infinite;
}
@keyframes confettifall {
  0% { transform: translateY(-4vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(740deg); opacity: 0.7; }
}

#banner {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  background: #0e4f7a; border: 1px solid #2392d0; border-radius: 8px;
  padding: 8px 14px; display: flex; gap: 12px; align-items: center;
  font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,0.5); z-index: 30;
}

#citymenu {
  position: absolute; z-index: 25; width: 250px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.6); padding: 10px;
}
#citymenu h3 { margin: 0 0 6px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
#citymenu .menuline { font-size: 12px; color: var(--dim); margin-bottom: 8px; }
#citymenu button { display: block; width: 100%; text-align: left; margin-top: 5px; font-size: 13px; }
#citymenu .closex { position: absolute; top: 6px; right: 8px; width: auto; border: none; background: none; color: var(--dim); padding: 2px 6px; }

/* ---------- Sidebar ---------- */
#side {
  width: 370px; flex-shrink: 0; overflow-y: auto;
  background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px; padding: 10px;
}
.boxtitle { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); margin-bottom: 6px; }
#turnbox { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
#turnbox .who { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
#turnbox .phaseline { color: var(--dim); font-size: 12px; margin-top: 2px; }
.pips { display: inline-flex; gap: 4px; margin-left: 6px; }
.pip { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.pip.spent { background: #2a3a5c; }

#actionsbox .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#actionsbox button.wide { grid-column: 1 / -1; }
#actionsbox { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }

.playercard { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 6px; }
.playercard.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.playercard .phead { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.rolechip { font-size: 11px; padding: 2px 8px; border-radius: 10px; color: #0b1220; font-weight: 700; }
.roledesc { font-size: 11px; color: var(--dim); line-height: 1.35; margin: 3px 0 2px; }
.ploc { font-size: 12px; color: var(--dim); margin: 2px 0 6px; }
.hand { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.hand .card { width: 100%; height: 27px; padding: 2px 7px; font-size: 11.5px; }
.card {
  font-size: 12px; padding: 3px 8px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.25);
  color: #fff; display: inline-flex; align-items: center; gap: 5px; font-weight: 600;
  position: relative; min-width: 0;
}
.card .cardname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.card:hover { border-color: #fff; z-index: 35; }
.card.clickable { cursor: pointer; }
.card.clickable:hover { outline: 2px solid #fff; }
.card.infotap { cursor: pointer; }
.card .playmini {
  margin-left: auto; padding: 0 5px; font-size: 9px; line-height: 16px; border-radius: 4px;
  background: rgba(255,255,255,0.22); border: none; color: #fff; flex-shrink: 0;
}
.cardtip {
  display: none; position: fixed; width: 220px;
  background: #0d1526; border: 1px solid var(--accent); border-radius: 8px;
  padding: 8px 10px; font-size: 11.5px; font-weight: 500; color: var(--text); line-height: 1.45;
  white-space: normal; z-index: 90; box-shadow: 0 10px 34px rgba(0,0,0,0.65); text-align: left;
}
.cardtip.open { display: block; animation: tippop 0.14s ease-out; }
@keyframes tippop { from { opacity: 0; } to { opacity: 1; } }
.cardtip .play {
  display: block; margin-top: 7px; background: #0e4f7a; border: 1px solid #2392d0;
  color: #fff; border-radius: 5px; padding: 3px 10px; font-size: 11px;
}
.card.blue { background: #1d4ed8; }
.card.yellow { background: #a16207; }
.card.black { background: #334155; }
.card.red { background: #b91c1c; }
.card.event { background: #166534; }
.card.event .play { background: rgba(255,255,255,0.2); border: none; color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.card.selected { outline: 2px solid #fff; }

#statusbox { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px; font-size: 12px; color: var(--dim); }
#statusbox .srow { display: flex; justify-content: space-between; padding: 1px 0; }
#statusbox b { color: var(--text); }
.cubedot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

#logbox { flex: 1; min-height: 120px; display: flex; flex-direction: column; }
#log { flex: 1; overflow-y: auto; font-size: 12px; background: #0d1526; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
#log .entry { margin-bottom: 3px; color: var(--dim); }
#log .entry.good { color: var(--good); }
#log .entry.bad { color: var(--bad); font-weight: 600; }
#log .entry.news {
  color: #e2c08d; font-style: italic; line-height: 1.4;
  margin: 5px 0; padding: 5px 8px 5px 9px;
  background: rgba(226, 192, 141, 0.07);
  border-left: 2px solid #e2c08d; border-radius: 0 4px 4px 0;
}

/* ---------- News ticker ---------- */
#ticker {
  display: flex; align-items: center; flex-shrink: 0; height: 34px;
  background: #0d1526; border-bottom: 1px solid var(--line);
}
.tickertag {
  flex-shrink: 0; display: flex; align-items: center; height: 100%; padding: 0 12px;
  font-size: 11px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase;
  color: #0b1220; background: #e2c08d;
}
#tickerwrap {
  flex: 1; position: relative; height: 100%; overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 18px, #000 calc(100% - 18px), transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 18px, #000 calc(100% - 18px), transparent);
}
#tickertrack {
  position: absolute; left: 0; top: 0; height: 100%;
  display: flex; align-items: center; white-space: nowrap; will-change: transform;
}
.tickeritem { display: inline-flex; align-items: center; color: #e2c08d; font-style: italic; font-size: 13px; }
.tickeritem .tickersep { color: var(--accent); font-style: normal; margin: 0 16px; opacity: 0.7; }

/* ---------- Modals ---------- */
#modal, #stateModal, #setup {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5, 9, 18, 0.72);
  display: flex; align-items: center; justify-content: center;
}
#modal { z-index: 60; }
#setup { z-index: 70; overflow-y: auto; }
/* Docked variant: no backdrop, anchored at the bottom, map stays interactive around it. */
#stateModal.docked {
  background: none; pointer-events: none;
  align-items: flex-end; justify-content: center; padding-bottom: 16px;
}
#stateModal.docked .dialog {
  pointer-events: auto; width: min(760px, 92vw); max-height: 44vh;
  border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 12px 48px rgba(0,0,0,0.7);
}
.dialog {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; width: min(560px, 92vw); max-height: 86vh; overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0,0,0,0.7);
  animation: dlgpop 0.22s ease-out;
}
@keyframes dlgpop { from { transform: scale(0.93); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.dialog h2 { margin: 0 0 10px; font-size: 18px; }
.dialog h2.epi { color: var(--bad); }
.dialog .sub { color: var(--dim); font-size: 13px; margin-bottom: 12px; }
.dialog .btnrow { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; justify-content: flex-end; }
.dialog .list button { display: block; width: 100%; text-align: left; margin-top: 6px; }
.dialog .handpick { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.fcrow { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.fcrow .pos { width: 22px; color: var(--dim); font-size: 12px; }
.fcrow .updown button { padding: 1px 8px; margin-left: 4px; }

/* ---------- Setup ---------- */
.setuprow { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.setuprow label { width: 130px; color: var(--dim); font-size: 13px; }
.setupdesc { margin: -6px 0 10px 140px; font-size: 11px; color: var(--dim); line-height: 1.35; }
.bigtitle { font-size: 26px; font-weight: 800; margin: 0 0 2px; }
.subtitle { color: var(--dim); margin: 0 0 16px; font-size: 13px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #7a2e2e; border: 1px solid #c05050; color: #fff;
  border-radius: 8px; padding: 9px 16px; z-index: 80; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,0.6);
}

/* ---------- Game over ---------- */
.gameover h2 { font-size: 26px; }
.gameover h2.win { color: var(--good); }
.gameover h2.loss { color: var(--bad); }

/* ---- online lobby & connection ---- */
.connDot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.roomcode { display: flex; gap: 8px; justify-content: center; margin: 10px 0 16px; }
.roomcode span {
  font-size: 34px; font-weight: 800; letter-spacing: 1px;
  background: #0b1220; border: 1px solid #2b3a55; border-radius: 10px;
  padding: 6px 14px; color: var(--accent, #38bdf8);
}
