@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=Inter:wght@300;400;500;600&display=swap');

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

:root {
    --bg-primary:    #0d0d0d;
    --bg-card:       #1a1a2e;
    --bg-elevated:   #16213e;
    --bg-input:      #0f0f1a;
    --accent:        #c9a84c;
    --accent-hover:  #e8c56a;
    --accent-dim:    rgba(201,168,76,0.15);
    --danger:        #e63946;
    --danger-dim:    rgba(230,57,70,0.15);
    --success:       #2a9d8f;
    --success-dim:   rgba(42,157,143,0.15);
    --text-primary:  #f0f0f0;
    --text-secondary:#8a8aa0;
    --border:        #2a2a4a;
    --border-light:  #3a3a5a;
    --gold:          #ffd700;
    --silver:        #c0c0c0;
    --bronze:        #cd7f32;
    --radius:        10px;
    --shadow:        0 4px 24px rgba(0,0,0,0.5);
}

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

/* ─── Layout ───────────────────────────────────────────────── */
.page-center {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1rem;
}

.container-sm {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ─── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.card-sm {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
}

/* ─── Typography ───────────────────────────────────────────── */
h1, h2, h3 {
    font-family: 'Playfair Display', serif;
    color: var(--text-primary);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }

.text-accent   { color: var(--accent); }
.text-muted    { color: var(--text-secondary); font-size: 0.9rem; }
.text-center   { text-align: center; }

/* ─── Logo / Brand ─────────────────────────────────────────── */
.brand {
    text-align: center;
    margin-bottom: 3rem;
}
.brand h1 {
    font-size: 3rem;
    color: var(--accent);
    letter-spacing: 0.05em;
}
.brand p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

/* ─── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.75rem;
    border-radius: var(--radius);
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

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

.btn-primary {
    background: var(--accent);
    color: #0d0d0d;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--border-light);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-lg { padding: 1.1rem 2.5rem; font-size: 1.15rem; }
.btn-full { width: 100%; }

/* ─── Forms ────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1.25rem;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}
.form-group input, .form-group select {
    width: 100%;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    padding: 0.75rem 1rem;
    transition: border-color 0.15s;
    outline: none;
}
.form-group input:focus, .form-group select:focus {
    border-color: var(--accent);
}
.form-group input::placeholder {
    color: var(--text-secondary);
}

/* ─── Join Code Display ────────────────────────────────────── */
.join-code-display {
    font-family: 'Courier New', monospace;
    font-size: clamp(2.5rem, 8vw, 4.5rem);
    font-weight: 900;
    letter-spacing: 0.35em;
    color: var(--accent);
    text-align: center;
    background: var(--accent-dim);
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
    text-shadow: 0 0 20px rgba(201,168,76,0.4);
}

/* ─── Quote Card ───────────────────────────────────────────── */
.quote-card {
    background: var(--bg-card);
    border-left: 5px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 2rem 2.5rem;
    margin: 1.5rem 0;
    box-shadow: var(--shadow);
}
.quote-text {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    line-height: 1.75;
    color: var(--text-primary);
}
.quote-text::before { content: '\201E'; color: var(--accent); font-size: 1.5em; line-height: 0; vertical-align: -0.4em; }
.quote-text::after  { content: '\201D'; color: var(--accent); font-size: 1.5em; line-height: 0; vertical-align: -0.4em; }

/* ─── Answer Buttons ───────────────────────────────────────── */
.answers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 1.5rem;
}
@media (max-width: 480px) {
    .answers-grid { grid-template-columns: 1fr; }
}

.answer-btn {
    background: var(--bg-elevated);
    border: 2px solid var(--border);
    color: var(--text-primary);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
    min-height: 3.5rem;
}
.answer-btn:hover:not(:disabled) {
    border-color: var(--accent);
    background: var(--accent-dim);
    transform: translateY(-1px);
}
.answer-btn:disabled { opacity: 0.65; cursor: not-allowed; }
.answer-btn.selected { border-color: var(--accent); background: var(--accent-dim); }
.answer-btn.correct  { border-color: var(--success); background: var(--success-dim); color: #6ee7df; }
.answer-btn.wrong    { border-color: var(--danger);  background: var(--danger-dim);  color: #f08a91; }

/* ─── Timer Bar ────────────────────────────────────────────── */
.timer-wrap {
    margin: 0.75rem 0 1.5rem;
}
.timer-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}
.timer-bar {
    height: 7px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.timer-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--accent) 60%, var(--danger));
    background-size: 200% 100%;
    transition: width 0.9s linear;
    border-radius: 4px;
}

