@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Fredoka+One&display=swap');

:root {
    --bg: #0d0d1a;
    --bg2: #13132a;
    --card: #1a1a35;
    --card2: #22224a;
    --primary: #7c3aed;
    --primary-light: #a855f7;
    --accent: #06b6d4;
    --accent2: #f59e0b;
    --accent3: #10b981;
    --danger: #ef4444;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: rgba(255,255,255,0.08);
    --glow: 0 0 30px rgba(124,58,237,0.4);
    --radius: 16px;
    --radius-sm: 10px;
}

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

body {
    font-family: 'Nunito', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse at 20% 20%, rgba(124,58,237,0.15) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 80%, rgba(6,182,212,0.1) 0%, transparent 60%);
}

/* ---- NAVBAR ---- */
.navbar {
    background: rgba(13,13,26,0.9);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .logo {
    font-family: 'Fredoka One', cursive;
    font-size: 1.6rem;
    color: var(--primary-light);
    text-decoration: none;
    letter-spacing: 1px;
    text-shadow: 0 0 20px rgba(168,85,247,0.5);
}

.navbar .logo span { color: var(--accent); }

.nav-links { display: flex; gap: 0.5rem; align-items: center; }
.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.nav-links a:hover { color: var(--text); background: var(--card); }

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.4rem;
    border-radius: var(--radius-sm);
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    box-shadow: 0 4px 20px rgba(124,58,237,0.4);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(124,58,237,0.5); }

.btn-accent {
    background: linear-gradient(135deg, var(--accent), #0ea5e9);
    color: white;
    box-shadow: 0 4px 20px rgba(6,182,212,0.4);
}
.btn-accent:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(6,182,212,0.5); }

.btn-success {
    background: linear-gradient(135deg, var(--accent3), #059669);
    color: white;
    box-shadow: 0 4px 20px rgba(16,185,129,0.4);
}
.btn-success:hover { transform: translateY(-2px); }

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: white;
}
.btn-danger:hover { transform: translateY(-2px); }

.btn-ghost {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--card2); }

.btn-lg { padding: 0.9rem 2rem; font-size: 1.1rem; border-radius: var(--radius); }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.82rem; }

/* ---- CARDS ---- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}
.card-hover { transition: all 0.2s; cursor: pointer; }
.card-hover:hover { transform: translateY(-4px); border-color: rgba(124,58,237,0.4); box-shadow: var(--glow); }

/* ---- FORMS ---- */
.form-group { margin-bottom: 1.2rem; }
.form-group label {
    display: block;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    background: var(--bg2);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.7rem 1rem;
    transition: all 0.2s;
    outline: none;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(124,58,237,0.2);
    background: var(--card);
}
.form-group textarea { resize: vertical; min-height: 80px; }

/* ---- PAGE LAYOUT ---- */
.page { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }
.page-sm { max-width: 560px; margin: 0 auto; padding: 2rem 1.5rem; }

.page-title {
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    color: var(--primary-light);
    margin-bottom: 0.3rem;
}

