:root {
    --primary-color: #00ff88;
    --secondary-color: #00e5ff;
    --danger-color: #ff0055;
    --warning-color: #ffcc00;
    --bg-dark: #0a0b10;
    --bg-panel: rgba(20, 22, 35, 0.85);
    --border-light: rgba(255, 255, 255, 0.1);
    --text-main: #ffffff;
    --text-muted: #a0a5b5;
    --glass-blur: blur(20px);
    --gold: #ffd700;
    --silver: #c0c0c0;
    --bronze: #cd7f32;
    --btn-gradient: linear-gradient(135deg, #00ff88 0%, #00b359 100%);
    --btn-hover: linear-gradient(135deg, #33ff9f 0%, #00cc66 100%);
    --btn-shadow: 0 4px 15px rgba(0, 255, 136, 0.4);
    
    /* 8 Ball Pool specific */
    --hud-bg: linear-gradient(180deg, rgba(10, 15, 25, 0.95) 0%, rgba(5, 10, 15, 0.8) 100%);
    --avatar-size: 80px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-drag: none;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Montserrat', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* Base Body Styles */
body {
    background: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(0, 229, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255, 0, 85, 0.05) 0%, transparent 50%),
        url('data:image/svg+xml;utf8,<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><rect width="100" height="100" fill="none"/><path d="M0 100 L100 0 M-50 50 L50 -50 M50 150 L150 50" stroke="rgba(255,255,255,0.02)" stroke-width="1"/></svg>');
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    perspective: 1000px;
    touch-action: none; /* Crucial for mobile PWA to prevent scrolling/pull-to-refresh */
}

/* Import Font */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;800;900&display=swap');

/* =========================================
   LOBBY STYLES (index.html)
   ========================================= */

.lobby-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    position: relative;
}

/* Top Navigation Bar */
.top-nav {
    background: var(--hud-bg);
    border-bottom: 1px solid var(--border-light);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    z-index: 100;
}

.profile-section {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255,255,255,0.05);
    padding: 5px 20px 5px 5px;
    border-radius: 40px;
    border: 1px solid var(--border-light);
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.5);
}

.avatar-container {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2c3e50, #3498db);
    border: 3px solid #fff;
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 800;
}

.level-badge {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: var(--gold);
    color: #000;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 900;
    border: 2px solid #fff;
}

.player-info {
    display: flex;
    flex-direction: column;
}

.player-name-nav {
    font-size: 18px;
    font-weight: 800;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.player-title-nav {
    font-size: 12px;
    color: var(--secondary-color);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.currency-section {
    display: flex;
    gap: 20px;
}

.currency-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.6);
    padding: 8px 15px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.8);
    font-weight: 800;
    font-size: 16px;
    letter-spacing: 0.5px;
}

