:root {
  --bg: #eaeaea;
  --surface: #ffffff;
  --surface-alt: #f4f6f8;
  --slate: #192c3b;
  --slate-soft: #4a6072;
  --wine: #8c2342;
  --wine-hover: #a62b50;
  --gold: #c9922c;
  --border: #d5dce2;
  --correct: #1e7e4f;
  --correct-bg: #e7f6ee;
  --wrong: #b42336;
  --wrong-bg: #fdebec;
}

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

body {
  background: var(--bg);
  color: var(--slate);
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100dvh;
  padding: 12px;
}

h1, h2, h3, .lobby-clock, .timer-text {
  font-family: 'Jost', sans-serif;
  color: var(--slate);
}

.app-shell {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: calc(100dvh - 24px);
}

#gameView,
#lobbyView {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hidden {
  display: none !important;
}

/* Header */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--slate);
  color: #ffffff;
  border-radius: 14px;
  padding: 10px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--wine);
  color: #fff;
  font-family: 'Jost', sans-serif;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.5px;
}

.brand h1 {
  color: #ffffff;
  font-size: 1.08rem;
  line-height: 1.15;
}

.room-badge {
  font-size: 0.75rem;
  color: #f3c978;
  font-weight: 700;
}

.player-hud {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.hud-label {
  font-size: 0.72rem;
  color: #cbd5df;
  font-weight: 700;
}

.score-pill {
  color: #f3c978;
  font-size: 0.96rem;
}

.btn-save-pill {
  background: var(--gold);
  color: #192c3b;
  border: none;
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
}

/* Cards & Forms */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 4px 14px rgba(25, 44, 59, 0.06);
}

.join-card h2 {
  font-size: 1.45rem;
  margin-bottom: 6px;
}

.subtitle {
  color: var(--slate-soft);
  font-size: 0.94rem;
  line-height: 1.45;
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--slate);
}

.optional {
  color: var(--slate-soft);
  font-weight: 400;
}

input {
  width: 100%;
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--slate);
  font-family: inherit;
  font-size: 1rem;
  padding: 12px 14px;
  margin-bottom: 14px;
  outline: none;
}

input:focus {
  border-color: var(--wine);
  background: #fff;
}

.btn-primary {
  width: 100%;
  background: var(--wine);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-family: 'Jost', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}

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

.btn-secondary {
  background: var(--slate);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.modal-card .btn-ghost {
  background: var(--surface-alt);
  border-color: var(--border);
  color: var(--slate);
}

.full-width {
  width: 100%;
}

.error-msg {
  color: var(--wrong);
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 10px;
}

/* Lobby Screen */
.lobby-hero {
  text-align: center;
}

.lobby-clock {
  font-size: 3.1rem;
  font-weight: 800;
  color: var(--wine);
  line-height: 1.05;
  margin: 8px 0;
}

.signup-callout {
  margin-top: 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  font-size: 0.86rem;
}

.signup-callout p {
  color: var(--slate-soft);
  margin-top: 2px;
}

/* Status Bar & Live Point Ticker */
.status-bar {
  padding: 12px 14px;
}

.status-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.pill {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--slate);
}

.pill-dark {
  background: var(--slate);
  border-color: var(--slate);
  color: #ffffff;
}

.pill-accent {
  background: #f9eef1;
  border-color: #e4bcc7;
  color: var(--wine);
}

.pill-muted {
  color: var(--slate-soft);
}

.points-ticker {
  margin-left: auto;
  background: #fdf6e7;
  border: 1px solid #edd39b;
  color: #8a5e0b;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

.timer-text {
  font-weight: 800;
  font-size: 1rem;
  color: var(--wine);
  min-width: 38px;
  text-align: right;
}

.progress-track {
  width: 100%;
  height: 7px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--wine), var(--gold));
  transition: width 0.2s linear;
}

/* Full-Screen Ergonomic Question & 4-Button Grid */


.question-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px;
}

.question-prompt-area {
  flex: 1;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px 16px;
}

.question-card h2 {
  font-size: clamp(1.3rem, 2.4vw, 1.85rem);
  line-height: 1.38;
  max-width: 860px;
}

