/* ===== Reset & Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Press+Start+2P&family=Righteous&display=swap');

html, body {
    width: 100%;
    height: 100%;
    font-family: 'Righteous', 'Orbitron', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 100vh;
    letter-spacing: 0.05em;
}

/* ===== Game Wrapper ===== */
.game-wrapper {
    position: relative;
    width: 800px;
    height: 600px;
    background: linear-gradient(to bottom, #87ceeb, #e0f6ff);
    border: 4px solid #333;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    margin: 20px 0;
    flex-shrink: 0;
}

/* ===== Canvas ===== */
#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, #87ceeb 0%, #e0f6ff 100%);
}

/* ===== Game UI Overlay ===== */
.game-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* ===== Score Board ===== */
.score-board {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 10;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.95) 0%, rgba(255, 165, 0, 0.95) 100%);
    padding: 12px 18px;
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5), 0 4px 10px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.8);
}

.score-item .label {
    font-weight: 700;
    color: #333;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.score-item .value {
    font-size: 24px;
    font-weight: 900;
    color: #ff6b35;
    min-width: 60px;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
}

/* ===== Mute Button ===== */
.mute-btn {
    position: absolute;
    bottom: 15px;
    right: 15px;
    z-index: 11;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #667eea;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 22px;
    transition: all 0.3s ease;
    pointer-events: auto;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.mute-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

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

.mute-btn.muted {
    background: rgba(255, 100, 100, 0.9);
    border-color: #ff6b6b;
}

.mute-icon {
    display: inline-block;
    line-height: 1;
}

/* ===== Start Screen ===== */
.start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    pointer-events: auto;
}

.start-content {
    text-align: center;
    color: white;
    animation: slideIn 0.5s ease-out;
}

.start-content h1 {
    font-size: 56px;
    margin-bottom: 10px;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 3px 3px 10px rgba(0, 0, 0, 0.7);
    font-weight: 900;
    letter-spacing: 0.1em;
    color: #ffd700;
}

.start-content h2 {
    font-size: 42px;
    margin-bottom: 30px;
    color: #ffff00;
    text-shadow: 0 0 15px rgba(255, 255, 0, 0.6), 2px 2px 8px rgba(0, 0, 0, 0.7);
    font-weight: 700;
    letter-spacing: 0.08em;
}

.instructions {
    margin: 30px 0;
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 10px;
    font-size: 16px;
    line-height: 1.8;
}

.instructions p {
    margin: 10px 0;
}

.instructions strong {
    color: #ffd700;
}

/* ===== Topping Selection ===== */
.topping-selection {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 30px 0;
    padding: 0 20px;
}

.topping-option {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    pointer-events: auto;
}

.topping-option:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.topping-option.selected {
    background: rgba(255, 215, 0, 0.3);
    border-color: #ffd700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.topping-icon {
    font-size: 48px;
    margin-bottom: 10px;
    animation: bounce 2s infinite;
}

.topping-option:nth-child(2) .topping-icon {
    animation-delay: 0.2s;
}

.topping-option:nth-child(3) .topping-icon {
    animation-delay: 0.4s;
}

.topping-option p {
    font-size: 16px;
    font-weight: bold;
    margin: 0;
}

/* ===== Game Over Screen ===== */
.game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(135deg, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.85) 100%),
        url('assets/game-over/mie-kena-sambal.png') center/contain no-repeat;
    background-attachment: fixed;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    pointer-events: auto;
}

.game-over-screen.show {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

.game-over-content {
    text-align: center;
    color: white;
    animation: popIn 0.5s ease-out;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
}


.game-over-content h1 {
    font-size: 64px;
    margin-bottom: 20px;
    color: #ff4444;
    text-shadow: 0 0 20px rgba(255, 68, 68, 0.8), 3px 3px 10px rgba(0, 0, 0, 0.7);
    font-weight: 900;
    letter-spacing: 0.1em;
}

.game-over-score,
.game-over-high-score {
    font-size: 28px;
    margin: 15px 0;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5), 2px 2px 5px rgba(0, 0, 0, 0.5);
    font-weight: 700;
}

.game-over-score span,
.game-over-high-score span {
    color: #ffd700;
    font-weight: bold;
}