/* ---- ALERTS ---- */
.alert {
    padding: 0.8rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert-error { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-success { background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.3); color: #6ee7b7; }

/* ---- BADGE ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-purple { background: rgba(124,58,237,0.25); color: var(--primary-light); }
.badge-cyan { background: rgba(6,182,212,0.2); color: var(--accent); }
.badge-green { background: rgba(16,185,129,0.2); color: var(--accent3); }
.badge-yellow { background: rgba(245,158,11,0.2); color: var(--accent2); }

/* ---- GRID ---- */
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.2rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 1.2rem; }

/* ---- HERO ---- */
.hero {
    text-align: center;
    padding: 4rem 1rem 3rem;
}
.hero h1 {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(3rem, 8vw, 5.5rem);
    background: linear-gradient(135deg, #a855f7, #06b6d4, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
    margin-bottom: 1rem;
}
.hero p {
    font-size: 1.15rem;
    color: var(--text-muted);
    max-width: 500px;
    margin: 0 auto 2rem;
    font-weight: 600;
}

/* ---- JOIN FORM ---- */
.join-box {
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 24px;
    padding: 2.5rem;
    max-width: 420px;
    margin: 0 auto;
}
.join-box h2 {
    font-family: 'Fredoka One', cursive;
    font-size: 1.6rem;
    margin-bottom: 1.5rem;
    color: var(--accent);
    text-align: center;
}
.code-input {
    font-size: 2.2rem !important;
    font-weight: 900 !important;
    text-align: center !important;
    letter-spacing: 8px;
    color: var(--primary-light) !important;
}

/* ---- GAME CODE DISPLAY ---- */
.game-code-display {
    font-family: 'Fredoka One', cursive;
    font-size: 5rem;
    color: var(--accent2);
    text-align: center;
    text-shadow: 0 0 40px rgba(245,158,11,0.5);
    letter-spacing: 12px;
    animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow {
    0%, 100% { text-shadow: 0 0 30px rgba(245,158,11,0.4); }
    50% { text-shadow: 0 0 60px rgba(245,158,11,0.8), 0 0 100px rgba(245,158,11,0.3); }
}

/* ---- PLAYER LIST ---- */
.player-list { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 1rem; }
.player-chip {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    padding: 0.5rem 1.2rem;
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.95rem;
    animation: pop-in 0.3s cubic-bezier(0.68,-0.55,0.27,1.55);
}
@keyframes pop-in {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* ---- ANSWER BUTTONS ---- */
.answer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
}
.answer-btn {
    padding: 1.5rem 1rem;
    border-radius: var(--radius);
    border: none;
    font-family: 'Nunito', sans-serif;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s;
    color: white;
    text-align: center;
    line-height: 1.3;
    position: relative;
    overflow: hidden;
}
.answer-btn:hover:not(:disabled) { transform: scale(1.03); }
.answer-btn:active:not(:disabled) { transform: scale(0.97); }
.answer-btn:disabled { cursor: not-allowed; opacity: 0.6; }
.answer-btn.a { background: linear-gradient(135deg, #ef4444, #dc2626); }
.answer-btn.b { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.answer-btn.c { background: linear-gradient(135deg, #f59e0b, #d97706); }
.answer-btn.d { background: linear-gradient(135deg, #10b981, #059669); }
.answer-btn.correct { box-shadow: 0 0 0 4px #10b981, 0 0 30px rgba(16,185,129,0.6); }
.answer-btn.wrong { opacity: 0.35; }

/* ---- TIMER ---- */
.timer-bar-wrap {
    width: 100%;
    height: 12px;
    background: var(--card2);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}
.timer-bar {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #10b981, #f59e0b, #ef4444);
    transition: width 1s linear;
}

/* ---- SCOREBOARD ---- */
.score-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1.2rem;
    background: var(--card);
    border-radius: var(--radius-sm);
    margin-bottom: 0.6rem;
    border: 1px solid var(--border);
    transition: all 0.3s;
}
.score-row .rank {
    font-family: 'Fredoka One', cursive;
    font-size: 1.5rem;
    min-width: 2.5rem;
    text-align: center;
}
.score-row .rank.gold { color: #fbbf24; }
.score-row .rank.silver { color: #94a3b8; }
.score-row .rank.bronze { color: #cd7f32; }
.score-row .name { flex: 1; font-weight: 800; font-size: 1.05rem; }
.score-row .score {
    font-family: 'Fredoka One', cursive;
    font-size: 1.3rem;
    color: var(--primary-light);
}

/* ---- QUESTION CARD ---- */
.question-text {
    font-size: 1.5rem;
    font-weight: 800;
    text-align: center;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    line-height: 1.4;
}

/* ---- TABLE ---- */
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left;
    padding: 0.7rem 1rem;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.03); }

/* ---- MISC ---- */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.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; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.w-full { width: 100%; }

.floating-shapes {
    position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0;
}
.shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.04;
    animation: float-shape 15s infinite ease-in-out;
}
.shape:nth-child(1) { width: 300px; height: 300px; background: var(--primary); top: 10%; left: 5%; animation-delay: 0s; }
.shape:nth-child(2) { width: 200px; height: 200px; background: var(--accent); top: 60%; right: 10%; animation-delay: -5s; }
.shape:nth-child(3) { width: 150px; height: 150px; background: var(--accent2); bottom: 20%; left: 30%; animation-delay: -10s; }
@keyframes float-shape {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.9); }
}

/* ---- EMOJI CONFETTI ---- */
.confetti-wrap { position: fixed; inset: 0; pointer-events: none; z-index: 999; overflow: hidden; }
.confetti-piece {
    position: absolute;
    font-size: 1.5rem;
    animation: confetti-fall 3s ease-in forwards;
}
@keyframes confetti-fall {
    0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ---- WAITING ROOM ---- */
.waiting-header {
    text-align: center;
    padding: 2rem 0 1rem;
}
.waiting-header h1 {
    font-family: 'Fredoka One', cursive;
    font-size: 2.5rem;
    color: var(--primary-light);
}
.code-box {
    background: var(--card);
    border: 2px dashed rgba(245,158,11,0.4);
    border-radius: 24px;
    padding: 2rem;
    text-align: center;
    margin-bottom: 2rem;
}
.code-label {
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 640px) {
    .answer-grid { grid-template-columns: 1fr; }
    .game-code-display { font-size: 3.5rem; letter-spacing: 8px; }
    .navbar { padding: 0 1rem; }
    .page { padding: 1.5rem 1rem; }
}
