:root {
  --bg: #14182a;
  --panel: #1f253d;
  --text: #e6ecff;
  --muted: #8892b0;
  --accent: #4ade80;
  --danger: #f87171;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  min-height: 100vh;
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}

.hidden {
  display: none !important;
}

h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: 0.02em;
}

.subtitle {
  color: var(--muted);
  margin: 4px 0 24px;
}

#lobby-screen {
  background: var(--panel);
  padding: 24px;
  border-radius: 12px;
}

#join-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 320px;
}

#join-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
}

#join-form input {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #2e3656;
  background: #10152a;
  color: var(--text);
  font-size: 1rem;
}

button {
  padding: 10px 16px;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: #0f172a;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.1);
}

#lobby-waiting ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#lobby-waiting li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

#error-banner {
  margin-top: 16px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--danger);
  color: #1a0505;
}

#game-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #0b0f1f;
}

#audio-controls {
  position: fixed;
  top: 8px;
  right: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid #1f253d;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.75rem;
}

#audio-mute-btn {
  background: #1f2937;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.75rem;
  cursor: pointer;
}

#audio-mute-btn[aria-pressed="true"] {
  background: #3a1212;
  border-color: #7f1d1d;
}

#audio-volume-slider {
  width: 90px;
}

#hud {
  flex: 0 0 auto;
  display: flex;
  gap: 12px;
  padding: 8px 12px;
  background: var(--panel);
}

#ghost-banner {
  flex: 0 0 auto;
  padding: 8px 16px;
  background: #1f253d;
  border-left: 4px solid #facc15;
  color: #cbd5e1;
  font-style: italic;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.hud-pill {
  padding: 6px 10px;
  background: #10152a;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}

#game-canvas {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  background: #0b0f1f;
  image-rendering: pixelated;
}

.hud-pill {
  padding: 6px 10px;
  background: #10152a;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 90px;
}

.hud-label {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hud-value {
  font-weight: 600;
}

.hud-pill-release .hud-value {
  color: #4ade80;
} /* green */
.hud-pill-pipeline .hud-value {
  color: #60a5fa;
} /* blue */
.hud-pill-coffee .hud-value {
  color: #fb923c;
} /* orange */
.hud-pill-incidents .hud-value {
  color: #f87171;
} /* chaos-red */
.hud-pill-timer .hud-value {
  color: #facc15;
} /* yellow */
.hud-pill-role {
  font-weight: 600;
}

#game-stage {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  overflow: hidden;
}

#task-sidebar {
  flex: 0 0 220px;
  background: var(--panel);
  padding: 12px;
  font-size: 0.85rem;
  overflow-y: auto;
}

#task-sidebar h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#task-sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-row {
  background: #10152a;
  padding: 8px 10px;
  border-radius: 6px;
  border-left: 3px solid #475569;
}

.task-row-available {
  border-left-color: #4ade80;
}
.task-row-in_progress {
  border-left-color: #60a5fa;
}
.task-row-cooldown {
  border-left-color: #475569;
  opacity: 0.6;
}

#event-feed {
  flex: 0 0 240px;
  background: var(--panel);
  padding: 12px;
  font-size: 0.85rem;
  overflow-y: auto;
}

#event-feed h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#event-feed ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.event-row {
  background: #10152a;
  padding: 8px 10px;
  border-radius: 6px;
  border-left: 3px solid #475569;
  word-break: break-word;
}

.event-row-info {
  border-left-color: #60a5fa;
}
.event-row-warn {
  border-left-color: #fbbf24;
}
.event-row-danger {
  border-left-color: #f87171;
}

.event-empty {
  color: var(--muted);
  font-style: italic;
  background: transparent;
  border-left: 3px solid transparent;
  padding: 8px 10px;
}

.task-title {
  font-weight: 600;
}

.task-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

#sabotage-panel {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--panel);
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid #4a1e1e;
  min-width: 220px;
}

#sabotage-panel h3 {
  margin: 0 0 8px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #f87171;
}

