/* ==================== VARIABLES ==================== */
:root {
  --bg: #0a0a1a;
  --bg2: #12101f;
  --card: rgba(255,255,255,0.06);
  --card-hover: rgba(255,255,255,0.1);
  --border: rgba(255,255,255,0.08);
  --primary: #f59e0b;
  --primary-light: #fbbf24;
  --primary-glow: rgba(245,158,11,0.25);
  --secondary: #8b5cf6;
  --danger: #ef4444;
  --success: #10b981;
  --text: #f1f1f1;
  --text-dim: #8a8a9a;
  --radius: 14px;
  --radius-lg: 20px;
  --font-h: 'Nunito', sans-serif;
  --font-b: 'Inter', sans-serif;
}

/* ==================== RESET ==================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font-b);
  background: linear-gradient(145deg, var(--bg) 0%, #1a0e2e 50%, #0d1117 100%);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ==================== SCREENS ==================== */
.screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s ease;
  overflow-y: auto;
  padding: 20px 0;
}
.screen.active { opacity: 1; pointer-events: auto; }
.container {
  width: 100%; max-width: 420px;
  padding: 24px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.home-buttons { width: 100%; display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }

/* ==================== TYPOGRAPHY ==================== */
h1, h2, h3 { font-family: var(--font-h); }
.logo-section { text-align: center; margin-bottom: 12px; }
.logo-emoji {
  font-size: 72px;
  animation: bounce 2s ease-in-out infinite;
  filter: drop-shadow(0 0 30px var(--primary-glow));
}
.logo-title {
  font-size: 42px; font-weight: 900;
  background: linear-gradient(135deg, var(--primary-light), var(--primary), #e76f51);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; line-height: 1.15;
}
.logo-sub { color: var(--text-dim); font-size: 15px; margin-top: 6px; letter-spacing: 1px; }

.screen-title { font-size: 24px; font-weight: 800; text-align: center; }
.text-muted { color: var(--text-dim); font-size: 14px; }

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: var(--radius);
  font-family: var(--font-h); font-weight: 700; font-size: 16px;
  cursor: pointer; transition: all 0.2s ease;
  padding: 14px 28px;
}
.btn-lg { width: 100%; padding: 16px; font-size: 18px; border-radius: var(--radius-lg); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #e76f51);
  color: #1a0a00;
  box-shadow: 0 4px 20px var(--primary-glow);
}
.btn-primary:active { transform: scale(0.96); }
.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:active { background: var(--card-hover); }
.btn-ghost { background: none; color: var(--text-dim); font-size: 14px; padding: 10px; }
.btn-icon {
  width: 44px; height: 44px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); color: var(--text);
  font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.btn:disabled { opacity: 0.4; pointer-events: none; }
.pulse { animation: pulse 2s ease-in-out infinite; }

/* ==================== FORM ==================== */
.form-group { width: 100%; }
.form-group label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-dim); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1px;
}
.form-group input {
  width: 100%; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: 16px; font-family: var(--font-b);
  outline: none; transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--primary); }
.form-group input::placeholder { color: var(--text-dim); }

/* ==================== PROFESSIONS ==================== */
.prof-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  width: 100%;
}
.prof-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 4px;
  background: var(--card); border: 2px solid transparent;
  border-radius: var(--radius); cursor: pointer;
  transition: all 0.2s;
}
.prof-btn:active { transform: scale(0.94); }
.prof-btn.selected { border-color: var(--primary); background: rgba(245,158,11,0.12); }
.prof-btn .emoji { font-size: 28px; }
.prof-btn .name { font-size: 10px; color: var(--text-dim); font-weight: 600; }

/* ==================== LOBBY ==================== */
.room-code-box {
  text-align: center;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 24px; width: 100%;
}
.room-code-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 2px; }
.room-code-row { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 6px; }
.room-code {
  font-family: var(--font-h); font-size: 40px; font-weight: 900;
  letter-spacing: 8px; color: var(--primary-light);
  text-shadow: 0 0 20px var(--primary-glow);
}
.players-box { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.player-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--card); border-radius: var(--radius);
  animation: slideUp 0.3s ease;
}
.player-row .p-emoji { font-size: 28px; }
.player-row .p-name { font-weight: 700; flex: 1; }
.player-row .p-prof { font-size: 12px; color: var(--text-dim); }
.player-row .host-badge {
  font-size: 10px; background: var(--primary);
  color: #000; padding: 2px 8px; border-radius: 20px; font-weight: 700;
}
.lobby-settings {
  display: flex; align-items: center; gap: 16px;
  padding: 12px; background: var(--card);
  border-radius: var(--radius); width: 100%;
}
.lobby-settings label { flex: 1; font-size: 14px; font-weight: 600; }
.rounds-selector { display: flex; align-items: center; gap: 10px; }
.rounds-selector span { font-size: 24px; font-weight: 800; min-width: 30px; text-align: center; }
.lobby-footer { text-align: center; width: 100%; }
.player-count { font-size: 14px; color: var(--text-dim); margin-bottom: 12px; }

