:root {
    --bg-base: #0c0e15;
    --bg-surface: #141722;
    --bg-card: #1a1e2d;
    --bg-card-hover: #22273a;
    --bg-slide: #171a26;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.16);
    --border-focus: #6366f1;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #10b981;
    --danger: #ef4444;
    --quiz-red: #e21b3c;
    --quiz-blue: #1368ce;
    --quiz-yellow: #d89e00;
    --quiz-green: #26890c;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Rubik', sans-serif;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

body {
    background-color: var(--bg-base);
    background-image: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.14) 0%, rgba(12, 14, 21, 1) 75%);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.player-container {
    width: 100%;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bg-floating-orb {
    display: none;
}

.player-sparkle {
    display: none;
}

.btn-touch-ripple {
    position: absolute;
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 140px;
    height: 140px;
    background: rgba(255, 255, 255, 0.45);
    pointer-events: none;
    animation: touchRippleAnim 0.65s cubic-bezier(0, 0, 0.2, 1) forwards;
}

@keyframes touchRippleAnim {
    to { transform: translate(-50%, -50%) scale(3.5); opacity: 0; }
}

.player-header {
    height: 56px;
    background: var(--bg-surface);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    z-index: 20;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
}

.player-info img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid var(--border-subtle);
    object-fit: cover;
}

#my-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.rank-badge {
    background: #ffd700;
    color: #1a1a2e;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 800;
}

.player-score-box {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

#my-score {
    font-size: 17px;
    font-weight: 900;
    color: #fbbf24;
    font-variant-numeric: tabular-nums;
    transition: transform 0.2s;
    display: inline-block;
}

.score-pop-anim {
    animation: playerPointsPop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes playerPointsPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.35); color: #10b981; }
    100% { transform: scale(1); }
}

.pts-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.player-view {
    display: none !important;
    flex: 1;
    width: 100%;
    height: calc(100vh - 56px);
    height: calc(100dvh - 56px);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 16px;
    position: relative;
    overflow-y: auto;
}

.player-view.active {
    display: flex !important;
    animation: viewEnterAnim 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.15) forwards;
}

@keyframes viewEnterAnim {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.auth-card {
    background: var(--bg-surface);
    color: var(--text-primary);
    padding: 36px 28px;
    border-radius: var(--radius-xl);
    text-align: center;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border-subtle);
    position: relative;
    z-index: 5;
}

.auth-brand-badge {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 18px 14px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.auth-logo-img {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 8px;
    border: 2px solid var(--border-subtle);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.auth-crown-anim {
    font-size: 40px;
    display: inline-block;
}

.auth-brand-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
}

.auth-brand-tag {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    padding: 4px 14px;
    border-radius: 20px;
    margin-top: 4px;
}

.auth-card h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.auth-card p {
    font-size: 14.5px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.auth-btn-wrap {
    display: flex;
    justify-content: center;
    width: 100%;
}

.btn-discord-login {
    background-color: #5865f2;
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    padding: 14px 28px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    box-shadow: 0 4px 16px rgba(88, 101, 242, 0.4);
    transition: background-color 0.15s, transform 0.12s;
}

.btn-discord-login:hover {
    background-color: #4752c4;
    transform: translateY(-1px);
}

.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 16px 0 14px 0;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-subtle);
}

.auth-divider span {
    padding: 0 10px;
}

.quick-join-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.guest-name-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    text-align: center;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

.guest-name-input:focus {
    border-color: var(--primary);
}

.btn-guest-join {
    background: var(--success);
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    transition: transform 0.1s, background 0.15s;
}

.btn-guest-join:hover {
    background: #059669;
    transform: translateY(-1px);
}