.sabotage-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sabotage-btn {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #4a1e1e;
  color: var(--text);
  border: 1px solid #7a2e2e;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}

.sabotage-btn:disabled {
  cursor: not-allowed;
  background: #2a1414;
  color: var(--muted);
}

.sabotage-btn:hover:not(:disabled) {
  background: #6a2828;
}

.sabotage-btn.sabotage-active {
  border-color: #facc15;
  box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.4);
}

/* Tier 2.7 rework: per-sabotage object proximity hint. When chaos is not at
   the matching themed object, the button grays out and a small hint line
   appears under the label telling them WHERE to go. */
.sabotage-btn.sabotage-out-of-range {
  opacity: 0.55;
}

.sabotage-hint {
  display: block;
  font-size: 0.66rem;
  font-weight: 500;
  color: #fbbf24;
  margin-top: 2px;
  line-height: 1.15;
  text-transform: none;
  letter-spacing: 0;
  white-space: normal;
}

.sabotage-btn:not(.sabotage-out-of-range) .sabotage-hint {
  display: none;
}

.sabotage-cooldown-fill {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 0%;
  background: rgba(15, 23, 42, 0.55);
  pointer-events: none;
  transition: height 80ms linear;
}

.sabotage-label,
.sabotage-cooldown {
  position: relative; /* sit above the fill */
  z-index: 1;
}

.sabotage-cooldown {
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--muted);
}

#endscreen {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 31, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#endscreen-card {
  background: var(--panel);
  border-radius: 12px;
  padding: 32px 36px;
  width: 480px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

#endscreen-banner {
  margin: 0;
  font-size: 1.8rem;
}

#endscreen-banner[data-team="release_team"] {
  color: #4ade80;
}
#endscreen-banner[data-team="chaos_agents"] {
  color: #f87171;
}

#endscreen-reason {
  color: var(--muted);
  margin: 4px 0 24px;
}

#endscreen-card h3 {
  margin: 16px 0 8px;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

#endscreen-players {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.endscreen-row {
  display: grid;
  grid-template-columns: 1.2fr 1.4fr 1.4fr;
  gap: 8px;
  padding: 8px 12px;
  background: #10152a;
  border-radius: 6px;
  border-left: 3px solid #475569;
  align-items: center;
}

.endscreen-row-release_team {
  border-left-color: #60a5fa;
}
.endscreen-row-chaos_agents {
  border-left-color: #f87171;
}

.endscreen-name {
  font-weight: 600;
}
.endscreen-role {
  color: var(--muted);
  font-size: 0.85rem;
}
.endscreen-stats {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: right;
}

#endscreen-reset {
  margin-top: 24px;
  width: 100%;
}

#lobby-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 16px;
}

#lobby-logo {
  max-width: 320px;
  max-height: 160px;
  width: 100%;
  height: auto;
  object-fit: contain;
  margin-bottom: 4px;
}

#lobby-header .subtitle {
  margin-top: 0;
}

#demo-mode-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--muted);
  margin: 8px 0;
}

#demo-mode-row input {
  width: auto;
  margin: 0;
}

#map-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 0.9rem;
  color: var(--muted);
}

#map-selector label {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
}

#map-dropdown {
  flex: 1;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #2e3656;
  background: #10152a;
  color: var(--text);
  font-size: 0.9rem;
}

/* Sabotage icon inside the button */
.sabotage-btn-icon {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
}

.sabotage-icon {
  position: relative;
  z-index: 1;
  width: 36px;
  height: 36px;
  display: inline-block;
  border-radius: 4px;
}

/* Role badge in HUD + endscreen */
.role-badge {
  display: inline-block;
  width: 24px;
  height: 24px;
  vertical-align: middle;
  margin-right: 6px;
  border-radius: 4px;
  background-repeat: no-repeat;
}

.role-badge-lg {
  width: 40px;
  height: 40px;
  margin-right: 10px;
}

/* Endscreen rows show role badge before the role-team text */
.endscreen-row {
  grid-template-columns: auto 1.2fr 1.4fr 1.4fr;
}