/* ===== Buttons ===== */
.btn-start,
.btn-restart {
    margin-top: 30px;
    padding: 18px 50px;
    font-size: 22px;
    font-weight: 900;
    color: white;
    background: linear-gradient(135deg, #ff6b35 0%, #ff8c5a 100%);
    border: 3px solid #ffff00;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.8), 0 6px 20px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
    pointer-events: auto;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.btn-start:hover,
.btn-restart:hover {
    transform: translateY(-4px);
    box-shadow: 0 0 30px rgba(255, 107, 53, 1), 0 10px 25px rgba(0, 0, 0, 0.5);
}

.btn-start:active,
.btn-restart:active {
    transform: translateY(-1px);
}

/* ===== Animations ===== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fall {
    from {
        transform: translateY(-50px) rotateZ(0deg);
        opacity: 1;
    }
    to {
        transform: translateY(650px) rotateZ(360deg);
        opacity: 1;
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

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

/* ===== Responsive Design ===== */

/* Tablet & smaller desktop (768px to 1024px) */
@media (max-width: 1024px) {
    .game-wrapper {
        width: 90vw;
        height: 67.5vw;
        max-width: 800px;
        max-height: 600px;
    }

    .topping-selection {
        gap: 15px;
        padding: 0 10px;
    }

    .topping-option {
        padding: 15px;
    }

    .topping-icon {
        font-size: 40px;
    }
}

/* Small devices (max 768px) */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .game-wrapper {
        width: 100vw;
        max-width: 100%;
        height: 75vw;
        max-height: 85vh;
        border: 3px solid #333;
    }

    #gameCanvas {
        width: 100%;
        height: 100%;
    }

    .start-content {
        padding: 20px;
    }

    .start-content h1 {
        font-size: 42px;
        margin-bottom: 8px;
        text-shadow: 0 0 18px rgba(255, 215, 0, 0.7), 2px 2px 8px rgba(0, 0, 0, 0.7);
    }

    .start-content h2 {
        font-size: 32px;
        margin-bottom: 20px;
        text-shadow: 0 0 12px rgba(255, 255, 0, 0.5), 2px 2px 6px rgba(0, 0, 0, 0.7);
    }

    .instructions {
        font-size: 13px;
        padding: 15px;
        margin: 15px 0;
    }

    .topping-selection {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
        margin: 20px 0;
        padding: 0 10px;
    }

    .topping-option {
        padding: 12px 8px;
        border-radius: 10px;
    }

    .topping-icon {
        font-size: 36px;
        margin-bottom: 8px;
    }

    .topping-option p {
        font-size: 12px;
    }

    .score-board {
        top: 10px;
        left: 10px;
        right: 10px;
        gap: 10px;
    }

    .score-item {
        padding: 8px 12px;
        font-size: 12px;
    }

    .score-item .label {
        font-size: 11px;
    }

    .score-item .value {
        font-size: 16px;
        min-width: 40px;
    }

    .mute-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
        bottom: 10px;
        right: 10px;
    }

    .game-over-content h1 {
        font-size: 38px;
        margin-bottom: 12px;
        margin-top: 15px;
        text-shadow: 0 0 15px rgba(255, 68, 68, 0.6), 2px 2px 8px rgba(0, 0, 0, 0.7);
    }

    .game-over-score,
    .game-over-high-score {
        font-size: 18px;
        margin: 12px 0;
        font-weight: 700;
    }


    .btn-start,
    .btn-restart {
        margin-top: 20px;
        margin-bottom: 15px;
        padding: 14px 35px;
        font-size: 18px;
        font-weight: 900;
    }
}

