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

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: manipulation;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    font-family: 'Press Start 2P', cursive;
    overflow: hidden;
    padding: 10px;
}

.game-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
    max-width: 850px;
}

.title {
    color: #ffd700;
    font-size: 28px;
    text-shadow: 4px 4px 0 #8b4513, -2px -2px 0 #ff6b35;
    letter-spacing: 2px;
    animation: titleBounce 1s ease-in-out infinite;
}

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

#gameCanvas {
    border: 6px solid #2d5a27;
    border-radius: 8px;
    box-shadow: 
        0 0 0 4px #1a3518,
        0 0 40px rgba(45, 90, 39, 0.5),
        inset 0 0 100px rgba(0,0,0,0.1);
    cursor: pointer;
    image-rendering: pixelated;
    max-width: 100%;
    height: auto;
    touch-action: none;
}

.score-display {
    position: absolute;
    top: 80px;
    right: 20px;
    color: #ffd700;
    font-size: 24px;
    text-shadow: 2px 2px 0 #333;
    z-index: 10;
}

.instructions {
    color: #88c070;
    font-size: 10px;
    text-align: center;
    line-height: 2;
    opacity: 0.8;
    padding: 0 10px;
}

.instructions span {
    color: #ffd700;
}

.copyright {
    color: #556b5a;
    font-size: 8px;
    margin-top: 5px;
    opacity: 0.7;
}

/* Overlay styles */
.overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    border: 4px solid #2d5a27;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    z-index: 100;
    min-width: 280px;
    max-width: 90%;
}

.overlay.hidden {
    display: none !important;
}

.start-overlay.hidden {
    display: none !important;
}

.overlay h2 {
    color: #ff6b35;
    font-size: 18px;
    margin-bottom: 15px;
    text-shadow: 2px 2px 0 #8b2500;
}

.overlay .final-score {
    color: #ffd700;
    font-size: 14px;
    margin-bottom: 8px;
}

.overlay .high-score {
    color: #88c070;
    font-size: 11px;
    margin-bottom: 8px;
}

.overlay .global-high-score {
    color: #ffd700;
    font-size: 10px;
    margin-bottom: 15px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.overlay button {
    font-family: 'Press Start 2P', cursive;
    background: linear-gradient(180deg, #4ade80 0%, #22c55e 100%);
    color: #1a3518;
    border: none;
    padding: 15px 30px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 4px 0 #15803d;
    transition: all 0.1s;
    touch-action: manipulation;
    margin-top: 0.5cm; /* Move button lower by 0.5cm */
}

.overlay button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #15803d;
}

.overlay button:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #15803d;
}

.start-overlay h2 {
    color: #ffd700;
    text-shadow: 2px 2px 0 #8b4513;
}

.start-overlay .tips {
    color: #88c070;
    font-size: 8px;
    line-height: 2.5;
    margin-bottom: 20px;
}

/* Difficulty Selection Bar */
.difficulty-bar {
    position: absolute;
    top: -45px;
    right: 0px;
    display: flex;
    gap: 6px;
    z-index: 150;
}

.diff-btn {
    font-family: 'Press Start 2P', cursive;
    padding: 8px 12px;
    font-size: 8px;
    cursor: pointer;
    border: 3px solid transparent;
    border-radius: 6px;
    transition: all 0.2s;
    opacity: 0.6;
    touch-action: manipulation;
}

.diff-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.diff-btn.selected {
    opacity: 1;
    border-color: #fff;
    transform: scale(1.05);
}

