: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;
}

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

.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-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;
}

.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);
}

.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;
}

/* 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;
}

/* 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;
}

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