:root {
  --bg: #0b0d12;
  --panel: #161922;
  --text: #e6e6e6;
  --muted: #9aa0a6;
  --accent: #ff4d4f;
  --good: #3ecf5f;
  --mixed: #f5c26b;
  --bad: #ff4d4f;
  --twist: #a78bfa;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', monospace;
  margin: 0;
  padding: 2rem 3rem;
  min-height: 100vh;
}

/* !important is deliberate -- #gate and #control-bar each set their own
   `display` via an ID selector, which otherwise beats a plain .hidden class
   on specificity alone and silently fails to hide (this is exactly what
   broke the host password gate: the class toggled correctly, the ID rule
   just won anyway). This class must always win regardless of what else
   targets the same element. */
.hidden { display: none !important; }

.banner { width: 100%; max-width: 640px; margin: 0 auto 1rem; }
.banner img { width: 100%; height: auto; display: block; border-radius: 10px; box-shadow: 0 0 0 1px #2a1418; }

h1 { color: var(--accent); letter-spacing: 0.05em; font-size: 3rem; text-align: center; }
h2 { font-size: 2rem; text-align: center; }
.muted { color: var(--muted); text-align: center; }

.timer { font-size: 5rem; text-align: center; color: var(--accent); font-weight: bold; margin: 1rem 0; }
.timer.clickable { cursor: pointer; user-select: none; }
.timer.clickable:hover { opacity: 0.85; }
.timer.paused { color: var(--mixed); }
.timer.paused::after { content: "⏸ PAUSED"; display: block; font-size: 1.1rem; letter-spacing: 0.1em; margin-top: 0.3rem; }

#lobby-teams { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; }
#lobby-teams li {
  background: var(--panel); padding: 1rem 1.25rem 1rem 2rem; border-radius: 8px; font-size: 1.5rem;
  display: flex; align-items: center; gap: 0.75rem;
}
.remove-team-btn {
  --badge-bg: var(--muted);
  padding: 0; width: 2rem; height: 2rem; min-width: 2rem;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; color: var(--muted); cursor: pointer; border-radius: 50%;
}
.remove-team-btn:hover { color: var(--text); }
.remove-team-btn:hover, .remove-team-btn:focus-visible { --badge-bg: var(--bad); }
.remove-team-btn.armed {
  --badge-bg: var(--bad); width: auto; padding: 0 0.75rem; border-radius: 6px;
  background: var(--bad); color: #fff; font-size: 0.95rem; white-space: nowrap;
}

.checkbox-label {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  color: var(--muted); font-size: 0.9rem; margin-top: 1.5rem; cursor: pointer;
}
.checkbox-label input { width: 1.1rem; height: 1.1rem; cursor: pointer; }

#start-button {
  display: block; margin: 1rem auto 0; padding: 1.2rem 3rem; font-size: 1.5rem;
  background: var(--panel); color: var(--text); border: 2px solid var(--accent); border-radius: 8px;
  cursor: pointer;
}
#start-button:disabled { opacity: 0.3; cursor: not-allowed; }
#start-button:hover:not(:disabled) { background: var(--accent); color: var(--bg); }

.team-grid, .result-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem; margin-top: 1.5rem;
}

.team-card {
  background: var(--panel); border-radius: 8px; padding: 1.2rem; text-align: center;
  border: 2px solid #333; font-size: 1.4rem;
}
.team-card.locked { border-color: var(--good); }
.team-card .check { display: block; font-size: 2rem; margin-top: 0.4rem; color: var(--muted); }
.team-card.locked .check { color: var(--good); }

.decision-scene { max-width: 640px; margin: 2rem auto 0; }
.decision-scene img {
  width: 100%; height: auto; display: block; border-radius: 10px;
  box-shadow: 0 0 0 1px #2a1418; opacity: 0.9;
}

.scenario-photo { max-width: 420px; margin: 2rem auto 0; }
.scenario-photo img {
  width: 100%; height: auto; display: block; border-radius: 10px;
  box-shadow: 0 0 0 1px #2a1418;
}

.dossier { background: var(--panel); border-left: 6px solid var(--accent); padding: 1.2rem; margin: 1.5rem 0; }
.dossier-round { text-align: center; color: var(--muted); letter-spacing: 0.15em; font-size: 1.2rem; }
/* See play.css's .practice-label -- same swap-in for the round heading
   during the optional practice round. */
.practice-label { color: var(--muted); font-weight: bold; letter-spacing: 0.05em; }
.dossier-hint { font-style: italic; font-size: 1.4rem; }

#scenario-narrative { font-size: 1.3rem; max-width: 900px; margin: 1rem auto; text-align: center; }
.demand { font-size: 2.5rem; color: var(--accent); text-align: center; font-weight: bold; margin: 1.5rem 0; }

