/* Who Wants to Be a Millionaire — dark theme, gold accents */

:root {
  --bg: #050b16;
  --bg2: #0a1628;
  --panel: #0f1f38;
  --panel2: #12253f;
  --accent: #1a3a6b;
  --accent-hover: #25508f;
  --gold: #ffd700;
  --gold-soft: #f0c414;
  --gold-dark: #b8860b;
  --text: #e8f0ff;
  --muted: #8aa0c0;
  --correct: #1b8a4a;
  --correct-glow: rgba(27, 138, 74, 0.45);
  --wrong: #c0392b;
  --wrong-glow: rgba(192, 57, 43, 0.45);
  --border: rgba(255, 215, 0, 0.22);
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --font: "Montserrat", system-ui, sans-serif;
  --font-display: "Orbitron", "Montserrat", sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(255, 215, 0, 0.12), transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(26, 58, 107, 0.35), transparent 50%),
    radial-gradient(ellipse 50% 30% at 10% 80%, rgba(15, 31, 56, 0.8), transparent 50%);
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

/* Screens */
.screen {
  display: none;
  animation: fadeIn 0.35s ease;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes pulse-gold {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.4)); transform: scale(1); }
  50% { filter: drop-shadow(0 0 22px rgba(255, 215, 0, 0.85)); transform: scale(1.06); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

@keyframes flash-correct {
  0% { box-shadow: 0 0 0 0 var(--correct-glow); }
  50% { box-shadow: 0 0 24px 4px var(--correct-glow); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@keyframes flash-wrong {
  0% { box-shadow: 0 0 0 0 var(--wrong-glow); }
  50% { box-shadow: 0 0 24px 4px var(--wrong-glow); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Cards */
.card {
  background: linear-gradient(160deg, var(--panel2), var(--bg2));
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  max-width: 480px;
  margin: 8vh auto 24px;
  text-align: center;
}

.login-card {
  max-width: 440px;
}

.logo-ring {
  width: 96px;
  height: 96px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: conic-gradient(from 180deg, var(--gold), #fff3a0, var(--gold-dark), var(--gold));
  padding: 4px;
  animation: pulse-gold 3s ease-in-out infinite;
}

.logo-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--bg2);
  display: grid;
  place-items: center;
}

.logo-m {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--gold);
}

.title {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 4vw, 1.85rem);
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 10px;
  letter-spacing: 0.02em;
}

.title span,
.gold {
  color: var(--gold);
}

.subtitle {
  color: var(--muted);
  margin: 0 0 28px;
  font-size: 0.95rem;
}

.muted {
  color: var(--muted);
}

/* Form */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  margin-bottom: 14px;
}

.login-form label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.login-form input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 215, 0, 0.28);
  background: rgba(5, 11, 22, 0.7);
  color: var(--text);
  font-size: 1.05rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-form input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.15);
}

.error-msg {
  color: #ff8a80;
  font-size: 0.9rem;
  margin: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, opacity 0.2s, box-shadow 0.2s;
}

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

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-lg {
  width: 100%;
  padding: 15px 20px;
  font-size: 1.05rem;
  margin-top: 6px;
}

.btn-gold {
  background: linear-gradient(180deg, #ffe566, var(--gold) 40%, var(--gold-dark));
  color: #1a1200;
  box-shadow: 0 4px 18px rgba(255, 215, 0, 0.28);
}

.btn-gold:hover:not(:disabled) {
  box-shadow: 0 6px 24px rgba(255, 215, 0, 0.45);
}

.btn-ghost {
  background: transparent;
  color: var(--gold-soft);
  border: 1px solid rgba(255, 215, 0, 0.35);
  width: 100%;
  margin-top: 10px;
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 215, 0, 0.08);
}

.btn-outline {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold-dark);
  padding: 10px 16px;
}

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

