/* RESET & BASE VARIABLES */
:root {
    --bg-dark: #0f172a;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --secondary: #ec4899;
    --secondary-hover: #db2777;
    --neon: #06b6d4;
    --wa-green: #25D366;
    --wa-green-hover: #128C7E;
    --text-main: #f8fafc;
    --glass-bg: rgba(15, 23, 42, 0.75);
    --glass-border: rgba(255, 255, 255, 0.1);
    
    --ticker-bg: #1e293b;
    --footer-bg: #0f172a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

input {
    user-select: auto;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    overflow: hidden; /* Prevent scrolling outside app */
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* TOP TICKER */
.ticker-wrapper {
    width: 100%;
    background-color: var(--ticker-bg);
    overflow: hidden;
    padding: 8px 0;
    border-bottom: 1px solid var(--glass-border);
    position: relative;
    z-index: 10;
}

.ticker-track {
    display: inline-flex;
    width: max-content;
    white-space: nowrap;
    animation: ticker linear 20s infinite;
}

.ticker-item {
    display: inline-block;
    padding: 0 30px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--neon);
    text-shadow: 0 0 5px rgba(6, 182, 212, 0.5);
}

@keyframes ticker {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* MAIN APP CONTAINER */
.app-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background-color: #000;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

/* HUD elements */
.hud {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 5;
    pointer-events: none;
}

.hud.hidden { display: none; }

#current-score {
    font-size: 3rem;
    font-weight: 900;
    text-shadow: 2px 4px 0px #000, 0 0 10px rgba(0,0,0,0.5);
    color: #fff;
}

.icon-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: #fff;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    transition: transform 0.2s;
}
.icon-btn:active { transform: scale(0.9); }

.sound-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 50;
}

/* OVERLAYS & GLASSMORPHISM */
.overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: block; /* Switch to block to prevent flexbox top-clipping */
    padding: 40px 20px 80px 20px; /* Top padding acts as centering, bottom padding protects from cutoffs */
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain; /* Prevents scroll chaining to body */
}
.overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.overlay.hidden { display: none !important; }

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* LANDING CONTENT */
.landing-content, .game-over-content {
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 25px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    margin: 0 auto; /* Horizontally center in the block container */
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.game-title {
    font-size: 2.5rem;
    line-height: 1.1;
    font-weight: 900;
}
.neon-text {
    color: var(--secondary);
    text-shadow: 0 0 10px rgba(236, 72, 153, 0.5);
    font-size: 1.8rem;
}

/* PLAYER SELECT */
.players-flex {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
}
.player-card {
    background: rgba(0,0,0,0.3);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 15px;
    min-width: 100px;
    cursor: pointer;
    transition: all 0.2s;
}
.player-card.active {
    border-color: var(--neon);
    background: rgba(6, 182, 212, 0.2);
    transform: scale(1.05);
}
.player-card img {
    width: 75px;
    height: 75px;
    object-fit: contain;
    display: block;
    margin: 0 auto 5px;
}
.player-card span { font-weight: 700; font-size: 1rem; }

/* PROMO CARD */
.promo-card {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(236, 72, 153, 0.1));
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 15px;
    text-align: left;
}
.promo-title { font-weight: 700; font-size: 1rem; margin-bottom: 5px; color: var(--neon); }
.promo-subtitle { font-size: 0.8rem; color: #cbd5e1; margin-bottom: 15px; }

.promo-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: stretch;
}
.promo-input[type="text"] {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: none;
    background: #0f172a;
    color: #fff;
    outline: none;
    font-size: 0.9rem;
    box-sizing: border-box; /* fix for mobile overflow overflow */
}
.promo-input-group input:focus { 
    border-color: var(--neon);
    background: rgba(0,0,0,0.8);
}

/* BUTTONS */
.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    color: #fff;
    text-align: center;
}
.btn:active { transform: scale(0.95); }

.btn-primary { background: var(--primary); box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4); }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: var(--secondary); box-shadow: 0 4px 15px rgba(236, 72, 153, 0.4); width: auto; padding: 0 20px; display: flex; align-items: center; justify-content: center; }
.btn-secondary:hover { background: var(--secondary-hover); }

.btn-insta { background: linear-gradient(45deg, #f09433 0%,#e6683c 25%,#dc2743 50%,#cc2366 75%,#bc1888 100%); font-size: 0.9rem; }
.btn-wa { background: var(--wa-green); box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4); }
.btn-wa:hover { background: var(--wa-green-hover); }

.pulse {
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(59,130,246, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 15px rgba(59,130,246, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(59,130,246, 0); }
}

/* GAME OVER SCORE BOX */
.score-display {
    display: flex;
    justify-content: center;
    gap: 20px;
}
.score-box {
    background: rgba(0,0,0,0.4);
    padding: 10px 20px;
    border-radius: 10px;
}
.score-box p { font-size: 0.8rem; color: #94a3b8; font-weight: 700; }
.score-box h3 { font-size: 2rem; color: var(--neon); }

/* LEADERBOARD (LOCKED) */
.leaderboard-container {
    position: relative;
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    padding: 15px;
    min-height: 150px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
}
.leaderboard-list {
    transition: filter 0.3s ease;
}
.leaderboard-list h4 { margin-bottom: 10px; color: var(--secondary); }
.leaderboard-list ul {
    list-style: none;
    text-align: left;
    font-size: 0.9rem;
}
.leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.lock-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2;
    padding: 20px;
    transition: opacity 0.3s;
}
.lock-overlay p { margin-bottom: 15px; font-weight: 700; font-size: 1.1rem; }
.locked .leaderboard-list { filter: blur(5px); }

/* FOOTER */
.bottom-footer {
    text-align: center;
    background-color: var(--footer-bg);
    border-top: 1px solid var(--glass-border);
    z-index: 10;
    padding-top: 15px;
}
.bottom-footer a { color: var(--neon); text-decoration: none; font-weight: 700; }
.footer-desc { font-size: 0.8rem; color: #64748b; margin-top: 5px; }

/* BOTTOM MERCURY TICKER */
.bottom-marquee {
    width: 100%;
    background-color: #f8fafc; /* Mercury White */
    color: #0f172a; /* Dark text */
    overflow: hidden;
    padding: 4px 0;
    position: relative;
    border-top: 1px solid #cbd5e1;
}
.bottom-marquee-track {
    display: inline-block;
    white-space: nowrap;
    animation: bottomTicker 20s linear infinite;
}
.bottom-marquee-track span {
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 1px;
    padding: 0 10px;
}
@keyframes bottomTicker {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* Responsive adjustments */
@media (max-width: 400px) {
    .promo-title { font-size: 0.9rem; }
    .game-title { font-size: 2rem; }
}
