:root{
  --bg:#0a0d11;
  --panel:#12161c;
  --panel2:#1a212a;
  --panel3:#202833;
  --border:#2b3540;
  --text:#e7e2d3;
  --muted:#8b93a0;
  --dim:#5c6672;
  --teal:#3fc1b5;
  --amber:#d9a441;
  --red:#e5564f;
  --violet:#9b87d9;
  --heart:#e0556b;
  --diamond:#4fd1c5;
  --club:#b7adc9;
  --spade:#ff6e62;
  --gold:#e8c468;
  --good:#5fd089;
  --bad:#ff6e62;
  --andromedan:#00e676;         /* Andromedan invasion — alien green */
  --andromedan-dim:#00c853;
}
*{box-sizing:border-box;}
html,body{
  margin:0;padding:0;height:100%;
  background:var(--bg);
  color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;
  overflow-x:hidden;
}
body{
  background-image:
    radial-gradient(ellipse at 20% -10%, rgba(63,193,181,0.07), transparent 50%),
    radial-gradient(ellipse at 90% 10%, rgba(229,86,79,0.06), transparent 45%);
  /* Suppress stray text selection during play (cards, buttons, chips, labels).
     Selectable zones (comms log, modal text, center message, flavor) opt back
     in below. */
  user-select:none;
  -webkit-user-select:none;
  -moz-user-select:none;
}
.comms-feed, .comms-feed *,
.modal-box, .modal-box *,
#center-msg,
.dealer-flavor,
.log-line, .log-line *{
  user-select:text;
  -webkit-user-select:text;
  -moz-user-select:text;
}
/* Buttons are interactive controls, never text content — !important wins
   over .modal-box * (specificity 0,1,0) which would otherwise let users
   accidentally select "Continue" / "Close" labels inside scoring modals. */
button, button *{
  user-select:none !important;
  -webkit-user-select:none !important;
  -moz-user-select:none !important;
}