.currency-badge.coins { color: var(--gold); }
.currency-badge.cash { color: #2ecc71; }
.currency-badge.tickets { color: #9b59b6; }

.currency-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    background: radial-gradient(circle at top left, rgba(255,255,255,0.4), transparent);
}
.currency-badge.coins .currency-icon { background-color: var(--gold); color: #000; }
.currency-badge.cash .currency-icon { background-color: #2ecc71; color: #fff; }
.currency-badge.tickets .currency-icon { background-color: #9b59b6; color: #fff; }

.add-btn {
    background: var(--btn-gradient);
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    margin-left: 10px;
    transition: transform 0.2s;
}
.add-btn:hover { transform: scale(1.1); }
.add-btn:active { transform: scale(0.95); }

/* Main Lobby Area (Carousel) */
.carousel-viewport {
    flex: 1;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden; /* Hide anything outside the main view */
    width: 100%;
}

.carousel-track {
    display: flex;
    align-items: center;
    gap: 30px;
    padding: 0 calc(50vw - 160px); /* Center alignment based on card width */
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.game-mode-card {
    min-width: 320px;
    height: 450px;
    flex-shrink: 0;
    background: linear-gradient(180deg, rgba(30, 35, 50, 0.9) 0%, rgba(15, 20, 30, 0.95) 100%);
    border-radius: 24px;
    border: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    
    /* Carousel coverflow styles */
    opacity: 0.5;
    transform: scale(0.85); /* Scale down inactive cards */
    transition: transform 0.4s, opacity 0.4s, box-shadow 0.4s;
}

.game-mode-card.active-slide {
    opacity: 1;
    transform: scale(1.05); /* Scale up active card */
    box-shadow: 0 30px 60px rgba(0,0,0,0.8), inset 0 2px 10px rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.3);
    z-index: 10;
}

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 20;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.nav-arrow:hover {
    background: rgba(0, 229, 255, 0.5);
    border-color: #00e5ff;
}

.nav-arrow.disabled {
    opacity: 0;
    cursor: not-allowed;
    pointer-events: none;
}

.left-arrow { left: 20px; }
.right-arrow { right: 20px; }

/* Specific Card Themes */
.game-mode-card[data-mode="8ball"] { border-top: 4px solid var(--primary-color); }
.game-mode-card[data-mode="9ball"] { border-top: 4px solid var(--warning-color); }
.game-mode-card[data-mode="timeattack"] { border-top: 4px solid var(--danger-color); }
.game-mode-card[data-mode="practice"] { border-top: 4px solid var(--secondary-color); }

.card-icon {
    width: 120px;
    height: 120px;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 60px;
    box-shadow: inset 0 5px 15px rgba(0,0,0,0.8), 0 10px 20px rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.05);
    position: relative;
    z-index: 2;
}

.game-mode-card h2 {
    font-size: 32px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    text-align: center;
    z-index: 2;
}

.game-mode-card p {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    line-height: 1.5;
    margin-bottom: 30px;
    flex: 1;
    z-index: 2;
}

.play-btn {
    background: var(--btn-gradient);
    color: #000;
    border: none;
    padding: 15px 40px;
    border-radius: 30px;
    font-size: 20px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    box-shadow: var(--btn-shadow);
    transition: all 0.2s;
    width: 100%;
    z-index: 2;
}

.play-btn:hover {
    background: var(--btn-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 255, 136, 0.6);
}

.play-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 10px rgba(0, 255, 136, 0.4);
}

.entry-fee {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0,0,0,0.8);
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 14px;
    font-weight: 800;
    color: var(--gold);
    border: 1px solid rgba(255,215,0,0.3);
    display: flex;
    align-items: center;
    gap: 5px;
    z-index: 2;
}

/* Minigames Specific Styles */
#scratch-canvas {
    border-radius: 10px;
    cursor: crosshair;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
    touch-action: none;
    background: #fff;
    margin: 20px auto;
    display: block;
}

.spin-wheel-container {
    position: relative;
    width: 300px;
    height: 300px;
    margin: 20px auto;
}

.spin-wheel {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(
        #f1c40f 0 45deg, #e67e22 45deg 90deg, 
        #e74c3c 90deg 135deg, #9b59b6 135deg 180deg, 
        #3498db 180deg 225deg, #1abc9c 225deg 270deg, 
        #2ecc71 270deg 315deg, #f39c12 315deg 360deg
    );
    border: 10px solid #222;
    box-shadow: 0 0 30px rgba(0,0,0,0.8), inset 0 0 20px rgba(0,0,0,0.5);
    transition: transform 3s cubic-bezier(0.25, 0.1, 0.25, 1);
    position: relative;
    overflow: hidden;
}

.spin-wheel-slice {
    position: absolute;
    width: 50%;
    height: 20px; /* Adjust height to center text vertically relative to the origin */
    top: calc(50% - 10px);
    left: 50%;
    transform-origin: 0% 50%;
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Text at the edge of the wheel */
    padding-right: 20px;
    font-weight: 900;
    font-size: 18px;
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    box-sizing: border-box;
    /* Adjust rotation based on index via inline styles */
}