/* ─── Countdown ────────────────────────────────────────────── */
.countdown-wrap {
    text-align: center;
    padding: 3rem 1rem;
}
.countdown-number {
    font-family: 'Playfair Display', serif;
    font-size: clamp(6rem, 20vw, 10rem);
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
    animation: cdpulse 0.9s ease-in-out infinite;
    text-shadow: 0 0 40px rgba(201,168,76,0.6);
}
.countdown-label {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-top: 1rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}
@keyframes cdpulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%       { transform: scale(1.08); opacity: 0.85; }
}

/* ─── Leaderboard ──────────────────────────────────────────── */
.leaderboard {
    list-style: none;
}
.leaderboard-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.35rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    transition: background 0.15s;
}
.leaderboard-row.rank-1 { border-color: var(--gold);   background: rgba(255,215,0,0.07); }
.leaderboard-row.rank-2 { border-color: var(--silver); background: rgba(192,192,192,0.05); }
.leaderboard-row.rank-3 { border-color: var(--bronze); background: rgba(205,127,50,0.07); }
.leaderboard-row.is-me  { box-shadow: inset 3px 0 0 var(--accent); }

.lb-rank { font-weight: 700; font-size: 1.1rem; min-width: 1.5rem; color: var(--text-secondary); }
.leaderboard-row.rank-1 .lb-rank { color: var(--gold); }
.leaderboard-row.rank-2 .lb-rank { color: var(--silver); }
.leaderboard-row.rank-3 .lb-rank { color: var(--bronze); }

.lb-name  { flex: 1; font-weight: 500; }
.lb-score { font-weight: 700; color: var(--accent); font-size: 1.1rem; }
.lb-time  { font-size: 0.8rem; color: var(--text-secondary); min-width: 4rem; text-align: right; }

/* ─── Voters List (host playing view) ─────────────────────── */
.voters-list {
    list-style: none;
}
.voter-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    margin-bottom: 0.3rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    font-size: 0.9rem;
}
.voter-name { flex: 1; font-weight: 500; }
.voter-time { color: var(--accent); font-weight: 600; font-size: 0.85rem; }
.voter-dot  { width: 8px; height: 8px; background: var(--success); border-radius: 50%; }

/* ─── Round Result highlight ───────────────────────────────── */
.result-correct, .result-wrong {
    text-align: center;
    padding: 1.5rem;
    border-radius: var(--radius);
    margin: 1rem 0;
    font-size: 1.2rem;
    font-weight: 600;
}
.result-correct { background: var(--success-dim); border: 2px solid var(--success); color: #6ee7df; }
.result-wrong   { background: var(--danger-dim);  border: 2px solid var(--danger);  color: #f08a91; }

/* ─── Player Chip (waiting room) ───────────────────────────── */
.player-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.player-chip {
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 999px;
    padding: 0.3rem 0.9rem;
    font-size: 0.9rem;
    font-weight: 500;
    animation: chipIn 0.3s ease;
}
@keyframes chipIn {
    from { transform: scale(0.8); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

/* ─── Host 2-column layout ─────────────────────────────────── */
.host-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 768px) {
    .host-layout { grid-template-columns: 1fr; }
}

/* ─── Section titles ───────────────────────────────────────── */
.section-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* ─── Spinner ──────────────────────────────────────────────── */
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Answered overlay (player) ───────────────────────────── */
.answered-overlay {
    text-align: center;
    padding: 2rem 1rem;
}
.answered-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}
.answered-text {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

/* ─── Utility ──────────────────────────────────────────────── */
.hidden  { display: none !important; }
.mt-1   { margin-top: 0.5rem; }
.mt-2   { margin-top: 1rem; }
.mt-3   { margin-top: 1.5rem; }
.mb-1   { margin-bottom: 0.5rem; }
.mb-2   { margin-bottom: 1rem; }
.gap-1  { gap: 0.5rem; }
.flex   { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.round-badge {
    display: inline-block;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 999px;
    padding: 0.2rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ─── Toast notification ───────────────────────────────────── */
#toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
    font-size: 0.9rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
    z-index: 1000;
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.toast-success { border-color: var(--success); color: #6ee7df; }
#toast.toast-error   { border-color: var(--danger);  color: #f08a91; }

/* ─── Index page choice cards ──────────────────────────────── */
.choice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 2.5rem;
}
@media (max-width: 560px) { .choice-grid { grid-template-columns: 1fr; } }

.choice-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    text-align: center;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s ease;
    cursor: pointer;
}
.choice-card:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(201,168,76,0.2);
}
.choice-card .choice-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.choice-card h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.choice-card p  { color: var(--text-secondary); font-size: 0.95rem; line-height: 1.5; }

/* ─── Correct answer reveal ────────────────────────────────── */
.correct-answer-box {
    background: var(--success-dim);
    border: 2px solid var(--success);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    margin: 1rem 0;
    text-align: center;
}
.correct-answer-box .label { font-size: 0.8rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.1em; }
.correct-answer-box .name  { font-size: 1.4rem; font-weight: 700; color: #6ee7df; margin-top: 0.25rem; }
