:root {
    --primary: #4e54c8;
    --secondary: #8f94fb;
    --bg-dark: #0f172a;
    --card-bg: #1e293b;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --correct: #10b981;
    --wrong: #ef4444;
    --btn-hover: #6366f1;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Nunito', sans-serif; }
body { background: linear-gradient(135deg, var(--bg-dark) 0%, #171e30 100%); color: var(--text); min-height: 100vh; overflow-x: hidden; }

/* REACTION CONTAINER */
#reaction-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; overflow: hidden; }
.floating-emoji { position: absolute; bottom: 10px; right: 10%; font-size: 3rem; animation: floatUpAndFade 2s ease-out forwards; }
@keyframes floatUpAndFade { 0% { transform: translateY(0) scale(1); opacity: 1; } 100% { transform: translateY(-300px) scale(1.5); opacity: 0; } }

/* SCREENS */
.screen { display: flex; flex-direction: column; align-items: center; min-height: 100vh; padding: 20px; transition: opacity 0.3s; }
.hidden { display: none !important; }

/* CARDS & PANELS */
.card, .panel { background: var(--card-bg); border-radius: 20px; padding: 30px; box-shadow: 0 10px 25px rgba(0,0,0,0.5); text-align: center; }
.login-card { max-width: 400px; width: 100%; margin: auto; }
.login-card h1 { font-family: 'Fredoka One', cursive; color: var(--secondary); margin-bottom: 10px; }
.login-card p { color: var(--text-muted); margin-bottom: 20px; }
.error-text { color: var(--wrong) !important; font-size: 0.9rem; margin-top: -10px; margin-bottom: 15px; }

.login-leaderboard { margin-top: 30px; width: 100%; max-width: 400px; padding: 20px; }
.login-leaderboard h3 { margin-bottom: 15px; color: var(--secondary); font-family: 'Fredoka One', cursive; font-size: 1.2rem; }
.login-leaderboard .lb-item { padding: 10px; font-size: 0.95rem; }

input[type="text"] { width: 100%; padding: 15px; border-radius: 10px; border: 2px solid #334155; background: #0f172a; color: white; font-size: 1rem; margin-bottom: 15px; outline: none; text-align: center; }
input[type="text"]:focus { border-color: var(--secondary); }

.login-inputs { margin-bottom: 15px; }
.login-info { color: #f59e0b; font-size: 0.85rem; margin-bottom: 20px; line-height: 1.4; padding: 0 10px; }

/* BUTTONS */
.btn { width: 100%; padding: 15px; border: none; border-radius: 10px; font-weight: bold; font-size: 1.1rem; cursor: pointer; transition: 0.2s; }
.primary-btn { background: var(--primary); color: white; }
.primary-btn:hover { background: var(--btn-hover); transform: translateY(-2px); }
.secondary-btn { background: #334155; color: white; }
.secondary-btn:hover { background: #475569; }

/* AVATARS */
.avatar-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 20px; }
.avatar-option { font-size: 2.5rem; padding: 10px; background: #0f172a; border-radius: 15px; cursor: pointer; transition: 0.2s; border: 2px solid transparent; }
.avatar-option:hover { transform: scale(1.1); }
.avatar-option.selected { border-color: var(--secondary); background: #1e293b; transform: scale(1.1); }

/* LOBBY */
.lobby-header { display: flex; justify-content: space-between; align-items: center; width: 100%; max-width: 800px; margin-bottom: 30px; }
.lobby-header .btn { width: auto; padding: 10px 20px; }
.lobby-content { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; width: 100%; max-width: 800px; }
.match-panel { grid-column: span 2; }
.player-list { list-style: none; text-align: left; max-height: 300px; overflow-y: auto; }
.player-list li { display: flex; justify-content: space-between; align-items: center; padding: 15px; background: #0f172a; margin-bottom: 10px; border-radius: 10px; cursor: pointer; transition: 0.2s; border: 1px solid transparent; }
.player-list li:hover { border-color: var(--secondary); transform: translateX(5px); }
.player-status { font-size: 0.8rem; padding: 4px 8px; border-radius: 5px; font-weight: bold; }
.status-lobby { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.status-auto { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }

/* LEADERBOARD */
#leaderboard-list .lb-item { display: flex; align-items: center; justify-content: space-between; padding: 12px; background: #0f172a; margin-bottom: 8px; border-radius: 8px; }
.lb-rank { font-weight: bold; color: var(--secondary); width: 30px; }
.lb-name { flex-grow: 1; text-align: left; padding-left: 10px; font-weight: bold; }
.lb-score { color: #f59e0b; font-weight: bold; }

/* GAME UI */
.game-header { display: flex; justify-content: space-between; align-items: stretch; width: 100%; max-width: 800px; margin-bottom: 20px; }
.player-card { background: var(--card-bg); padding: 15px 25px; border-radius: 15px; display: flex; flex-direction: column; align-items: center; min-width: 120px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
.player-card.right { align-items: center; }
.player-card .avatar { font-size: 2.5rem; margin-bottom: 5px; }
.player-card .name { font-weight: bold; font-size: 1.1rem; color: var(--secondary); }
.player-card .score { font-family: 'Fredoka One', cursive; font-size: 1.8rem; color: #f59e0b; }

.round-card { background: var(--card-bg); padding: 15px; border-radius: 15px; flex-grow: 1; margin: 0 15px; display: flex; flex-direction: column; justify-content: center; align-items: center; }
#round-info { font-weight: bold; color: var(--text-muted); font-size: 0.9rem; letter-spacing: 2px; text-transform: uppercase; }
.status-msg { margin-top: 5px; font-weight: bold; font-size: 1.2rem; }

.game-area { background: var(--card-bg); width: 100%; max-width: 800px; border-radius: 20px; padding: 30px; display: flex; flex-direction: column; align-items: center; position: relative; }

/* SVG CLOCK */
.clock-container { display: flex; flex-direction: column; align-items: center; width: 100%; }
.clock-svg { width: 220px; height: 220px; margin: 20px auto; border-radius: 50%; box-shadow: inset 0 0 20px rgba(0,0,0,0.5), 0 10px 20px rgba(0,0,0,0.3); background: #fff; }
.clock-face { fill: none; stroke: #334155; stroke-width: 4; }
.clock-marks line { stroke: #64748b; stroke-width: 3; }
.clock-number { font-family: 'Nunito', sans-serif; font-size: 18px; font-weight: bold; fill: #1e293b; text-anchor: middle; dominant-baseline: central; }
.hand-hour { stroke: #1e293b; stroke-width: 8; stroke-linecap: round; transition: transform 0.5s cubic-bezier(0.4, 2.08, 0.55, 0.44); }
.hand-minute { stroke: var(--primary); stroke-width: 5; stroke-linecap: round; transition: transform 0.5s cubic-bezier(0.4, 2.08, 0.55, 0.44); }
.clock-center { fill: #1e293b; }

.q-label { margin: 20px 0; font-size: 1.5rem; color: var(--text); font-family: 'Fredoka One', cursive;}
.digital-time-display { font-family: 'Fredoka One', cursive; font-size: 5rem; color: #fff; letter-spacing: 5px; text-shadow: 0 0 20px rgba(78, 84, 200, 0.5); margin: 30px 0; }
.text-question { font-size: 1.5rem; text-align: center; margin: 40px 10px; line-height: 1.5; color: var(--text); }

/* OPTIONS */
.options-grid { display: grid; grid-template-columns: 1fr; gap: 15px; width: 100%; margin-top: 20px; }
.option-btn { background: #0f172a; color: var(--text); border: 2px solid #334155; border-radius: 12px; padding: 18px; font-size: 1.2rem; font-weight: bold; cursor: pointer; transition: all 0.2s; outline: none; }
.option-btn:hover:not(:disabled) { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 5px 15px rgba(78, 84, 200, 0.2); }
.option-btn:disabled { cursor: not-allowed; opacity: 0.9; }

/* REACTION BAR */
.reaction-bar { position: absolute; right: 10px; top: -50px; background: var(--card-bg); padding: 5px; border-radius: 20px; display: flex; gap: 5px; box-shadow: 0 5px 10px rgba(0,0,0,0.3); }
.reaction-bar button { background: none; border: none; font-size: 1.5rem; cursor: pointer; transition: 0.2s; padding: 5px; border-radius: 50%; }
.reaction-bar button:hover { background: rgba(255,255,255,0.1); transform: scale(1.2); }

/* RESULT SCREEN */
.result-card h1 { font-family: 'Fredoka One', cursive; margin-bottom: 10px; color: #f59e0b; }
.final-score { font-size: 3rem; font-family: 'Fredoka One', cursive; margin: 20px 0; color: var(--secondary); }
.rematch-btn { font-size: 1.2rem; padding: 15px; margin-bottom: 10px; background: #10b981; }
.rematch-btn:hover { background: #059669; }

/* MODALS */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); display: flex; justify-content: center; align-items: center; z-index: 1000; }
.modal-content { background: var(--card-bg); padding: 30px; border-radius: 20px; text-align: center; max-width: 400px; width: 90%; }
.inviter-info { margin: 20px 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.inviter-info .avatar { font-size: 3rem; }
.modal-buttons { display: flex; gap: 10px; }

@media (max-width: 768px) {
    .lobby-content { grid-template-columns: 1fr; }
    .game-header { padding: 0 10px; }
    .player-card { min-width: 80px; padding: 10px; }
    .player-card .name { font-size: 0.9rem; }
    .player-card .score { font-size: 1.5rem; }
    .round-card { margin: 0 10px; padding: 10px; }
    .digital-time-display { font-size: 3.5rem; }
    .clock-svg { width: 180px; height: 180px; }
}
