@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;700;900&display=swap');

:root {
    --bg-color: #0f0f1a;
    --canvas-bg: #1a1a2e;
    --accent-color: #3b82f6;
    /* Blue */
    --accent-color-glow-strong: rgba(59, 130, 246, 0.4);
    --accent-color-glow-medium: rgba(59, 130, 246, 0.2);
    --accent-color-glow-weak: rgba(59, 130, 246, 0.1);
    --text-color: #ffffff;
    --ui-bg: rgba(22, 33, 62, 0.9);
}

body {
    margin: 0 auto;
    padding: 0;
    background: var(--bg-color);
    color: var(--text-color);
    font-family: 'Outfit', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    max-width: 1200px;
    /* padding-top removed */
}

/* #game-container styles now inherited from global #game-container in style.css */

canvas {
    background: linear-gradient(to bottom, #16213e, #1a1a2e);
    display: block;
    max-width: 100%;
    max-height: 100%;
}

/* Mobile responsive canvas - Full viewport */
@media (max-width: 768px) {
    canvas {
        width: 100vw !important;
        height: auto !important;
        max-width: 100vw;
        max-height: calc(100vh - 60px);
        /* Only account for header */
    }

    .game-container {
        position: relative;
        width: 100vw;
        height: calc(100vh - 60px);
        /* Full height minus header */
        margin: 0;
        padding: 0;
        display: block;
        justify-content: center;
        align-items: center;
    }

    body {
        max-width: 100vw;
        padding: 0;
        margin: 0;
        overflow: hidden;
    }
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#top-ui {
    display: flex;
    justify-content: space-between;
    padding: 20px;
}

#score {
    font-size: 32px;
    font-weight: 900;
    text-shadow: 3px 3px 0 #000;
    color: #fff;
}

#combo-container {
    text-align: right;
    transform: rotate(-5deg);
}

#combo-text {
    font-size: 24px;
    color: #ffd700;
    font-weight: bold;
    text-shadow: 2px 2px 0 #000;
}

#combo-value {
    font-size: 48px;
    font-weight: 900;
    color: #ff4d4d;
    text-shadow: 3px 3px 0 #000;
    line-height: 1;
}

#start-screen,
#game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    /* Higher z-index to ensure visibility above controllers */
    backdrop-filter: blur(5px);
    transition: opacity 0.3s ease;
    pointer-events: auto;
}

/* Ensure start button has good spacing and is clickable on mobile */
@media (max-width: 768px) {

    #start-screen button,
    #game-over-screen button {
        margin: 20px;
        padding: 18px 48px;
        font-size: 1.4rem;
        min-height: 60px;
        min-width: 200px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    #start-screen {
        padding: 40px 20px;
        box-sizing: border-box;
    }
}

.hidden {
    display: none !important;
}

h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 0 0 10px var(--accent-color);
    letter-spacing: 2px;
    text-align: center;
}

p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    color: #cbd5e1;
}

button {
    padding: 12px 32px;
    font-size: 1.2rem;
    font-weight: 600;
    color: #0f0f1a;
    background-color: var(--accent-color);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px var(--accent-color);
}

button:active {
    transform: translateY(0);
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
}

.key {
    background: #333;
    padding: 10px 15px;
    border-radius: 8px;
    border-bottom: 4px solid #111;
    font-weight: bold;
    font-family: monospace;
}

.key.space {
    padding: 10px 30px;
}

.blink {
    animation: blink 1s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.stats p {
    font-size: 24px;
    margin: 10px 0;
}

/* .top-bar styles moved to global style.css */

.stats-display {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 600;
}

.stats-display #username-display {
    color: var(--accent-color);
    font-weight: 700;
    transition: all 0.3s ease;
}


.stat-item {
    color: #94a3b8;
}

.stat-item span {
    color: #fff;
    font-weight: 700;
}

/* Game-specific styles below - button styles are now global */

.settings-placeholder {
    width: 40px;
    height: 40px;
    opacity: 0;
    pointer-events: none;
}

.score-display,
.combo-display {
    font-size: 1.5rem;
    font-weight: 700;
    text-shadow: 0 0 10px var(--accent-color);
}

