/* PAC-MAN PAGE STYLES */

:root {
    --pacman-body: #FFCC00;
    --ghost-blinky: #FF0000;
    --ghost-pinky: #FFB8FF;
    --ghost-inky: #00FFFF;
    --ghost-clyde: #FFB847;
    --ghost-frightened: #2121DE;
    --ghost-eyes: #FFFFFF;
    --maze-wall: #2121DE;
    --pellet: #FFB897;
    --power-pellet: #FFB897;
    --pacman-grid: rgba(0, 0, 0, 0.03);
}

/* Page Container */
.pacman-page {
    max-width: 100vw;
    margin: 0 auto;
    padding: 0.5rem;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden;
}

/* Header */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}

.game-header .logo-link {
    display: block;
    width: 80px;
    transition: opacity 0.2s ease;
}

.game-header .logo-link:hover {
    opacity: 0.6;
    animation: none;
}

.game-header .logo-link svg {
    width: 100%;
    height: auto;
}

.game-header h1 {
    font-family: "GT Alpina", Times, serif;
    font-size: 1.25rem;
    font-weight: 300;
    visibility: visible;
    width: auto;
    height: auto;
    text-indent: 0;
    text-overflow: clip;
    padding: 0;
}

/* Game Wrapper */
.game-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    min-height: 0;
}

/* Board Container */
.board-container {
    position: relative;
    height: 100%;
    max-height: calc(100vh - 220px);
    aspect-ratio: 1 / 1;
    width: min(90vw, 480px);
}

/* Game Board - 21x21 grid */
.game-board {
    display: grid;
    grid-template-columns: repeat(21, 1fr);
    grid-template-rows: repeat(21, 1fr);
    width: 100%;
    height: 100%;
    border: 2px solid var(--color-content-primary);
    background: #000;
}

.game-board .cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Maze Walls */
.cell.wall {
    background-color: var(--maze-wall);
    border-radius: 2px;
}

/* Empty path (including ghost house) */
.cell.path,
.cell.ghost-house {
    background-color: #000;
}

/* Pellets */
.cell.pellet::after {
    content: '';
    width: 20%;
    height: 20%;
    background-color: var(--pellet);
    border-radius: 50%;
}

/* Power Pellets */
.cell.power-pellet::after {
    content: '';
    width: 60%;
    height: 60%;
    background-color: var(--power-pellet);
    border-radius: 50%;
    animation: pulse 0.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.7); opacity: 0.6; }
}

/* Pac-Man */
.cell.pacman::after {
    content: '';
    width: 80%;
    height: 80%;
    background: conic-gradient(var(--pacman-body) 0deg 70deg, transparent 70deg 110deg, var(--pacman-body) 110deg 360deg);
    border-radius: 50%;
    position: absolute;
    transform: rotate(var(--pacman-rotation, 0deg));
    animation: chomp 0.2s linear infinite;
}

.cell.pacman.dir-right { --pacman-rotation: 0deg; }
.cell.pacman.dir-left { --pacman-rotation: 180deg; }
.cell.pacman.dir-up { --pacman-rotation: -90deg; }
.cell.pacman.dir-down { --pacman-rotation: 90deg; }

@keyframes chomp {
    0%, 100% { background: conic-gradient(var(--pacman-body) 0deg 75deg, transparent 75deg 105deg, var(--pacman-body) 105deg 360deg); }
    50% { background: conic-gradient(var(--pacman-body) 0deg 60deg, transparent 60deg 120deg, var(--pacman-body) 120deg 360deg); }
}

/* Ghosts */
.cell.ghost::after {
    content: '';
    width: 80%;
    height: 80%;
    border-radius: 50% 50% 0 0;
    position: absolute;
    clip-path: polygon(0% 0%, 0% 85%, 15% 100%, 30% 85%, 50% 100%, 70% 85%, 85% 100%, 100% 85%, 100% 0%);
}

.cell.ghost.blinky::after { background-color: var(--ghost-blinky); }
.cell.ghost.pinky::after { background-color: var(--ghost-pinky); }
.cell.ghost.inky::after { background-color: var(--ghost-inky); }
.cell.ghost.clyde::after { background-color: var(--ghost-clyde); }

