* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    overflow: hidden;
    font-family: 'Nunito', 'Segoe UI', sans-serif;
    touch-action: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

img, a, button, div, span, p, h1, h2, h3 {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

canvas {
    display: block;
}

#ui {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#hud {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 15px;
    gap: 10px;
}

#left-hud, #right-hud {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#left-hud > div, #right-hud > div {
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 18px;
    border-radius: 14px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    font-size: 17px;
    font-weight: 700;
    color: #333;
}

#score {
    background: linear-gradient(135deg, #fff9c4, #fff176) !important;
    border: 2px solid #ffd54f;
}

#eggs-carried {
    transition: background 0.3s, color 0.3s;
}

#eggs-stored {
    background: linear-gradient(135deg, #c8e6c9, #a5d6a7) !important;
    border: 2px solid #81c784;
}

#center-hud {
    flex: 1;
    display: flex;
    justify-content: center;
}

#speed-indicator {
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 24px;
    border-radius: 14px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    text-align: center;
    min-width: 130px;
}

#speed-indicator span {
    font-size: 13px;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.speed-bar {
    width: 100%;
    height: 12px;
    background: #e0e0e0;
    border-radius: 6px;
    margin-top: 6px;
    overflow: hidden;
}

.speed-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #27ae60, #2ecc71);
    border-radius: 6px;
    transition: width 0.2s ease, background 0.3s ease;
}

#lives {
    font-size: 22px;
    text-align: right;
}

#mute-btn {
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid #ddd;
    padding: 8px 14px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 22px;
    transition: all 0.2s;
    pointer-events: auto;
}

#mute-btn:hover {
    background: #f0f0f0;
    transform: scale(1.05);
}

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

#bottom-hud {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
}

#corn-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: linear-gradient(135deg, #FFD54F, #FFC107);
    border: 4px solid #FF8F00;
    padding: 16px 32px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 20px;
    font-family: inherit;
    font-weight: 800;
    color: #5D4037;
    box-shadow: 0 6px 20px rgba(255,152,0,0.5);
    transition: all 0.2s;
    pointer-events: auto;
}

#corn-btn:hover:not(:disabled) {
    transform: scale(1.08);
    box-shadow: 0 8px 25px rgba(255,152,0,0.6);
}

#corn-btn:active:not(:disabled) {
    transform: scale(0.95);
}

#corn-btn:disabled {
    cursor: not-allowed;
    filter: grayscale(50%);
    opacity: 0.6;
}

#corn-count {
    background: rgba(255,255,255,0.9);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 18px;
    min-width: 30px;
    text-align: center;
}

#dropoff-hint {
    position: absolute;
    bottom: 160px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    padding: 16px 35px;
    border-radius: 25px;
    font-size: 20px;
    font-weight: 800;
    box-shadow: 0 6px 25px rgba(76,175,80,0.5);
    animation: bounce 0.5s infinite alternate;
}

@keyframes bounce {
    from { transform: translateX(-50%) translateY(0); }
    to { transform: translateX(-50%) translateY(-10px); }
}

#corn-notification {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: linear-gradient(135deg, #FFD54F, #FFC107);
    color: #5D4037;
    padding: 22px 40px;
    border-radius: 22px;
    font-size: 22px;
    font-weight: 800;
    box-shadow: 0 8px 35px rgba(255,152,0,0.5);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 100;
}

#corn-notification.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* Death explanation modal */
#death-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #fff, #fff5f5);
    padding: 35px 50px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 12px 50px rgba(0,0,0,0.35);
    pointer-events: auto;
    border: 4px solid #e57373;
    max-width: 90%;
    width: 380px;
    animation: modalAppear 0.3s ease-out;
}

@keyframes modalAppear {
    from {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

#death-modal .death-icon {
    font-size: 60px;
    margin-bottom: 10px;
}

#death-modal h2 {
    color: #c62828;
    margin-bottom: 18px;
    font-size: 28px;
    font-weight: 800;
}

