/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: 'Press Start 2P', monospace;
    color: #fff;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

/* ===== GAME WRAPPER ===== */
#game-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    padding: 4px;
}

/* ===== SCORE BOARD ===== */
#score-board {
    display: none;
}

.score-label {
    color: #fff;
    text-align: center;
    margin-bottom: 2px;
}

.score-value {
    color: #fff;
    text-align: center;
    font-size: 12px;
}

#score-section,
#highscore-section {
    text-align: center;
    flex: 1;
}

/* ===== SOUND TOGGLE ===== */
#sound-toggle {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    image-rendering: pixelated;
    background: rgba(0, 0, 0, 0.75);
    border: 2px solid #444;
    border-radius: 4px;
    z-index: 50;
}

/* ===== CANVAS ===== */
#game-canvas {
    display: block;
    background: #000;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ===== BOTTOM INFO ===== */
#bottom-info {
    display: none;
}

#lives-display {
    display: flex;
    gap: 4px;
}

.life-icon {
    width: 16px;
    height: 16px;
}

#fruit-display {
    display: flex;
    gap: 4px;
}

/* ===== TOUCH CONTROLS ===== */
#touch-controls {
    display: none;
    justify-content: center;
    align-items: center;
    padding: 8px 0;
    gap: 24px;
}

#flick-pad {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: rgba(255, 255, 0, 0.1);
    border: 2px solid rgba(255, 255, 0, 0.4);
    position: relative;
    touch-action: none;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

#flick-pad.active {
    background: rgba(255, 255, 0, 0.2);
}

.flick-arrow {
    position: absolute;
    color: rgba(255, 255, 0, 0.45);
    font-size: 20px;
    line-height: 1;
    transition: color 0.05s;
    pointer-events: none;
}

.flick-up    { top: 10px;    left: 50%; transform: translateX(-50%); }
.flick-down  { bottom: 10px; left: 50%; transform: translateX(-50%); }
.flick-left  { left: 10px;   top: 50%;  transform: translateY(-50%); }
.flick-right { right: 10px;  top: 50%;  transform: translateY(-50%); }

#flick-pad[data-dir="up"]    .flick-up    { color: #ffff00; }
#flick-pad[data-dir="down"]  .flick-down  { color: #ffff00; }
#flick-pad[data-dir="left"]  .flick-left  { color: #ffff00; }
#flick-pad[data-dir="right"] .flick-right { color: #ffff00; }

#flick-dot {
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 0, 0.55);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: transform 0.06s ease;
    pointer-events: none;
}

#flick-pad[data-dir="up"]    #flick-dot { transform: translate(-50%, calc(-50% - 38px)); }
#flick-pad[data-dir="down"]  #flick-dot { transform: translate(-50%, calc(-50% + 38px)); }
#flick-pad[data-dir="left"]  #flick-dot { transform: translate(calc(-50% - 38px), -50%); }
#flick-pad[data-dir="right"] #flick-dot { transform: translate(calc(-50% + 38px), -50%); }

/* ===== SPLASH ===== */
#splash-screen {
    background: #000;
    z-index: 200;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 8vw;
}

#splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.4em;
    text-align: center;
}

.splash-line {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(18px, 5vw, 18px);
    color: #fff;
    line-height: 2.2;
    opacity: 0;
    transition: opacity 1.2s ease;
    white-space: pre-wrap;
}

.splash-line.visible {
    opacity: 1;
}

@media (min-width: 768px) {
    .splash-line {
        font-size: clamp(14px, 2.2vw, 22px);
    }
}

/* ===== OVERLAYS ===== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    padding: 20px;
}

.pac-title {
    font-size: 42px;
    color: #ffff00;
    text-shadow: 0 0 20px rgba(255, 255, 0, 0.6),
        0 0 40px rgba(255, 255, 0, 0.3);
    margin-bottom: 30px;
    letter-spacing: 4px;
}

.pac-logo-anim {
    font-size: 28px;
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    overflow: hidden;
    position: relative;
}

.dot-trail {
    color: #ffb8ae;
    letter-spacing: 6px;
}

.pac-icon {
    image-rendering: pixelated;
    animation: truckDriveIn 1.5s ease-out forwards;
}

.ghost-icons {
    font-size: 30px;
    animation: ghostFloat 0.6s infinite alternate;
}

.start-instruction {
    font-size: 11px;
    color: #ffcc00;
    margin-bottom: 16px;
}

.controls-info {
    margin-top: 12px;
    color: #aaa;
}

.key-grid {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
}

.key-row {
    display: flex;
    gap: 4px;
}

.key-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    font-size: 14px;
    background: #333;
    border: 1px solid #666;
    border-bottom: 3px solid #555;
    border-radius: 4px;
    color: #ddd;
    font-family: sans-serif;
}

.controls-alt {
    font-size: 11px;
    color: #777;
    letter-spacing: 0.05em;
}

.game-over-title {
    font-size: 32px;
    color: #ff0000;
    text-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
    margin-bottom: 20px;
}

#final-score-text {
    font-size: 14px;
    color: #ffff00;
    margin-bottom: 24px;
}

/* ===== ANIMATIONS ===== */
@keyframes blink {

    0%,
    49% {
        opacity: 1;
    }

    50%,
    100% {
        opacity: 0;
    }
}

.blink {
    animation: blink 1s infinite;
}

@keyframes truckDriveIn {
    0% {
        transform: translateX(-300px);
    }

    100% {
        transform: translateX(0);
    }
}

@keyframes ghostFloat {
    0% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(-4px);
    }
}

/* ===== MOBILE ===== */
@media (pointer: coarse),
(max-width: 600px) {
    #touch-controls {
        display: flex;
    }
}

@media (max-width: 480px) {
    .pac-title {
        font-size: 28px;
    }

    .pac-logo-anim {
        font-size: 20px;
    }

    .pac-icon {
        font-size: 26px;
    }

    .start-instruction {
        font-size: 9px;
    }

    #score-board {
        font-size: 8px;
    }

    .score-value {
        font-size: 10px;
    }

    #flick-pad {
        width: 120px;
        height: 120px;
    }
}