/* Override #hud-role-pill to fit a tiny badge inline */
#hud-role.with-badge {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Emergency Meeting button — small floating button center-top while in War Room */
#emergency-meeting-btn {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #f87171;
  color: #1a0505;
  border: 2px solid #fee2e2;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 12px 24px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(248, 113, 113, 0.4);
  z-index: 90;
}

#emergency-meeting-btn:hover {
  background: #fca5a5;
}

/* Take-Down button — chaos-only, sits next to the emergency meeting button. */
#takedown-btn {
  position: fixed;
  top: 80px;
  right: 24px;
  background: #b91c1c;
  color: #fee2e2;
  border: 2px solid #fca5a5;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 12px 24px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(185, 28, 28, 0.5);
  z-index: 90;
}

#takedown-btn:hover:not(:disabled) {
  background: #dc2626;
}

#takedown-btn:disabled {
  cursor: not-allowed;
  background: #475569;
  color: #cbd5e1;
  border-color: #475569;
  box-shadow: none;
  opacity: 0.7;
}

/* Body-report button — anyone alive can report when in range. */
#report-btn {
  position: fixed;
  top: 140px;
  right: 24px;
  background: #facc15;
  color: #1a1505;
  border: 2px solid #fde68a;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 12px 24px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(250, 204, 21, 0.4);
  z-index: 90;
}

#report-btn:hover:not(:disabled) {
  background: #fde047;
}

#report-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Meeting overlay */
#meeting-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 31, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 95;
}

#meeting-card {
  background: var(--panel);
  border-radius: 12px;
  padding: 28px 32px;
  width: 480px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  border: 2px solid #c084fc;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

#meeting-title {
  margin: 0;
  color: #c084fc;
  font-size: 1.4rem;
}

.meeting-countdown {
  font-size: 2rem;
  font-weight: 700;
  margin: 8px 0 18px;
  color: #facc15;
  font-variant-numeric: tabular-nums;
}

#meeting-card h3 {
  margin: 12px 0 8px;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

#meeting-vote-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meeting-vote-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #10152a;
  padding: 8px 12px;
  border-radius: 6px;
}

.meeting-vote-name {
  flex: 1;
  font-weight: 600;
}

.meeting-vote-btn {
  padding: 6px 14px;
  border-radius: 4px;
  border: none;
  background: #4ade80;
  color: #0f172a;
  font-weight: 600;
  cursor: pointer;
}

.meeting-vote-btn:disabled {
  background: #334155;
  color: var(--muted);
  cursor: not-allowed;
}

#meeting-skip-btn {
  margin-top: 16px;
  width: 100%;
  background: #475569;
  color: var(--text);
}

#meeting-skip-btn:hover:not(:disabled) {
  background: #64748b;
}

#meeting-skip-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.meeting-status {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

/* Voting result toast */
#voting-result-toast {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(11, 15, 31, 0.95);
  border: 2px solid #facc15;
  border-radius: 12px;
  padding: 20px 28px;
  z-index: 96;
  animation: votingToastFadeIn 200ms ease-out;
  pointer-events: none;
}

#voting-result-text {
  margin: 0;
  color: #facc15;
  font-size: 1.2rem;
  text-align: center;
}

#voting-result-text .voting-result-verdict {
  /* Verdict stays the loud yellow headline. */
}

#voting-result-text .voting-result-lastwords {
  /* "Last words" subtitle — dimmer + italic so it reads as a quote. */
  margin-top: 8px;
  color: #d4d4aa;
  font-size: 0.95rem;
  font-style: italic;
  opacity: 0.85;
}

@keyframes votingToastFadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

#in-game-menu {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 31, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 110;
}

#in-game-menu-card {
  background: var(--panel);
  border-radius: 12px;
  padding: 28px 32px;
  width: 480px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  border: 2px solid #60a5fa;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

#in-game-menu-card h2 {
  margin: 0 0 16px;
  color: #60a5fa;
  font-size: 1.4rem;
}

#in-game-menu-card h3 {
  margin: 14px 0 6px;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

#menu-recap p,
#menu-task-list {
  margin: 0;
  padding: 0;
}

#menu-task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-task-row {
  display: flex;
  justify-content: space-between;
  background: #10152a;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.9rem;
}