.lobby-badge {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 38px 28px;
    text-align: center;
    position: relative;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.player-lobby-logo {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 14px;
    border: 2px solid var(--border-subtle);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.lobby-icon {
    font-size: 56px;
    margin-bottom: 12px;
}

.lobby-badge h2 {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.lobby-badge p {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.lobby-ready-card {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.player-header-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-player-sound {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn-player-sound:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-player-sound.unmuted {
    border-color: var(--success);
    color: #34d399;
}

.btn-player-sound.muted {
    color: var(--text-muted);
}

.pulse-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #26890c;
    animation: pulseGlow 1.5s infinite;
}

@keyframes pulseGlow {
    0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(38,137,12,0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(38,137,12,0); }
    100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(38,137,12,0); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.countdown-wrap {
    text-align: center;
}

#player-countdown-num {
    font-size: 130px;
    font-weight: 900;
    color: #ffa602;
    text-shadow: 0 6px 15px rgba(0,0,0,0.4);
    animation: zoomPulse 0.9s infinite alternate;
}

.countdown-wrap p {
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
}

@keyframes zoomPulse {
    from { transform: scale(0.92); }
    to { transform: scale(1.08); }
}

#view-question-preview {
    text-align: center;
    padding: 20px;
}

.player-preview-card {
    background: #ffffff;
    color: #222222;
    padding: 30px 24px;
    border-radius: 24px;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.player-preview-badge {
    background: #46178f;
    color: #ffffff;
    padding: 5px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 800;
}

.preview-spinner-wrap {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 8px 0;
}

.preview-spinner {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 6px solid #f0edf8;
    border-top: 6px solid #ffd700;
    border-right: 6px solid #ffa602;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#player-preview-countdown {
    font-size: 46px;
    font-weight: 900;
    color: #46178f;
    animation: zoomPulse 1s infinite alternate;
}

.player-preview-title {
    font-size: 22px;
    font-weight: 800;
    color: #111111;
    line-height: 1.35;
    text-align: center;
}

.player-preview-desc {
    font-size: 15px;
    color: #666666;
    font-weight: 600;
}

.preview-bar-track {
    width: 100%;
    height: 8px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 6px;
}

.preview-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ffd700, #ffa602);
    transition: width 4s linear;
}

#view-game {
    display: none !important;
}

#view-game.active {
    display: flex !important;
    padding: 10px;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    height: calc(100vh - 56px);
}

.player-q-card {
    width: 100%;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 12px 14px 10px 14px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.35);
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    max-width: 600px;
    margin: 0 auto;
    flex-shrink: 0;
}

.player-q-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.player-q-badge {
    background: var(--bg-card);
    color: var(--brand-primary);
    border: 1px solid var(--border-subtle);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 800;
}

.player-timer-pill {
    background: rgba(226, 27, 60, 0.12);
    color: #f87171;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 15px;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px solid rgba(226, 27, 60, 0.3);
}

.player-timer-pill.urgent {
    background: #e21b3c;
    color: #ffffff;
    animation: urgentPulse 0.5s infinite alternate;
}

@keyframes urgentPulse {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

.timer-sec-label {
    font-size: 11px;
    font-weight: 700;
    opacity: 0.8;
}

.player-q-text {
    font-size: 17px;
    font-weight: 800;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.35;
    margin: 2px 0;
}

.player-q-media-wrap {
    text-align: center;
    max-height: 110px;
    overflow: hidden;
    border-radius: 8px;
    margin: 2px 0;
}

.player-q-media-wrap img {
    max-width: 100%;
    max-height: 110px;
    object-fit: cover;
    border-radius: 8px;
}

.player-timer-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 4px;
}

.player-timer-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ff4757, #ffa502, #2ed573);
    background-size: 200% 100%;
    animation: timerShimmer 2s linear infinite;
    transition: width 1s linear;
}

@keyframes timerShimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.controller-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 12px;
    width: 100%;
    flex: 1;
    max-width: 620px;
    margin: 0 auto;
}

.ctrl-btn {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    transition: transform 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.12s, filter 0.12s, opacity 0.2s;
    outline: none;
    position: relative;
    overflow: hidden;
}

.ctrl-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 60%);
    pointer-events: none;
}

.ctrl-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(0,0,0,0.35);
    filter: brightness(1.06);
}

.ctrl-btn:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    filter: brightness(0.95);
}

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

.ctrl-btn.selected {
    opacity: 1 !important;
    filter: brightness(1.15);
    box-shadow: 0 0 0 4px #ffffff, 0 8px 25px rgba(0,0,0,0.45);
    transform: scale(1.02);
}

.btn-opt-0, .btn-red {
    background: var(--quiz-red);
}
.btn-opt-1, .btn-blue {
    background: var(--quiz-blue);
}
.btn-opt-2, .btn-yellow {
    background: var(--quiz-yellow);
}
.btn-opt-3, .btn-green {
    background: var(--quiz-green);
}

.ctrl-badge {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #ffffff;
    font-size: 24px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    line-height: 1;
}

.ctrl-btn:hover:not(:disabled) .ctrl-badge {
    transform: scale(1.08);
}

