:root {
  --accent-primary: #38bdf8;
  --accent-positive: #22c55e;
  --accent-negative: #ef4444;
  --accent-barrier: #a855f7;
  --bg-canvas: #111116;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html, body {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-canvas);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, monospace;
  color: #ffffff;
}

#appRoot {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background-color: var(--bg-canvas);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#canvasContainer {
  position: relative;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#canvasContainer:active {
  cursor: grabbing;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Heads Up Display (HUD) - Spans full width with responsive typography */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(12px + env(safe-area-inset-top, 0px)) clamp(14px, 3vw, 36px) 12px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: linear-gradient(180deg, rgba(12, 12, 18, 0.90) 0%, rgba(12, 12, 18, 0) 100%);
  z-index: 10;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.hud-item {
  display: flex;
  flex-direction: column;
}

.hud-label {
  font-size: clamp(10px, 1.1vw, 13px);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.55);
}

.hud-val {
  font-size: clamp(20px, 2.5vw, 32px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

.hud-val.squad {
  color: var(--accent-primary);
}

.hud-val.score {
  color: #ffffff;
}

.hud-val.level {
  color: var(--accent-barrier);
}

.hud-subbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.seed-badge {
  font-size: clamp(10px, 1vw, 12px);
  font-family: monospace;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.07);
  padding: 3px 8px;
  border-radius: 4px;
}

.rival-badge {
  font-size: clamp(10px, 1vw, 12px);
  font-weight: 700;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.35);
  padding: 3px 9px;
  border-radius: 4px;
}

.hud-mini-btn {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  font-size: clamp(10px, 1vw, 12px);
  font-weight: 700;
  padding: 4px 10px;
  cursor: pointer;
}

.hud-mini-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

#hudBuffs {
  font-size: clamp(11px, 1.2vw, 14px);
  font-weight: 800;
  color: #eab308;
  letter-spacing: 0.8px;
  min-height: 16px;
  text-align: center;
}

/* Modal Overlay - Fullscreen backdrop with responsive centered content */
#gameModal {
  position: absolute;
  inset: 0;
  background: rgba(13, 13, 19, 0.88);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: clamp(16px, 3vw, 40px);
  text-align: center;
  z-index: 20;
  transition: opacity 0.22s ease;
}

.hidden {
  display: none !important;
}

#gameModal.hidden {
  display: none !important;
}

.modal-topbar {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: clamp(16px, 3vw, 36px);
  right: clamp(16px, 3vw, 36px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.auth-pill, .lb-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-size: clamp(11px, 1vw, 13px);
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1;
  box-sizing: border-box;
  transition: background 0.15s ease, border-color 0.15s ease;
}

#authPillText {
  display: inline-block;
  line-height: 1;
  vertical-align: middle;
}

.auth-pill:hover, .lb-pill-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.g-icon {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  color: #111116;
  font-weight: 900;
  font-size: 10px;
}

#overlayTitle {
  font-size: clamp(24px, 4vw, 40px);
  font-weight: 900;
  letter-spacing: 1.5px;
  margin-top: 14px;
  margin-bottom: 4px;
  text-transform: uppercase;
  color: var(--accent-primary);
  text-shadow: 0 0 24px rgba(56, 189, 248, 0.4);
}

#overlaySubtitle {
  font-size: clamp(12px, 1.4vw, 15px);
  color: rgba(255, 255, 255, 0.72);
  margin-bottom: 14px;
  line-height: 1.4;
  letter-spacing: 0.5px;
}

/* Constrain interactive modal blocks cleanly on wide screens while canvas stays 100vw */
.config-bar,
.run-stats-box,
.modal-rules,
.modal-actions {
  width: 100%;
  max-width: 520px;
  box-sizing: border-box;
}

.config-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 14px;
  box-sizing: border-box;
  width: 100%;
  max-width: 520px;
}