.menu-task-status {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#menu-audio-slot {
  margin: 16px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#menu-audio-slot #audio-controls {
  position: static;
  display: flex;
  align-items: center;
  gap: 10px;
}

#menu-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

#menu-actions button {
  flex: 1 1 140px;
  min-width: 140px;
}

#menu-leave-btn {
  background: #f87171;
}

#menu-abort-btn {
  background: #fb923c;
}

#menu-hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

#mini-game-modal {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 31, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 105;
}

#mini-game-card {
  background: var(--panel);
  border-radius: 12px;
  padding: 28px 32px;
  width: 540px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  border: 2px solid #4ade80;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

#mini-game-card h2 {
  margin: 0 0 18px;
  color: #4ade80;
  font-size: 1.35rem;
}

#mini-game-body {
  margin: 0 0 18px;
}

#mini-game-cancel-btn {
  background: #f87171;
  display: block;
  margin: 0 auto;
}

.mini-game-progress {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.mini-game-test-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mini-game-test {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #10152a;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.92rem;
  text-align: left;
  color: var(--text);
}

.mini-game-test:hover:not(.fixed) {
  border-color: #facc15;
}

.mini-game-test .order {
  background: #1f2937;
  border-radius: 999px;
  padding: 2px 9px;
  font-weight: 700;
  color: #94a3b8;
}

.mini-game-test.fixed {
  background: #163d2c;
  cursor: default;
  opacity: 0.85;
}

.mini-game-test.fixed .order {
  background: #4ade80;
  color: #0b0f1f;
}

/* --- Tier 3.3 cable_pairing --------------------------------------------- */

.mini-game-cable-board {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 24px;
  align-items: stretch;
  min-height: 240px;
}

.mini-game-cable-col {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 12px;
}

.mini-game-cable-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.mini-game-cable-node {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  border: 3px solid rgba(11, 15, 31, 0.85);
  cursor: pointer;
  align-self: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  position: relative;
  z-index: 2;
  transition: transform 80ms ease-out;
}

.mini-game-cable-col-src .mini-game-cable-node {
  align-self: flex-start;
}
.mini-game-cable-col-dst .mini-game-cable-node {
  align-self: flex-end;
}

.mini-game-cable-node.selected {
  outline: 3px solid #facc15;
  transform: scale(1.08);
}

.mini-game-cable-node.connected {
  cursor: default;
  opacity: 0.65;
}

/* --- Tier 3.4 coffee_pour ----------------------------------------------- */

.mini-game-coffee-stage {
  display: flex;
  justify-content: center;
  margin: 12px 0 18px;
}

.mini-game-coffee-cup {
  position: relative;
  width: 110px;
  height: 220px;
  background: rgba(11, 15, 31, 0.55);
  border: 3px solid #94a3b8;
  border-top: none;
  border-radius: 0 0 14px 14px;
  overflow: hidden;
}

.mini-game-coffee-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: linear-gradient(180deg, #b45309 0%, #6b3a0a 100%);
  transition: background 80ms linear;
}

.mini-game-coffee-fill.in-sweet {
  background: linear-gradient(180deg, #4ade80 0%, #166534 100%);
}

.mini-game-coffee-sweet {
  position: absolute;
  left: 0;
  right: 0;
  background: rgba(74, 222, 128, 0.18);
  border-top: 1px dashed rgba(74, 222, 128, 0.65);
  border-bottom: 1px dashed rgba(74, 222, 128, 0.65);
  pointer-events: none;
}

.mini-game-coffee-stop-btn {
  display: block;
  margin: 0 auto;
  padding: 14px 28px;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: #f87171;
  color: #0b0f1f;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
}

.mini-game-progress.status-success {
  color: #4ade80;
  font-weight: 700;
}

/* --- Tier 3.5 log_filter ------------------------------------------------- */

.mini-game-log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 360px;
  overflow-y: auto;
}

.mini-game-log-line {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  background: #10152a;
  border-left: 4px solid #475569;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.85rem;
  color: var(--text);
}

.mini-game-log-tag {
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 3px;
  background: #1f2937;
  color: #94a3b8;
  flex: 0 0 auto;
}

.mini-game-log-error {
  border-left-color: #f87171;
}
.mini-game-log-error .mini-game-log-tag {
  background: #7f1d1d;
  color: #fecaca;
}
.mini-game-log-warn {
  border-left-color: #fbbf24;
}
.mini-game-log-warn .mini-game-log-tag {
  background: #78350f;
  color: #fde68a;
}
.mini-game-log-info {
  border-left-color: #60a5fa;
}
.mini-game-log-info .mini-game-log-tag {
  background: #1e3a8a;
  color: #bfdbfe;
}

.mini-game-log-line.marked {
  background: #163d2c;
  cursor: default;
  opacity: 0.85;
}
.mini-game-log-line.marked .mini-game-log-tag {
  background: #166534;
  color: #bbf7d0;
}

.mini-game-log-msg {
  flex: 1 1 auto;
  word-break: break-word;
}

/* --- Tier 3.7 diff_review ---------------------------------------------- */

.mini-game-diff-list {
  list-style: decimal inside;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 360px;
  overflow-y: auto;
  counter-reset: diffline;
}

.mini-game-diff-line {
  padding: 8px 12px;
  border-radius: 6px;
  background: #10152a;
  border-left: 4px solid #475569;
  cursor: pointer;
  color: var(--text);
}

.mini-game-diff-line .mini-game-diff-code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.85rem;
  color: #cbd5e1;
}