.cell.ghost.frightened::after {
    background-color: var(--ghost-frightened);
    animation: ghost-flash 0.3s ease-in-out infinite;
}

.cell.ghost.frightened.ending::after {
    animation: ghost-flash-warning 0.2s ease-in-out infinite;
}

@keyframes ghost-flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes ghost-flash-warning {
    0%, 100% { background-color: var(--ghost-frightened); }
    50% { background-color: #FFFFFF; }
}

/* Ghost eyes (eaten state) */
.cell.ghost.eaten::after {
    background-color: transparent;
    width: 60%;
    height: 40%;
    border-radius: 0;
    clip-path: none;
}

.cell.ghost.eaten::before {
    content: '';
    position: absolute;
    width: 50%;
    height: 30%;
    background: radial-gradient(circle at 30% 50%, var(--ghost-eyes) 30%, #000 32%, #000 50%, transparent 52%),
                radial-gradient(circle at 70% 50%, var(--ghost-eyes) 30%, #000 32%, #000 50%, transparent 52%);
}

/* Game Overlay */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.2s ease;
    touch-action: auto;
}

.game-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    color: #fff;
}

.overlay-content h2 {
    font-family: "GT Alpina", Times, serif;
    font-size: 1.5rem;
    font-weight: 300;
    margin-bottom: 0.5rem;
    padding: 0;
}

.overlay-content p {
    font-family: "GT Alpina Typewriter", Courier, monospace;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.031rem;
    margin-bottom: 1rem;
    opacity: 0.7;
    padding: 0;
}

/* Game Button */
.game-btn {
    font-family: "GT Alpina Typewriter", Courier, monospace;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.031rem;
    padding: 0.75rem 1.5rem;
    border: 1px solid #fff;
    background: transparent;
    color: #fff;
    cursor: crosshair;
    transition: all 0.15s ease;
    touch-action: manipulation;
}

.game-btn:hover {
    background: #fff;
    color: #000;
}

/* Stats Panel */
.stats-panel {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--color-content-primary);
    border-bottom: 1px solid var(--color-content-primary);
    opacity: 0.15;
    flex-shrink: 0;
}

.stats-panel .stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.stats-panel small {
    font-family: "GT Alpina Typewriter", Courier, monospace;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.031rem;
    opacity: 0.5;
}

.stats-panel span {
    font-family: "GT Alpina Typewriter", Courier, monospace;
    font-size: 1rem;
}

/* Controls Info */
.controls-info {
    margin-top: 0.5rem;
    text-align: center;
    flex-shrink: 0;
}

.controls-info small {
    opacity: 0.4;
    font-size: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.mobile-only {
    display: none;
}

/* Music Toggle */
.music-toggle-wrapper {
    display: inline-flex;
    align-items: center;
}

.music-toggle {
    font-family: "GT Alpina Typewriter", Courier, monospace;
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--color-content-primary);
    background: transparent;
    color: var(--color-content-primary);
    cursor: crosshair;
    transition: all 0.15s ease;
    opacity: 0.3;
    line-height: 1;
}

.music-toggle:hover {
    opacity: 0.6;
}

.music-toggle.active {
    opacity: 1;
    background: var(--color-content-primary);
    color: var(--color-surface-primary);
}

/* Mobile Responsive */
@media screen and (max-width: 600px) {
    .pacman-page {
        padding: 0.5rem;
    }

    .game-header {
        margin-bottom: 0.5rem;
    }

    .game-header .logo-link {
        width: 50px;
    }

    .game-header h1 {
        font-size: 0.9rem;
    }

    .board-container {
        max-height: calc(100dvh - 180px);
        width: min(92vw, 420px);
    }

    .stats-panel {
        gap: 0.75rem;
        margin-top: 0.5rem;
        padding: 0.5rem 0;
    }

    .stats-panel small {
        font-size: 0.5rem;
    }

    .stats-panel span {
        font-size: 0.8rem;
    }

    .desktop-only {
        display: none;
    }

    .mobile-only {
        display: inline;
    }
}

@media screen and (max-width: 360px) {
    .board-container {
        max-height: calc(100dvh - 160px);
        width: min(94vw, 360px);
    }
}