/* ==================== QUESTION MANAGEMENT ==================== */
.qm-section {
  width: 100%;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
}
.qm-title { font-size: 16px; font-weight: 800; margin-bottom: 10px; }
.mode-toggle { display: flex; gap: 8px; margin-bottom: 12px; }
.mode-btn {
  flex: 1; padding: 10px;
  border-radius: var(--radius); border: 2px solid var(--border);
  background: var(--card); color: var(--text-dim);
  font-family: var(--font-h); font-weight: 700; font-size: 14px;
  cursor: pointer; transition: all 0.2s;
}
.mode-btn:active { transform: scale(0.96); }
.mode-btn.active {
  border-color: var(--primary); background: rgba(245,158,11,0.12);
  color: var(--text);
}
.mode-btn.disabled { pointer-events: none; opacity: 0.6; }
.mode-content { animation: slideUp 0.2s ease; }
.qm-desc { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; line-height: 1.4; }
.qm-desc strong { color: var(--primary-light); }
.qm-count { font-size: 12px; color: var(--text-dim); margin-top: 8px; text-align: center; }
.qm-add-row { display: flex; gap: 8px; width: 100%; }
.qm-add-row input {
  flex: 1; padding: 10px 12px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text);
  font-size: 14px; font-family: var(--font-b); outline: none;
}
.qm-add-row input:focus { border-color: var(--primary); }
.qm-add-row input::placeholder { color: var(--text-dim); }
.btn-sm { padding: 10px 16px; font-size: 18px; border-radius: 10px; min-width: 44px; }
.qm-custom-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.qm-custom-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: rgba(139,92,246,0.08); border: 1px solid rgba(139,92,246,0.15);
  border-radius: 10px; font-size: 13px;
  animation: slideUp 0.2s ease;
}
.qm-custom-item .cq-text { flex: 1; }
.qm-custom-item .cq-author { font-size: 11px; color: var(--text-dim); }
.qm-custom-item .cq-del {
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2);
  color: var(--danger); cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.qm-custom-item .cq-del:hover { background: rgba(239,68,68,0.2); }
.qm-host-only { display: none; }

/* ==================== TIME SELECTOR ==================== */
.time-section {
  width: 100%; display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
}
.time-section label { font-size: 13px; font-weight: 600; white-space: nowrap; }
.time-options { display: flex; gap: 6px; flex: 1; justify-content: flex-end; }
.time-btn {
  padding: 6px 14px; border-radius: 10px;
  border: 1.5px solid var(--border); background: var(--card);
  color: var(--text-dim); font-family: var(--font-h);
  font-weight: 700; font-size: 13px; cursor: pointer;
  transition: all 0.2s;
}
.time-btn:active { transform: scale(0.94); }
.time-btn.active {
  border-color: var(--primary); background: rgba(245,158,11,0.12);
  color: var(--text);
}


/* ==================== QUESTION ==================== */
.round-header {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; font-size: 14px;
}
.round-num {
  background: var(--card); padding: 6px 14px;
  border-radius: 20px; font-weight: 700; font-size: 13px;
}
.round-cat { font-size: 28px; }
.question-card {
  background: linear-gradient(135deg, rgba(245,158,11,0.1), rgba(139,92,246,0.08));
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius-lg); padding: 28px 24px;
  text-align: center; width: 100%;
  animation: slideUp 0.4s ease;
}
.q-prefix { font-size: 14px; color: var(--text-dim); margin-bottom: 8px; }
.q-text { font-size: 22px; font-weight: 800; line-height: 1.3; }
.timer-bar {
  width: 100%; height: 6px;
  background: var(--card); border-radius: 3px; overflow: hidden;
}
.timer-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--danger));
  transition: width 0.3s linear;
}
.timer-fill.running { animation: timerShrink 15s linear forwards; }

