/* Pac-Man - Classic Arcade Game */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Nunito:wght@400;600;700&display=swap');

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

body {
    font-family: 'Nunito', sans-serif;
    background: #000;
    min-height: 100vh;
    color: #fff;
    overflow-x: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.game-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 10px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.back-btn {
    display: inline-block;
    color: #ffff00;
    text-decoration: none;
    font-weight: 600;
    margin-bottom: 10px;
    transition: color 0.3s;
}

.back-btn:hover {
    color: #fff;
}

/* Header */
.game-header {
    text-align: center;
    margin-bottom: 10px;
}

.game-header h1 {
    font-family: 'Press Start 2P', cursive;
    font-size: 2rem;
    color: #ffff00;
    text-shadow: 3px 3px 0 #ff0000;
    letter-spacing: 4px;
}

.stats-bar {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.stat-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 15px;
    border-radius: 10px;
    border: 2px solid #2121de;
}

.stat-label {
    color: #aaa;
    font-size: 0.7rem;
    margin-right: 5px;
}

.stat-item span:last-child {
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
}

.lives-display span:last-child {
    color: #ffff00;
    letter-spacing: 3px;
}

/* Screens */
.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

.screen.hidden {
    display: none;
}

/* Start Screen */
.pacman-art {
    margin-bottom: 20px;
}

.pacman-icon {
    width: 80px;
    height: 80px;
    background: #ffff00;
    border-radius: 50%;
    margin: 0 auto 15px;
    position: relative;
    animation: chomp 0.4s linear infinite;
}

.pacman-icon::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 35px;
    width: 10px;
    height: 10px;
    background: #000;
    border-radius: 50%;
}

@keyframes chomp {
    0%, 100% {
        clip-path: polygon(100% 50%, 50% 0%, 0% 0%, 0% 100%, 50% 100%);
    }
    50% {
        clip-path: polygon(100% 50%, 50% 25%, 0% 0%, 0% 100%, 50% 75%);
    }
}

.ghost-icons {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.ghost {
    width: 30px;
    height: 35px;
    border-radius: 15px 15px 0 0;
    position: relative;
    animation: float 1s ease-in-out infinite;
}

.ghost::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 8px;
    background: inherit;
    clip-path: polygon(0% 0%, 20% 100%, 40% 0%, 60% 100%, 80% 0%, 100% 100%, 100% 0%);
}