.answers-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 768px) {
  .answers-grid {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

  .answer-btn {
    padding: 18px 20px;
    font-size: 1.08rem;
  }
}

.answer-btn:hover:not(:disabled) {
  border-color: var(--wine);
  background: #ffffff;
}

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

.choice-letter {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Jost', sans-serif;
  font-weight: 800;
  color: var(--slate);
}

.answer-btn.selected {
  border-color: var(--slate);
  background: #e6ecf1;
}

.answer-btn.selected .choice-letter {
  background: var(--slate);
  color: #ffffff;
  border-color: var(--slate);
}

.answer-btn.correct {
  border-color: var(--correct);
  background: var(--correct-bg);
}

.answer-btn.correct .choice-letter {
  background: var(--correct);
  color: #ffffff;
  border-color: var(--correct);
}

.answer-btn.wrong {
  border-color: var(--wrong);
  background: var(--wrong-bg);
}

.answer-btn.wrong .choice-letter {
  background: var(--wrong);
  color: #ffffff;
  border-color: var(--wrong);
}

/* Feedback & Sommelier Note */
.feedback-box {
  margin-top: 14px;
  background: var(--surface-alt);
  border-left: 4px solid var(--wine);
  border-radius: 10px;
  padding: 12px 14px;
}

.feedback-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.points-badge {
  background: #fdf6e7;
  color: #8a5e0b;
  border: 1px solid #edd39b;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
}

.explanation-text {
  color: var(--slate-soft);
  font-size: 0.92rem;
  line-height: 1.45;
}

.inline-signup-bar {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--slate-soft);
}

.link-btn {
  background: none;
  border: none;
  color: var(--wine);
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
}

/* Leaderboard */
.lb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.lb-caption {
  font-size: 0.78rem;
  color: var(--slate-soft);
}

.lb-tabs {
  display: flex;
  gap: 6px;
}

.tab-btn {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--slate-soft);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--slate);
  border-color: var(--slate);
  color: #ffffff;
}

.leaderboard-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lb-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.92rem;
}

.lb-row.me {
  border: 1.5px solid var(--wine);
  background: #fdf6f8;
}

.lb-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lb-rank {
  font-family: 'Jost', sans-serif;
  font-weight: 800;
  color: var(--wine);
  width: 24px;
}

.lb-sub {
  font-size: 0.76rem;
  color: var(--slate-soft);
}

.lb-score {
  font-family: 'Jost', sans-serif;
  font-weight: 800;
  color: var(--slate);
}

.lb-empty {
  color: var(--slate-soft);
  font-size: 0.9rem;
  text-align: center;
  padding: 12px 0;
}

/* OTP Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(25, 44, 59, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.otp-sent-note {
  font-size: 0.88rem;
  color: var(--slate-soft);
  margin-bottom: 12px;
}
.round-optin-box {
  margin: 16px auto 6px;
  max-width: 380px;
}

.optin-btn.committed {
  background: var(--correct);
  cursor: default;
}

.optin-hint {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--slate-soft);
}

/* Answer distribution bar & badge during Reveal phase */
.answer-btn {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.answer-btn .btn-main {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.answer-pct-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0%;
  background: rgba(15, 23, 42, 0.08);
  z-index: 1;
  transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.answer-btn.correct .answer-pct-fill {
  background: rgba(22, 163, 74, 0.22);
}

.answer-btn.wrong .answer-pct-fill {
  background: rgba(220, 38, 38, 0.16);
}

.answer-pct-badge {
  position: relative;
  z-index: 2;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: inherit;
  white-space: nowrap;
}

.answer-pct-badge.hidden {
  display: none;
}
/* Only apply hover highlight on devices with a real mouse cursor */
@media (hover: hover) {
  .answer-btn:not(:disabled):hover {
    border-color: #D97706;
    background: #FFFBEB;
  }
}

.answer-btn:focus {
  outline: none;
}
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #FFFFFF;
  border: 1.5px solid #D97706;
  border-radius: 8px;
  padding: 3px 7px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
}

.brand-logo-badge img {
  display: block;
  height: 38px;
  width: auto; /* Maintains exact 581:400 aspect ratio (~55px wide) */
  object-fit: contain;
}

@media (max-width: 480px) {
  .brand-logo-badge img {
    height: 32px;
  }
}
.input-with-btn {
  display: flex;
  gap: 8px;
  align-items: stretch;
  width: 100%;
}

.input-with-btn input {
  flex: 1;
  min-width: 0; /* Prevents flex overflow on narrow mobile screens */
  margin: 0;
}

.input-with-btn button {
  flex-shrink: 0;
  white-space: nowrap;
  margin: 0;
  padding: 0 14px;
}