.result-card {
  background: var(--panel); border-radius: 8px; padding: 1.2rem; border: 3px solid #333;
  display: flex; flex-direction: column; gap: 0.3rem;
}
.result-card.good { border-color: var(--good); }
.result-card.mixed { border-color: var(--mixed); }
.result-card.bad { border-color: var(--bad); }
.result-card .team-name { font-size: 1.3rem; font-weight: bold; }
.result-card .choice { color: var(--muted); letter-spacing: 0.05em; }
.result-card .detail { font-size: 0.95rem; }
.result-card .cost { font-size: 1.5rem; color: var(--bad); align-self: flex-end; }

/* Misattribution reveal -- a distinct "twist" color (not the good/mixed/bad
   severity palette, since this isn't any one team's outcome) so it reads as
   its own kind of information: the round's threat actor turned out to be
   someone else. Shared markup/classes with play.css's team-facing version. */
.misattribution-reveal {
  background: var(--panel); border: 2px solid var(--twist); border-radius: 8px;
  padding: 1.1rem 1.4rem; margin-bottom: 1.5rem; max-width: 900px; margin-left: auto; margin-right: auto;
}
.misattribution-title { color: var(--twist); font-weight: bold; letter-spacing: 0.05em; margin-bottom: 0.5rem; }
.misattribution-summary { font-size: 1.05rem; }

.bar-row { display: flex; align-items: center; gap: 1rem; margin: 0.9rem 0; }
.bar-rank { width: 2rem; font-size: 1.3rem; color: var(--muted); text-align: right; }
.bar-name { width: 12rem; font-size: 1.3rem; }
.bar-track { flex: 1; background: var(--panel); border-radius: 6px; height: 2rem; overflow: hidden; }
.bar-fill { height: 100%; background: var(--good); transition: width 0.6s ease; }
.bar-fill.negative { background: var(--bad); width: 2px !important; }
.bar-value { width: 6rem; font-size: 1.3rem; text-align: right; }
.bar-row.winner { background: rgba(245, 194, 107, 0.1); border-radius: 8px; }
.bar-row.winner .bar-name { color: var(--mixed); font-weight: bold; }
.bar-row.winner .bar-name::after { content: " \1F3C6"; }
.bar-row.winner .bar-fill { background: var(--mixed); }

/* ---- Debrief (post-game host screen) ---- */

.debrief-view { max-width: 1200px; margin: 0 auto; }

/* Bare circle used in the After Action "Reveal Configurations" table cells
   -- same visual language as play.js's setup-screen circles (fill/color by
   token cost), just the circle alone since the table's row/column headers
   already say category and team. */
.config-circle { width: 2rem; height: 2rem; border-radius: 50%; border: 2px solid #2a2a2a; margin: 0 auto; }

.debrief-chart-svg { width: 100%; height: auto; margin-top: 1rem; }
.debrief-legend { display: flex; flex-wrap: wrap; gap: 1.25rem; justify-content: center; margin-top: 1rem; }
.debrief-legend-item { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 1rem; color: var(--text); }
.debrief-legend-dot { width: 0.85rem; height: 0.85rem; border-radius: 50%; display: inline-block; }

/* ---- After Action (replaces the old Config Reveal / Cost Curves /
   Talking Points tabs with one Prev/Next-driven sequence) ---- */

.aa-nav {
  display: flex; align-items: center; justify-content: center; gap: 1.5rem;
  margin-bottom: 1rem;
}
.aa-page-indicator { color: var(--muted); font-size: 1.1rem; min-width: 4rem; text-align: center; }
.aa-page h2 { margin-bottom: 0.25rem; }

.aa-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.aa-table th, .aa-table td { padding: 0.6rem 0.9rem; text-align: center; border-bottom: 1px solid #2a2a2a; }
.aa-table thead th { color: var(--muted); font-size: 1rem; font-weight: normal; border-bottom: 2px solid #333; }
.aa-table tbody th {
  text-align: left; color: var(--text); font-size: 1rem; font-weight: bold; white-space: nowrap;
}

.rules-table-wrap { max-width: 1100px; margin: 1rem auto 0; overflow-x: auto; }
.rules-table { max-width: 1100px; margin: 0; }
.rules-table td { white-space: nowrap; }
.aa-configs-table tbody th { font-size: 0.95rem; }
.aa-summary-table td { font-size: 0.95rem; color: var(--text); }

.aa-closing-question {
  max-width: 900px; margin: 2.5rem auto 0; font-size: 2rem; line-height: 1.5;
  text-align: center; color: var(--text);
}

#control-bar {
  position: fixed; top: 1rem; right: 1rem; display: flex; gap: 0.6rem; z-index: 10;
}
#control-error { color: var(--bad); font-size: 0.9rem; align-self: center; }
#control-bar button {
  padding: 0.6rem 1rem; font-size: 1rem;
  background: var(--panel); color: var(--muted); border: 1px solid #333; border-radius: 6px;
  cursor: pointer;
}
#control-bar button:hover { color: var(--text); border-color: var(--accent); }

/* Bottom-right, deliberately away from #control-bar (top-right) and the
   Rules/Threats/Settings .nav-bar (top-left) -- always visible regardless
   of phase or which sub-screen is showing, so it never collides with them. */
#reset-game-button {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 10;
  padding: 0.6rem 1rem; font-size: 0.9rem;
  background: var(--panel); color: var(--muted); border: 1px solid #333; border-radius: 6px;
  cursor: pointer;
}
#reset-game-button:hover { color: var(--bad); border-color: var(--bad); }