.spin-wheel-pointer {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 0; 
    height: 0; 
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-top: 30px solid #fff;
    filter: drop-shadow(0 5px 5px rgba(0,0,0,0.5));
    z-index: 10;
}

#profile-rings::-webkit-scrollbar {
    height: 8px;
}
#profile-rings::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
}
#profile-rings::-webkit-scrollbar-thumb {
    background: rgba(255,215,0,0.5);
    border-radius: 4px;
}

/* Achievement Items */
.achievement-item {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 15px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s;
    text-align: left;
}

.achievement-item.unlocked {
    background: rgba(255, 215, 0, 0.1);
    border-color: var(--gold);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.2);
}

.achievement-item.unlocked .achievement-icon {
    filter: grayscale(0);
    opacity: 1;
    transform: scale(1.1);
}

.achievement-icon {
    font-size: 40px;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    filter: grayscale(1);
    opacity: 0.5;
    transition: all 0.3s;
}

.achievement-info h4 {
    color: var(--text-main);
    font-size: 18px;
    margin-bottom: 5px;
}

.achievement-item.unlocked .achievement-info h4 {
    color: var(--gold);
}

.achievement-info p {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.3;
}

/* Background graphics for cards */
.card-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    opacity: 0.1;
    background-image: repeating-linear-gradient(45deg, #fff 0, #fff 1px, transparent 1px, transparent 20px);
    z-index: 1;
    pointer-events: none;
}

/* Bottom Tab Bar */
.bottom-nav {
    background: var(--hud-bg);
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: center;
    padding: 15px 0;
    gap: 20px;
    z-index: 100;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
}

.nav-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid transparent;
    padding: 15px 30px;
    border-radius: 15px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    min-width: 100px;
}

.nav-btn i {
    font-size: 24px;
}

.nav-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.nav-btn.active {
    background: rgba(0, 229, 255, 0.1);
    border-color: rgba(0, 229, 255, 0.3);
    color: var(--secondary-color);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.2);
    transform: translateY(-5px);
}


/* =========================================
   GAME STYLES (game.html)
   ========================================= */

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #1a1e29 0%, #0a0c12 100%);
}

canvas {
    z-index: 1;
    /* High-fidelity table shadow */
    box-shadow: 
        0 50px 100px rgba(0,0,0,0.9), 
        0 20px 40px rgba(0,0,0,0.7),
        inset 0 0 150px rgba(0,0,0,0.8),
        0 0 0 4px #2c1b12, /* Inner wood rail */
        0 0 0 15px #4a2e1b, /* Outer wood rail */
        0 0 0 17px rgba(255,255,255,0.1); /* Rail highlight */
    background-color: #0b5e2c; /* Classic green felt */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="4" stitchTiles="stitch"/></filter><rect width="100" height="100" filter="url(%23noise)" opacity="0.05"/></svg>'); /* Procedural felt texture */
    border-radius: 10px; /* Slight rounding for the wood */
    cursor: crosshair;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Subtle room ambiance reflection on the screen */
body::after {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 40%, rgba(0,0,0,0.6) 100%);
    pointer-events: none;
    z-index: 50;
}

/* UI Layer over Canvas */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

/* Top Bar HUD (8 Ball Pool Style) */
#top-bar {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    max-width: 1200px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: auto;
}

.player-hud {
    display: flex;
    align-items: center;
    background: var(--bg-panel);
    border-radius: 50px;
    padding: 5px 25px 5px 5px;
    border: 1px solid var(--border-light);
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    transition: all 0.3s;
    position: relative;
    min-width: 250px;
}

.player-hud.p2 {
    flex-direction: row-reverse;
    padding: 5px 5px 5px 25px;
}

/* Active Turn Highlight */
.player-hud.active {
    background: rgba(30, 35, 50, 0.95);
    border-color: rgba(255,255,255,0.3);
}
.player-hud.active.p1 {
    box-shadow: 0 10px 30px rgba(0,0,0,0.6), 0 0 20px rgba(0, 229, 255, 0.3);
}
.player-hud.active.p2 {
    box-shadow: 0 10px 30px rgba(0,0,0,0.6), 0 0 20px rgba(255, 0, 85, 0.3);
}