.mini-game-diff-line.marked {
  background: #163d2c;
  border-left-color: #34d399;
  cursor: default;
  opacity: 0.9;
}

.mini-game-diff-line.marked .mini-game-diff-code {
  color: #bbf7d0;
}

/* --- Tier 3.7 stability_balance ---------------------------------------- */

.mini-game-stability-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
}

.mini-game-stability-row {
  display: grid;
  grid-template-columns: 36px 100px 1fr 36px;
  align-items: center;
  gap: 12px;
}

.mini-game-stability-btn {
  height: 32px;
  border-radius: 6px;
  border: 1px solid #475569;
  background: #1f2937;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  font-size: 1.1rem;
}

.mini-game-stability-btn:hover {
  background: #334155;
}

.mini-game-stability-labelwrap {
  display: flex;
  flex-direction: column;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.85rem;
}

.mini-game-stability-label {
  color: #94a3b8;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  text-transform: uppercase;
}

.mini-game-stability-value {
  color: var(--text);
  font-weight: 700;
}

.mini-game-stability-bar {
  position: relative;
  height: 22px;
  border-radius: 6px;
  background: #10152a;
  border: 1px solid #1f2937;
  overflow: hidden;
}

.mini-game-stability-green {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(52, 211, 153, 0.18);
  border-left: 1px dashed rgba(52, 211, 153, 0.5);
  border-right: 1px dashed rgba(52, 211, 153, 0.5);
  pointer-events: none;
}

.mini-game-stability-fill {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  border-radius: 4px;
  background: #f87171;
  transition:
    width 0.15s linear,
    background 0.15s linear;
}

.mini-game-stability-fill.in-green {
  background: #34d399;
}

/* --- Tier 3.7 release_notes -------------------------------------------- */

.mini-game-release-list {
  list-style: decimal inside;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}

.mini-game-release-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  background: #10152a;
  border-left: 4px solid #475569;
  cursor: pointer;
}

.mini-game-release-row:hover {
  background: #161c33;
}

.mini-game-release-msg {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.82rem;
  color: #cbd5e1;
  flex: 1 1 auto;
  word-break: break-word;
}

.mini-game-release-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 4px;
  text-transform: uppercase;
  flex: 0 0 auto;
}

.mini-game-release-badge.cat-unassigned {
  background: #1f2937;
  color: #94a3b8;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.mini-game-release-badge.cat-feature {
  background: #14532d;
  color: #bbf7d0;
}
.mini-game-release-badge.cat-bugfix {
  background: #1e3a8a;
  color: #bfdbfe;
}
.mini-game-release-badge.cat-breaking {
  background: #7f1d1d;
  color: #fecaca;
}
.mini-game-release-badge.cat-noprod {
  background: #4a044e;
  color: #f5d0fe;
}