/* Game header */
.game-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.game-header > div {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.game-header .muted {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.game-header strong {
  font-size: 1rem;
  color: var(--gold);
}

.money-badge strong {
  font-family: var(--font-display);
}

/* Layout */
.game-layout {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 16px;
  align-items: start;
}

.game-main {
  min-width: 0;
}

/* Lifelines */
.lifelines {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 14px;
}

.lifeline {
  flex: 1;
  max-width: 130px;
  background: linear-gradient(180deg, #163a5c, #0d2840);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 12px;
  color: var(--text);
  padding: 10px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  transition: background 0.2s, opacity 0.2s, transform 0.15s;
}

.lifeline:hover:not(:disabled) {
  background: linear-gradient(180deg, #1e4a72, #123550);
  transform: translateY(-2px);
}

.lifeline:disabled,
.lifeline.used {
  opacity: 0.35;
  cursor: not-allowed;
  text-decoration: line-through;
  transform: none;
}

.ll-icon {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--gold);
}

.ll-label {
  font-size: 0.78rem;
  font-weight: 600;
}

/* Question */
.question-panel {
  background: linear-gradient(160deg, #153056, #0c1c34);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  text-align: center;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.category {
  display: inline-block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold-soft);
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 999px;
  padding: 4px 12px;
  margin-bottom: 12px;
}

.question-text {
  margin: 0;
  font-size: clamp(1.05rem, 2.8vw, 1.35rem);
  line-height: 1.45;
  font-weight: 600;
}

/* Hint panel */
.hint-panel {
  background: rgba(255, 215, 0, 0.08);
  border: 1px solid rgba(255, 215, 0, 0.25);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  color: var(--gold-soft);
  font-size: 0.95rem;
  line-height: 1.4;
  animation: fadeIn 0.3s ease;
}

.hint-panel .audience-bars {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.hint-panel .bar-row {
  display: grid;
  grid-template-columns: 24px 1fr 40px;
  gap: 8px;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text);
}

.hint-panel .bar-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.hint-panel .bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  border-radius: 999px;
  transition: width 0.5s ease;
}

/* Answers */
.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.answer-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: linear-gradient(180deg, #1a3a6b, #122848);
  border: 1px solid rgba(120, 160, 220, 0.25);
  border-radius: 12px;
  color: var(--text);
  padding: 14px 16px;
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  min-height: 58px;
}

.answer-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #25508f, #1a3a6b);
  border-color: rgba(255, 215, 0, 0.45);
  transform: translateY(-1px);
}

.answer-btn:disabled {
  cursor: default;
}

.answer-btn .letter {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 215, 0, 0.15);
  color: var(--gold);
  font-weight: 800;
  font-size: 0.9rem;
  border: 1px solid rgba(255, 215, 0, 0.35);
}

.answer-btn .answer-text {
  flex: 1;
  line-height: 1.3;
}

.answer-btn.removed {
  opacity: 0.25;
  pointer-events: none;
  text-decoration: line-through;
}

.answer-btn.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.25);
}

.answer-btn.correct {
  background: linear-gradient(180deg, #1f9d55, #146b3a);
  border-color: #3ddc84;
  animation: flash-correct 0.7s ease;
}

.answer-btn.wrong {
  background: linear-gradient(180deg, #d64545, #8b1e1e);
  border-color: #ff6b6b;
  animation: flash-wrong 0.7s ease, shake 0.45s ease;
}

.answer-btn.locked {
  pointer-events: none;
}

/* Game actions */
.game-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 2px 12px;
}

.safe-info {
  font-size: 0.88rem;
  color: var(--muted);
}

.safe-info strong {
  color: var(--gold-soft);
}

/* Ladder */
.ladder {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 10px;
  position: sticky;
  top: 12px;
}

.ladder h3 {
  margin: 0 0 10px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.ladder-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ladder-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ladder-list li.safe {
  color: var(--gold-soft);
  font-weight: 600;
}

.ladder-list li.passed {
  color: #4caf70;
}

.ladder-list li.current {
  background: rgba(255, 215, 0, 0.15);
  color: var(--gold);
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(255, 215, 0, 0.35);
}

.ladder-list li .lvl {
  opacity: 0.75;
  min-width: 1.4em;
}

/* Results */
.result-card {
  max-width: 460px;
  margin-top: 10vh;
}

.result-icon {
  font-size: 3.2rem;
  margin-bottom: 8px;
}

.pulse-gold {
  animation: pulse-gold 2s ease-in-out infinite;
}

.result-name {
  font-size: 1.1rem;
  margin: 0 0 6px;
  color: var(--muted);
}

.result-sum {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  font-weight: 700;
  margin: 0 0 14px;
  color: var(--text);
}

.win-card .result-sum {
  color: var(--gold);
}

.correct-reveal {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 14px;
}

.correct-answer {
  margin: 6px 0 0;
  font-weight: 700;
  color: #6ee7a0;
  font-size: 1.05rem;
}

.result-msg {
  color: var(--muted);
  margin: 0 0 22px;
  line-height: 1.45;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Hall of Fame */
.hof-card {
  max-width: 640px;
}

.hof-table-wrap {
  overflow-x: auto;
  margin-bottom: 20px;
  border-radius: 10px;
  border: 1px solid rgba(255, 215, 0, 0.15);
}

.hof-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.hof-table th,
.hof-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.hof-table th {
  color: var(--gold-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(0, 0, 0, 0.25);
}

.hof-table tbody tr:nth-child(1) td {
  color: var(--gold);
  font-weight: 700;
}

.hof-table tbody tr:hover td {
  background: rgba(255, 215, 0, 0.04);
}

.hof-empty {
  text-align: center;
  color: var(--muted);
  padding: 28px !important;
}

/* Mobile */
@media (max-width: 800px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .ladder {
    order: -1;
    position: static;
  }

  .ladder-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }

  .ladder-list li {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    font-size: 0.7rem;
    padding: 6px;
  }

  .answers {
    grid-template-columns: 1fr;
  }

  .game-header {
    grid-template-columns: 1fr;
  }

  .card {
    margin-top: 4vh;
    padding: 24px 18px;
  }
}

@media (max-width: 420px) {
  .ladder-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .lifeline {
    max-width: none;
  }
}

/* ── v2.1: Welcome back, modals, hint animations ─────────── */

.welcome-back {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.welcome-back[hidden] {
  display: none !important;
}

.welcome-text {
  margin: 0 0 6px;
  font-size: 1.05rem;
  color: var(--text);
}

.welcome-text strong {
  color: var(--gold);
}

.login-form[hidden] {
  display: none !important;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.85rem;
}

/* Host floating avatar */
.host-avatar {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(255, 215, 0, 0.45);
  background: linear-gradient(160deg, #1a3a6b, #0d1f38);
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  display: grid;
  place-items: center;
}

.host-avatar:hover {
  transform: scale(1.08);
  box-shadow: 0 0 18px rgba(255, 215, 0, 0.35);
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(3, 8, 18, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: linear-gradient(160deg, var(--panel2), var(--bg2));
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 24px 22px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  transform: translateY(10px) scale(0.96);
  transition: transform 0.3s ease;
}

.modal-overlay.visible .modal {
  transform: none;
}

/* Host modal */
.host-modal-avatar {
  font-size: 2.4rem;
  margin-bottom: 10px;
  animation: pulse-gold 2s ease-in-out infinite;
}

.host-modal-text {
  margin: 0 0 16px;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--text);
  font-weight: 600;
}

/* Friend call modal */
.friend-modal {
  text-align: left;
  max-width: 440px;
}

.friend-call-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 215, 0, 0.15);
}

.friend-phone-icon {
  font-size: 1.6rem;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.25);
  flex-shrink: 0;
}

.friend-phone-icon.ringing {
  animation: phone-ring 0.4s ease-in-out infinite;
}

.friend-phone-icon.connected {
  animation: none;
  box-shadow: 0 0 12px rgba(61, 220, 132, 0.5);
  border-color: #3ddc84;
}

@keyframes phone-ring {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-12deg) scale(1.08); }
  50% { transform: rotate(12deg) scale(1.05); }
  75% { transform: rotate(-8deg) scale(1.08); }
}