.config-group {
  display: flex;
  flex-direction: column;
  text-align: left;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 12px;
  border-radius: 8px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.config-group:hover,
.config-group:focus-within {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(255, 255, 255, 0.075);
}

.config-group label {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.config-group select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  background: #151824;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 700;
  outline: none;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.config-group select:focus {
  border-color: var(--accent-primary, #38bdf8);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

/* Run Stats Box */
.run-stats-box {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

/* End-of-Run Score Submission & Name Customization Prompt */
.score-submit-prompt {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 520px;
  box-sizing: border-box;
}

.prompt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.prompt-title {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #38bdf8;
}

.prompt-score {
  font-size: 13px;
  font-weight: 900;
  font-family: monospace;
  color: #22c55e;
}

.prompt-desc {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.45;
  margin: 0;
}

.prompt-name-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.prompt-name-row label {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: rgba(255, 255, 255, 0.55);
}

.prompt-input-wrap {
  display: flex;
  gap: 6px;
}

.prompt-input-wrap input {
  flex: 1;
  background: #14141d;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 700;
  outline: none;
  transition: border-color 0.15s ease;
}

.prompt-input-wrap input:focus {
  border-color: #38bdf8;
}

.prompt-inline-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.prompt-inline-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.prompt-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.prompt-btn-primary, .prompt-btn-secondary {
  flex: 1;
  padding: 9px 12px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: filter 0.15s ease;
}

.prompt-btn-primary {
  background: #22c55e;
  border: 1px solid #16a34a;
  color: #052e16;
}

.prompt-btn-primary:hover {
  filter: brightness(1.1);
}

.prompt-btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.7);
}

.prompt-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.prompt-status-msg {
  font-size: 11px;
  font-weight: 700;
  color: #38bdf8;
  padding: 4px 6px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.1);
}

.stat-cell {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat-lbl {
  font-size: 9.5px;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 700;
  letter-spacing: 0.8px;
}

.stat-num {
  font-size: 20px;
  font-weight: 900;
  color: #ffffff;
}

.modal-rules {
  background: linear-gradient(180deg, rgba(22, 27, 44, 0.88) 0%, rgba(13, 16, 27, 0.95) 100%);
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: 12px;
  padding: 13px 15px;
  margin-bottom: 15px;
  text-align: left;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.briefing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.briefing-badge {
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--accent-primary, #38bdf8);
  display: flex;
  align-items: center;
  gap: 6px;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.briefing-hint {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

.briefing-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.briefing-card {
  display: flex;
  align-items: center;
  gap: 11px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 11px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.briefing-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateX(2px);
}

.briefing-icon-box {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.briefing-icon-box.accent-cyan {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.22), rgba(14, 165, 233, 0.1));
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.briefing-icon-box.accent-gold {
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.22), rgba(245, 158, 11, 0.1));
  border: 1px solid rgba(250, 204, 21, 0.42);
}

.briefing-icon-box.accent-hazard {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.22), rgba(220, 38, 38, 0.1));
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.briefing-info {
  flex: 1;
  min-width: 0;
}

.briefing-title {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #ffffff;
  margin-bottom: 2px;
}

.briefing-desc {
  font-size: 11.5px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.82);
  margin: 0;
}

.briefing-desc b {
  color: #ffffff;
}

/* Badges inside descriptions */
.badge-mult {
  display: inline-block;
  background: rgba(250, 204, 21, 0.16);
  border: 1px solid rgba(250, 204, 21, 0.45);
  color: #facc15;
  font-weight: 800;
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.4px;
}

.badge-vault {
  display: inline-block;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #38bdf8;
  font-weight: 700;
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 4px;
}

.badge-hazard {
  display: inline-block;
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #f87171;
  font-weight: 800;
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.4px;
}

.badge-boss {
  display: inline-block;
  background: rgba(168, 85, 247, 0.18);
  border: 1px solid rgba(168, 85, 247, 0.45);
  color: #c084fc;
  font-weight: 800;
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 4px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.primary-btn {
  width: 100%;
  background: var(--accent-primary);
  color: #0b0b10;
  border: none;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 1.5px;
  padding: 14px 24px;
  border-radius: 8px;
  cursor: pointer;
  text-transform: uppercase;
  transition: transform 0.12s ease, filter 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 20px rgba(56, 189, 248, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary-btn:hover {
  filter: brightness(1.12);
  box-shadow: 0 6px 26px rgba(56, 189, 248, 0.52);
  transform: translateY(-1px);
}

.primary-btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn-arrow {
  display: inline-block;
  transition: transform 0.15s ease;
}

.primary-btn:hover .btn-arrow {
  transform: translateX(4px);
}

.secondary-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}

.google-claim-btn, .share-btn {
  flex: 1;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 11px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.google-claim-btn {
  background: #ffffff;
  color: #111116;
}

.share-btn {
  background: rgba(168, 85, 247, 0.22);
  border-color: #a855f7;
  color: #ffffff;
}

/* Challenge & Share Modal */
#shareModal {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 15, 0.94);
  backdrop-filter: blur(12px);
  z-index: 35;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: clamp(10px, 2.5vw, 24px);
}

.share-card {
  width: 100%;
  max-width: 480px;
  max-height: min(92vh, 760px);
  background: #15151e;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 18px 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

.share-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.share-header h2 {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #ffffff;
}

.share-preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 16px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 12px;
}

#sharePreviewCanvas {
  max-width: 220px;
  width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  display: block;
}

.share-preview-hint {
  font-size: 11px;
  font-family: monospace;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 8px;
  text-align: center;
}

.share-actions-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.share-opt-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #ffffff;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.share-opt-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.share-social-row {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.share-pill {
  flex: 1;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.share-pill:hover {
  transform: translateY(-1px);
  opacity: 0.9;
}

.share-pill.whatsapp {
  background: #128c7e;
  color: #ffffff;
}

.share-pill.twitter {
  background: #0f1419;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #38bdf8;
}

.share-pill.reddit {
  background: #ff4500;
  color: #ffffff;
}

.share-status-toast {
  background: rgba(34, 197, 94, 0.2);
  border: 1px solid #22c55e;
  color: #4ade80;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 6px;
  animation: fadeIn 0.15s ease;
}

/* Leaderboard Modal */
#leaderboardModal {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(10px);
  z-index: 30;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: clamp(12px, 3vw, 32px);
}

.lb-card {
  width: 100%;
  max-width: 560px;
  height: min(88vh, 760px);
  background: #15151e;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lb-header {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.lb-header h2 {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1.2px;
  color: var(--accent-primary);
}

.close-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 18px;
  cursor: pointer;
}

.lb-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #101017;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.lb-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  font-weight: 800;
  padding: 11px 6px;
  cursor: pointer;
}