.mini-game-release-submit {
  margin-top: 14px;
  padding: 10px 16px;
  border-radius: 6px;
  border: none;
  background: #475569;
  color: #cbd5e1;
  font-weight: 600;
  cursor: not-allowed;
}

.mini-game-release-submit.ready {
  background: var(--accent);
  color: #0f172a;
  cursor: pointer;
}

/* --- Tier 3.6 sprint_trim ----------------------------------------------- */

.mini-game-sprint-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mini-game-sprint-ticket {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #10152a;
  border: 2px solid #1f2937;
  cursor: pointer;
  color: var(--text);
}

.mini-game-sprint-points {
  font-weight: 700;
  background: #1f2937;
  border-radius: 999px;
  padding: 2px 10px;
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.mini-game-sprint-title {
  flex: 1 1 auto;
}

.mini-game-sprint-tag {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 3px;
  background: #1f2937;
  color: #94a3b8;
}

.mini-game-sprint-ticket.priority {
  border-color: #7f1d1d;
}
.mini-game-sprint-ticket.priority .mini-game-sprint-tag {
  background: #7f1d1d;
  color: #fecaca;
}

.mini-game-sprint-ticket.removed {
  opacity: 0.5;
  background: #1f2937;
  text-decoration: line-through;
}
.mini-game-sprint-ticket.removed .mini-game-sprint-tag {
  background: #475569;
  color: #cbd5e1;
}

#touch-controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
}

#touch-joystick {
  position: absolute;
  left: 24px;
  bottom: 24px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(11, 15, 31, 0.6);
  border: 2px solid rgba(96, 165, 250, 0.55);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

#touch-joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 60px;
  height: 60px;
  margin: -30px 0 0 -30px;
  border-radius: 50%;
  background: rgba(96, 165, 250, 0.85);
  border: 2px solid #0b0f1f;
  pointer-events: none;
  transition: transform 60ms ease-out;
}

#touch-action-buttons {
  position: absolute;
  right: 24px;
  bottom: 24px;
  display: grid;
  grid-template-columns: 64px 64px;
  grid-gap: 12px;
  pointer-events: auto;
}

#touch-action-buttons button {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(96, 165, 250, 0.55);
  background: rgba(11, 15, 31, 0.7);
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
  touch-action: manipulation;
}

#touch-btn-task {
  background: rgba(74, 222, 128, 0.85);
  color: #0b0f1f;
}

#touch-btn-repair {
  background: rgba(248, 113, 113, 0.85);
  color: #0b0f1f;
}

#touch-btn-vent {
  background: rgba(192, 132, 252, 0.8);
  color: #0b0f1f;
}

#touch-btn-menu {
  font-size: 1.4rem;
}

/* --- Mobile drawer + compact HUD ----------------------------------------- */

/* Edge-tabs are hidden on desktop and only appear when touch-active. */
.mobile-edge-tab {
  display: none;
}

