@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    background-color: #87CEEB;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    touch-action: manipulation;
}

#game-container {
    position: relative;
    border: 4px solid #5BA3C9;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(100, 180, 255, 0.3);
}

#gameCanvas {
    display: block;
    background: linear-gradient(180deg, #87CEEB 0%, #B0E0E6 50%, #E0F7FA 100%);
    cursor: pointer;
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    pointer-events: none;
}

#score-display {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #fff;
    font-size: 16px;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.4), -1px -1px 0 rgba(0,0,0,0.2);
    letter-spacing: 1px;
}

/* Help Button */
#help-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.7);
    background: rgba(72, 160, 220, 0.8);
    color: white;
    font-size: 20px;
    font-weight: bold;
    font-family: 'Press Start 2P', monospace;
    cursor: pointer;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s, background 0.2s;
}

#help-btn:hover {
    transform: scale(1.1);
    background: rgba(72, 180, 240, 0.9);
}

#help-btn:active {
    transform: scale(0.95);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(135deg, #1a3a5c 0%, #2d5a8a 100%);
    border: 3px solid #5BA3C9;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 0 30px rgba(72, 160, 220, 0.4);
    font-family: 'Press Start 2P', monospace;
}

.modal-content h2 {
    color: #FECA57;
    font-size: 18px;
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 2px 2px 0 #000;
}

.modal-content h3 {
    color: #87CEEB;
    font-size: 12px;
    margin: 16px 0 8px 0;
    text-shadow: 1px 1px 0 #000;
}

.modal-content p {
    color: #fff;
    font-size: 9px;
    line-height: 1.8;
    margin: 4px 0;
}

.modal-content p.green { color: #90EE90; }
.modal-content p.gold { color: #FFD700; }
.modal-content p.red { color: #FF6347; }
.modal-content p.blue { color: #87CEEB; }

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border: none;
    background: rgba(255, 0, 0, 0.6);
    color: white;
    font-size: 20px;
    border-radius: 50%;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    background: rgba(255, 0, 0, 0.8);
}

.got-it-btn {
    display: block;
    width: 100%;
    margin-top: 20px;
    padding: 12px;
    background: linear-gradient(180deg, #48DBFB 0%, #0ABDE3 100%);
    border: 2px solid #0984C4;
    border-radius: 8px;
    color: white;
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    cursor: pointer;
    text-shadow: 1px 1px 0 #000;
}

.got-it-btn:hover {
    background: linear-gradient(180deg, #74E8FF 0%, #38CDEB 100%);
}

.got-it-btn:active {
    transform: scale(0.98);
}

/* Mobile Portrait Mode */
@media (max-width: 850px), (pointer: coarse) {
    body {
        flex-direction: column;
        justify-content: flex-start;
        padding-top: 5px;
    }

    #game-container {
        border-width: 2px;
        border-radius: 4px;
        max-width: calc(100vw - 10px);
    }

    #gameCanvas {
        width: calc(100vw - 10px);
        max-width: 800px;
        height: auto;
    }

    #score-display {
        font-size: 10px;
        top: 3px;
        right: 8px;
    }
}

/* Mobile Landscape Mode */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        padding: 5px;
    }

    #game-container {
        max-height: calc(100vh - 10px);
        max-height: calc(100dvh - 10px);
    }

    #gameCanvas {
        width: auto;
        height: calc(100vh - 20px);
        height: calc(100dvh - 20px);
        max-height: 600px;
    }

    #score-display {
        font-size: 8px;
        top: 2px;
        right: 5px;
    }
}

/* Prevent text selection and callouts on touch */
canvas, button {
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* Mobile modal adjustments */
@media (max-width: 850px) {
    .modal-content {
        padding: 16px;
        max-height: 70vh;
    }

    .modal-content h2 {
        font-size: 14px;
    }

    .modal-content h3 {
        font-size: 10px;
    }

    .modal-content p {
        font-size: 8px;
    }

    #help-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
}