.ghost.red { background: #ff0000; animation-delay: 0s; }
.ghost.pink { background: #ffb8ff; animation-delay: 0.15s; }
.ghost.cyan { background: #00ffff; animation-delay: 0.3s; }
.ghost.orange { background: #ffb852; animation-delay: 0.45s; }

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

#startScreen h2 {
    font-size: 1.3rem;
    color: #00ffff;
    margin-bottom: 10px;
}

.instructions {
    color: #aaa;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

/* High Scores Panel */
.high-scores-panel {
    background: rgba(33, 33, 222, 0.3);
    border: 2px solid #2121de;
    border-radius: 10px;
    padding: 15px 25px;
    margin-bottom: 20px;
    min-width: 280px;
}

.high-scores-panel h3 {
    font-family: 'Press Start 2P', cursive;
    color: #ffff00;
    font-size: 0.8rem;
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.high-scores-panel ol {
    list-style: none;
    text-align: left;
}

.high-scores-panel li {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid rgba(33, 33, 222, 0.5);
    font-size: 0.85rem;
}

.high-scores-panel li:last-child {
    border-bottom: none;
}

.high-scores-panel .score-name {
    color: #00ffff;
}

.high-scores-panel .score-value {
    color: #ffff00;
    font-weight: 700;
}

/* Buttons */
.play-btn {
    background: linear-gradient(135deg, #2121de 0%, #1a1aaa 100%);
    color: #ffff00;
    border: 3px solid #ffff00;
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.3s;
    font-family: 'Press Start 2P', cursive;
}

.play-btn:hover {
    background: #ffff00;
    color: #2121de;
    transform: scale(1.05);
}

.play-btn:active {
    transform: scale(0.98);
}

.menu-btn {
    display: inline-block;
    background: transparent;
    color: #00ffff;
    border: 2px solid #00ffff;
    padding: 12px 25px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s;
    margin-left: 15px;
}

.menu-btn:hover {
    background: #00ffff;
    color: #000;
}

/* Game Canvas */
#gameScreen {
    padding: 0;
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#gameCanvas {
    display: block;
    border: 4px solid #2121de;
    border-radius: 5px;
    background: #000;
    touch-action: none;
    max-width: 100%;
    height: auto;
}

/* Touch Controls */
.touch-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 15px;
    gap: 5px;
}

.touch-row {
    display: flex;
    gap: 50px;
}

.touch-btn {
    width: 60px;
    height: 60px;
    background: rgba(33, 33, 222, 0.6);
    border: 3px solid #2121de;
    border-radius: 15px;
    color: #ffff00;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.touch-btn:active {
    background: #2121de;
    transform: scale(0.95);
}

/* Game Over Screen */
#gameOverTitle, #levelCompleteScreen h2 {
    font-family: 'Press Start 2P', cursive;
    font-size: 1.8rem;
    color: #ff0000;
    text-shadow: 2px 2px 0 #fff;
    margin-bottom: 25px;
}

#levelCompleteScreen h2 {
    color: #00ff00;
}

.level-message {
    font-size: 1.2rem;
    color: #ffff00;
    margin-bottom: 20px;
}

.final-stats {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.final-stat {
    background: rgba(33, 33, 222, 0.3);
    border: 2px solid #2121de;
    border-radius: 10px;
    padding: 15px 20px;
    min-width: 110px;
}

.final-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: #ffff00;
    font-family: 'Press Start 2P', cursive;
}

.final-label {
    display: block;
    font-size: 0.8rem;
    color: #aaa;
    margin-top: 5px;
}

/* New High Score */
.new-high-score {
    background: linear-gradient(135deg, rgba(255, 255, 0, 0.2) 0%, rgba(255, 0, 0, 0.2) 100%);
    border: 3px solid #ffff00;
    border-radius: 10px;
    padding: 20px 30px;
    margin-bottom: 25px;
    animation: blink 0.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { border-color: #ffff00; }
    50% { border-color: #ff0000; }
}

.new-high-score p {
    font-family: 'Press Start 2P', cursive;
    font-size: 1rem;
    color: #ffff00;
    margin-bottom: 15px;
}

.new-high-score input {
    background: #000;
    border: 2px solid #2121de;
    border-radius: 5px;
    padding: 10px 15px;
    color: #ffff00;
    font-size: 1rem;
    width: 180px;
    text-align: center;
    margin-right: 10px;
    font-family: 'Press Start 2P', cursive;
}

.new-high-score input::placeholder {
    color: #666;
    font-family: 'Nunito', sans-serif;
}

.save-btn {
    background: #ffff00;
    color: #000;
    border: none;
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.save-btn:hover {
    background: #fff;
    transform: translateY(-2px);
}

.game-over-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

/* Responsive */
@media (max-width: 500px) {
    .game-header h1 {
        font-size: 1.4rem;
    }

    .stats-bar {
        gap: 8px;
    }

    .stat-item {
        padding: 5px 10px;
        font-size: 0.85rem;
    }

    .pacman-icon {
        width: 60px;
        height: 60px;
    }

    .play-btn {
        padding: 12px 30px;
        font-size: 0.9rem;
    }

    .touch-btn {
        width: 55px;
        height: 55px;
        font-size: 1.3rem;
    }

    .touch-row {
        gap: 40px;
    }

    .final-stats {
        gap: 10px;
    }

    .final-stat {
        padding: 10px 15px;
        min-width: 90px;
    }

    .final-value {
        font-size: 1.3rem;
    }

    .game-over-buttons {
        flex-direction: column;
    }

    .menu-btn {
        margin-left: 0;
    }
}

/* Hide touch controls on desktop */
@media (min-width: 769px) {
    .touch-controls {
        display: none;
    }
}