@media (pointer: coarse) {
  #touch-controls:not(.hidden) {
    display: block;
  }
  /* Hide the floating audio-controls bar on touch — they live in the menu now. */
  body.touch-active #audio-controls {
    display: none;
  }

  /* Compact HUD: pills wrap into rows, smaller font, fits a 360px portrait. */
  body.touch-active #hud {
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 6px;
    justify-content: center;
  }
  body.touch-active .hud-pill {
    min-width: 0;
    padding: 3px 6px;
    gap: 4px;
    border-radius: 4px;
    font-size: 0.78rem;
    flex: 1 1 auto;
  }
  body.touch-active .hud-label {
    font-size: 0.6rem;
    letter-spacing: 0.03em;
  }
  body.touch-active .hud-value {
    font-size: 0.78rem;
  }
  body.touch-active #hud-role {
    flex: 1 0 100%;
    justify-content: center;
    text-align: center;
    font-size: 0.72rem;
  }

  /* Tasks-Sidebar becomes a left off-canvas drawer. */
  body.touch-active #task-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(82vw, 320px);
    z-index: 95;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.45);
    transform: translateX(-100%);
    transition: transform 220ms ease-out;
  }
  body.drawer-tasks-open #task-sidebar {
    transform: translateX(0);
  }

  /* Sabotage-Panel becomes a right off-canvas drawer (was already fixed bottom-right). */
  body.touch-active #sabotage-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: min(82vw, 320px);
    min-width: 0;
    border-radius: 0;
    border: none;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.45);
    overflow-y: auto;
    z-index: 95;
    padding: 14px 12px;
    transform: translateX(100%);
    transition: transform 220ms ease-out;
  }
  body.drawer-sabo-open #sabotage-panel:not(.hidden) {
    transform: translateX(0);
  }

  /* Event-feed eats too much portrait width and is non-essential — hide on touch. */
  body.touch-active #event-feed {
    display: none;
  }

  /* Edge-tabs: vertical labels glued to the screen edge. */
  body.touch-active .mobile-edge-tab {
    display: block;
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(11, 15, 31, 0.85);
    color: var(--text);
    border: 1px solid rgba(96, 165, 250, 0.55);
    padding: 14px 6px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    pointer-events: auto;
    touch-action: manipulation;
    z-index: 96;
    user-select: none;
  }
  body.touch-active .mobile-edge-tab-left {
    left: 0;
    border-left: none;
    border-radius: 0 8px 8px 0;
  }
  body.touch-active .mobile-edge-tab-right {
    right: 0;
    border-right: none;
    border-radius: 8px 0 0 8px;
  }
  body.touch-active #mobile-tab-sabo {
    border-color: rgba(248, 113, 113, 0.6);
    color: #fca5a5;
  }

  /* When a drawer is open, the joystick + action buttons would overlap the
     drawer content — hide them so the user can read/tap freely. */
  body.drawer-tasks-open #touch-joystick,
  body.drawer-tasks-open #touch-action-buttons,
  body.drawer-sabo-open #touch-joystick,
  body.drawer-sabo-open #touch-action-buttons {
    display: none;
  }
}

/* Tier 3.5: Lobby role picker -------------------------------------------- */

.lobby-role-picker {
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.55);
  border-radius: 8px;
  border: 1px solid rgba(99, 102, 241, 0.35);
}

.lobby-role-picker label {
  font-size: 0.85rem;
  color: #cbd5e1;
}

.lobby-role-picker select {
  padding: 6px 8px;
  border-radius: 4px;
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #475569;
  font-size: 0.95rem;
}

.lobby-role-hint {
  font-size: 0.72rem;
  color: #94a3b8;
  margin: 2px 0 0;
  font-style: italic;
}

/* Tier 3.9.2: AI-NPC lobby controls -------------------------------------- */

#bot-controls {
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: rgba(30, 41, 59, 0.55);
  border-radius: 8px;
  border: 1px dashed rgba(148, 163, 184, 0.4);
}

#btn-add-bot {
  align-self: flex-start;
  padding: 6px 12px;
  background: #334155;
  color: #f1f5f9;
  border: 1px solid #64748b;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}

#btn-add-bot:hover {
  background: #475569;
}

.lobby-bot-hint {
  font-size: 0.72rem;
  color: #94a3b8;
  margin: 0;
  font-style: italic;
}

.lobby-bot-row {
  opacity: 0.85;
  font-style: italic;
}

.lobby-bot-kick {
  margin-left: 8px;
  padding: 2px 8px;
  background: transparent;
  color: #f87171;
  border: 1px solid #f87171;
  border-radius: 3px;
  font-size: 0.75rem;
  cursor: pointer;
}

.lobby-bot-kick:hover {
  background: rgba(248, 113, 113, 0.18);
}

/* Tier 3.5: Personal coffee meter (HUD) ---------------------------------- */

.hud-pill-my-coffee {
  background: linear-gradient(135deg, #c2410c, #ea580c);
  border: 1px solid #fdba74;
  color: #fed7aa;
  position: relative;
  overflow: hidden;
}

.hud-pill-my-coffee.coffee-low {
  background: linear-gradient(135deg, #7f1d1d, #991b1b);
  border-color: #ef4444;
  color: #fecaca;
  animation: my-coffee-pulse 1.6s ease-in-out infinite;
}

@keyframes my-coffee-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.6);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(248, 113, 113, 0);
  }
}