.friend-modal-title {
  margin: 0;
  font-size: 1rem;
  color: var(--gold);
}

.friend-status {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.friend-avatar {
  margin-left: auto;
  font-size: 2rem;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 215, 0, 0.2);
  flex-shrink: 0;
}

.friend-chat {
  min-height: 140px;
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  padding: 4px 2px;
}

.chat-bubble {
  align-self: flex-start;
  background: rgba(26, 58, 107, 0.55);
  border: 1px solid rgba(120, 160, 220, 0.25);
  border-radius: 12px 12px 12px 4px;
  padding: 10px 12px;
  font-size: 0.92rem;
  line-height: 1.4;
  color: var(--text);
  max-width: 95%;
  animation: bubble-in 0.3s ease;
}

.chat-bubble.chat-final {
  background: rgba(255, 215, 0, 0.12);
  border-color: rgba(255, 215, 0, 0.4);
  color: var(--gold-soft);
  font-weight: 600;
}

.chat-confidence {
  margin-top: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gold);
}

.chat-typing {
  color: var(--muted);
  letter-spacing: 0.15em;
  animation: blink-dots 1s steps(3, end) infinite;
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@keyframes blink-dots {
  0%, 20% { opacity: 0.3; }
  50% { opacity: 1; }
  100% { opacity: 0.3; }
}

.friend-modal .btn {
  width: 100%;
}

/* Lifeline pre-result animations */
.lifeline.anim-shake {
  animation: shake 0.45s ease;
}

.lifeline.anim-pulse-ring {
  animation: lifeline-ring 0.5s ease;
}

.lifeline.anim-expand {
  animation: lifeline-expand 0.45s ease;
}

@keyframes lifeline-ring {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.0); }
  30% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(255, 215, 0, 0.25); }
  60% { transform: scale(0.96); box-shadow: 0 0 0 14px rgba(255, 215, 0, 0.08); }
}

@keyframes lifeline-expand {
  0% { transform: scale(1); }
  40% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

/* 50:50 removing animation */
.answer-btn.removing {
  animation: option-remove 0.4s ease forwards;
  pointer-events: none;
}

@keyframes option-remove {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0.2; transform: scale(0.96); text-decoration: line-through; }
}

/* Audience bar animation enhancement */
.hint-panel .bar-fill {
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (max-width: 800px) {
  .host-avatar {
    right: 12px;
    bottom: 12px;
    width: 46px;
    height: 46px;
    font-size: 1.3rem;
  }

  .friend-modal,
  .host-modal {
    max-width: 100%;
  }
}
