/* ============================================
   DRIVE MAD - Game Screen Styles
   ============================================ */

/* ============================================
   GAME SCREEN LAYOUT
   ============================================ */

#game-screen {
    background: #1a1a2e;
    display: none;
    flex-direction: column;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 10;
}

#game-screen.active {
    display: flex;
}

/* ============================================
   HUD
   ============================================ */

.hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 100%);
    pointer-events: none;
}

.hud-left,
.hud-center,
.hud-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hud-left {
    flex: 1 1 0;
    justify-content: flex-start;
}

.hud-center {
    flex: 1 1 0;
    justify-content: center;
}

.hud-right {
    flex: 1 1 0;
    justify-content: flex-end;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 4px 10px;
    backdrop-filter: blur(4px);
}

.hud-label {
    font-size: 0.55rem;
    color: rgba(255,255,255,0.5);
    letter-spacing: 2px;
    font-weight: 600;
    line-height: 1;
}

.hud-value {
    font-size: clamp(0.85rem, 2.5vw, 1.1rem);
    font-weight: 800;
    color: white;
    letter-spacing: 1px;
    line-height: 1.2;
}

.pause-btn {
    position: static;
    flex: 0 0 auto;
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    color: white;
    font-size: 1.1rem;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: all;
    transition: background 0.15s ease, transform 0.15s ease;
    backdrop-filter: blur(4px);
    -webkit-tap-highlight-color: transparent;
}

.pause-btn:hover {
    background: rgba(255,255,255,0.15);
}

.pause-btn:active {
    transform: scale(0.9);
}

/* ============================================
   CHECKPOINT INDICATOR
   ============================================ */

.checkpoint-indicator {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
    background: linear-gradient(135deg, rgba(6,214,160,0.9), rgba(6,180,130,0.9));
    border: 2px solid rgba(6,214,160,0.5);
    border-radius: 20px;
    padding: 8px 20px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: white;
    box-shadow: 0 4px 20px rgba(6,214,160,0.4);
    animation: slideDown 0.3s ease, fadeOut 0.5s ease 1.5s forwards;
    pointer-events: none;
}

/* ============================================
   CANVAS
   ============================================ */

#game-canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    position: absolute;
    inset: 0;
    touch-action: none;
}

/* ============================================
   TOUCH CONTROLS
   ============================================ */

.touch-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    pointer-events: none;
    /* Hidden by default — shown only on mobile via responsive.css */
    display: none;
}

.touch-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
    pointer-events: none;
}

.touch-btn {
    pointer-events: all;
    width: clamp(80px, 22vw, 120px);
    height: clamp(70px, 18vw, 100px);
    border-radius: 16px;
    border: 2px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(8px);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    transition: background 0.1s ease, border-color 0.1s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    user-select: none;
}

.touch-btn:active,
.touch-btn.pressed {
    background: rgba(255,107,53,0.35);
    border-color: rgba(255,107,53,0.7);
    transform: scale(0.95);
}

.touch-left {
    border-color: rgba(100,150,255,0.3);
}

.touch-jump {
    border-color: rgba(6,214,160,0.5);
    background: rgba(6,214,160,0.12);
    font-size: 1.1rem;
}

.touch-jump:active,
.touch-jump.active {
    background: rgba(6,214,160,0.35);
    border-color: rgba(6,214,160,0.8);
    transform: scale(0.93);
}

.touch-left:active,
.touch-left.pressed {
    background: rgba(100,150,255,0.25);
    border-color: rgba(100,150,255,0.7);
}

.touch-btn-icon {
    font-size: clamp(1.4rem, 5vw, 2rem);
    line-height: 1;
}

.touch-btn-label {
    font-size: clamp(0.55rem, 1.8vw, 0.7rem);
    font-weight: 700;
    letter-spacing: 1.5px;
    opacity: 0.7;
}

/* ============================================
   PAUSE MENU
   ============================================ */

#pause-menu .overlay-content {
    border-color: rgba(124,58,237,0.3);
}

#pause-menu .overlay-title {
    color: var(--color-accent2, #ffd166);
}

/* ============================================
   LEVEL COMPLETE
   Fits fully on screen — never needs scrolling.
   Every size is viewport-height aware so the
   whole popup scales down on short screens.
   ============================================ */

#level-complete {
    padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
    overflow: hidden;
}

#level-complete .overlay-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: min(420px, 100%);
    max-height: 100%;
    padding: clamp(10px, 2.4vh, 28px) clamp(12px, 4vw, 32px);
    border-color: rgba(6,214,160,0.3);
    /* safety net: if a screen is absurdly short it can still be scrolled,
       but the scrollbar itself stays hidden */
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#level-complete .overlay-content::-webkit-scrollbar {
    display: none;
}

