:root {
    --neon-cyan: #00f3ff;
    --neon-magenta: #ff00ea;
    --neon-gold: #ffb700;
    --dark-bg: #030008;
    --tg-ui-top: 16px;
    --tg-ui-right: 8px;
}

html {
    height: 100%;
    height: -webkit-fill-available;
}
body {
    margin: 0; padding: 0; overflow: hidden;
    background-color: var(--dark-bg);
    font-family: 'Orbitron', sans-serif;
    touch-action: none; color: white; user-select: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    position: fixed;
    width: 100%;
    height: 100%;
    height: 100dvh;
}
canvas {
    display: block;
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.text-gradient-cyan { color: #fff; text-shadow: 0 0 10px rgba(0,243,255,0.8), 0 0 20px rgba(0,243,255,0.4); }
.text-gradient-magenta { color: #fff; text-shadow: 0 0 10px rgba(255,0,234,0.8), 0 0 20px rgba(255,0,234,0.4); }
.text-gradient-gold { color: #fff; text-shadow: 0 0 10px rgba(255,183,0,0.8), 0 0 20px rgba(255,183,0,0.4); }

.ui-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 20;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    box-sizing: border-box;
}

.btn {
    pointer-events: auto; position: relative; display: flex; align-items: center; justify-content: center; gap: 8px;
    background: rgba(10, 10, 15, 0.6); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 12px; padding: 14px 24px;
    font-weight: 800; text-transform: uppercase; letter-spacing: 0.15em;
    color: #fff; overflow: hidden; z-index: 1;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}
.btn::after {
    content: ''; position: absolute; bottom: 0; left: 0; width: 100%; height: 2px;
    background: rgba(255, 255, 255, 0.2); transition: all 0.3s ease; z-index: -1;
}
.btn:hover { border-color: rgba(255, 255, 255, 0.2); transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5); }
.btn:hover::after { height: 100%; opacity: 0.15; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; filter: grayscale(1); pointer-events: none; }

.btn-cyan { color: #fff; text-shadow: 0 0 8px rgba(0, 243, 255, 0.5); border-color: rgba(0, 243, 255, 0.2); }
.btn-cyan::after { background: var(--neon-cyan); }
.btn-cyan:hover { background: rgba(0, 243, 255, 0.05); border-color: var(--neon-cyan); box-shadow: 0 8px 20px rgba(0, 243, 255, 0.2); }

.btn-magenta { color: #fff; text-shadow: 0 0 8px rgba(255, 0, 234, 0.5); border-color: rgba(255, 0, 234, 0.2); }
.btn-magenta::after { background: var(--neon-magenta); }
.btn-magenta:hover { background: rgba(255, 0, 234, 0.05); border-color: var(--neon-magenta); box-shadow: 0 8px 20px rgba(255, 0, 234, 0.2); }

.btn-gold { color: #fff; text-shadow: 0 0 8px rgba(255, 183, 0, 0.5); border-color: rgba(255, 183, 0, 0.2); }
.btn-gold::after { background: var(--neon-gold); }
.btn-gold:hover { background: rgba(255, 183, 0, 0.05); border-color: var(--neon-gold); box-shadow: 0 8px 20px rgba(255, 183, 0, 0.2); }

.btn-ton { color: #fff; text-shadow: 0 0 8px rgba(56, 189, 248, 0.5); border-color: rgba(56, 189, 248, 0.2); }
.btn-ton::after { background: #38bdf8; }
.btn-ton:hover { background: rgba(56, 189, 248, 0.05); border-color: #38bdf8; box-shadow: 0 8px 20px rgba(56, 189, 248, 0.2); }

.btn-play-master {
    background: var(--neon-cyan); color: #000; border: none; border-radius: 12px;
    font-weight: 900; text-shadow: none; box-shadow: 0 0 20px rgba(0, 243, 255, 0.4);
}
.btn-play-master::after { display: none; }
.btn-play-master:hover {
    background: #fff; color: #000; letter-spacing: 0.25em;
    box-shadow: 0 0 40px rgba(0, 243, 255, 0.6), 0 0 20px rgba(255, 0, 234, 0.4);
    transform: scale(1.03);
}

.glass-panel {
    background: rgba(15, 15, 20, 0.25);
    backdrop-filter: blur(45px) saturate(150%); -webkit-backdrop-filter: blur(45px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-top: 1px solid rgba(255, 255, 255, 0.4);
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 24px; pointer-events: auto;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.9), inset 0 0 20px rgba(255, 255, 255, 0.1);
    animation: float 8s ease-in-out infinite;
}

.shop-card {
    background: rgba(255, 255, 255, 0.02); border: 1px solid rgba(255, 255, 255, 0.05); border-radius: 16px; padding: 16px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); cursor: pointer; position: relative; overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.shop-card::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: radial-gradient(circle at 50% 0%, rgba(255,255,255,0.1), transparent 70%); opacity: 0; transition: opacity 0.3s; z-index: 0; }
.shop-card > * { position: relative; z-index: 1; }
.shop-card:hover { border-color: rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.05); transform: translateY(-4px); box-shadow: 0 15px 30px rgba(0,0,0,0.5); }
.shop-card:hover::before { opacity: 1; }
.shop-card.selected { border-color: var(--neon-cyan); background: rgba(0, 243, 255, 0.05); box-shadow: 0 0 20px rgba(0, 243, 255, 0.2), inset 0 0 10px rgba(0, 243, 255, 0.05); }

.bg-grid { background-image: linear-gradient(rgba(0, 243, 255, 0.02) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 243, 255, 0.02) 1px, transparent 1px); background-size: 40px 40px; }

@keyframes float { 0%, 100% { transform: translateY(0px); } 50% { transform: translateY(-4px); } }
.no-scrollbar::-webkit-scrollbar { display: none; }

@keyframes overdrive-text { 0%, 100% { opacity: 1; transform: scale(1) skew(0deg); filter: hue-rotate(0deg); } 20% { transform: scale(1.1) skew(-10deg); filter: hue-rotate(90deg); } 40% { opacity: 0.8; transform: scale(1.05) skew(10deg); } 60% { transform: scale(1.2) skew(0deg); filter: hue-rotate(180deg); } 80% { opacity: 0.9; transform: scale(1.1) skew(-5deg); } }
.overdrive-alert { animation: overdrive-text 0.3s infinite; text-shadow: 4px 4px 0 var(--neon-magenta), -4px -4px 0 var(--neon-cyan); }
.hud-overdrive-active { box-shadow: inset 0 0 80px rgba(0, 243, 255, 0.15); animation: overdrive-bg 0.5s infinite alternate; }
@keyframes overdrive-bg { 0% { background: rgba(255, 255, 255, 0); } 100% { background: rgba(255, 0, 234, 0.05); } }

.podium-container { display: flex; align-items: flex-end; justify-content: center; gap: 12px; margin-bottom: 16px; height: 240px; padding-top: 96px; box-sizing: border-box; position: relative; overflow: visible; }
.podium { display: flex; flex-direction: column; align-items: center; width: 32%; position: relative; justify-content: flex-start; padding-top: 10px; transition: all 0.3s; }
.podium-1 { height: 100%; background: linear-gradient(to top, rgba(255, 183, 0, 0.05), rgba(255, 183, 0, 0.25)); border: 2px solid rgba(255, 183, 0, 0.6); border-bottom: none; box-shadow: 0 -15px 40px rgba(255, 183, 0, 0.2), inset 0 10px 20px rgba(255, 183, 0, 0.1); border-radius: 12px 12px 0 0; z-index: 3; }
.podium-2 { height: 75%; background: linear-gradient(to top, rgba(200, 200, 200, 0.05), rgba(200, 200, 200, 0.2)); border: 1px solid rgba(200, 200, 200, 0.5); border-bottom: none; border-radius: 8px 8px 0 0; box-shadow: 0 -10px 30px rgba(255,255,255,0.1); z-index: 2; }
.podium-3 { height: 60%; background: linear-gradient(to top, rgba(205, 127, 50, 0.05), rgba(205, 127, 50, 0.2)); border: 1px solid rgba(205, 127, 50, 0.5); border-bottom: none; border-radius: 8px 8px 0 0; box-shadow: 0 -10px 30px rgba(205, 127, 50, 0.1); z-index: 1; }

#payment-overlay {
    position: fixed;
    backdrop-filter: blur(15px);
    background: rgba(0,0,0,0.85);
    z-index: 200;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

#global-glass { transition: opacity 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); backdrop-filter: blur(60px) saturate(180%) brightness(0.45) contrast(1.1); -webkit-backdrop-filter: blur(60px) saturate(180%) brightness(0.45) contrast(1.1); }

#global-balances {
    top: var(--tg-ui-top) !important;
    right: var(--tg-ui-right) !important;
}

@keyframes welcome-in {
    0% { opacity: 0; transform: scale(0.8) translateY(30px); }
    50% { opacity: 1; transform: scale(1.02) translateY(-5px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

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

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

.animate-welcome-in { animation: welcome-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
.animate-float { animation: float 3s ease-in-out infinite; }
.animate-shimmer { 
    background-size: 200% 100%;
    animation: shimmer 3s linear infinite;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
#game-ui {
    padding-top: max(env(safe-area-inset-top), 8px) !important;
    padding-bottom: max(env(safe-area-inset-bottom), 16px) !important;
    overflow: visible;
}

/* menu-screen: no override — flex justify-center keeps it centred */

/* HUD: score/gems respect Telegram safe area so they don't hide behind header */
#hud {
    padding-top: max(calc(var(--tg-ui-top) + 8px), 28px) !important;
    position: fixed !important;
    top: 0 !important; left: 0 !important;
    width: 100% !important; height: 100% !important;
    z-index: 25;
}

/* Non-menu tall/scrollable screens start below the balance bar */
#difficulty-screen,
#skins-screen,
#maps-screen,
#shop-screen,
#exchange-screen,
#tasks-screen,
#gifts-screen,
#leaderboard-screen,
#wallet-screen,
#game-over-screen {
    margin-top: max(calc(var(--tg-ui-top) + 44px), 60px) !important;
    height: auto !important;
    max-height: calc(100dvh - max(calc(var(--tg-ui-top) + 44px), 60px) - 20px) !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