/* Very small devices (max 480px) */
@media (max-width: 480px) {
    html, body {
        min-height: 100vh;
        overflow-y: auto;
    }

    .game-wrapper {
        width: 100vw;
        height: 100vw;
        max-height: 90vh;
        border: 2px solid #333;
        border-radius: 5px;
        margin: auto;
    }

    .start-content {
        padding: 15px;
    }

    .start-content h1 {
        font-size: 28px;
        margin-bottom: 3px;
    }

    .start-content h2 {
        font-size: 20px;
        margin-bottom: 15px;
    }

    .instructions {
        font-size: 12px;
        padding: 12px;
        margin: 12px 0;
    }

    .topping-selection {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        margin: 15px 0;
        padding: 0 8px;
    }

    .topping-option {
        padding: 10px 6px;
    }

    .topping-icon {
        font-size: 32px;
        margin-bottom: 5px;
    }

    .topping-option p {
        font-size: 11px;
    }

    .score-board {
        flex-direction: column;
        gap: 5px;
        width: auto;
    }

    .score-item {
        padding: 6px 10px;
        font-size: 11px;
    }

    .score-item .value {
        font-size: 14px;
    }

    .mute-btn {
        width: 38px;
        height: 38px;
        font-size: 16px;
        bottom: 8px;
        right: 8px;
    }

    .game-over-content {
        padding: 20px 12px;
        max-height: 85vh;
        overflow-y: auto;
    }

    .game-over-content h1 {
        font-size: 30px;
        margin-bottom: 12px;
        margin-top: 10px;
        text-shadow: 0 0 12px rgba(255, 68, 68, 0.6), 2px 2px 6px rgba(0, 0, 0, 0.7);
    }

    .game-over-score,
    .game-over-high-score {
        font-size: 15px;
        margin: 7px 0;
        font-weight: 700;
    }


    .btn-start,
    .btn-restart {
        margin-top: 18px;
        margin-bottom: 10px;
        padding: 12px 28px;
        font-size: 16px;
        font-weight: 900;
        border: 2px solid #ffff00;
    }
}

/* ===== Mobile Controls (Buttons) ===== */
.mobile-controls {
    position: relative;
    width: 100%;
    padding: 15px 0;
    z-index: 12;
    pointer-events: auto;
    display: none;
    justify-content: center;
    gap: 50px;
}

.mobile-controls.active {
    display: flex;
}

.control-btn {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    border: 3px solid white;
    background: linear-gradient(135deg, #ff6b35 0%, #ff8c5a 100%);
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    user-select: none;
    touch-action: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.control-btn:hover {
    background: linear-gradient(135deg, #ff7a4a 0%, #ff9b6a 100%);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
}

/* Control buttons show only on mobile */
@media (max-width: 768px) {
    .mobile-controls {
        display: none;
        gap: 40px;
    }

    .mobile-controls.active {
        display: flex;
    }

    .control-btn {
        width: 55px;
        height: 55px;
        font-size: 24px;
    }
}

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

/* ===== Footer ===== */
footer.footer {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 30px 20px;
    text-align: center;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.2);
    margin-top: auto;
}

.footer-content {
    max-width: 800px;
    margin: 0 auto;
}

.footer-content p {
    color: white;
    font-size: 14px;
    margin-bottom: 15px;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.social-link {
    display: inline-block;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    border-radius: 20px;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-weight: bold;
    font-size: 14px;
}

.social-link:hover {
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(255, 255, 255, 0.8);
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.social-link:active {
    transform: translateY(-1px);
}

/* ===== Utility Classes ===== */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* ===== Footer Responsive ===== */
@media (max-width: 768px) {
    footer.footer {
        padding: 20px 15px;
        margin-top: 15px;
    }

    .footer-content p {
        font-size: 12px;
        margin-bottom: 12px;
    }

    .social-links {
        gap: 15px;
    }

    .social-link {
        padding: 8px 16px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    footer.footer {
        padding: 15px 10px;
        margin-top: 10px;
    }

    .footer-content p {
        font-size: 11px;
        margin-bottom: 10px;
    }

    .social-links {
        gap: 10px;
    }

    .social-link {
        padding: 8px 14px;
        font-size: 12px;
    }
}

/* ===== Back to Home Button ===== */
.back-home-btn {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 999;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(15, 10, 4, 0.85);
    backdrop-filter: blur(10px);
    color: #F59E0B;
    text-decoration: none;
    font-family: 'Righteous', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 10px 20px;
    border-radius: 50px;
    border: 1px solid rgba(245, 158, 11, 0.35);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
    white-space: nowrap;
}

.back-home-btn:hover {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.7);
    transform: translateY(-2px);
}

@media (max-width: 480px) {
    .back-home-btn {
        font-size: 0.75rem;
        padding: 8px 14px;
        top: 10px;
        left: 10px;
    }
}
