:root {
    --bg-dark: #0f172a;
    --primary: #5b50f6;
    --primary-hover: #483ea8;
    --accent: #ffb800;
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(15, 23, 42, 0.75);
    --glass-border: rgba(255, 255, 255, 0.15);
}

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

body, html {
    width: 100%; height: 100%; overflow: hidden;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark); color: var(--text-light);
}

#ui-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 10;
}

.ui-view {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center;
    background: var(--glass-bg); backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    pointer-events: auto; transition: opacity 0.3s ease;
}

#hud.ui-view {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    pointer-events: none;
}

.hidden-ui { display: none !important; opacity: 0; }

/* BRANDING & LOGO */
.game-logo {
    font-size: 2.8rem; font-weight: 900; letter-spacing: 2px;
    color: var(--text-light); text-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.game-logo span { color: var(--accent); }
.game-logo.small { font-size: 2rem; margin-bottom: 20px; }
.tagline { color: var(--text-muted); font-size: 1rem; margin-bottom: 24px; }

/* CARDS & CONTAINERS */
.brand-card, .modal-card, .menu-card, .question-card {
    background: rgba(30, 41, 59, 0.85); border: 1px solid var(--glass-border);
    padding: 32px 40px; border-radius: 20px; text-align: center;
    max-width: 480px; width: 90%; box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.modal-card.wide { max-width: 650px; }

/* MOBILE SCROLLING FIX FOR QUESTION CARD */
.question-card {
    max-height: 85vh; /* Prevents card from exceeding screen height */
    overflow-y: auto; /* Enables scrolling for long text */
}

.question-card::-webkit-scrollbar { width: 8px; }
.question-card::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); border-radius: 4px; }
.question-card::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 4px; }

/* LOADING BAR */
.loading-container { width: 100%; margin: 20px 0; }
.loading-bar-track {
    width: 100%; height: 14px; background: rgba(255,255,255,0.1);
    border-radius: 10px; overflow: hidden; border: 1px solid var(--glass-border);
}
#loading-bar-fill {
    width: 0%; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 0.2s ease;
}
#loading-text { color: var(--text-muted); font-size: 0.9rem; margin-top: 8px; }

/* TIP ENGINE */
.tip-card {
    background: rgba(255,255,255,0.05); padding: 14px; border-radius: 12px;
    margin-top: 20px; border-left: 4px solid var(--accent);
}
.tip-label { font-size: 0.75rem; font-weight: 800; color: var(--accent); letter-spacing: 1px; }
#loading-tip-text { font-size: 0.9rem; color: var(--text-light); margin-top: 4px; transition: opacity 0.3s; }

.pulse-text { margin-top: 24px; color: var(--accent); font-weight: 800; animation: pulse 1.5s infinite; cursor: pointer; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* BUTTONS & INPUTS */
.ui-btn, .btn {
    width: 100%; padding: 14px 20px; border: none; border-radius: 12px;
    font-size: 1rem; font-weight: 700; cursor: pointer; transition: all 0.2s;
    margin-top: 10px; display: inline-block;
}
.ui-btn.primary, .btn { background: var(--primary); color: white; }
.ui-btn.primary:hover, .btn:hover { background: var(--primary-hover); transform: translateY(-2px); }
.ui-btn.secondary { background: rgba(255,255,255,0.1); color: white; }
.ui-btn.outline { background: transparent; border: 2px solid var(--glass-border); color: white; }

.ui-input {
    width: 100%; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--glass-border);
    background: rgba(0,0,0,0.2); color: white; margin-bottom: 10px; font-size: 0.95rem;
}

/* CHARACTER CAROUSEL SLOT */
.char-carousel-slot { display: flex; gap: 16px; margin: 20px 0; }
.char-preview-card {
    flex: 1; padding: 20px; border-radius: 14px; background: rgba(255,255,255,0.05);
    border: 2px solid transparent; cursor: pointer;
}
.char-preview-card.active { border-color: var(--primary); background: rgba(91, 80, 246, 0.15); }
.char-avatar-placeholder { font-size: 3rem; margin-bottom: 8px; }

