:root {
  --bg-primary: #070a0f;
  --bg-elevated: rgba(16, 22, 33, 0.78);
  --bg-surface: rgba(255, 255, 255, 0.035);
  --bg-surface-hover: rgba(255, 255, 255, 0.07);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(76, 141, 255, 0.55);
  --text-primary: #eef2f8;
  --text-secondary: #8c96aa;
  --text-muted: #5a6478;
  --ct-blue: #3da5ff;
  --ct-glow: rgba(61, 165, 255, 0.25);
  --t-orange: #ff8a3d;
  --t-glow: rgba(255, 138, 61, 0.22);
  --accent-grad: linear-gradient(135deg, #4c8dff 0%, #26b7ff 100%);
  --status-live: #10b981;
  --status-warn: #f59e0b;
  --status-off: #ef4444;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow-card: 0 24px 64px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==================== LANDING PAGE ==================== */

body.landing-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
  overflow-x: hidden;
  background-image:
    radial-gradient(circle at 15% 15%, rgba(61, 165, 255, 0.14) 0%, transparent 42%),
    radial-gradient(circle at 85% 85%, rgba(255, 138, 61, 0.1) 0%, transparent 42%),
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 44px 44px, 44px 44px;
}

.landing-container {
  width: 100%;
  max-width: 460px;
  position: relative;
  z-index: 1;
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
}

.brand-header {
  text-align: center;
  margin-bottom: 2rem;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: rgba(61, 165, 255, 0.1);
  border: 1px solid rgba(61, 165, 255, 0.25);
  color: var(--ct-blue);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.brand-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-live);
  box-shadow: 0 0 8px var(--status-live);
  animation: pulse 2s infinite;
}

.logo {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 0.4rem;
  background: linear-gradient(135deg, #ffffff 10%, #7cc4ff 55%, #3da5ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
  display: none;
  align-items: center;
  gap: 0.5rem;
}

.alert.show {
  display: flex;
}

.alert-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.32);
  color: #fca5a5;
}

.alert-info {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.28);
  color: #6ee7b7;
}

.input-group {
  margin-bottom: 1.5rem;
}

.input-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.input-wrapper {
  display: flex;
  gap: 0.65rem;
}

.input-field {
  flex: 1;
  min-width: 0;
  background: rgba(6, 9, 14, 0.75);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  font-size: 1.15rem;
  color: var(--text-primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  text-align: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.input-field:focus {
  outline: none;
  border-color: var(--border-focus);
  background: rgba(61, 165, 255, 0.06);
  box-shadow: 0 0 0 3px rgba(76, 141, 255, 0.15);
}

.input-field::placeholder {
  color: var(--text-muted);
  letter-spacing: 0.24em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.85rem 1.4rem;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-grad);
  color: #ffffff;
  box-shadow: 0 6px 20px rgba(61, 165, 255, 0.28);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(61, 165, 255, 0.4);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.room-preview {
  margin-top: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: none;
  align-items: center;
  justify-content: space-between;
}

.room-preview.show {
  display: flex;
}

.info-section {
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
}

.info-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.steps-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(61, 165, 255, 0.16);
  color: var(--ct-blue);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.step-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* ==================== ROOM / RADAR PAGE ==================== */

body.room-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  background:
    radial-gradient(circle at 50% 0%, rgba(61, 165, 255, 0.07) 0%, transparent 55%),
    var(--bg-primary);
}

.hud-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.25rem;
  background: rgba(12, 16, 24, 0.9);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(12px);
  gap: 1rem;
  flex-wrap: wrap;
  z-index: 10;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mini {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.brand-mini:hover {
  color: var(--ct-blue);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-indicator.live {
  background: var(--status-live);
  box-shadow: 0 0 8px var(--status-live);
  animation: pulse 2s infinite;
}

.status-indicator.reconnect {
  background: var(--status-warn);
  box-shadow: 0 0 8px var(--status-warn);
  animation: pulse-warn 1s infinite;
}

.status-indicator.offline {
  background: var(--status-off);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@keyframes pulse-warn {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.room-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  background: rgba(61, 165, 255, 0.1);
  border: 1px solid rgba(61, 165, 255, 0.25);
  color: var(--ct-blue);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.15s ease;
}

.room-badge:hover {
  background: rgba(61, 165, 255, 0.18);
}

.hud-stats {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.stat-card {
  display: flex;
  flex-direction: column;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.04);
  min-width: 72px;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
}

.stat-value {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.team-legend {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.75rem;
  font-weight: 600;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-secondary);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dot.ct {
  background: var(--ct-blue);
  box-shadow: 0 0 6px var(--ct-glow);
}

.legend-dot.t {
  background: var(--t-orange);
  box-shadow: 0 0 6px var(--t-glow);
}

.hud-controls {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.32rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.toggle-switch:hover {
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--text-primary);
}

.toggle-switch input {
  accent-color: var(--ct-blue);
  cursor: pointer;
  width: 14px;
  height: 14px;
}

.btn-icon {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-icon:hover {
  background: rgba(76, 141, 255, 0.18);
  border-color: rgba(76, 141, 255, 0.4);
  color: var(--ct-blue);
}

.radar-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow: hidden;
  position: relative;
}

.radar-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas#radar {
  display: block;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65);
}

.banner {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  backdrop-filter: blur(10px);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: #fcd34d;
  display: none;
  z-index: 5;
  white-space: nowrap;
}

.banner.show {
  display: block;
}

.waiting-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 4;
  transition: opacity 0.25s ease;
}

.waiting-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

.waiting-card {
  background: rgba(14, 19, 29, 0.86);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(14px);
  padding: 1.5rem 2rem;
  border-radius: var(--radius-lg);
  text-align: center;
  max-width: 340px;
  box-shadow: var(--shadow-card);
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(61, 165, 255, 0.2);
  border-top-color: var(--ct-blue);
  border-radius: 50%;
  margin: 0 auto 0.9rem;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.waiting-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
}

.waiting-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(16, 22, 33, 0.95);
  border: 1px solid rgba(61, 165, 255, 0.35);
  color: var(--text-primary);
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 820px) {
  .hud-header {
    padding: 0.65rem 0.85rem;
    gap: 0.65rem;
  }

  .team-legend {
    display: none;
  }
}

@media (max-width: 520px) {
  .card {
    padding: 1.5rem;
  }

  .input-wrapper {
    flex-direction: column;
  }

  .logo {
    font-size: 2.1rem;
  }

  .stat-card {
    min-width: 60px;
    padding: 0.2rem 0.55rem;
  }

  .hud-controls {
    margin-left: auto;
  }
}