#death-modal .death-reason {
    font-size: 18px;
    color: #555;
    margin-bottom: 12px;
    font-weight: 600;
}

#death-modal .death-tip {
    font-size: 16px;
    color: #2e7d32;
    background: rgba(76, 175, 80, 0.15);
    padding: 12px 18px;
    border-radius: 12px;
    margin-bottom: 18px;
    font-weight: 600;
}

#death-modal .lives-remaining {
    font-size: 20px;
    color: #e53935;
    margin-bottom: 20px;
    font-weight: 700;
}

#death-modal .lives-remaining span {
    font-size: 24px;
}

#continue-btn {
    background: linear-gradient(135deg, #42a5f5, #1e88e5);
    color: white;
    border: none;
    padding: 16px 45px;
    font-size: 20px;
    border-radius: 16px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 800;
    transition: all 0.2s;
    box-shadow: 0 6px 20px rgba(30,136,229,0.4);
}

#continue-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(30,136,229,0.5);
}

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

#game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #fff, #f8f8f8);
    padding: 45px 70px;
    border-radius: 28px;
    text-align: center;
    box-shadow: 0 12px 50px rgba(0,0,0,0.3);
    pointer-events: auto;
    border: 4px solid #e0e0e0;
}

#game-over h1 {
    color: #e74c3c;
    margin-bottom: 22px;
    font-size: 46px;
    font-weight: 800;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.1);
}

#game-over p {
    font-size: 24px;
    margin-bottom: 32px;
    color: #333;
    font-weight: 600;
}

#final-score {
    color: #27ae60;
    font-weight: 800;
}

#play-again {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    border: none;
    padding: 20px 55px;
    font-size: 24px;
    border-radius: 18px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 800;
    transition: all 0.2s;
    box-shadow: 0 6px 20px rgba(39,174,96,0.4);
}

#play-again:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 25px rgba(39,174,96,0.5);
}

#play-again:active {
    transform: scale(0.95);
}

#instructions {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 14px 28px;
    border-radius: 18px;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    max-width: 95%;
}

#instructions p {
    margin: 0;
}

.hidden {
    display: none !important;
}

/* Peacock tracker arrow */
#peacock-tracker {
    position: fixed;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    z-index: 50;
    transition: opacity 0.2s;
}

#peacock-arrow {
    font-size: 36px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    animation: pulse-warning 0.8s infinite alternate;
}

#peacock-distance {
    background: rgba(220, 20, 60, 0.9);
    color: white;
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    margin-top: 2px;
    white-space: nowrap;
}

@keyframes pulse-warning {
    from { transform: scale(1); }
    to { transform: scale(1.15); }
}

/* Mobile responsive */
@media (max-width: 768px) {
    #hud {
        padding: 8px;
        flex-wrap: nowrap;
        gap: 5px;
    }

    #left-hud, #right-hud {
        gap: 5px;
    }

    #left-hud > div, #right-hud > div {
        padding: 6px 10px;
        font-size: 13px;
        border-radius: 10px;
    }

    /* Hide speed indicator on mobile to save space */
    #center-hud {
        display: none;
    }

    #lives {
        font-size: 18px;
    }

    #mute-btn {
        padding: 6px 10px;
        font-size: 18px;
        border-radius: 10px;
    }

    #bottom-hud {
        bottom: 60px;
    }

    /* Bigger corn button for touch */
    #corn-btn {
        padding: 16px 28px;
        font-size: 18px;
        border-radius: 16px;
        min-height: 56px;
    }

    #corn-count {
        font-size: 16px;
        padding: 3px 10px;
    }

    #instructions {
        font-size: 11px;
        padding: 10px 15px;
        bottom: 8px;
        border-radius: 12px;
    }

    #death-modal {
        padding: 25px 30px;
        width: 90%;
        max-width: 340px;
    }

    #death-modal .death-icon {
        font-size: 48px;
    }

    #death-modal h2 {
        font-size: 22px;
        margin-bottom: 14px;
    }

    #death-modal .death-reason {
        font-size: 15px;
    }

    #death-modal .death-tip {
        font-size: 14px;
        padding: 10px 14px;
    }

    #death-modal .lives-remaining {
        font-size: 18px;
    }

    #continue-btn {
        padding: 14px 35px;
        font-size: 18px;
        min-height: 52px;
    }

    #game-over {
        padding: 30px 35px;
        width: 90%;
        max-width: 350px;
    }

    #game-over h1 {
        font-size: 32px;
        margin-bottom: 15px;
    }

    #game-over p {
        font-size: 18px;
        margin-bottom: 25px;
    }

    #play-again {
        padding: 16px 40px;
        font-size: 20px;
        min-height: 56px;
    }

    #dropoff-hint {
        bottom: 130px;
        font-size: 16px;
        padding: 12px 25px;
    }

    #corn-notification {
        font-size: 18px;
        padding: 18px 30px;
        top: 40%;
    }
}