#gate {
  position: fixed; inset: 0; background: var(--bg); display: flex;
  align-items: center; justify-content: center; z-index: 100;
}
.gate-box {
  background: var(--panel); border: 2px solid var(--accent); border-radius: 10px;
  padding: 2.5rem 3rem; text-align: center; min-width: 320px;
}
.gate-box h1 { font-size: 2rem; margin-top: 0; }
.gate-box label { display: block; color: var(--muted); margin-bottom: 0.5rem; font-size: 1.1rem; }
.gate-box input {
  width: 100%; padding: 0.8rem; font-size: 1.2rem; background: var(--bg);
  border: 1px solid #333; color: var(--text); border-radius: 4px; margin-bottom: 1rem;
  box-sizing: border-box;
}
.gate-box button {
  width: 100%; padding: 0.8rem; font-size: 1.1rem; background: var(--bg);
  color: var(--text); border: 2px solid var(--accent); border-radius: 4px; cursor: pointer;
}
.gate-box button:hover { background: var(--accent); color: var(--bg); }
.error { color: var(--bad); min-height: 1.2em; margin-top: 0.75rem; }

#next-team-button {
  display: block; margin: 2rem auto 0; padding: 1rem 2.5rem; font-size: 1.3rem;
  background: var(--panel); color: var(--text); border: 2px solid var(--accent); border-radius: 8px;
  cursor: pointer;
}
#next-team-button:hover { background: var(--accent); color: var(--bg); }

#new-game-button {
  display: block; margin: 2rem auto 0; padding: 1rem 2.5rem; font-size: 1.3rem;
  background: var(--panel); color: var(--text); border: 2px solid var(--accent); border-radius: 8px;
  cursor: pointer;
}
#new-game-button:hover { background: var(--accent); color: var(--bg); }

/* Pre-game hub (Basic Rules / Meet the Threat Actors / Configure Backup
   Posture) -- host-only, shown after Start Game, before the live Setup
   Phase screen. Pure local navigation on this device; doesn't touch
   server state or affect what team devices are doing. */
.hub-tiles {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem;
  margin-top: 2rem; max-width: 1100px; margin-left: auto; margin-right: auto;
}
.hub-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.6rem;
  text-align: left; padding: 1.5rem; background: var(--panel); color: var(--text);
  border: 2px solid #333; border-radius: 10px; cursor: pointer; font-family: inherit;
}
.hub-tile:hover { border-color: var(--accent); }
.hub-tile strong { font-size: 1.4rem; }
.hub-tile span { color: var(--muted); font-size: 1rem; }
.hub-tile-primary { border-color: var(--accent); background: rgba(255, 77, 79, 0.08); }

/* top-left, not top-right -- #control-bar (Back/Next) lives in the top-right
   corner whenever it's visible too (it's hidden during the lobby phase,
   where these Rules/Threats/Settings screens live, but keeping this pinned
   left avoids a collision if that ever changes). */
.nav-bar { position: fixed; top: 1rem; left: 1rem; display: flex; gap: 0.6rem; z-index: 10; }
.nav-button {
  padding: 0.6rem 1.1rem; font-size: 1rem; font-family: inherit;
  background: var(--panel); color: var(--text); border: 1px solid #333; border-radius: 6px;
  cursor: pointer;
}
.nav-button:hover { border-color: var(--accent); }
.nav-button:disabled { visibility: hidden; }

.rules-choices {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem;
  max-width: 1100px; margin: 1.5rem auto;
}
.rules-choice { background: var(--panel); border-radius: 8px; padding: 1.25rem; }
.rules-choice strong { display: block; font-size: 1.2rem; margin-bottom: 0.5rem; }
.rules-choice span { color: var(--muted); }

