/* Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --cyan: #00f5ff;
    --pink: #ff2d78;
    --yellow: #ffe600;
    --green: #39ff14;
    --bg-color: #07080f;
    --hud-bg: rgba(0, 0, 0, 0.85);
    --hud-height: 60px;
    --ad-height: 0px;
}

html, body {
    overflow: hidden; /* Fix for ArcadeHub viewport */
    height: 100%;
    background-color: var(--bg-color);
    color: #fff;
    font-family: 'Exo 2', sans-serif;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

/* Layout Structure */
#game-root {
    display: flex;
    flex-direction: column;
    height: 100dvh; /* Standard fix */
    position: fixed;
    inset: 0;
}

/* HUD */
#hud {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    height: var(--hud-height);
    padding: 0 12px;
    background: rgba(0,0,0,0.85);
    border-bottom: 1px solid #00f5ff;
    box-shadow: 0 0 18px rgba(0,245,255,0.25);
    flex-shrink: 0;
    z-index: 100;
}

@media (max-width: 600px) {
    :root {
        --hud-height: 48px;
        --ad-height: 0px;
    }
    #hud {
        height: var(--hud-height);
        padding: 0 10px;
    }
}

.hud-left {
    display: flex;
    justify-content: flex-start;
}

.hud-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hud-right {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.score {
    font-family: 'Orbitron', monospace;
    font-size: 22px; /* 16px mobile */
    font-weight: 900;
    color: #ffe600;
    text-shadow: 0 0 10px #ffe600;
    line-height: 1;
}

.level-tag {
    font-size: 9px;
    color: #aaa;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 1px;
}

.lives {
    font-size: 14px;
    margin-bottom: 2px;
    letter-spacing: 2px;
    filter: drop-shadow(0 0 5px var(--pink));
}

.hud-btn {
    background: rgba(0, 245, 255, 0.1);
    border: 1px solid var(--cyan);
    color: var(--cyan);
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: bold;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 0 5px rgba(0, 245, 255, 0.3);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.hud-btn:hover {
    background: rgba(0, 245, 255, 0.3);
    box-shadow: 0 0 10px rgba(0, 245, 255, 0.6);
}

@media (max-width: 600px) {
    .hud-btn {
        padding: 4px 8px;
        font-size: 12px;
    }
    .score { font-size: 16px; }
}

/* Canvas Wrapper */
#canvas-wrap {
    flex: 1 1 0;
    position: relative;
    overflow: hidden;
    height: calc(100dvh - var(--hud-height) - var(--ad-height));
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Ad Banner */
#ad-banner {
    flex-shrink: 0;
    height: var(--ad-height);
    padding-bottom: env(safe-area-inset-bottom);
    background: #0a0a14;
    border-top: 1px solid #1a1a2e;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 600px) {
    #ad-banner { height: var(--ad-height); }
    #hud { height: var(--hud-height); }
}

.ad-placeholder-text {
    color: #555;
    font-size: 12px;
    letter-spacing: 2px;
}

/* Overlays */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(7, 8, 15, 0.93);
    z-index: 50;
    gap: 18px;
    text-align: center;
}

.hidden {
    display: none !important;
}