.vote-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  width: 100%;
}
.vote-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  background: var(--card); border: 2px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  font-family: var(--font-h); font-size: 15px; font-weight: 700;
  color: var(--text); transition: all 0.2s;
}
.vote-btn:active { transform: scale(0.95); }
.vote-btn.voted {
  border-color: var(--primary); background: rgba(245,158,11,0.15);
  pointer-events: none;
}
.vote-btn.disabled { opacity: 0.5; pointer-events: none; }
.vote-btn .v-emoji { font-size: 24px; }
.vote-btn .v-check { margin-left: auto; opacity: 0; transition: opacity 0.2s; }
.vote-btn.voted .v-check { opacity: 1; }
.vote-status { font-size: 13px; color: var(--text-dim); }
#vote-check { color: var(--success); }

/* ==================== RESULTS ==================== */
.results-q {
  text-align: center; font-size: 14px; color: var(--text-dim);
  background: var(--card); padding: 12px 20px; border-radius: var(--radius);
  width: 100%;
}
.results-q span { color: var(--text); font-weight: 600; }
.q-prefix-sm { color: var(--text-dim); }
.res-winner {
  text-align: center; padding: 24px;
  animation: slideUp 0.5s ease;
}
.res-winner .winner-emoji { font-size: 56px; animation: bounce 1s ease-in-out infinite; }
.res-winner .winner-name {
  font-size: 28px; font-weight: 900; font-family: var(--font-h);
  margin: 8px 0;
}
.res-winner .winner-label {
  font-size: 20px; font-weight: 800;
  color: var(--primary); text-shadow: 0 0 20px var(--primary-glow);
}
.res-breakdown { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.res-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--card);
  border-radius: var(--radius); animation: slideUp 0.3s ease;
}
.res-row .r-emoji { font-size: 22px; }
.res-row .r-name { font-weight: 600; font-size: 14px; flex: 1; }
.res-row .r-bar {
  height: 8px; border-radius: 4px;
  background: var(--secondary); transition: width 0.6s ease;
  min-width: 4px;
}
.res-row .r-count {
  font-weight: 800; font-size: 16px; min-width: 24px; text-align: right;
}
.res-row .r-voters { font-size: 11px; color: var(--text-dim); width: 100%; margin-top: 4px; }
.res-row.is-winner { background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.3); }
.res-timer { text-align: center; }
.res-footer { text-align: center; width: 100%; margin-top: 8px; }

/* ==================== GAME OVER ==================== */
.go-title {
  font-size: 36px; font-weight: 900; text-align: center;
  animation: slideUp 0.5s ease;
}
.awards-box { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.award-card {
  text-align: center; padding: 20px;
  background: linear-gradient(135deg, rgba(245,158,11,0.1), rgba(139,92,246,0.08));
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius-lg);
  animation: slideUp 0.5s ease;
}
.award-card .a-title { font-size: 24px; font-weight: 900; font-family: var(--font-h); }
.award-card .a-emoji { font-size: 48px; margin: 8px 0; }
.award-card .a-name { font-size: 20px; font-weight: 800; color: var(--primary-light); }
.award-card .a-desc { font-size: 13px; color: var(--text-dim); margin-top: 4px; }
.rankings-box { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.rank-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--card); border-radius: var(--radius);
  animation: slideUp 0.3s ease;
}
.rank-row .rank-pos { font-size: 18px; font-weight: 900; min-width: 28px; }
.rank-row .rank-emoji { font-size: 24px; }
.rank-row .rank-name { flex: 1; font-weight: 700; }
.rank-row .rank-drinks { font-size: 14px; color: var(--primary); font-weight: 700; }

/* ==================== TOAST ==================== */
#toast-box {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 1000; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 20px;
  background: rgba(30,30,50,0.95); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; font-weight: 600;
  backdrop-filter: blur(10px);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
}
.toast.error { border-color: var(--danger); color: var(--danger); }

/* ==================== CONFETTI ==================== */
#confetti {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 999;
}

/* ==================== ANIMATIONS ==================== */
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 20px var(--primary-glow); }
  50% { transform: scale(1.03); box-shadow: 0 4px 30px var(--primary-glow); }
}
@keyframes timerShrink {
  from { width: 100%; background: var(--success); }
  60% { background: var(--primary); }
  to { width: 0%; background: var(--danger); }
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ==================== RESPONSIVE ==================== */
@media (min-width: 500px) {
  .container { padding: 32px 24px; }
  .logo-title { font-size: 52px; }
  .vote-grid { grid-template-columns: repeat(3, 1fr); }
}