/* Presented as a card from a 10-card "Threat" deck -- poker-card
   proportions (5:7), a mirrored rank+suit index in opposite corners like a
   real playing card (readable right-side-up from either end), a skull
   standing in for the suit since every card in this deck is the same
   "suit". Prev/next controls are the .threat-card-nav arrows flanking the
   card (see .threat-card-row below), not a top corner rank/suit anymore. */
.threat-card-row { display: flex; align-items: center; justify-content: center; gap: 1.5rem; }
.threat-card-nav {
  flex-shrink: 0; width: 3rem; height: 3rem; border-radius: 50%;
  background: var(--panel); border: 2px solid var(--accent); color: var(--accent);
  font-size: 1.4rem; display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.threat-card-nav:hover { background: var(--accent); color: var(--bg); }
.threat-card {
  position: relative;
  background: linear-gradient(160deg, #1b1f2a 0%, #12141b 100%);
  border: 2px solid var(--accent);
  border-radius: 26px;
  width: 480px;
  aspect-ratio: 5 / 7;
  padding: 2rem 2.25rem;
  margin: 1.5rem auto 0;
  box-shadow: 0 0 0 1px #2a1418, 0 24px 56px -14px rgba(255, 77, 79, 0.4), 0 6px 18px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  overflow: hidden;
}
.threat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.02) 0 2px, transparent 2px 14px);
  pointer-events: none;
}
.threat-card-art {
  margin-top: 2rem;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, rgba(255, 77, 79, 0.18), transparent 70%);
  border: 3px solid rgba(255, 77, 79, 0.45);
  box-shadow: 0 0 24px -2px rgba(255, 77, 79, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.threat-card-art svg { width: 130px; height: 130px; }
.threat-card-art img { width: 100%; height: 100%; object-fit: cover; }
.threat-card h2 { margin: 1.4rem 0 0; font-size: 2.2rem; }
.threat-card-divider {
  width: 60%;
  height: 1px;
  margin: 1.1rem 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.6;
}
.threat-card p { color: var(--muted); font-size: 1.2rem; font-style: italic; margin: 0; }
.threat-progress { text-align: center; color: var(--muted); margin-top: 1.25rem; letter-spacing: 0.05em; font-size: 1.1rem; }

.bot-icon { margin-right: 0.4em; }

.settings-bots {
  max-width: 700px; margin: 1rem auto; display: flex; flex-direction: column; gap: 0.75rem;
}
.settings-bot-option {
  display: flex; align-items: center; gap: 0.75rem; text-align: left;
  background: var(--panel); border-radius: 8px; padding: 0.85rem 1.1rem; cursor: pointer;
}
.settings-bot-option input { width: 1.2rem; height: 1.2rem; flex-shrink: 0; }
.settings-bot-option .bot-icon { margin-right: 0; font-size: 1.3rem; }
.settings-bot-option strong { display: block; }
.settings-bot-option .settings-hint { display: block; margin-top: 0.15rem; }

.settings-field {
  max-width: 400px; margin: 2rem auto 1rem; display: flex; flex-direction: column;
  gap: 0.5rem; text-align: left;
}
.settings-field label { color: var(--muted); font-size: 1.1rem; }
.settings-hint { font-size: 0.85rem; opacity: 0.8; }
.settings-field input {
  padding: 0.7rem; font-size: 1.2rem; background: var(--bg);
  border: 1px solid #333; color: var(--text); border-radius: 4px; box-sizing: border-box;
}

.settings-attackers {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.25rem; max-width: 1100px; margin: 0 auto;
}
.settings-attacker-card {
  background: var(--panel); border-radius: 8px; padding: 1.2rem; border: 2px solid #333;
  text-align: left;
}
.settings-attacker-card h3 { margin: 0 0 0.8rem; font-size: 1.3rem; }
.settings-attacker-group {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-bottom: 0.6rem;
}
.settings-attacker-group label {
  display: flex; flex-direction: column; gap: 0.3rem; color: var(--muted); font-size: 0.9rem;
}
.settings-attacker-group input {
  width: 4.5rem; padding: 0.4rem; font-size: 1rem; background: var(--bg);
  border: 1px solid #333; color: var(--text); border-radius: 4px;
}
.settings-computed { color: var(--muted); font-size: 0.95rem; margin-left: auto; }
.settings-computed span { color: var(--text); font-weight: bold; }

.settings-outcome-costs {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem; max-width: 1100px; margin: 1.5rem auto 0;
}
.settings-outcome-costs label {
  display: flex; flex-direction: column; gap: 0.4rem; color: var(--muted);
  font-size: 0.95rem; background: var(--panel); border: 2px solid #333;
  border-radius: 8px; padding: 1rem;
}
.settings-outcome-costs input {
  padding: 0.5rem; font-size: 1.1rem; background: var(--bg);
  border: 1px solid #333; color: var(--text); border-radius: 4px;
}