/* Avatar Frame */
.hud-avatar {
    position: relative;
    width: var(--avatar-size);
    height: var(--avatar-size);
    border-radius: 50%;
    background: #111;
    border: 4px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 900;
    z-index: 2;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8), 0 5px 15px rgba(0,0,0,0.5);
    transition: border-color 0.3s;
}

.player-hud.active.p1 .hud-avatar { border-color: var(--secondary-color); }
.player-hud.active.p2 .hud-avatar { border-color: var(--danger-color); }

/* Turn Timer Ring */
.turn-timer {
    position: absolute;
    top: -6px;
    left: -6px;
    width: calc(var(--avatar-size) + 12px);
    height: calc(var(--avatar-size) + 12px);
    border-radius: 50%;
    border: 6px solid transparent;
    border-top-color: var(--primary-color);
    border-right-color: var(--primary-color);
    animation: spinTimer 15s linear forwards;
    opacity: 0;
    z-index: 1;
}
.player-hud.active .turn-timer { opacity: 1; }

@keyframes spinTimer {
    0% { transform: rotate(0deg); border-color: var(--primary-color); border-bottom-color: transparent; border-left-color: transparent; }
    50% { border-color: var(--warning-color); border-bottom-color: transparent; border-left-color: transparent; }
    100% { transform: rotate(360deg); border-color: var(--danger-color); border-bottom-color: transparent; border-left-color: transparent; }
}

.hud-info {
    display: flex;
    flex-direction: column;
    margin: 0 15px;
    flex: 1;
}

.player-hud.p2 .hud-info { text-align: right; }

.hud-name {
    font-size: 20px;
    font-weight: 800;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    margin-bottom: 2px;
}

.hud-status {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 600;
    background: rgba(0,0,0,0.5);
    padding: 2px 10px;
    border-radius: 10px;
    display: inline-block;
    align-self: flex-start;
}
.player-hud.p2 .hud-status { align-self: flex-end; }

.ball-container {
    display: flex;
    gap: 5px;
    margin-top: 8px;
    min-height: 20px;
}
.player-hud.p2 .ball-container { justify-content: flex-end; }

.mini-ball {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    box-shadow: inset -2px -2px 4px rgba(0,0,0,0.5), 1px 1px 3px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.2);
}

/* Center Score/Timer Display */
#score-board {
    font-size: 48px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3), 0 5px 15px rgba(0,0,0,0.8);
    background: var(--bg-panel);
    padding: 10px 40px;
    border-radius: 30px;
    border: 1px solid var(--border-light);
    box-shadow: 0 15px 30px rgba(0,0,0,0.6), inset 0 2px 5px rgba(255,255,255,0.1);
    backdrop-filter: var(--glass-blur);
    letter-spacing: 2px;
    align-self: flex-start;
    margin-top: 10px;
}

/* In-Game Buttons */
.icon-btn {
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    transition: all 0.2s;
    backdrop-filter: blur(5px);
}
.icon-btn:hover {
    background: rgba(255,255,255,0.1);
    transform: scale(1.1);
}
.icon-btn:active {
    transform: scale(0.95);
}

.floating-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    pointer-events: auto;
}

/* Power Bar Area (Vertical Right Side) */
#controls-layer {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    pointer-events: none;
}

.control-panel {
    background: var(--bg-panel);
    padding: 15px;
    border-radius: 20px;
    pointer-events: auto;
    border: 1px solid var(--border-light);
    box-shadow: 0 15px 30px rgba(0,0,0,0.6), inset 0 2px 5px rgba(255,255,255,0.05);
    backdrop-filter: var(--glass-blur);
    display: flex;
    flex-direction: column;
    align-items: center;
}