.diff-btn.novice {
    background: linear-gradient(180deg, #4ade80 0%, #22c55e 100%);
    color: #1a3518;
    box-shadow: 0 3px 0 #15803d;
}

.diff-btn.intermediate {
    background: linear-gradient(180deg, #fbbf24 0%, #f59e0b 100%);
    color: #78350f;
    box-shadow: 0 3px 0 #b45309;
}

.diff-btn.pro {
    background: linear-gradient(180deg, #f87171 0%, #ef4444 100%);
    color: #7f1d1d;
    box-shadow: 0 3px 0 #b91c1c;
}

.current-difficulty {
    color: #88c070;
    font-size: 10px;
    margin-top: 15px;
}

/* Floating particles */
.particle {
    position: fixed;
    width: 4px;
    height: 4px;
    background: #ffd700;
    opacity: 0.3;
    animation: float 10s infinite linear;
}

@keyframes float {
    0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
    10% { opacity: 0.3; }
    90% { opacity: 0.3; }
    100% { transform: translateY(-100vh) rotate(360deg); opacity: 0; }
}

/* Mobile touch hint */
.touch-hint {
    display: none;
    color: #ffd700;
    font-size: 10px;
    text-align: center;
    margin-top: 10px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* ==================== */
/* RESPONSIVE BREAKPOINTS */
/* ==================== */

/* Tablet (iPad) - Portrait and Landscape */
@media screen and (max-width: 1024px) {
    .title {
        font-size: 24px;
    }
    
    .difficulty-bar {
        top: -40px;
        gap: 4px;
    }
    
    .diff-btn {
        padding: 6px 10px;
        font-size: 7px;
    }
    
    .overlay {
        padding: 25px;
        min-width: 300px;
    }
    
    .overlay h2 {
        font-size: 16px;
    }
    
    .start-overlay .tips {
        font-size: 7px;
        line-height: 2.2;
    }
}

/* Phone - Landscape */
@media screen and (max-width: 850px) and (orientation: landscape) {
    body {
        padding: 5px;
    }
    
    .game-container {
        gap: 5px;
    }
    
    .title {
        font-size: 16px;
        margin-bottom: 0;
    }
    
    .instructions, .copyright {
        display: none;
    }
    
    .difficulty-bar {
        position: fixed;
        top: 5px;
        right: 10px;
    }
    
    .overlay {
        padding: 15px;
        min-width: 250px;
    }
    
    .overlay h2 {
        font-size: 12px;
        margin-bottom: 10px;
    }
    
    .overlay button {
        padding: 10px 20px;
        font-size: 10px;
    }
    
    .start-overlay .tips {
        font-size: 6px;
        line-height: 2;
        margin-bottom: 10px;
    }
}

/* Phone - Portrait */
@media screen and (max-width: 600px) {
    body {
        padding: 10px;
        padding-top: 60px;
    }
    
    .game-container {
        gap: 10px;
        width: 100%;
    }
    
    .title {
        font-size: 18px;
        letter-spacing: 1px;
    }
    
    .difficulty-bar {
        position: fixed;
        top: 10px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        gap: 4px;
    }
    
    .diff-btn {
        padding: 6px 8px;
        font-size: 6px;
    }
    
    .instructions {
        font-size: 8px;
        line-height: 1.8;
    }
    
    .copyright {
        font-size: 6px;
    }
    
    .touch-hint {
        display: block;
    }
    
    .overlay {
        padding: 20px;
        min-width: auto;
        width: 90%;
        max-width: 320px;
    }
    
    .overlay h2 {
        font-size: 14px;
        margin-bottom: 12px;
    }
    
    .overlay .final-score {
        font-size: 12px;
    }
    
    .overlay .high-score {
        font-size: 10px;
        margin-bottom: 15px;
    }
    
    .overlay button {
        padding: 12px 24px;
        font-size: 10px;
    }
    
    .start-overlay .tips {
        font-size: 6px;
        line-height: 2;
        margin-bottom: 15px;
    }
    
    .current-difficulty {
        font-size: 8px;
    }
}

/* Very small phones */
@media screen and (max-width: 380px) {
    body {
        padding: 5px;
        padding-top: 55px;
    }
    
    .title {
        font-size: 14px;
    }
    
    .diff-btn {
        padding: 5px 6px;
        font-size: 5px;
    }
    
    .overlay {
        padding: 15px;
    }
    
    .overlay h2 {
        font-size: 12px;
    }
    
    .overlay button {
        padding: 10px 18px;
        font-size: 9px;
    }
    
    .start-overlay .tips {
        font-size: 5px;
    }
}

/* Prevent zoom on double tap for iOS */
* {
    touch-action: manipulation;
}