/* Extra small screens */
@media (max-width: 400px) {
    #left-hud > div, #right-hud > div {
        padding: 5px 8px;
        font-size: 12px;
    }

    #corn-btn {
        padding: 14px 20px;
        font-size: 16px;
    }

    #instructions {
        font-size: 10px;
        padding: 8px 12px;
    }

    #death-modal {
        padding: 20px 20px;
    }

    #death-modal .death-icon {
        font-size: 40px;
    }

    #death-modal h2 {
        font-size: 20px;
    }

    #death-modal .death-reason {
        font-size: 14px;
    }

    #death-modal .death-tip {
        font-size: 13px;
    }

    #game-over {
        padding: 25px 25px;
    }

    #game-over h1 {
        font-size: 28px;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    #hud {
        padding: 5px 10px;
    }

    #left-hud > div, #right-hud > div {
        padding: 4px 8px;
        font-size: 12px;
    }

    #bottom-hud {
        bottom: 40px;
    }

    #corn-btn {
        padding: 10px 20px;
        font-size: 14px;
        min-height: 44px;
    }

    #instructions {
        display: none;
    }

    #dropoff-hint {
        bottom: 100px;
        font-size: 14px;
        padding: 10px 20px;
    }

    #death-modal {
        padding: 15px 25px;
        max-width: 450px;
    }

    #death-modal .death-icon {
        font-size: 36px;
        margin-bottom: 5px;
    }

    #death-modal h2 {
        font-size: 18px;
        margin-bottom: 8px;
    }

    #death-modal .death-reason {
        font-size: 13px;
        margin-bottom: 6px;
    }

    #death-modal .death-tip {
        font-size: 12px;
        padding: 6px 10px;
        margin-bottom: 8px;
    }

    #death-modal .lives-remaining {
        font-size: 14px;
        margin-bottom: 10px;
    }

    #continue-btn {
        padding: 10px 25px;
        font-size: 14px;
    }

    #game-over {
        padding: 20px 30px;
    }

    #game-over h1 {
        font-size: 24px;
        margin-bottom: 10px;
    }

    #game-over p {
        font-size: 14px;
        margin-bottom: 15px;
    }

    #play-again {
        padding: 12px 30px;
        font-size: 16px;
    }
}

/* Tap to Start Overlay */
#tap-to-start {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(46, 125, 50, 0.95), rgba(27, 94, 32, 0.95));
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    pointer-events: auto;
    cursor: pointer;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#tap-to-start.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.tap-content {
    text-align: center;
    color: white;
}

.tap-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: tap-bounce 1s ease-in-out infinite;
}

.tap-content h2 {
    font-size: 42px;
    font-weight: 800;
    margin-bottom: 10px;
    text-shadow: 3px 3px 0 rgba(0,0,0,0.2);
}

.tap-content p {
    font-size: 24px;
    margin-bottom: 30px;
    opacity: 0.9;
}

.tap-prompt {
    font-size: 20px;
    padding: 15px 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 30px;
    display: inline-block;
    animation: tap-pulse 1.5s ease-in-out infinite;
}

@keyframes tap-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

@keyframes tap-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}