#power-bar-container {
    width: 40px;
    height: 350px;
    background: linear-gradient(to right, #111, #222, #111);
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    border: 2px solid #333;
    box-shadow: 
        inset 0 10px 20px rgba(0,0,0,0.9), 
        0 0 0 1px rgba(255,255,255,0.1),
        0 10px 20px rgba(0,0,0,0.5);
}

/* Metallic markers on power bar */
#power-bar-container::before {
    content: ''; position: absolute; top: 25%; left: 0; width: 100%; height: 2px; background: rgba(255,255,255,0.1); z-index: 2;
}
#power-bar-container::after {
    content: ''; position: absolute; top: 50%; left: 0; width: 100%; height: 2px; background: rgba(255,255,255,0.2); z-index: 2;
}
.marker-75 {
    position: absolute; top: 75%; left: 0; width: 100%; height: 2px; background: rgba(255,255,255,0.1); z-index: 2; pointer-events: none;
}

#power-bar {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(to top, #00e5ff, #00ff88 50%, #ffcc00 80%, #ff0055 100%);
    transition: height 0.05s ease-out;
    box-shadow: 0 0 20px rgba(255,255,255,0.3), inset 0 0 10px rgba(255,255,255,0.5);
    border-radius: 0 0 18px 18px;
}

.power-cue-icon {
    margin-bottom: 10px;
    font-size: 24px;
    color: var(--text-muted);
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

#fine-tune-aim {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

#fine-tune-aim button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #333, #111);
    border: 1px solid #444;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5), inset 0 2px 4px rgba(255,255,255,0.1);
}
#fine-tune-aim button:active {
    background: #000;
    box-shadow: inset 0 4px 8px rgba(0,0,0,0.8);
}

/* Indicators and Overlays */
.ball-in-hand-indicator {
    position: absolute;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: rgba(0, 229, 255, 0.1);
    padding: 15px 30px; 
    border-radius: 40px;
    border: 2px dashed var(--secondary-color);
    color: var(--secondary-color);
    font-weight: 800; text-transform: uppercase;
    letter-spacing: 2px; font-size: 24px;
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.2);
    animation: pulseGlow 1.5s infinite;
    pointer-events: none;
    display: none;
    text-shadow: 0 2px 5px rgba(0,0,0,0.8);
}
.ball-in-hand-indicator.active { display: block; }

@keyframes pulseGlow {
    0% { transform: translate(-50%, -50%) scale(1); box-shadow: 0 0 20px rgba(0, 229, 255, 0.2); }
    50% { transform: translate(-50%, -50%) scale(1.05); box-shadow: 0 0 40px rgba(0, 229, 255, 0.6); }
    100% { transform: translate(-50%, -50%) scale(1); box-shadow: 0 0 20px rgba(0, 229, 255, 0.2); }
}

#message-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: radial-gradient(circle, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 70%);
    width: 100%;
    padding: 80px 0;
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

#message-overlay.hidden {
    opacity: 0;
    transform: translate(-50%, -40%) scale(0.9);
}

#main-message {
    font-size: 90px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 6px;
    text-shadow: 
        4px 4px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000,
        0 10px 20px rgba(0,0,0,0.8);
    margin: 0;
    background: linear-gradient(to bottom, #ffffff, #a0a5b5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 20px rgba(255,255,255,0.3));
}

#sub-message {
    font-size: 32px;
    color: var(--warning-color);
    margin-top: 15px;
    font-weight: 800;
    text-shadow: 2px 2px 5px rgba(0,0,0,0.9);
    letter-spacing: 2px;
}

/* Modals (Menu, Options, Results) */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    pointer-events: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
    overflow: hidden;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