.game-title {
    font-family: 'Orbitron', monospace;
    font-size: 48px;
    font-weight: 700;
    background: linear-gradient(to right, var(--cyan), var(--pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(0, 245, 255, 0.5));
    animation: glowPulse 2s infinite alternate;
    margin-bottom: 10px;
}

@media (max-width: 600px) {
    .game-title { font-size: 32px; }
}

.subtitle {
    font-size: 18px;
    color: #ccc;
    margin-bottom: 40px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.controls-hint {
    background: rgba(0, 0, 0, 0.6);
    padding: 15px 25px;
    border-radius: 8px;
    border: 1px solid #333;
    margin-bottom: 40px;
    font-size: 14px;
    line-height: 1.6;
    color: #aaa;
}

.controls-hint b {
    color: var(--cyan);
}

.controls-hint i {
    color: var(--yellow);
    display: block;
    margin-top: 5px;
}

.action-btn {
    background: linear-gradient(45deg, rgba(0,245,255,0.2), rgba(255,45,120,0.2));
    border: 2px solid var(--cyan);
    color: #fff;
    font-family: 'Orbitron', monospace;
    font-size: 24px;
    font-weight: bold;
    padding: 15px 40px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(0, 245, 255, 0.3), inset 0 0 10px rgba(0, 245, 255, 0.2);
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.action-btn:hover {
    transform: scale(1.05);
    background: linear-gradient(45deg, rgba(0,245,255,0.4), rgba(255,45,120,0.4));
    box-shadow: 0 0 30px rgba(0, 245, 255, 0.6), inset 0 0 15px rgba(0, 245, 255, 0.4);
    text-shadow: 0 0 10px #fff;
}

.btn-hub-over {
    font-size: 18px;
    padding: 10px 30px;
    border-color: #888;
    text-decoration: none;
    margin-top: -5px;
}

.game-over-title {
    font-family: 'Orbitron', monospace;
    font-size: 42px;
    color: var(--pink);
    text-shadow: 0 0 15px var(--pink);
    margin-bottom: 10px;
}

.score-board {
    margin-bottom: 20px;
}

.score-board p {
    font-size: 16px;
    color: #888;
    letter-spacing: 2px;
}

#final-score {
    font-family: 'Orbitron', monospace;
    font-size: 56px;
    color: var(--yellow);
    text-shadow: 0 0 20px var(--yellow);
    margin: 5px 0 15px;
    line-height: 1;
}

#best-score {
    color: #fff;
    font-weight: bold;
}

.pause-title {
    font-family: 'Orbitron', monospace;
    font-size: 42px;
    color: var(--cyan);
    text-shadow: 0 0 15px var(--cyan);
    margin-bottom: 20px;
    letter-spacing: 4px;
}

/* Animations */
@keyframes glowPulse {
    0% { filter: drop-shadow(0 0 10px rgba(0, 245, 255, 0.5)); }
    100% { filter: drop-shadow(0 0 25px rgba(255, 45, 120, 0.8)); }
}

#combo-flash {
    position: absolute;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Orbitron', monospace;
    font-size: clamp(18px, 5vw, 30px);
    font-weight: 900;
    color: #ffe600;
    text-shadow: 0 0 14px #ffe600;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 40;
}

#combo-flash.active {
    opacity: 1;
    animation: popOut 0.5s ease-out;
}

@keyframes popOut {
    0% { transform: translateX(-50%) scale(0.5); opacity: 1; }
    50% { transform: translateX(-50%) scale(1.2); opacity: 1; }
    100% { transform: translateX(-50%) scale(1.5); opacity: 0; }
}

/* Share Buttons */
.share-buttons {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

.share-btn {
    padding: 10px 20px;
    font-family: 'Orbitron', monospace;
    font-size: 14px;
    font-weight: bold;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.share-btn:hover {
    transform: scale(1.05);
}

.wa-btn {
    background-color: #25D366;
    box-shadow: 0 0 10px rgba(37, 211, 102, 0.4);
}

.wa-btn:hover {
    box-shadow: 0 0 15px rgba(37, 211, 102, 0.8);
}

.x-btn {
    background-color: #000000;
    border: 1px solid #333;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.x-btn:hover {
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

/* Virtual Mobile Controls */
#mobile-controls {
    display: none;
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
    z-index: 100;
}

.v-btn {
    width: 65px;
    height: 65px;
    background: rgba(0, 245, 255, 0.15);
    border: 2px solid rgba(0, 245, 255, 0.4);
    border-radius: 50%;
    color: var(--cyan);
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    transition: all 0.1s;
    backdrop-filter: blur(4px);
}

.v-btn:active {
    background: rgba(0, 245, 255, 0.5);
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--cyan);
}

.v-btn-main {
    width: 80px;
    height: 80px;
    border-color: var(--pink);
    color: var(--pink);
    font-size: 36px;
}

.v-btn-main:active {
    background: rgba(255, 45, 120, 0.5);
    box-shadow: 0 0 20px var(--pink);
}

@media (max-width: 768px) {
    #mobile-controls {
        display: flex;
        align-items: flex-end;
    }
}