.lb-tab.active {
  color: #ffffff;
  border-bottom-color: var(--accent-primary);
  background: rgba(255, 255, 255, 0.03);
}

.lb-meta-sub {
  padding: 6px 14px;
  font-size: 10.5px;
  font-family: monospace;
  color: rgba(255, 255, 255, 0.45);
  background: rgba(0, 0, 0, 0.25);
}

.lb-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lb-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
  font-size: 13px;
}

.lb-row.highlight {
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.45);
}

.lb-rank {
  width: 36px;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.6);
}

.lb-row:nth-child(1) .lb-rank { color: #fbbf24; }
.lb-row:nth-child(2) .lb-rank { color: #cbd5e1; }
.lb-row:nth-child(3) .lb-rank { color: #d97706; }

.lb-name {
  flex: 1;
  text-align: left;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-tier-tag {
  font-size: 9.5px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 10px;
  background: rgba(255, 255, 255, 0.1);
}

.lb-score {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--accent-positive);
}

.lb-caller-bar {
  padding: 10px 14px;
  background: #0e0e14;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.lb-signin-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  color: #111116;
  border: none;
  border-radius: 5px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

/* User Avatars */
.auth-pill-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--accent-cyan);
  display: block;
  flex-shrink: 0;
  margin: 0;
}

.lb-caller-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--accent-cyan);
  margin-right: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}

.lb-player-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.25);
  margin-right: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}

.user-avatar-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-cyan);
  color: #0b0b10;
  font-weight: 900;
  flex-shrink: 0;
}

/* ==========================================================================
   End-of-Stage Boss Encounter & Stage Clear System
   ========================================================================== */

/* Boss Health Bar HUD */
.boss-hud {
  position: absolute;
  top: calc(58px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: min(92%, 420px);
  z-index: 15;
  pointer-events: none;
  background: rgba(10, 8, 18, 0.76);
  border: 1px solid rgba(168, 85, 247, 0.45);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.6), 0 0 12px rgba(168, 85, 247, 0.22);
  border-radius: 8px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeInDown 0.3s ease-out;
}

