:root {
  --bg: #0D0C0B;
  --surface: #1A1714;
  --surface-glass: rgba(26, 23, 20, 0.78);
  --border: rgba(246, 241, 231, 0.12);
  --text: #F6F1E7;
  --text-muted: #A89F91;
  --amber: #F59E0B;
  --amber-hover: #FBBF24;
  --amber-text: #14110F;
  --live: #EF4444;
  --ok: #22C55E;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* Waiting screen */
.waiting-screen {
  position: relative;
  width: 100%;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  overflow-y: auto;
}

.ambient-glow {
  position: fixed;
  inset: -20%;
  background: radial-gradient(circle at 50% 42%, rgba(245, 158, 11, 0.16), transparent 56%);
  pointer-events: none;
  z-index: 0;
}

.waiting-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 36px 26px 30px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}

.emblem-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
}

.emblem-pulse {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.32), transparent 70%);
  animation: pulseGlow 2.8s ease-in-out infinite;
}

.emblem-svg {
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 8px 20px rgba(245, 158, 11, 0.28));
}

@keyframes pulseGlow {
  0%, 100% {
    transform: scale(0.92);
    opacity: 0.55;
  }
  50% {
    transform: scale(1.18);
    opacity: 1;
  }
}

.brand-title {
  margin: 0 0 10px;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.waiting-status {
  margin: 0 0 6px;
  font-size: 1.22rem;
  font-weight: 700;
  color: var(--amber);
}

.waiting-subtitle {
  margin: 0 0 12px;
  font-size: 1.02rem;
  font-weight: 500;
  color: var(--text);
}

.waiting-hint {
  margin: 0 auto 20px;
  max-width: 310px;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.waiting-meta {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.88rem;
  color: var(--text);
}

.pill-subtle {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
}

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

.dot-warm {
  background: var(--amber);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.8);
}

.dot-live {
  background: var(--live);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.9);
  animation: liveBlink 1.5s ease-in-out infinite;
}

@keyframes liveBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  padding: 13px 20px;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-amber {
  background: var(--amber);
  color: var(--amber-text);
}

.btn-amber:hover {
  background: var(--amber-hover);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-full {
  width: 100%;
}

/* Live stage */
.live-stage {
  position: relative;
  width: 100%;
  height: 100dvh;
  background: #000;
}

.screen-scroll {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
}

.screen-scroll.mode-contain .screen-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.screen-scroll.mode-width {
  display: block;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.screen-scroll.mode-width .screen-img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
}

.screen-img {
  transition: filter 0.2s ease;
}

.screen-img.night-invert {
  filter: invert(1) hue-rotate(180deg);
}

/* Floating HUD */
.hud {
  position: fixed;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.hud-top {
  top: max(12px, env(safe-area-inset-top));
  padding: 0 12px;
}

.hud-bottom {
  bottom: max(14px, env(safe-area-inset-bottom));
  padding: 0 12px;
}

.hud.hud-hidden {
  opacity: 0;
  transform: translateY(8px);
}

.hud-top.hud-hidden {
  transform: translateY(-8px);
}

.hud.hud-hidden .hud-pill,
.hud.hud-hidden .hud-toolbar {
  pointer-events: none;
}

.hud-pill,
.hud-toolbar {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.hud-toolbar {
  gap: 6px;
  padding: 6px 8px;
  max-width: 100%;
  overflow-x: auto;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #FCA5A5;
}

.hud-brand {
  font-size: 0.88rem;
  font-weight: 600;
}

.hud-sep {
  color: var(--text-muted);
}

.hud-viewers {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.84rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.tool-btn.active {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.45);
  color: var(--amber-hover);
}

.tool-btn-amber {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.35);
  color: var(--amber-hover);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.tool-btn.active .status-dot {
  background: var(--ok);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.75);
}

/* Reconnecting banner */
.reconnect-banner {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 35;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(26, 23, 20, 0.92);
  border: 1px solid rgba(245, 158, 11, 0.4);
  font-size: 0.84rem;
  color: var(--amber-hover);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* QR Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 26px 24px 24px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}

.modal-title {
  margin: 0 0 6px;
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-subtitle {
  margin: 0 0 18px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.qr-box {
  display: inline-flex;
  padding: 14px;
  border-radius: 18px;
  background: #FFFFFF;
  margin-bottom: 14px;
}

.qr-box svg {
  display: block;
  width: 196px;
  height: 196px;
}

.qr-url {
  margin: 0 0 16px;
  font-size: 0.84rem;
  color: var(--amber);
  word-break: break-all;
}

/* Tip modal */
.tip-badge {
  display: inline-block;
  margin: 0 0 16px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.14);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #86EFAC;
  font-size: 0.82rem;
  font-weight: 500;
}

.tip-phone-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.tip-phone-value {
  font-size: 1.32rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  user-select: all;
}

.tip-bank-hint {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--amber);
}

.tip-steps {
  margin: 16px 0 14px;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.bank-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.bank-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 11px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.15s ease;
}

.bank-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

@media (max-width: 480px) {
  .tool-btn {
    padding: 7px 10px;
    font-size: 0.8rem;
  }
}
