/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f1a;
  --bg2: #1a1a2e;
  --bg3: #16213e;
  --card: #1e1e3a;
  --card2: #252545;
  --accent: #7c3aed;
  --accent2: #a855f7;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --blue: #3b82f6;
  --text: #f1f5f9;
  --text2: #94a3b8;
  --border: rgba(255,255,255,0.08);
  --radius: 12px;
  --radius-lg: 20px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

.hint {
  color: var(--text2);
  font-size: 0.875rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent2); transform: translateY(-1px); }
.btn-secondary { background: var(--card2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: #2e2e52; }
.btn-warning { background: var(--yellow); color: #000; }
.btn-warning:hover:not(:disabled) { background: #fbbf24; }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn-danger:hover:not(:disabled) { background: var(--red); color: #fff; }
.btn-lg { padding: 1rem 2rem; font-size: 1.1rem; width: 100%; border-radius: var(--radius-lg); }
.btn-green { background: var(--green); color: #fff; }

/* ── Screens ──────────────────────────────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: flex; }

/* ── Shared: game code display (used in landing overlay + host panel) ─────── */
.game-code-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}
.game-code-display .label { font-size: 0.8rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.1em; }
.game-code-display .code {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  font-family: monospace;
  color: var(--accent2);
}

.share-link-box {
  display: flex;
  gap: 0.5rem;
}
.share-link-box input {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  color: var(--text2);
  font-size: 0.85rem;
  min-width: 0;
}

.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
#qr-div, #lobby-qr {
  border-radius: var(--radius);
  background: white;
  padding: 8px;
  display: inline-block;
}
#qr-div img, #lobby-qr img { display: block; }

/* ── Buzz overlay (shared) ───────────────────────────────────────────────── */
/* ── Confirm modal ───────────────────────────────────────────────────────── */
.confirm-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.15s ease;
}
.confirm-modal.hidden { display: none; }
.confirm-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 2rem 1.5rem;
  min-width: 300px;
  max-width: 420px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  animation: specialIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.confirm-message {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  line-height: 1.4;
}
.confirm-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}
.confirm-actions .btn { min-width: 90px; }

.buzz-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}
.buzz-overlay.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }

.buzz-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.buzz-selfie-wrap {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid var(--yellow);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card2);
}
.buzz-selfie-wrap img { width: 100%; height: 100%; object-fit: cover; }
.buzz-initials { font-size: 3rem; font-weight: 800; }
.buzz-team-name { font-size: 2rem; font-weight: 800; color: var(--yellow); }
.buzz-points { font-size: 1.5rem; font-weight: 700; color: var(--green); }
.buzz-label { font-size: 1rem; color: var(--text2); }

/* ── Special overlays (lone hero / precise estimate) ─────────────────────── */
.special-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  animation: specialIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.special-overlay.hidden { display: none; }

@keyframes specialIn {
  from { opacity: 0; transform: scale(0.7); }
  to   { opacity: 1; transform: scale(1); }
}

.special-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem;
}

.special-icon {
  font-size: 5rem;
  animation: specialIconPulse 0.6s ease 0.1s both;
}
@keyframes specialIconPulse {
  0%   { transform: scale(0) rotate(-20deg); }
  70%  { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.special-title {
  font-size: 2.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, #f59e0b, #fbbf24, #fde68a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.01em;
}

/* Precise variant uses green tones */
.special-overlay.precise .special-title {
  background: linear-gradient(135deg, #10b981, #34d399, #6ee7b7);
  -webkit-background-clip: text;
  background-clip: text;
}

/* Worst estimate variant uses red-orange tones */
.special-overlay.worst .special-title {
  background: linear-gradient(135deg, #ef4444, #f97316, #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.special-overlay.worst .special-icon {
  animation: worstIconShake 0.6s ease 0.1s both;
}
@keyframes worstIconShake {
  0%   { transform: scale(0) rotate(-30deg); }
  50%  { transform: scale(1.3) rotate(10deg); }
  70%  { transform: scale(0.95) rotate(-5deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.special-selfie-wrap {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid var(--yellow);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card2);
}
.special-selfie-wrap img { width: 100%; height: 100%; object-fit: cover; }
.special-initials { font-size: 2.4rem; font-weight: 800; }
.special-overlay.precise .special-selfie-wrap { border-color: #34d399; }
.special-overlay.worst   .special-selfie-wrap { border-color: #f97316; }

.special-team {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
}
.special-subtitle {
  font-size: 1rem;
  color: var(--text2);
}
.special-points {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--yellow);
  margin-top: 0.25rem;
}
.special-overlay.precise .special-points { color: var(--green); }

/* ── Trophy ──────────────────────────────────────────────────────────────── */
.trophy { font-size: 5rem; text-align: center; }

/* ── Confetti ────────────────────────────────────────────────────────────── */
.confetti-piece {
  position: fixed;
  top: -20px;
  z-index: 9998;
  pointer-events: none;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0%   { top: -20px; opacity: 1; }
  80%  { opacity: 1; }
  100% { top: 110vh; opacity: 0; }
}

/* ── Text input ──────────────────────────────────────────────────────────── */
.text-input {
  width: 100%;
  background: var(--bg2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  color: var(--text);
  font-size: 1.1rem;
  outline: none;
  transition: border-color 0.15s;
}
.text-input:focus { border-color: var(--accent); }

/* ── Language switcher ───────────────────────────────────────────────────── */
.lang-bar {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}
.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text2);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1;
}
.lang-btn img { display: block; border-radius: 1px; }
.lang-btn:hover { background: var(--card); color: var(--text); }
.lang-btn-active {
  background: rgba(124,58,237,0.2);
  border-color: var(--accent2);
  color: var(--accent2);
}
/* Compact variant used in host header */
.lang-bar-compact .lang-btn { padding: 0.25rem 0.5rem; font-size: 0.75rem; letter-spacing: 0.04em; }
