* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
    overscroll-behavior: none;
}

.container {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 700px;
    width: 100%;
    overflow-y: auto;
    max-height: 95vh;
    -webkit-overflow-scrolling: touch;
}

/* Header Navigation */
header {
    margin-bottom: 20px;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.back-btn {
    align-self: flex-start;
    text-decoration: none;
    color: #F59E0B;
    font-size: 1em;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.3s;
    background: #FEF3C7;
}

.back-btn:hover {
    background: #FDE68A;
    transform: translateX(-2px);
}

h1 {
    text-align: center;
    color: #F59E0B;
    margin: 0;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    border-radius: 10px;
    color: white;
    font-size: 1.2em;
    font-weight: bold;
}

#gameCanvas {
    border: 4px solid #F59E0B;
    border-radius: 10px;
    display: block;
    margin: 0 auto;
    background: #f7fafc;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    cursor: pointer;
    touch-action: none;
    max-width: 100%;
    height: auto;
}

.controls {
    margin-top: 20px;
    text-align: center;
}

button {
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.1em;
    border-radius: 25px;
    cursor: pointer;
    margin: 5px;
    transition: all 0.3s;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.6);
}

button:active {
    transform: translateY(0);
}

.instructions {
    margin-top: 20px;
    padding: 15px;
    background: #FEF3C7;
    border-radius: 10px;
    border-left: 4px solid #F59E0B;
}

.instructions h3 {
    color: #F59E0B;
    margin-bottom: 10px;
}

.instructions p {
    color: #4a5568;
    line-height: 1.6;
}

.mobile-text {
    display: none;
}

@media (max-width: 768px) {
    .desktop-text {
        display: none;
    }
    
    .mobile-text {
        display: block;
        font-size: 0.9rem;
    }
    
    .instructions {
        padding: 12px;
    }
    
    .instructions h3 {
        font-size: 1rem;
        margin-bottom: 8px;
    }
}

#gameOver {
    display: none;
    text-align: center;
    margin-top: 20px;
    padding: 20px;
    border-radius: 10px;
}

#gameOver.win {
    background: #d1fae5;
    border-left: 4px solid #10b981;
}

#gameOver.lose {
    background: #fed7d7;
    border-left: 4px solid #f56565;
}

#gameOver h2 {
    margin-bottom: 10px;
}

#gameOver.win h2 {
    color: #047857;
}

#gameOver.lose h2 {
    color: #c53030;
}

/* Ad Placeholders */
.ad-placeholder {
    background: #f3f4f6;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    color: #9ca3af;
    margin: 20px auto;
    max-width: 728px;
}

.ad-top {
    margin-bottom: 20px;
}

.ad-middle {
    margin: 30px 0;
}

.ad-bottom {
    margin-top: 20px;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 15px;
    }
    
    #gameCanvas {
        width: 100%;
        height: auto;
    }
    
    h1 {
        font-size: 2em;
    }
    
    .game-info {
        font-size: 1em;
        flex-wrap: wrap;
    }
    
    .ad-placeholder {
        font-size: 0.9em;
        padding: 15px;
    }
}

/* iOS Safe Area */
@supports (padding: max(0px)) {
    body {
        padding-top: max(10px, env(safe-area-inset-top));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }
}

/* Prevent text selection */
#gameCanvas,
button {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