/* Header timers — game total + current mission, mono so digits don't reflow. */
.timers{
  font-family:ui-monospace,SFMono-Regular,Consolas,Menlo,monospace;
  font-size:12px;
  color:var(--muted);
  letter-spacing:0.02em;
}
.timers .t-label{color:var(--dim);margin-right:4px;font-weight:600;}
.timers b{color:var(--text);font-weight:600;}
.timers .sep{color:var(--dim);margin:0 6px;}
.mono{font-family:ui-monospace,SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;}
h1,h2,h3{margin:0;font-weight:700;letter-spacing:0.02em;}
button{
  font-family:inherit;cursor:pointer;border:1px solid var(--border);
  background:var(--panel2);color:var(--text);border-radius:6px;
  padding:10px 16px;font-size:14px;transition:all .15s ease;
}
button:hover:not(:disabled){border-color:var(--teal);filter:brightness(1.3);}
button:disabled{opacity:0.35;cursor:not-allowed;}
button.primary{background:linear-gradient(180deg,var(--teal),#2a9890);color:#06120f;border:none;font-weight:700;}
button.primary:hover:not(:disabled){filter:brightness(1.3);}
button.danger{border-color:var(--spade);color:var(--spade);}
.hidden{display:none !important;}
::-webkit-scrollbar{width:8px;height:8px;}
::-webkit-scrollbar-thumb{background:var(--border);border-radius:4px;}

/* ---------- Setup Screen ---------- */
#setup-screen{
  min-height:100vh;display:flex;align-items:center;justify-content:center;
  padding:24px;
}
.setup-card{
  max-width:640px;width:100%;background:var(--panel);border:1px solid var(--border);
  border-radius:14px;padding:36px;box-shadow:0 20px 60px rgba(0,0,0,0.5);
}
.brand{text-align:center;margin-bottom:6px;}
.brand .glyph{font-size:13px;color:var(--teal);letter-spacing:0.35em;text-transform:uppercase;font-family:ui-monospace,monospace;}
.brand h1{font-size:38px;letter-spacing:0.08em;background:linear-gradient(180deg,#fff,var(--teal));-webkit-background-clip:text;background-clip:text;color:transparent;}
.brand p{color:var(--muted);font-size:14px;margin-top:6px;}
.brand .version{font-size:10px;color:var(--dim);letter-spacing:0.2em;font-family:monospace;margin-top:4px;}
.setup-section{margin-top:26px;}
.setup-section label.title{display:block;font-size:12px;text-transform:uppercase;letter-spacing:0.12em;color:var(--muted);margin-bottom:10px;}
.count-row{display:flex;gap:8px;flex-wrap:wrap;}
.count-row button{flex:1;min-width:54px;font-size:16px;font-weight:700;}
.count-row button.selected{background:var(--teal);color:#06120f;border-color:var(--teal);}

/* Presets row — quick distribution buttons sitting above the per-tier
   counters. Clicking a preset auto-fills the counters; manual counter
   edits drop the preset selection to "Custom". */
/* Locked sections — used by the opponent-mix picker until the player
   count is chosen. Visually communicates "you can't use this yet" without
   removing it from the layout. */
.setup-section.locked{
  opacity:0.42;
  pointer-events:none;
  position:relative;
  filter:saturate(0.4);
}
.setup-section.locked .title:after{
  content:' 🔒';
  font-size:0.85em;
  color:var(--muted);
}

.presets-row{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:14px;}
.presets-row button{
  padding:6px 12px;font-size:12px;font-family:monospace;letter-spacing:0.04em;
  background:var(--panel3);border:1px solid var(--border);color:var(--text);
  border-radius:5px;cursor:pointer;transition:filter .15s ease;
}
.presets-row button:hover{filter:brightness(1.3);}
.presets-row button.selected{
  background:var(--teal);color:#06120f;border-color:var(--teal);
}
.presets-row button.custom{font-style:italic;}

/* Per-tier counter rows — one row per AI tier, with a label + IQ badge
   on the left and an inline [−] N [+] stepper on the right. */
.mix-counters{display:flex;flex-direction:column;gap:8px;}
.mix-row{
  display:flex;align-items:center;gap:12px;
  padding:10px 14px;background:var(--panel2);border:1px solid var(--border);border-radius:6px;
}
.mix-row .mix-label{flex:1;font-weight:700;font-size:14px;}
.mix-row .mix-iq{
  font-family:ui-monospace,SFMono-Regular,Consolas,Menlo,monospace;
  font-size:10px;font-weight:600;letter-spacing:0.08em;
  color:var(--gold);background:rgba(232,196,104,0.08);
  border:1px solid rgba(232,196,104,0.35);border-radius:3px;
  padding:1px 6px;cursor:help;margin-right:8px;
}
.mix-stepper{display:flex;align-items:center;gap:6px;}
.mix-stepper button{
  width:30px;height:30px;padding:0;font-size:18px;font-weight:700;line-height:1;
  background:var(--panel3);border:1px solid var(--border);color:var(--text);
  border-radius:4px;cursor:pointer;transition:filter .15s ease;
}
.mix-stepper button:hover:not(:disabled){filter:brightness(1.3);}
.mix-stepper button:disabled{opacity:0.3;cursor:not-allowed;}
.mix-stepper .mix-count{
  min-width:28px;text-align:center;font-family:monospace;font-size:16px;font-weight:700;
  color:var(--text);
}

/* Status line — green check when total matches, red warning otherwise */
.mix-status{
  font-family:monospace;font-size:12px;letter-spacing:0.04em;
  padding:8px 12px;margin-top:8px;border-radius:5px;
  background:var(--panel2);border:1px solid var(--border);
  color:var(--muted);text-align:center;
}
.mix-status.ok{color:var(--good);border-color:var(--good);background:rgba(95,208,137,0.06);}
.mix-status.bad{color:var(--bad);border-color:var(--bad);background:rgba(229,86,79,0.06);}

/* Difficulty buttons carry an IQ badge below the label, so they use a
   stacked layout rather than the simple single-line layout of player-count
   buttons. .ai-btn is added per-button by app.js. */
.count-row button.ai-btn{
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:4px;padding:10px 14px;line-height:1.2;
}
.count-row button.ai-btn .ai-label{font-size:14px;font-weight:700;}
.count-row button.ai-btn .ai-iq{
  font-family:ui-monospace,SFMono-Regular,Consolas,Menlo,monospace;
  font-size:10px;font-weight:600;letter-spacing:0.08em;
  color:var(--gold);background:rgba(232,196,104,0.08);
  border:1px solid rgba(232,196,104,0.35);border-radius:3px;
  padding:1px 6px;cursor:help;
}
.count-row button.ai-btn.selected .ai-iq{
  color:#3a2a00;background:rgba(0,0,0,0.18);border-color:rgba(0,0,0,0.3);
}
.setup-foot{margin-top:30px;display:flex;justify-content:flex-end;gap:10px;align-items:center;}
.setup-foot-link{
  color:var(--teal);font-family:monospace;font-size:13px;text-decoration:none;
  padding:8px 14px;border:1px solid var(--teal);border-radius:5px;
  transition:background .15s ease, color .15s ease;
  margin-right:auto;
}
.setup-foot-link:hover{background:var(--teal);color:#06120f;}
.setup-blurb{font-size:13px;color:var(--dim);line-height:1.6;margin-top:18px;border-top:1px solid var(--border);padding-top:16px;}

/* Once the user clicks "Determine Dealer", the setup-card switches into
   dealer-mode: settings are locked, so we hide the count / AI / blurb /
   foot sections and let the dealer-draw section be its own clean stage. */
.setup-card.dealer-mode .setup-section:not(#dealer-draw-section),
.setup-card.dealer-mode .setup-blurb,
.setup-card.dealer-mode .setup-foot{
  display:none !important;
}

/* Flavor excerpt shown above the dealer-draw — quoted-block style with
   an amber accent bar to signal "this is from the rulebook." */
.dealer-flavor{
  font-size:12.5px;
  color:var(--muted);
  font-style:italic;
  line-height:1.65;
  margin:10px 0 16px;
  padding:12px 14px;
  background:rgba(255,255,255,0.025);
  border-left:2px solid var(--amber);
  border-radius:0 4px 4px 0;
}

/* ---------- Game Screen ---------- */
#game-screen{display:none;min-height:100vh;flex-direction:column;}
#game-screen.active{display:flex;}
header.topbar{
  display:flex;align-items:center;justify-content:space-between;
  padding:10px 18px;background:var(--panel);border-bottom:1px solid var(--border);
  flex-wrap:wrap;gap:8px;
}
.topbar .title{display:flex;align-items:center;gap:10px;}
.topbar .title .glyph{color:var(--teal);font-family:monospace;font-size:11px;letter-spacing:0.3em;}
.topbar h2{font-size:18px;letter-spacing:0.05em;}
.topbar .meta{display:flex;gap:18px;font-size:12px;color:var(--muted);font-family:monospace;}
.topbar .meta b{color:var(--text);}
.topbar .actions{display:flex;gap:8px;}
.topbar button{padding:6px 12px;font-size:12px;}

.table-wrap{flex:1;display:flex;min-height:0;}
.table-main{flex:1;display:flex;flex-direction:column;min-width:0;padding:14px;gap:12px;}

.opponents-row{display:flex;gap:10px;flex-wrap:wrap;justify-content:center;}
.seat{
  background:var(--panel);border:1px solid var(--border);border-radius:10px;
  padding:10px 12px;min-width:150px;position:relative;
}
.seat.active-turn{border-color:var(--teal);box-shadow:0 0 0 1px var(--teal), 0 0 16px rgba(63,193,181,0.25);}
.seat .seat-head{display:flex;align-items:center;gap:8px;}
.avatar{
  width:30px;height:30px;border-radius:50%;display:flex;align-items:center;justify-content:center;
  font-weight:800;font-size:12px;color:#06120f;flex-shrink:0;
}
.seat .name{font-size:13px;font-weight:700;}
.seat .role{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:0.05em;}
.seat .stats{display:flex;gap:12px;margin-top:8px;font-size:11px;font-family:monospace;color:var(--muted);}
.seat .stats b{color:var(--text);}
.seat .exposed-tag{position:absolute;top:6px;right:8px;font-size:9px;color:var(--amber);font-family:monospace;letter-spacing:0.05em;}
/* Human's hand-exposed indicator — a dedicated full-width banner so the
   player can't possibly miss that their hand is visible to the AIs.
   Toggled by [hidden] attribute on #human-exposed-banner. */
.human-exposed-banner{
  display:block;
  margin:8px 0 10px 0;
  padding:9px 14px;
  font-size:13px;font-family:ui-monospace,SFMono-Regular,Consolas,Menlo,monospace;
  letter-spacing:0.04em;font-weight:700;
  color:#1a0f00;
  background:linear-gradient(90deg, var(--amber), #f3c46b);
  border:2px solid var(--amber);
  border-radius:6px;
  text-align:center;
  box-shadow:0 0 14px rgba(217,164,65,0.45), inset 0 0 12px rgba(255,255,255,0.15);
  animation:pulse 1.6s infinite;
}
.human-exposed-banner[hidden]{display:none;}
.bubble{
  position:absolute;bottom:100%;left:50%;transform:translateX(-50%);margin-bottom:8px;
  background:var(--panel3);border:1px solid var(--border);border-radius:8px;padding:7px 10px;
  font-size:12px;max-width:220px;width:max-content;z-index:30;
  box-shadow:0 6px 18px rgba(0,0,0,0.45);
  animation:bpop .18s ease;
}
.bubble:after{content:"";position:absolute;top:100%;left:50%;transform:translateX(-50%);
  border:6px solid transparent;border-top-color:var(--panel3);}
@keyframes bpop{from{opacity:0;transform:translateX(-50%) translateY(4px);}to{opacity:1;transform:translateX(-50%) translateY(0);}}

.center-area{
  flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;
  background:var(--panel);border:1px solid var(--border);border-radius:12px;
  padding:18px;position:relative;min-height:220px;gap:14px;
}
.reserve-indicator{
  position:absolute;top:12px;right:14px;font-family:monospace;font-size:11px;
  color:var(--amber);display:flex;align-items:center;gap:8px;
}
.reserve-indicator .reserve-label{letter-spacing:0.1em;}
.reserve-indicator .reserve-stack{display:inline-flex;gap:2px;align-items:center;min-height:20px;}
.reserve-indicator .reserve-stack:empty:after{content:'EMPTY';color:var(--dim);font-size:10px;letter-spacing:0.1em;}
.card-mini{
  display:inline-block;width:14px;height:20px;border-radius:2px;
  background:repeating-linear-gradient(135deg,#1d2733,#1d2733 3px,#222e3b 3px,#222e3b 6px);
  border:1px solid var(--border);
  box-shadow:0 1px 2px rgba(0,0,0,0.4);
}
.invasion-banner{
  position:absolute;top:12px;left:14px;font-family:monospace;font-size:11px;color:var(--andromedan);
  display:flex;align-items:center;gap:6px;animation:pulse 1.4s infinite;
  text-shadow:0 0 8px var(--andromedan);
}
@keyframes pulse{0%,100%{opacity:1;}50%{opacity:0.4;}}
.trick-slots{
  display:flex;gap:14px;
  align-items:center;flex-wrap:wrap;justify-content:center;
  height:148px;   /* fixed so timestamps don't shift cards around between renders */
}
.trick-slot{display:flex;flex-direction:column;align-items:center;gap:4px;}
.player-chip{
  display:inline-block;
  font-size:10px;
  text-transform:uppercase;
  letter-spacing:0.05em;
  font-weight:700;
  padding:3px 8px;
  border-radius:3px;
  box-shadow:0 1px 2px rgba(0,0,0,0.4);
  vertical-align:baseline;
}
.play-timestamp{
  font-family:monospace;
  font-size:10px;
  color:var(--dim);
  letter-spacing:0.05em;
  margin-top:4px;
  padding-top:8px;
  position:relative;
  min-width:64px;
  text-align:center;
}
.play-timestamp:before{
  content:'';
  position:absolute;
  top:0; left:0; right:0;
  height:1px;
  background:var(--border);
}
.play-timestamp:after{
  content:'';
  position:absolute;
  top:-3px; left:50%;
  transform:translateX(-50%);
  width:6px; height:6px;
  border-radius:50%;
  background:var(--amber);
  border:1px solid var(--bg);
}
.continue-prompt{
  position:absolute;
  bottom:14px;
  left:50%;
  transform:translateX(-50%);
  animation:fadeIn 0.22s ease-out;
}
.continue-prompt button{
  padding:8px 24px;
  font-size:13px;
  font-weight:700;
}
@keyframes fadeIn{from{opacity:0;transform:translateX(-50%) translateY(4px);}to{opacity:1;transform:translateX(-50%) translateY(0);}}
.led-suit-tag{font-family:monospace;font-size:11px;color:var(--muted);}
.center-msg{font-size:13px;color:var(--muted);text-align:center;min-height:18px;}

.human-area{background:var(--panel);border:1px solid var(--border);border-radius:12px;padding:12px 14px;transition:transform 0.4s ease-out;}
.human-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px;}
.human-head .name{font-weight:700;font-size:14px;color:#c0c0c0;}
.human-head .stats{font-family:monospace;font-size:11px;color:var(--muted);}
.human-head .stats .pile-link{
  color:#c0c0c0;
  cursor:pointer;
  text-decoration:underline;
  text-decoration-style:dotted;
  text-decoration-color:rgba(192,192,192,0.45);
  text-underline-offset:2px;
  padding:0 2px;
  border-radius:3px;
  transition:background-color .12s ease, text-decoration-color .12s ease;
}
.human-head .stats .pile-link:hover{
  background:rgba(192,192,192,0.14);
  text-decoration-color:#c0c0c0;
}

/* Universal "winning" elevation — works on any element that has a transform
   transition declared on its base style (.seat, .human-area, .dealer-draw-cell). */
.seat{transition:transform 0.4s ease-out;}
.winning-seat{
  transform:translateY(-20px);
}

/* Cell for each card+name pair shown during the dealer-draw flow.
   Internal layout stays vertical (card on top, label beneath); the cells
   themselves flow horizontally via the .modal-options defaults. */
.dealer-draw-cell{
  display:flex;
  flex-direction:column;
  align-items:center;
  text-align:center;
  transition:transform 0.4s ease-out;
}

/* Big score readout that appears in the center while cards fly to the
   winner, then scales down and fades to 0 over the same ~620ms. */
.win-score{
  position:absolute;
  left:50%; top:50%;
  transform:translate(-50%, -50%) scale(1);
  opacity:1;
  font-family:ui-monospace,SFMono-Regular,Consolas,monospace;
  text-shadow:0 0 14px rgba(0,0,0,0.65);
  transition:transform 0.62s ease-in, opacity 0.62s ease-in;
  pointer-events:none;
  z-index:6;
  white-space:nowrap;
  text-align:center;
}
.win-score.fade-out{
  transform:translate(-50%, -50%) scale(0.16);
  opacity:0;
}
.win-score.pos{color:var(--good);}
.win-score.neg{color:var(--bad);}
.win-score.zero{color:var(--muted);}
.win-score-big{
  font-size:78px;
  font-weight:900;
  line-height:0.9;
  letter-spacing:0.02em;
}
.win-score-sub{
  font-size:18px;
  font-weight:600;
  letter-spacing:0.05em;
  opacity:0.78;
  margin-top:6px;
  text-align:center;
  /* Inherit the parent .win-score color but at a slightly muted weight */
}
.hand-row{display:flex;gap:6px;flex-wrap:wrap;min-height:96px;align-items:flex-end;}

.card{
  width:58px;height:82px;border-radius:7px;border:1px solid rgba(0,0,0,0.4);
  background:linear-gradient(160deg,#f3efe4,#e6e0d0);
  color:#16181c;display:flex;flex-direction:column;justify-content:space-between;
  padding:4px 5px;font-weight:800;font-size:13px;flex-shrink:0;position:relative;
  box-shadow:0 2px 4px rgba(0,0,0,0.4);
}
.card .rank-top{line-height:1;}
.card .suit-mid{font-size:22px;align-self:center;line-height:1;}
.card .rank-bot{line-height:1;align-self:flex-end;transform:rotate(180deg);}
.card.suit-H{color:#c8281e;}        /* hearts: bold red */
.card.suit-D{color:#d27416;}        /* diamonds: warm orange */
.card.suit-C{color:#58606a;}        /* clubs: medium gray */
.card.suit-S{color:#1d3a6b;}        /* spades: deep navy */
.card.suit-JK{color:#9c7a14;background:linear-gradient(160deg,#fff3d6,#f0dca0);}
.card.clickable{cursor:pointer;transition:transform .12s ease;}
.card.clickable:hover{transform:translateY(-8px);}
.card.disabled{opacity:0.4;filter:grayscale(0.4);}
.card.tiny{width:40px;height:56px;font-size:9px;padding:3px;}
.card.tiny .suit-mid{font-size:14px;}
.card-back{
  width:58px;height:82px;border-radius:7px;border:1px solid var(--border);
  background:repeating-linear-gradient(135deg,#1d2733,#1d2733 6px,#222e3b 6px,#222e3b 12px);
  box-shadow:0 2px 4px rgba(0,0,0,0.4);position:relative;flex-shrink:0;
}
.card-back:after{content:"⌬";position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#3a4a5c;font-size:16px;}
.card-back.tiny{width:40px;height:56px;}

/* ---------- Comms Log ---------- */
.comms-panel{
  width:280px;flex-shrink:0;background:var(--panel);border-left:1px solid var(--border);
  display:flex;flex-direction:column;
}
.comms-head{
  padding:10px 14px;border-bottom:1px solid var(--border);font-family:monospace;font-size:11px;
  color:var(--teal);letter-spacing:0.1em;display:flex;justify-content:space-between;align-items:center;
}
.comms-head .live-dot{width:7px;height:7px;border-radius:50%;background:var(--good);animation:pulse 1.6s infinite;display:inline-block;margin-right:6px;}
.comms-head-right{display:flex;align-items:center;gap:10px;}
.comms-export-btn{
  font-family:monospace;font-size:10px;letter-spacing:0.06em;
  background:transparent;color:var(--teal);
  border:1px solid var(--teal);border-radius:4px;
  padding:3px 8px;cursor:pointer;
  transition:background .15s ease, color .15s ease;
}
.comms-export-btn:hover{
  background:var(--teal);color:#06120f;
}
.comms-feed{
  flex:1;overflow-y:auto;padding:10px;font-family:monospace;font-size:11.5px;line-height:1.5;
  max-height:calc(100vh - 90px);   /* anchors the auto-scroll so the feed can't grow the page */
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.012) 0px, rgba(255,255,255,0.012) 1px, transparent 1px, transparent 3px);
}
.log-line{margin-bottom:9px;}
.log-line .tag{font-weight:800;padding:1px 5px;border-radius:3px;margin-right:6px;font-size:10px;}
.log-line.system{color:var(--dim);font-style:italic;}
.log-line.system .marker{color:var(--amber);}
.log-line.andromedan{color:var(--andromedan);font-style:italic;text-shadow:0 0 6px var(--andromedan-dim);}
.log-line.andromedan .marker{color:var(--andromedan);}
.comms-toggle{display:none;}

@media (max-width:900px){
  .comms-panel{position:fixed;right:0;top:0;bottom:0;z-index:50;transform:translateX(100%);transition:transform .2s ease;}
  .comms-panel.open{transform:translateX(0);}
  .comms-toggle{display:inline-block;}
}

/* Phone-narrow: shrink cards so a 7-card hand fits on a ~380px viewport.
   Default card is 58×82; on phones we drop to 44×62. The tiny class
   (history modals, etc.) also shrinks proportionally. */
@media (max-width:600px){
  .card{
    width:44px;height:62px;padding:3px 4px;font-size:11px;border-radius:5px;
  }
  .card .suit-mid{font-size:17px;}
  .card-back{
    width:44px;height:62px;border-radius:5px;
  }
  .card-back:after{font-size:13px;}
  .card.tiny{width:32px;height:44px;font-size:8px;padding:2px;}
  .card.tiny .suit-mid{font-size:11px;}
  .card-back.tiny{width:32px;height:44px;}
  /* Tighten hand-row gap so the smaller cards stay together visually */
  .hand-row{gap:4px;}
  .human-exposed-banner{font-size:11px;padding:7px 10px;}
}

/* ---------- Modal ---------- */
#modal-root{position:fixed;inset:0;display:none;align-items:center;justify-content:center;z-index:100;padding:16px;}
#modal-root.open{display:flex;}
.modal-backdrop{position:absolute;inset:0;background:rgba(4,6,8,0.72);backdrop-filter:blur(2px);}
.modal-box{
  position:relative;background:var(--panel);border:1px solid var(--border);border-radius:12px;
  padding:24px;max-width:560px;width:100%;max-height:84vh;overflow-y:auto;
  box-shadow:0 24px 70px rgba(0,0,0,0.6);
}
.modal-box h3{font-size:17px;margin-bottom:6px;color:var(--teal);}
.modal-box .sub{font-size:13px;color:var(--muted);margin-bottom:16px;line-height:1.5;}
.modal-options{display:flex;flex-wrap:wrap;gap:10px;margin-bottom:18px;}
.modal-card-opt{display:flex;flex-direction:column;align-items:center;gap:6px;cursor:pointer;padding:4px;border-radius:8px;border:2px solid transparent;}
.modal-card-opt:hover{border-color:var(--border);}
.modal-card-opt.selected{border-color:var(--teal);background:rgba(63,193,181,0.1);}
.modal-card-opt .owner-lbl{
  font-family:monospace;font-size:10px;font-weight:700;letter-spacing:0.05em;
  color:var(--teal);padding:2px 6px;border:1px solid var(--teal);border-radius:3px;
  background:rgba(63,193,181,0.08);max-width:110px;text-align:center;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.modal-card-opt .owner-lbl.own{color:var(--gold);border-color:var(--gold);background:rgba(232,196,104,0.10);}
.modal-card-opt .lbl{font-size:10px;color:var(--muted);text-align:center;max-width:70px;}
.modal-btn-opt{padding:10px 16px;}
.modal-foot{display:flex;justify-content:flex-end;gap:10px;border-top:1px solid var(--border);padding-top:14px;margin-top:6px;}

/* ---------- Scoreboard / Results ---------- */
.score-table{width:100%;border-collapse:collapse;font-size:13px;margin-top:10px;}
.score-table th,.score-table td{padding:7px 9px;border-bottom:1px solid var(--border);text-align:left;}
.score-table th{color:var(--muted);font-weight:600;font-size:11px;text-transform:uppercase;letter-spacing:0.04em;}
.score-table td.num{text-align:right;font-family:monospace;}
.score-table .pos{color:var(--good);}
.score-table .neg{color:var(--bad);}
.pile-list{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px;}
.note-list{font-size:12px;color:var(--amber);margin:10px 0;padding-left:18px;}
.note-list li{margin-bottom:4px;}

.crown{font-size:48px;text-align:center;margin-bottom:6px;}

/* ---------- Score history modal ---------- */
.history-list{
  display:flex;flex-direction:column;gap:10px;
  margin-top:14px;
  max-height:50vh;overflow-y:auto;
  padding-right:4px;
}
.history-row{
  background:rgba(255,255,255,0.02);
  border:1px solid var(--border);
  border-radius:6px;
  padding:10px 12px;
}
.history-row .h-head{
  display:flex;justify-content:space-between;align-items:baseline;
  font-size:12px;color:var(--muted);
  margin-bottom:6px;
  padding-bottom:6px;
  border-bottom:1px dashed var(--border);
}
.history-row .h-when{color:var(--text);font-weight:600;}
.history-row .h-system{color:var(--teal);font-weight:700;margin-right:6px;letter-spacing:0.02em;}
.history-row .h-meta{font-family:ui-monospace,Consolas,monospace;font-size:11px;}
.history-table{width:100%;border-collapse:collapse;font-size:12.5px;}
.history-table td{padding:4px 6px;}
.history-table .h-rank{width:24px;color:var(--dim);font-family:monospace;font-size:11px;text-align:right;}
.history-table .h-name{color:var(--text);}
.history-table .h-total{text-align:right;font-family:monospace;font-weight:600;width:60px;}
.history-table .h-total.pos{color:var(--good);}
.history-table .h-total.neg{color:var(--bad);}
.history-table .is-winner{background:rgba(63,193,181,0.06);}
.history-table .is-human .h-name{font-style:italic;}
.h-chip{
  display:inline-block;
  color:#000;font-weight:700;font-size:10px;
  padding:1px 5px;border-radius:3px;
  font-family:ui-monospace,Consolas,monospace;
  margin-right:4px;
  letter-spacing:0.04em;
}
.h-tag{
  display:inline-block;
  font-size:10px;color:var(--teal);
  border:1px solid var(--teal);border-radius:3px;
  padding:0 4px;margin-left:6px;letter-spacing:0.04em;
}
.h-tag-you{color:var(--amber);border-color:var(--amber);}