.menu-box {
    background: linear-gradient(180deg, #1e2233 0%, #141722 100%);
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 30px 60px rgba(0,0,0,0.9), inset 0 2px 5px rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 450px;
    border: 1px solid rgba(255,255,255,0.05);
    transform: translateY(100%);
    transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

.overlay.active .menu-box {
    transform: translateY(0);
}

/* Specific Sliding Directions based on overlay ID or class if needed */
/* Let's make the shop slide from the bottom, and profile from the left */
#shop-overlay .menu-box, #quests-overlay .menu-box, #achievements-overlay .menu-box, #minigames-overlay .menu-box, #powerups-menu .menu-box {
    transform: translateY(100vh);
    height: 85vh; /* Take up most of the screen like a mobile drawer */
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    align-self: flex-end; /* Align to bottom */
    width: 100%;
    max-width: 1200px; /* Cap width on large screens */
}

#powerups-menu .menu-box {
    height: auto; /* Power-ups doesn't need 85vh, just whatever it fits */
    max-width: 600px;
}

#shop-overlay.active .menu-box, #quests-overlay.active .menu-box, #achievements-overlay.active .menu-box, #minigames-overlay.active .menu-box, #powerups-menu.active .menu-box {
    transform: translateY(0);
}

#profile-overlay .menu-box {
    transform: translateX(-100vw);
    height: 100vh;
    border-radius: 0;
    align-self: flex-start;
    margin-right: auto;
}

#profile-overlay.active .menu-box {
    transform: translateX(0);
}


.menu-box h1, .menu-box h2 {
    font-size: 42px;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 0 5px 15px rgba(0,0,0,0.8);
    background: linear-gradient(to right, #ffffff, #a0a5b5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Animations */
@keyframes slideUpFadeIn {
    0% { transform: translateY(50px) scale(0.95); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes pulsePlayBtn {
    0% { transform: scale(1); box-shadow: var(--btn-shadow); }
    50% { transform: scale(1.05); box-shadow: 0 6px 25px rgba(0, 255, 136, 0.8); }
    100% { transform: scale(1); box-shadow: var(--btn-shadow); }
}

/* Note: Overlays are handled by transition now, removed animation slideUpFadeIn to avoid conflict */

.play-btn {
    animation: pulsePlayBtn 2s infinite ease-in-out;
}
.play-btn:hover {
    animation: none; /* Stop pulsing on hover so transition takes over */
    transform: translateY(-2px) scale(1.05);
}

/* Generic Button Style for Modals */
button {
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 15px 30px;
    border-radius: 15px;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

button:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.5), 0 0 15px rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.3);
}

button:active {
    transform: translateY(2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

button.primary {
    background: var(--btn-gradient);
    color: #000;
    border: none;
    box-shadow: var(--btn-shadow);
}
button.primary:hover {
    background: var(--btn-hover);
    box-shadow: 0 6px 20px rgba(0, 255, 136, 0.6);
}

button.danger {
    background: linear-gradient(135deg, #ff0055, #cc0044);
    color: #fff;
    border: none;
}
button.danger:hover {
    background: linear-gradient(135deg, #ff3377, #e6004c);
    box-shadow: 0 6px 20px rgba(255, 0, 85, 0.4);
}

/* Toast Notifications */
#toast-container {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 300;
    pointer-events: none;
}
.toast {
    background: linear-gradient(to right, rgba(30,35,50,0.95), rgba(15,20,30,0.95));
    color: white;
    padding: 15px 30px;
    border-radius: 12px;
    font-weight: 700;
    box-shadow: 0 15px 30px rgba(0,0,0,0.6);
    animation: slideDown 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, fadeOut 0.5s 3.5s forwards;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 1px solid rgba(255,255,255,0.1);
    border-left: 4px solid var(--primary-color);
    backdrop-filter: blur(10px);
}

@keyframes slideDown {
    0% { transform: translateY(-100px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}
@keyframes fadeOut {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-20px); }
}

/* Emotes Panel */
#emotes-panel {
    position: absolute;
    top: 90px;
    right: 20px;
    display: flex;
    gap: 8px;
    pointer-events: auto;
    background: var(--bg-panel);
    padding: 10px;
    border-radius: 15px;
    border: 1px solid var(--border-light);
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    backdrop-filter: var(--glass-blur);
}

.emote-btn {
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    font-size: 24px;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.emote-btn:hover {
    transform: scale(1.15) translateY(-5px);
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.3);
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
}

/* Customize Box (Shop) Modals */
.customize-box {
    width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    padding-right: 10px;
}
.customize-box::-webkit-scrollbar {
    width: 8px;
}
.customize-box::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
}
.customize-box::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}
.customize-section {
    margin-bottom: 30px;
    text-align: left;
}
.customize-section h3 {
    margin-bottom: 15px;
    color: var(--warning-color);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 5px;
    font-size: 20px;
}
.options-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}
.opt-btn {
    flex: 0 0 calc(33.333% - 10px);
    padding: 20px 10px;
    font-size: 14px;
    border: 2px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    position: relative;
    border-radius: 16px;
    transition: all 0.2s;
}
.opt-btn:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.3);
}
.opt-btn.selected {
    border-color: var(--secondary-color);
    background: rgba(0, 229, 255, 0.1);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.2), inset 0 0 10px rgba(0, 229, 255, 0.1);
}
.opt-btn.locked {
    opacity: 0.6;
    background: rgba(255,0,0,0.05);
    border-color: rgba(255,0,0,0.2);
    filter: grayscale(80%);
}
.opt-btn.locked::after {
    content: '🔒';
    position: absolute;
    top: -10px; right: -10px;
    font-size: 24px;
    background: rgba(0,0,0,0.8);
    border-radius: 50%;
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
}
.opt-price {
    font-size: 14px;
    color: var(--gold);
    font-weight: 800;
    background: rgba(0,0,0,0.8);
    padding: 4px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255,215,0,0.3);
    margin-top: auto;
}