.ctrl-shape {
    font-size: 34px;
    color: #ffffff;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    line-height: 1;
}

.ctrl-text {
    font-size: 15px;
    font-weight: 800;
    color: #ffffff;
    text-align: center;
    line-height: 1.25;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
    word-break: break-word;
    max-width: 95%;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.locked-card {
    text-align: center;
    max-width: 380px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    padding: 32px 24px;
    border-radius: 20px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.35);
}

.locked-choice-preview {
    width: 84px;
    height: 84px;
    border-radius: 18px;
    margin: 0 auto 16px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(0,0,0,0.35);
    animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(255,255,255,0.2);
}

.locked-choice-badge, .locked-choice-shape {
    font-size: 42px;
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 2px 6px rgba(0,0,0,0.35);
}

.locked-card h2 {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
}

#locked-choice-label {
    font-size: 16px;
    color: var(--brand-primary);
    font-weight: 700;
    margin-bottom: 20px;
}

.bouncing-loader {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}

.bounce-dot {
    width: 14px;
    height: 14px;
    background: #ffffff;
    border-radius: 50%;
    animation: bouncer 0.6s infinite alternate;
}

.bounce-dot:nth-child(2) { animation-delay: 0.2s; }
.bounce-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bouncer {
    from { transform: translateY(0); opacity: 0.4; }
    to { transform: translateY(-14px); opacity: 1; }
}

.locked-subtext {
    font-size: 13px;
    color: var(--text-muted);
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

#view-result {
    text-align: center;
    transition: background 0.3s;
}

#view-result.result-correct {
    background: radial-gradient(circle, #2ebd11 0%, #1c7308 100%) !important;
}

#view-result.result-correct .res-icon {
    font-size: 92px;
    animation: victoryIconPop 0.65s cubic-bezier(0.175, 0.885, 0.32, 1.35) forwards;
    filter: drop-shadow(0 6px 14px rgba(0,0,0,0.3));
}

@keyframes victoryIconPop {
    0% { transform: scale(0) rotate(-45deg); opacity: 0; }
    60% { transform: scale(1.3) rotate(8deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

#view-result.result-wrong {
    background: radial-gradient(circle, #f32c4e 0%, #b80c29 100%) !important;
}

#view-result.result-wrong .result-box {
    animation: wrongShake 0.5s ease-in-out forwards;
}

#view-result.result-timeout {
    background: radial-gradient(circle, #d97706 0%, #9a3412 100%) !important;
}

#view-result.result-timeout .result-box {
    animation: wrongShake 0.5s ease-in-out forwards;
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    15%, 45%, 75% { transform: translateX(-10px); }
    30%, 60%, 90% { transform: translateX(10px); }
}

.result-box {
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

#result-title {
    font-size: 40px;
    font-weight: 900;
    text-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

.res-points {
    font-size: 30px;
    font-weight: 900;
    background: rgba(0,0,0,0.25);
    padding: 8px 26px;
    border-radius: 30px;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.25);
    animation: pointsFloatUp 0.6s ease-out forwards;
}

@keyframes pointsFloatUp {
    0% { transform: translateY(16px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.res-streak {
    font-size: 19px;
    font-weight: 900;
    color: #ffffff;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    padding: 8px 24px;
    border-radius: 30px;
    box-shadow: 0 0 25px rgba(245, 158, 11, 0.7);
    animation: flamePulse 1.2s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.5px;
}

@keyframes flamePulse {
    0% { transform: scale(1); box-shadow: 0 0 20px rgba(245, 158, 11, 0.6); }
    100% { transform: scale(1.06); box-shadow: 0 0 35px rgba(239, 68, 68, 0.9); }
}

.res-rank-box {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    padding: 8px 24px;
    border-radius: 30px;
    font-size: 18px;
    font-weight: 800;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.res-correct-info {
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 12px 16px;
    border-radius: 12px;
    width: 100%;
    margin-top: 6px;
}

.correct-label {
    font-size: 13px;
    opacity: 0.9;
    display: block;
    margin-bottom: 4px;
}

.correct-text-pill {
    font-size: 16px;
    font-weight: 800;
    color: #ffffff;
}

.scoreboard-player-card {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    padding: 22px 18px;
    border-radius: 20px;
    max-width: 460px;
    width: 100%;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.25);
}

.sb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 12px;
}

.sb-header h2 {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
}

.sb-my-standing {
    background: linear-gradient(135deg, #ffd700, #ffb703);
    color: #0f172a;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 800;
    box-shadow: 0 3px 8px rgba(255, 215, 0, 0.25);
}

.sb-players-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 52vh;
    overflow-y: auto;
    padding: 4px;
    -webkit-overflow-scrolling: touch;
}

.sb-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    animation: sbRowSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.25) both;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.sb-row:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.sb-row.rank-1 {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.12) 0%, rgba(26, 30, 45, 0.95) 100%);
    border-color: rgba(255, 215, 0, 0.4);
    box-shadow: 0 4px 14px rgba(255, 215, 0, 0.15);
}