#level-complete .complete-header {
    margin-bottom: 0;
}

#level-complete .complete-flag {
    font-size: clamp(1.4rem, 5vh, 2.5rem);
    line-height: 1;
    margin-bottom: clamp(2px, 0.8vh, 8px);
}

#level-complete .overlay-title {
    font-size: clamp(1.05rem, 4.2vh, 2.2rem);
    line-height: 1.15;
    margin-bottom: clamp(2px, 1vh, 12px);
    color: var(--color-accent, #06d6a0);
    text-shadow: 0 0 20px rgba(6,214,160,0.4);
}

#level-complete .complete-subtitle {
    font-size: clamp(0.7rem, 1.9vh, 1rem);
    line-height: 1.3;
}

#level-complete .complete-stats {
    gap: clamp(6px, 2vw, 20px);
    margin: clamp(6px, 1.6vh, 16px) 0;
}

#level-complete .stat-item {
    padding: clamp(5px, 1.2vh, 12px) clamp(8px, 2.4vw, 16px);
    min-width: clamp(56px, 20vw, 80px);
    gap: 2px;
}

#level-complete .stat-label {
    font-size: clamp(0.5rem, 1.3vh, 0.65rem);
    line-height: 1.2;
}

#level-complete .stat-value {
    font-size: clamp(0.9rem, 2.6vh, 1.4rem);
    line-height: 1.2;
}

#level-complete .star-rating {
    gap: 6px;
    margin: clamp(4px, 1vh, 12px) 0;
}

#level-complete .star {
    font-size: clamp(1.1rem, 3.6vh, 2.2rem);
    line-height: 1;
}

#level-complete .complete-bonuses {
    gap: clamp(3px, 0.6vh, 6px);
    margin: clamp(4px, 1vh, 10px) 0 0;
}

#level-complete .bonus-item {
    font-size: clamp(0.65rem, 1.7vh, 0.8rem);
    padding: clamp(2px, 0.5vh, 4px) 8px;
    line-height: 1.3;
}

#level-complete .overlay-buttons {
    gap: clamp(5px, 1.1vh, 10px);
    margin-top: clamp(8px, 2vh, 20px);
}

#level-complete .overlay-btn {
    padding: clamp(7px, 1.4vh, 13px) 16px;
    font-size: clamp(0.72rem, 1.9vh, 1rem);
    line-height: 1.2;
}

/* Very short screens (landscape phones) — tighten further */
@media (max-height: 430px) {
    #level-complete .overlay-content {
        padding: 8px 12px;
    }

    #level-complete {
        padding-top: max(8px, env(safe-area-inset-top));
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    #level-complete .complete-flag {
        display: none;
    }

    #level-complete .overlay-title {
        margin-bottom: 2px;
    }

    #level-complete .complete-stats {
        margin: 4px 0;
    }

    #level-complete .stat-item {
        padding: 4px 10px;
    }

    #level-complete .star-rating {
        margin: 2px 0;
    }

    #level-complete .complete-bonuses {
        gap: 3px;
    }

    #level-complete .bonus-item {
        padding: 2px 8px;
    }

    #level-complete .overlay-buttons {
        margin-top: 6px;
    }

    #level-complete .overlay-btn {
        padding: 5px 14px;
    }
}

/* ============================================
   CRASH SCREEN
   ============================================ */

#crash-screen .overlay-content {
    border-color: rgba(239,35,60,0.3);
}

/* ============================================
   ABILITIES (boost / super jump)
   ============================================ */

.ability-bar {
    position: absolute;
    right: max(14px, env(safe-area-inset-right));
    bottom: 150px;
    z-index: 55;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.ability-btn {
    pointer-events: all;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid var(--ability-color, #ffd166);
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(6px);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    cursor: pointer;
    opacity: 0.9;
    box-shadow: 0 0 14px 0 var(--ability-color, #ffd166);
    transition: transform 0.12s ease, opacity 0.2s ease, box-shadow 0.12s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    user-select: none;
    animation: abilityPulse 1.8s ease-in-out infinite;
}

.ability-btn .ability-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.ability-btn .ability-key {
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    opacity: 0.75;
    margin-top: 1px;
}

.ability-btn:active {
    transform: scale(0.88);
}

.ability-btn.spent {
    opacity: 0.3;
    filter: grayscale(1);
    box-shadow: none;
    cursor: default;
    animation: none;
}

@keyframes abilityPulse {
    0%, 100% { opacity: 0.78; }
    50% { opacity: 1; }
}

.speed-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.speed-overlay.active {
    opacity: 1;
}
