/* ========================================
   Pac-Man: MemoryPing Edition - Styles
   Retro 8-bit aesthetic for Telegram WebApp
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #0a0a0f;
    --wall-color: #1a1a2e;
    --pellet-color: #00ff88;
    --path-highlight: #ffff00;
    --ghost-color: #ff4444;
    --decay-flash: #ff6666;
    --score-color: #00ffff;
    --text-primary: #ffffff;
    --text-secondary: #888888;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
    font-family: 'Press Start 2P', monospace;
    color: var(--text-primary);
    touch-action: none;
    /* Prevent default touch behaviors */
    -webkit-user-select: none;
    user-select: none;
}

/* ========================================
   Game Container
   ======================================== */

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
}

#game-canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ========================================
   HUD - Score and Timer
   ======================================== */

#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10;
}

#score-display,
#timer-display {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hud-label {
    font-size: 8px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

#score-value {
    font-size: 16px;
    color: var(--score-color);
}

#timer-value {
    font-size: 16px;
    color: var(--path-highlight);
}

#mute-btn {
    background: transparent;
    border: 2px solid var(--text-secondary);
    border-radius: 8px;
    font-size: 18px;
    padding: 4px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#mute-btn:hover {
    border-color: var(--score-color);
    transform: scale(1.1);
}

#mute-btn:active {
    transform: scale(0.95);
}

/* ========================================
   Path Indicator (during memorization)
   ======================================== */

#path-indicator {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--path-highlight);
    color: var(--bg-dark);
    padding: 8px 16px;
    font-size: 10px;
    border-radius: 4px;
    z-index: 15;
    animation: pulse 0.5s ease-in-out infinite alternate;
}

#path-indicator.hidden {
    display: none;
}

#path-indicator.fade-out {
    opacity: 0;
    transition: opacity 300ms ease-out;
}

@keyframes pulse {
    from {
        transform: translateX(-50%) scale(1);
    }

    to {
        transform: translateX(-50%) scale(1.05);
    }
}

/* ========================================
   Overlay Screens
   ======================================== */

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 15, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#overlay.hidden {
    display: none;
}

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px;
}

.screen.hidden {
    display: none;
}

/* Ready Screen */
#ready-screen h1 {
    font-size: 28px;
    color: var(--path-highlight);
    margin-bottom: 8px;
    text-shadow: 0 0 10px var(--path-highlight);
}

#ready-screen h2 {
    font-size: 12px;
    color: var(--score-color);
    margin-bottom: 20px;
}

#hero-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    image-rendering: pixelated;
    animation: float 2s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.instruction {
    font-size: 10px;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

#start-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    padding: 15px 40px;
    background: var(--pellet-color);
    color: var(--bg-dark);
    border: none;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}

#start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px var(--pellet-color);
}

#start-btn:active {
    transform: scale(0.95);
}

/* Countdown Screen */
#countdown-screen {
    display: flex;
    align-items: center;
    justify-content: center;
}

#countdown-number {
    font-size: 80px;
    color: var(--path-highlight);
    text-shadow: 0 0 30px var(--path-highlight);
    animation: countPulse 1s ease-in-out infinite;
}

@keyframes countPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* End Screen */
#end-screen h1 {
    font-size: 24px;
    color: var(--ghost-color);
    margin-bottom: 30px;
    text-shadow: 0 0 15px var(--ghost-color);
}

#final-stats {
    margin-bottom: 20px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    width: 200px;
    margin-bottom: 12px;
}

.stat-label {
    font-size: 10px;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 12px;
    color: var(--score-color);
}

.sending-text {
    font-size: 8px;
    color: var(--text-secondary);
    animation: blink 1s infinite;
}

@keyframes blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0.3;
    }
}

/* ========================================
   Memory Decay Flash Effect
   ======================================== */

#game-canvas.decay-flash {
    filter: brightness(1.5) saturate(0.5);
    transition: filter 0ms;
}

/* ========================================
   Responsive adjustments
   ======================================== */

@media (max-height: 600px) {
    #ready-screen h1 {
        font-size: 22px;
    }

    #ready-screen h2 {
        font-size: 10px;
    }

    #hero-logo {
        width: 60px;
        height: 60px;
    }

    #start-btn {
        padding: 12px 30px;
        font-size: 12px;
    }
}