@media (max-width: 600px) {
  #overlayTitle {
    font-size: clamp(22px, 5.5vw, 32px);
    margin-top: 10px;
    margin-bottom: 2px;
  }
  #overlaySubtitle {
    font-size: 11.5px;
    margin-bottom: 10px;
  }
  .config-bar {
    gap: 8px;
    margin-bottom: 10px;
  }
  .config-group {
    padding: 6px 10px;
  }
  .config-group select {
    padding: 5px 8px;
    font-size: 11.5px;
  }
  .modal-rules {
    padding: 10px 12px;
    margin-bottom: 12px;
  }
  .briefing-card {
    padding: 6px 9px;
    gap: 8px;
  }
  .briefing-icon-box {
    width: 28px;
    height: 28px;
    font-size: 14px;
    border-radius: 6px;
  }
  .briefing-title {
    font-size: 11px;
  }
  .briefing-desc {
    font-size: 10.5px;
    line-height: 1.35;
  }
  .primary-btn {
    padding: 12px 18px;
    font-size: 14px;
  }

  .boss-hud {
    top: calc(52px + env(safe-area-inset-top, 0px));
    width: min(94%, 390px);
    padding: 4px 8px;
    gap: 2.5px;
    background: rgba(10, 8, 18, 0.70);
  }
  .boss-name {
    font-size: 11px;
    letter-spacing: 0.8px;
  }
  .boss-hp-text {
    font-size: 10px;
  }
  .boss-modules-bar {
    gap: 3px;
    font-size: 8.5px;
  }
  .boss-module {
    padding: 1px 4px;
    border-radius: 3px;
  }
  .boss-phase-badge {
    font-size: 8.5px;
  }
  .boss-hp-bar-bg {
    height: 6px;
    border-radius: 3px;
  }
}

.boss-hud-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.boss-name {
  font-size: clamp(10px, 1.2vw, 13px);
  font-weight: 900;
  letter-spacing: 1.2px;
  color: #f472b6;
  text-shadow: 0 0 8px rgba(244, 114, 182, 0.6);
  text-transform: uppercase;
}

.boss-hp-text {
  font-size: clamp(10px, 1.1vw, 12px);
  font-weight: 800;
  font-family: monospace;
  color: #ffffff;
}

.boss-modules-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  font-size: clamp(8px, 1vw, 10px);
  font-weight: 800;
}

.boss-module {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #38bdf8;
  transition: all 0.25s ease;
}

.boss-module.destroyed {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.15);
  text-decoration: line-through;
  opacity: 0.6;
}

.boss-phase-badge {
  color: #fbbf24;
  letter-spacing: 0.5px;
  font-size: clamp(8px, 0.95vw, 10px);
  font-weight: 900;
  text-transform: uppercase;
}

.boss-phase-badge.phase2 {
  color: #f43f5e;
  animation: phaseAlertPulse 0.5s infinite alternate;
}

@keyframes phaseAlertPulse {
  from { transform: scale(1); opacity: 0.85; }
  to { transform: scale(1.08); opacity: 1; }
}

.boss-hp-bar-bg {
  width: 100%;
  height: 9px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.boss-hp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ef4444 0%, #f59e0b 45%, #22c55e 100%);
  border-radius: 4px;
  transition: width 0.08s ease-out;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.7);
}

/* Sector Ingress Announcement Card */
.sector-banner {
  position: absolute;
  top: 26%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 18;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.94) 0%, rgba(10, 14, 26, 0.96) 100%);
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 12px;
  padding: 14px 28px;
  text-align: center;
  box-shadow: 0 8px 36px rgba(0, 0, 0, 0.75), 0 0 24px rgba(56, 189, 248, 0.25);
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: sectorBannerIntro 2.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.sector-banner-title {
  font-size: clamp(16px, 2.5vw, 24px);
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--accent-primary, #38bdf8);
  text-transform: uppercase;
  text-shadow: 0 0 16px rgba(56, 189, 248, 0.6);
}

.sector-banner-sub {
  font-size: clamp(11px, 1.3vw, 13px);
  font-weight: 700;
  letter-spacing: 0.8px;
  color: rgba(255, 255, 255, 0.88);
}

@keyframes sectorBannerIntro {
  0% {
    opacity: 0;
    transform: translate(-50%, -40%) scale(0.92);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.0);
  }
  75% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -58%) scale(0.96);
  }
}

/* Boss Warning Siren Flash */
.boss-warning {
  position: absolute;
  top: 36%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  pointer-events: none;
  background: rgba(239, 68, 68, 0.92);
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: clamp(14px, 2.2vw, 20px);
  font-weight: 900;
  letter-spacing: 2px;
  text-align: center;
  box-shadow: 0 0 35px rgba(239, 68, 68, 0.85);
  animation: bossAlertPulse 0.4s ease-in-out infinite alternate;
}

@keyframes bossAlertPulse {
  0% {
    transform: translate(-50%, -50%) scale(0.96);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.6);
  }
  100% {
    transform: translate(-50%, -50%) scale(1.06);
    box-shadow: 0 0 40px rgba(239, 68, 68, 1);
  }
}

/* Stage Clear Modal */
#stageClearModal {
  position: absolute;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(9, 9, 14, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 18px;
}