/* HUD & QUESTION CARD OVERLAYS */
#hud-top-bar {
    position: absolute; top: 20px; left: 20px; display: flex; gap: 16px; align-items: center;
    background: var(--glass-bg); padding: 12px 20px; border-radius: 20px;
    border: 1px solid var(--glass-border); pointer-events: auto;
    flex-wrap: wrap; 
    max-width: calc(100vw - 190px); 
}

.hud-btn {
    background: rgba(255,255,255,0.1); border: 1px solid var(--glass-border);
    color: white; border-radius: 50%; width: 36px; height: 36px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; transition: 0.2s; 
}
.hud-btn:hover { background: rgba(255,255,255,0.2); }

.hud-banner.alert {
    position: absolute; top: 80px; left: 50%; transform: translateX(-50%);
    background: #ef4444; color: white; padding: 10px 24px; border-radius: 20px; font-weight: 800;
}
#game-area {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center; pointer-events: auto;
}

/* --- 3D SHOWROOM STYLES --- */
.transparent-view {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.char-showroom-overlay {
    position: absolute; width: 100%; height: 100%;
    display: flex; flex-direction: column; justify-content: space-between;
    align-items: center; padding: 40px 20px; pointer-events: none;
}

.showroom-title {
    background: var(--glass-bg); padding: 15px 30px; border-radius: 20px;
    border: 1px solid var(--glass-border); text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.showroom-controls {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; max-width: 600px; margin-top: auto; margin-bottom: 20px;
    pointer-events: auto;
}

.nav-btn {
    background: var(--primary); color: white; border: none;
    width: 60px; height: 60px; border-radius: 50%; font-size: 1.5rem;
    cursor: pointer; box-shadow: 0 10px 20px rgba(0,0,0,0.5); transition: 0.2s;
}
.nav-btn:hover { background: var(--accent); transform: scale(1.1); }

.char-info-box {
    background: var(--glass-bg); padding: 20px; border-radius: 16px;
    border: 1px solid var(--glass-border); text-align: center;
    flex: 1; margin: 0 20px;
}
.char-info-box h3 { color: var(--accent); font-size: 1.5rem; margin-bottom: 5px; }

.showroom-confirm {
    max-width: 300px; pointer-events: auto; font-size: 1.2rem; padding: 16px;
}

/* --- IN-GAME POPUP MODALS --- */
#custom-modal-overlay {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100vw; 
    height: 100vh;
    background: rgba(0, 0, 0, 0.45); 
    display: flex; 
    justify-content: center;
    align-items: center; 
    z-index: 9999;
    backdrop-filter: blur(4px); 
    -webkit-backdrop-filter: blur(4px);
}

.custom-modal-card {
    background: #ffffff; 
    padding: 30px 40px; 
    border-radius: 16px;
    text-align: center; 
    max-width: 420px; 
    width: 85%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4); 
    border: 3px solid #333333;
    animation: popIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
}

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

#custom-modal-title { 
    margin: 0 0 12px 0; 
    color: #111111; 
    font-size: 1.5rem; 
}

#custom-modal-text { 
    color: #444444; 
    font-size: 1.1rem; 
    line-height: 1.5; 
    margin: 0 0 24px 0; 
}

/* --- MOBILE CONTROLS --- */
#joystick-zone {
    position: absolute;
    bottom: 50px;
    left: 50px;
    width: 120px;
    height: 120px;
    pointer-events: auto;
    z-index: 100;
}

#jump-btn {
    position: absolute;
    bottom: 70px;
    right: 50px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-weight: 800;
    font-size: 1.1rem;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    pointer-events: auto;
    cursor: pointer;
    z-index: 100;
    transition: transform 0.1s, background 0.1s;
}

#jump-btn:active {
    transform: scale(0.9);
    background: var(--primary-hover);
}

/* --- LEADERBOARD STYLES --- */
.leaderboard-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    margin: 15px 0;
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--glass-border);
}

.leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1.1rem;
}

.leaderboard-item:last-child {
    border-bottom: none;
}

.lb-rank {
    color: var(--accent);
    font-weight: 900;
    width: 40px;
    text-align: left;
}

.lb-name {
    flex: 1;
    text-align: left;
    font-weight: 600;
    padding-left: 10px;
}

.lb-score {
    color: var(--primary);
    font-weight: 800;
    background: rgba(255,255,255,0.9);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.9rem;
}