/* Call Pocket UI */
.pocket-call-btn {
    position: absolute;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, rgba(255,204,0,0.3) 0%, rgba(255,204,0,0.8) 100%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: pointer;
    z-index: 100;
    animation: pulseCall 1s infinite alternate;
    border: 2px dashed #fff;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 900;
    text-shadow: 1px 1px 2px #000;
}
.pocket-call-btn:hover {
    background: radial-gradient(circle, rgba(255,204,0,0.6) 0%, rgba(255,204,0,1) 100%);
    transform: translate(-50%, -50%) scale(1.1);
}
@keyframes pulseCall {
    from { box-shadow: 0 0 10px rgba(255,204,0,0.5); }
    to { box-shadow: 0 0 30px rgba(255,204,0,1); }
}

/* Replay Controls */
.replay-controls {
    background: var(--bg-panel) !important;
    border-color: var(--secondary-color) !important;
    box-shadow: 0 0 30px rgba(0, 229, 255, 0.2) !important;
}
.replay-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}
.replay-btn {
    padding: 15px !important;
    font-size: 24px !important;
    border-radius: 50% !important;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.replay-speed.selected {
    background: var(--danger-color) !important;
    border-color: #ff3377 !important;
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.5) !important;
}

/* Minimap */
#minimap-container {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 200px;
    height: 100px;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.8);
    background: rgba(0,0,0,0.8);
    pointer-events: none;
    z-index: 15;
    overflow: hidden;
}
#minimap {
    width: 100%;
    height: 100%;
    box-shadow: none;
    border-radius: 0;
}

/* =========================================
   MEDIA QUERIES (Mobile Landscape / PWA)
   ========================================= */