.stage-clear-card {
  width: min(92%, 420px);
  background: rgba(18, 18, 26, 0.96);
  border: 1.5px solid #fbbf24;
  box-shadow: 0 0 40px rgba(251, 191, 36, 0.35);
  border-radius: 14px;
  padding: clamp(20px, 3.5vw, 32px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  animation: popIn 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.stage-clear-badge {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2.2px;
  background: #fbbf24;
  color: #111116;
  padding: 4px 14px;
  border-radius: 999px;
  text-transform: uppercase;
}

.stage-clear-title {
  font-size: clamp(22px, 3.5vw, 30px);
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #ffffff 30%, #fbbf24 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
}

.stage-clear-sub {
  font-size: clamp(12px, 1.3vw, 14px);
  color: rgba(255, 255, 255, 0.7);
  margin-top: -6px;
}

.stage-clear-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  width: 100%;
  margin: 4px 0;
}

.sc-stat {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sc-label {
  font-size: 9px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
}

.sc-val {
  font-size: clamp(15px, 2vw, 20px);
  font-weight: 900;
  color: #ffffff;
}

.sc-val.mult {
  color: #a855f7;
}

.stage-next-preview {
  font-size: clamp(11px, 1.2vw, 13px);
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 6px;
  padding: 8px 12px;
  width: 100%;
  line-height: 1.4;
}

.pulse-glow {
  animation: buttonPulseGlow 1.8s infinite;
}

@keyframes buttonPulseGlow {
  0%, 100% {
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.45);
  }
  50% {
    box-shadow: 0 0 28px rgba(56, 189, 248, 0.85);
    transform: scale(1.02);
  }
}

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

/* Stage Resume Modal Prompt */
#resumePromptModal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.88);
  z-index: 1000;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 18px;
}

.resume-card {
  width: min(92%, 420px);
  background: rgba(18, 18, 26, 0.96);
  border: 1.5px solid #38bdf8;
  box-shadow: 0 0 40px rgba(56, 189, 248, 0.35);
  border-radius: 14px;
  padding: clamp(20px, 3.5vw, 32px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  animation: popIn 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.resume-badge {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2px;
  background: #0284c7;
  color: #ffffff;
  padding: 4px 14px;
  border-radius: 999px;
  text-transform: uppercase;
}

.resume-title {
  font-size: clamp(22px, 3.5vw, 28px);
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #ffffff 30%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
}

.resume-sub {
  font-size: clamp(12px, 1.3vw, 14px);
  color: rgba(255, 255, 255, 0.72);
  margin-top: -6px;
  line-height: 1.4;
}

.resume-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  width: 100%;
  margin: 4px 0;
}

.resume-stat {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.resume-stat-lbl {
  font-size: 9px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
}

.resume-stat-val {
  font-size: clamp(15px, 2.2vw, 19px);
  font-weight: 900;
  color: #ffffff;
  font-family: monospace;
}

.resume-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
}

.resume-btn-secondary {
  padding: 12px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.resume-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* On-Screen Smart Bomb Action Button */
.bomb-action-btn {
  position: absolute;
  right: 18px;
  bottom: clamp(92px, 16vh, 140px);
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.45) 0%, rgba(15, 23, 42, 0.92) 80%);
  border: 2px solid #38bdf8;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.55), inset 0 0 12px rgba(56, 189, 248, 0.35);
  animation: bombPulseGlow 1.8s infinite ease-in-out;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.bomb-action-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 0 28px rgba(56, 189, 248, 0.85), inset 0 0 18px rgba(56, 189, 248, 0.5);
  border-color: #67e8f9;
}

.bomb-action-btn:active {
  transform: scale(0.92);
}

.bomb-btn-icon {
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 0 6px #00f0ff);
}

.bomb-btn-label {
  font-size: 8.5px;
  font-weight: 900;
  letter-spacing: 0.8px;
  color: #bae6fd;
  text-transform: uppercase;
}

.bomb-count-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 11px;
  background: #f59e0b;
  border: 1.5px solid #ffffff;
  color: #0b0f19;
  font-size: 11px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

@keyframes bombPulseGlow {
  0%, 100% {
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.5), inset 0 0 10px rgba(56, 189, 248, 0.25);
    border-color: #38bdf8;
  }
  50% {
    box-shadow: 0 0 28px rgba(14, 165, 233, 0.85), inset 0 0 18px rgba(56, 189, 248, 0.55);
    border-color: #7dd3fc;
  }
}