.sb-row.rank-2 {
    background: linear-gradient(135deg, rgba(203, 213, 225, 0.1) 0%, rgba(26, 30, 45, 0.95) 100%);
    border-color: rgba(203, 213, 225, 0.3);
    box-shadow: 0 4px 10px rgba(148, 163, 184, 0.15);
}

.sb-row.rank-3 {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(26, 30, 45, 0.95) 100%);
    border-color: rgba(245, 158, 11, 0.3);
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.15);
}

.sb-row.highlight-me {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18) 0%, rgba(26, 30, 45, 0.98) 100%) !important;
    border: 1px solid var(--brand-primary) !important;
    box-shadow: 0 0 16px rgba(99, 102, 241, 0.3) !important;
    animation: highlightPulse 2s infinite ease-in-out;
}

.sb-row-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    overflow: hidden;
}

.sb-rank-wrap {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 28px;
}

.sb-rank-num {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-secondary);
}

.sb-medal {
    font-size: 14px;
}

.sb-row-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid var(--brand-primary);
    object-fit: cover;
    flex-shrink: 0;
}

.sb-name-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sb-player-name {
    font-weight: 700;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
}

.sb-streak-badge {
    background: linear-gradient(135deg, #ff4500, #ff8c00);
    color: #ffffff;
    font-size: 11px;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.sb-row-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.sb-pts-diff {
    background: #10b981;
    color: #ffffff;
    font-size: 11px;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 8px;
    animation: floatUpSmall 0.5s ease-out;
}

.sb-score-pts {
    font-weight: 800;
    color: #ffd700;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
    min-width: 70px;
    text-align: right;
}

.sb-wait-text {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin: 4px 0 0 0;
}

@keyframes sbRowSlideIn {
    0% { transform: translateY(20px) scale(0.95); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes highlightPulse {
    0%, 100% { box-shadow: 0 0 14px rgba(139, 92, 246, 0.3); }
    50% { box-shadow: 0 0 22px rgba(139, 92, 246, 0.6); }
}

@keyframes floatUpSmall {
    0% { transform: translateY(8px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

#view-end {
    text-align: center;
    position: relative;
}

#player-confetti-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.end-card {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    padding: 28px 20px;
    border-radius: 20px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
    z-index: 5;
    position: relative;
}

.end-trophy {
    font-size: 72px;
    line-height: 1;
    margin-bottom: 8px;
    animation: float 2s infinite ease-in-out;
}

#end-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.end-rank-highlight {
    font-size: 20px;
    font-weight: 800;
    color: #e21b3c;
    margin-bottom: 18px;
}

.end-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.stat-cell {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    padding: 12px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-val {
    font-size: 22px;
    font-weight: 800;
    color: var(--brand-primary);
}

.stat-lbl {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 2px;
}

.end-thanks {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    padding: 8px;
    border-radius: 10px;
}

@media (max-width: 480px) {
    .player-header {
        height: 52px;
        padding: 0 12px;
    }
    .player-info img {
        width: 32px;
        height: 32px;
    }
    #my-name {
        font-size: 15px;
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    #my-score {
        font-size: 18px;
    }
    .player-q-card {
        padding: 10px 12px;
        gap: 6px;
    }
    .player-q-text {
        font-size: 16px;
    }
    .controller-grid {
        gap: 8px;
    }
    .ctrl-btn {
        padding: 10px 8px;
        border-radius: 14px;
        gap: 4px;
    }
    .ctrl-badge {
        font-size: 20px;
    }
    .ctrl-text {
        font-size: 13px;
    }
    .result-box {
        gap: 8px;
    }
    #result-title {
        font-size: 30px;
    }
    .res-points {
        font-size: 24px;
        padding: 6px 20px;
    }
    .scoreboard-player-card {
        padding: 16px 12px;
    }
    .sb-row {
        padding: 8px 10px;
        font-size: 13px;
    }
    .sb-row-avatar {
        width: 28px;
        height: 28px;
    }
    .sb-score-pts {
        font-size: 14px;
        min-width: 55px;
    }
}

@media (max-height: 650px) {
    .player-header { height: 46px; }
    .player-q-card { padding: 6px 10px; }
    .player-q-text { font-size: 14px; line-height: 1.25; }
    .player-q-media-wrap { max-height: 70px; }
    .player-q-media-wrap img { max-height: 70px; }
    .ctrl-btn { padding: 8px 6px; gap: 4px; border-radius: 12px; }
    .ctrl-badge { font-size: 18px; }
    .ctrl-text { font-size: 12px; }
    .scoreboard-player-card { padding: 12px 10px; }
    .sb-players-list { max-height: 40vh; }
}

.auth-legal-notice {
    margin-top: 18px;
    font-size: 12.5px;
    color: #94a3b8;
    line-height: 1.5;
    text-align: center;
}

.auth-legal-notice a {
    color: #818cf8;
    text-decoration: underline;
    font-weight: 600;
    transition: color 0.2s;
}

.auth-legal-notice a:hover {
    color: #a5b4fc;
}

.app-global-footer {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    z-index: 10;
    pointer-events: auto;
}

.app-global-footer a {
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    transition: color 0.2s;
}

.app-global-footer a:hover {
    color: #818cf8;
    text-decoration: underline;
}

.foot-sep {
    opacity: 0.3;
}

.btn-player-settings {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    padding: 6px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, border-color 0.2s;
}

.btn-player-settings:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: var(--border-hover);
}

.btn-player-settings:active {
    transform: scale(0.96);
}

.btn-player-floating-settings {
    position: fixed;
    top: 14px;
    left: 14px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(20, 23, 34, 0.75);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 1000;
    transition: transform 0.2s, background 0.2s, border-color 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-player-floating-settings:hover {
    transform: scale(1.08) rotate(30deg);
    background: rgba(30, 35, 52, 0.9);
    border-color: var(--border-hover);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease;
}

.player-settings-card {
    background: var(--bg-surface);
    color: var(--text-primary);
    width: 92%;
    max-width: 440px;
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    animation: slideUp 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.settings-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    background: rgba(0, 0, 0, 0.25);
    border-bottom: 1px solid var(--border-subtle);
}

.settings-head h2 {
    font-size: 19px;
    font-weight: 800;
    margin: 0;
}

.btn-close {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.15s, color 0.15s;
}

.btn-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.settings-body {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-height: 70vh;
    overflow-y: auto;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.setting-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.setting-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.setting-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.setting-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.16);
    transition: 0.25s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.25s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #6366f1;
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.settings-select {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
    min-width: 140px;
}

.settings-select:focus {
    border-color: #6366f1;
}

.settings-foot {
    padding: 16px 24px;
    background: rgba(0, 0, 0, 0.25);
    border-top: 1px solid var(--border-subtle);
}

.btn-quiz {
    background: #10b981;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

.btn-quiz:hover {
    background: #059669;
    transform: translateY(-1px);
}

body.theme-neon {
    --bg-base: #060517;
    --bg-surface: #0e0b2a;
    --bg-card: #15113a;
    --bg-card-hover: #1f1854;
    --border-subtle: rgba(168, 85, 247, 0.2);
    --border-hover: rgba(168, 85, 247, 0.4);
    --primary: #8b5cf6;
    --border-focus: #a855f7;
    background-color: #060517 !important;
    background-image: radial-gradient(circle at 50% 0%, rgba(168, 85, 247, 0.25) 0%, rgba(6, 5, 23, 1) 80%) !important;
}

body.theme-light {
    --bg-base: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-slide: #f8fafc;
    --border-subtle: rgba(0, 0, 0, 0.1);
    --border-hover: rgba(0, 0, 0, 0.2);
    --border-focus: #4f46e5;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    background-color: #f1f5f9 !important;
    background-image: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.12) 0%, rgba(241, 245, 249, 1) 80%) !important;
    color: #0f172a !important;
}

body.theme-light .auth-card,
body.theme-light .player-lobby-card,
body.theme-light .result-card,
body.theme-light .player-settings-card {
    background: #ffffff !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08) !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}

body.theme-light .player-header {
    background: rgba(255, 255, 255, 0.88) !important;
    border-bottom-color: rgba(0, 0, 0, 0.08) !important;
}