@media (max-width: 950px), (max-height: 500px) {
    /* Scale down HUD variables */
    :root {
        --avatar-size: 50px;
    }

    /* Lobby Shrink */
    .top-nav {
        padding: 5px 15px;
    }
    .profile-section {
        gap: 5px;
        padding: 2px 10px 2px 2px;
    }
    .avatar-container {
        width: 40px; height: 40px; font-size: 16px;
    }
    .player-name-nav { font-size: 14px; }
    .currency-badge { padding: 4px 10px; font-size: 12px; }
    
    .main-content {
        padding: 10px calc(50vw - 120px);
        gap: 15px;
    }
    .game-mode-card {
        min-width: 240px;
        height: 300px;
        padding: 15px;
        border-radius: 15px;
    }
    .card-icon { width: 70px; height: 70px; font-size: 35px; margin-bottom: 10px; }
    .game-mode-card h2 { font-size: 20px; margin-bottom: 5px; }
    .game-mode-card p { font-size: 11px; margin-bottom: 15px; line-height: 1.2; }
    .play-btn { padding: 10px 20px; font-size: 14px; border-radius: 20px; }
    .entry-fee { top: 10px; right: 10px; padding: 3px 10px; font-size: 11px; }

    .bottom-nav {
        padding: 5px 0;
        gap: 5px;
    }
    .nav-btn {
        padding: 8px 15px;
        min-width: 70px;
        gap: 4px;
        font-size: 10px;
    }
    .nav-btn i { font-size: 18px; }

    /* Modals Shrink */
    .menu-box {
        min-width: 90%;
        max-width: 95%;
        padding: 20px;
        gap: 10px;
    }
    .menu-box h1, .menu-box h2 { font-size: 24px; margin-bottom: 10px; }
    button { padding: 10px 20px; font-size: 12px; }
    
    #shop-overlay .menu-box, #quests-overlay .menu-box, #achievements-overlay .menu-box, #minigames-overlay .menu-box {
        height: 90vh;
    }

    /* Game Scene Scaling */
    #top-bar { top: 5px; width: 98%; }
    .player-hud {
        min-width: 150px;
        padding: 2px 10px 2px 2px;
        border-radius: 30px;
    }
    .player-hud.p2 { padding: 2px 2px 2px 10px; }
    
    .hud-name { font-size: 14px; }
    .hud-status { font-size: 10px; padding: 1px 6px; }
    .mini-ball { width: 12px; height: 12px; }

    #score-board {
        font-size: 28px;
        padding: 5px 20px;
        border-radius: 20px;
        margin-top: 5px;
    }

    /* Game Controls (Power Bar & Icons) */
    .floating-btn, #btn-powerups {
        width: 40px; height: 40px; font-size: 16px;
    }
    .floating-btn { top: 10px; left: 10px; }
    #btn-powerups { top: 60px; left: 10px; }

    #controls-layer {
        right: 10px;
        gap: 10px;
    }
    .control-panel {
        padding: 10px;
        border-radius: 15px;
    }
    #power-bar-container {
        width: 30px;
        height: 200px;
    }
    .power-cue-icon { font-size: 18px; margin-bottom: 5px; }

    #fine-tune-aim button {
        width: 30px; height: 30px; font-size: 14px;
    }

    /* Minimap Shrink */
    #minimap-container {
        width: 140px; height: 70px;
        bottom: 10px; left: 10px;
        border-radius: 8px;
    }

    /* Main message */
    #main-message { font-size: 40px; letter-spacing: 2px; }
    #sub-message { font-size: 18px; }
    
    /* Emotes Panel */
    #emotes-panel {
        top: 60px; right: 80px; /* moved to avoid power bar overlap */
        padding: 5px;
    }
    .emote-btn { font-size: 18px; padding: 5px 8px; }
    
    /* Time Attack */
    #time-attack-timer {
        top: 60px; font-size: 24px; padding: 5px 15px; border-radius: 15px;
    }

    /* Options specific sizing */
    .opt-btn {
        flex: 0 0 calc(50% - 10px); /* 2 per row on small screens */
        padding: 10px 5px;
    }
    .opt-btn i { font-size: 24px !important; }
}

/* Ultra small landscape phones (e.g. iPhone SE landscape) */
@media (max-height: 380px) {
    #power-bar-container { height: 150px; }
    .avatar-container { width: 30px; height: 30px; font-size: 12px; }
    :root { --avatar-size: 40px; }
    #score-board { font-size: 20px; padding: 2px 10px; }
    .game-mode-card { height: 260px; }
    .card-icon { width: 50px; height: 50px; font-size: 25px; margin-bottom: 5px; }
}