/* Tier 3.5: Ability button (Coffee Run / Rollback / Standup) ------------- */

#ability-btn {
  position: fixed;
  bottom: 24px;
  right: 280px;
  z-index: 50;
  background: linear-gradient(135deg, #6d28d9, #7c3aed);
  color: #ede9fe;
  border: 1px solid #a78bfa;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.35);
}

#ability-btn:hover {
  filter: brightness(1.1);
}
#ability-btn:disabled {
  background: linear-gradient(135deg, #4b5563, #6b7280);
  border-color: #9ca3af;
  cursor: not-allowed;
  opacity: 0.65;
}

/* Tier 3.5: Role-Intro modal --------------------------------------------- */

#role-intro {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(6px);
}

#role-intro.hidden {
  display: none;
}

#role-intro-card {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 24px 28px;
  max-width: 460px;
  width: 92%;
  box-shadow: 0 8px 36px rgba(0, 0, 0, 0.6);
}

#role-intro-team-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

#role-intro.team-release #role-intro-team-badge {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border: 1px solid #22c55e;
}

#role-intro.team-chaos #role-intro-team-badge {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid #ef4444;
}

#role-intro-title {
  margin: 0 0 4px;
  font-size: 1.6rem;
  color: #ffffff;
}

#role-intro-blurb {
  margin: 0 0 10px;
  color: #cbd5e1;
  font-size: 0.95rem;
  font-style: italic;
}

#role-intro-description {
  margin: 0 0 14px;
  font-size: 0.9rem;
  color: #94a3b8;
  line-height: 1.45;
}

#role-intro h3 {
  margin: 14px 0 6px;
  font-size: 0.85rem;
  color: #93c5fd;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#role-intro ul {
  margin: 0;
  padding-left: 18px;
  font-size: 0.92rem;
  color: #e2e8f0;
}

#role-intro-ability-line {
  margin: 0;
  font-size: 0.92rem;
  color: #c4b5fd;
}

#role-intro-close {
  margin-top: 18px;
  width: 100%;
  padding: 10px 0;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}

#role-intro-close:hover {
  filter: brightness(1.1);
}

/* Tier 3.5: Personal task panel — highlight assigned tasks --------------- */

#task-sidebar .task-row.task-personal {
  border-left: 3px solid #fbbf24;
  background: rgba(251, 191, 36, 0.08);
}

#task-sidebar .task-row.task-personal::before {
  content: "★";
  color: #fbbf24;
  margin-right: 4px;
}

#task-sidebar .task-row.task-strength {
  border-left-color: #22c55e;
}

#task-sidebar .task-row.task-strength::before {
  content: "⚡";
  color: #4ade80;
  margin-right: 4px;
}

/* Tier 3.6: Meeting context block ---------------------------------------- */

#meeting-context {
  margin: 8px 0 12px;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.6);
  border-left: 3px solid #fbbf24;
  border-radius: 4px;
  text-align: left;
  font-size: 0.9rem;
}

#meeting-context p {
  margin: 4px 0;
  color: #cbd5e1;
}

#meeting-context-events {
  margin-top: 6px;
}

#meeting-context-events summary {
  cursor: pointer;
  color: #93c5fd;
  font-weight: 600;
  font-size: 0.85rem;
}

#meeting-context-events ul {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 0.82rem;
  color: #94a3b8;
}

/* Tier 3.7: Endscreen awards + postmortem -------------------------------- */

#endscreen-awards-block {
  text-align: left;
  margin: 14px 0;
}

#endscreen-awards li {
  margin: 4px 0;
  font-size: 0.92rem;
}

#endscreen-postmortem-block {
  text-align: left;
  margin: 14px 0;
}

#endscreen-postmortem {
  white-space: pre-wrap;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 12px 14px;
  color: #cbd5e1;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  max-height: 240px;
  overflow-y: auto;
}