.controls-legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 1rem;
    background-color: rgba(15, 23, 42, 0.9);
    border-top: 1px solid #334155;
    width: 100%;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #94a3b8;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.controls-legend .key {
    background-color: #334155;
    color: #f1f5f9;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.8rem;
    border-bottom: 2px solid #1e293b;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

/* ============================================
 * MOBILE/DESKTOP INSTRUCTION DISPLAY
 * ============================================ */

/* Show desktop instructions by default */
.desktop-instruction {
    display: block;
    text-align: center;
}

.mobile-instruction {
    display: none;
    text-align: center;
}

/* On mobile, show mobile instructions */
@media (max-width: 768px) {
    .desktop-instruction {
        display: none;
        text-align: center;
    }

    .mobile-instruction {
        display: block;
        text-align: center;
    }
}

/* ============================================
 * MOBILE CONTROLLER OVERLAY
 * ============================================ */

@media (max-width: 768px) {

    /* Override mobile controller to be overlay */
    .mobile-controls-layout {
        position: fixed !important;
        bottom: 30px !important;
        left: 15px !important;
        right: 15px !important;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        background: none !important;
        /* Remove background */
        border: none !important;
        /* Remove border */
        backdrop-filter: none !important;
        /* Remove backdrop filter */
        opacity: 0.7 !important;
        /* Set transparency */
        z-index: 1000;
        pointer-events: auto;
        display: none !important;
        /* Hidden by default */
        justify-content: space-between;
        align-items: flex-end;
        padding: 0 !important;
    }

    /* Show controller when game is running */
    .mobile-controls-layout.game-running {
        display: flex !important;
    }

    /* Left side action buttons */
    .mobile-left-controls {
        flex: none !important;
        border-right: none !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
    }

    /* Adjust button container to have proper spacing */
    .mobile-left-controls>div {
        display: flex !important;
        flex-direction: column !important;
        gap: 20px !important;
        /* Increase gap between buttons */
        align-items: center !important;
    }

    /* Right side D-pad */
    .mobile-dpad-container {
        flex: none !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
    }

    /* Make D-pad properly sized for overlay */
    .mobile-dpad {
        max-width: 120px !important;
        width: 120px !important;
        height: 120px !important;
    }

    /* Ensure D-pad base is properly contained */
    .dpad-base {
        width: 100% !important;
        height: 100% !important;
        position: relative !important;
    }

    /* D-pad buttons - make them more visible */
    .dpad-btn {
        width: 40px !important;
        height: 40px !important;
        font-size: 1rem !important;
        opacity: 1 !important;
        /* Ensure buttons are fully visible within the 0.7 container */
    }

    /* Action buttons - make them comfortable to tap */
    .mobile-pause-btn {
        width: 65px !important;
        height: 65px !important;
        font-size: 1.2rem !important;
        opacity: 1 !important;
        /* Ensure buttons are fully visible within the 0.7 container */
    }

    .mobile-pause-btn svg {
        width: 1.8rem !important;
        height: 1.8rem !important;
    }

    .dpad-btn svg {
        width: 1.2rem !important;
        height: 1.2rem !important;
    }

    /* Ensure proper button positioning within D-pad - spread out more */
    .dpad-btn.up {
        top: -20px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        height: 60px !important;
    }

    .dpad-btn.down {
        bottom: -20px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        height: 60px !important;
    }

    .dpad-btn.left {
        left: -20px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: 60px !important;
    }

    .dpad-btn.right {
        right: -20px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: 60px !important;
    }

    /* Fix active button transforms to maintain positioning */
    .dpad-btn.up.active,
    .dpad-btn.up:active {
        transform: translateX(-50%) scale(0.95) !important;
    }

    .dpad-btn.down.active,
    .dpad-btn.down:active {
        transform: translateX(-50%) scale(0.95) !important;
    }

    .dpad-btn.left.active,
    .dpad-btn.left:active {
        transform: translateY(-50%) scale(0.95) !important;
    }

    .dpad-btn.right.active,
    .dpad-btn.right:active {
        transform: translateY(-50%) scale(0.95) !important;
    }
}

@media (max-width: 480px) {
    .mobile-left-controls {
        flex-direction: row !important;
    }

    .mobile-dpad-container {
        padding-right: 20px !important;
    }
}