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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.game-container {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 600px;
    width: 100%;
}

.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-header h1 {
    color: #2c3e50;
    font-size: 2.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.game-icon {
    display: inline-block;
    font-size: 0.9em;
    animation: pulse-icon 2s ease-in-out infinite;
}

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

.game-stats {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1fr;
    gap: 12px;
    margin-bottom: 15px;
}

.stat-box {
    background: #ecf0f1;
    padding: 12px;
    border-radius: 12px;
    text-align: center;
    position: relative;
}

.stat-box.timer-box {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
}

.stat-box.score-box {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
}

.stat-box.high-score-box {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
}

.stat-label {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: block;
    margin-bottom: 4px;
    opacity: 0.9;
}

.stat-value {
    font-size: 1.6em;
    font-weight: bold;
    display: block;
}

.timer-value {
    font-size: 1.8em;
}

.timer-bar-container {
    margin-top: 8px;
    height: 6px;
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
    overflow: hidden;
}

.timer-bar {
    height: 100%;
    background: white;
    width: 100%;
    transition: width 0.1s linear;
}

.reset-high-score {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255,255,255,0.3);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.reset-high-score:hover {
    background: rgba(255,255,255,0.5);
    transform: rotate(180deg);
}

.difficulty-selector {
    margin: 15px 0;
    text-align: center;
}

.difficulty-selector h3 {
    color: #2c3e50;
    margin-bottom: 12px;
    font-size: 1.1em;
}

.difficulty-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.diff-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 20px;
    border: 3px solid #ecf0f1;
    background: white;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 90px;
}

.diff-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.diff-btn.active {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
}

.diff-emoji {
    font-size: 1.8em;
    margin-bottom: 4px;
}

.diff-name {
    font-weight: bold;
    color: #2c3e50;
    font-size: 0.85em;
}

.grid-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.grid {
    display: grid;
    gap: 6px;
    padding: 15px;
    background: #ecf0f1;
    border-radius: 12px;
    max-width: 380px;
    width: 100%;
}

.cell {
    aspect-ratio: 1;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.15s ease;
    border: 2px solid rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8em;
}

.cell:hover {
    transform: scale(1.05);
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.cell.active {
    animation: cellAppear 0.2s ease;
}

.cell.cherry-glow {
    animation: cherryGlow 0.5s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(233, 30, 99, 0.8);
}

.cell.banana-glow {
    animation: bananaGlow 0.5s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
}

@keyframes cellAppear {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes cherryGlow {
    0%, 100% { 
        box-shadow: 0 0 15px rgba(233, 30, 99, 0.6);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 30px rgba(233, 30, 99, 1);
        transform: scale(1.05);
    }
}

@keyframes bananaGlow {
    0%, 100% { 
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 30px rgba(255, 215, 0, 1);
        transform: scale(1.05);
    }
}

.controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 15px 0;
}

.btn {
    padding: 12px 35px;
    font-size: 1em;
    font-weight: bold;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
}

.rules-panel {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 12px;
    margin-top: 15px;
    border: 2px solid #e9ecef;
}

.rules-panel h3 {
    color: #2c3e50;
    margin-bottom: 12px;
    font-size: 1.1em;
    text-align: center;
}

.rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

.rule-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.rule-item.gold-rule {
    border-left-color: #f39c12;
}

.rule-item.banana-rule {
    border-left-color: #FFD700;
    background: linear-gradient(90deg, #fffacd 0%, white 100%);
}

.rule-item.cherry-rule {
    border-left-color: #e91e63;
    background: linear-gradient(90deg, #ffe6f0 0%, white 100%);
}

.rule-item.bomb-rule {
    border-left-color: #e67e22;
}

.rule-item.danger-rule {
    border-left-color: #e74c3c;
}

.rule-icon {
    font-size: 1.5em;
    min-width: 30px;
    text-align: center;
}

.rule-text {
    flex: 1;
}

.rule-text strong {
    display: block;
    color: #2c3e50;
    font-size: 0.85em;
    margin-bottom: 2px;
}

.rule-text p {
    color: #7f8c8d;
    font-size: 0.75em;
    margin: 0;
}

.goal-text {
    text-align: center;
    color: #667eea;
    font-weight: bold;
    margin-top: 10px;
    font-size: 0.95em;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: white;
    padding: 35px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    animation: slideUp 0.4s ease;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 2.5em;
    color: #7f8c8d;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
    padding: 0;
}

.modal-close:hover {
    color: #2c3e50;
    transform: scale(1.1);
}

.modal-content h2 {
    font-size: 2.2em;
    margin-bottom: 15px;
    color: #2c3e50;
    margin-top: 10px;
}

.modal-content p {
    font-size: 1.1em;
    color: #7f8c8d;
    margin: 10px 0;
}

.game-over-stats {
    margin: 20px 0;
}

.final-stat {
    font-size: 1.3em;
    font-weight: bold;
    color: #2c3e50;
    margin: 10px 0;
}

.final-stat.high {
    color: #f39c12;
    font-size: 1.5em;
}

.pulse {
    animation: pulse 0.3s ease;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.shake {
    animation: shake 0.5s ease;
}

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

.flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    animation: flash 0.6s ease;
    z-index: 999;
}

@keyframes flash {
    0% { opacity: 0; }
    50% { opacity: 0.7; }
    100% { opacity: 0; }
}

.jackpot {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    padding: 30px 60px;
    border-radius: 20px;
    font-size: 2.5em;
    font-weight: bold;
    z-index: 9999;
    box-shadow: 0 20px 60px rgba(243, 156, 18, 0.6);
    animation: jackpotAnim 1.5s ease forwards;
    pointer-events: none;
}

/* BANANA PARTY */
.banana-party {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
    padding: 35px 70px;
    border-radius: 22px;
    font-size: 2.8em;
    font-weight: bold;
    z-index: 9999;
    box-shadow: 0 25px 70px rgba(255, 215, 0, 0.7);
    animation: bananaPartyAnim 2s ease forwards;
    pointer-events: none;
    text-align: center;
}

/* CHERRY SUPER JACKPOT */
.cherry-jackpot {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #e91e63, #c2185b);
    color: white;
    padding: 40px 80px;
    border-radius: 25px;
    font-size: 3em;
    font-weight: bold;
    z-index: 10000;
    box-shadow: 0 30px 80px rgba(233, 30, 99, 0.8);
    animation: cherryJackpotAnim 3s ease forwards;
    pointer-events: none;
    text-align: center;
}

/* FALLING COINS */
.coin {
    position: fixed;
    font-size: 2.5em;
    z-index: 9998;
    pointer-events: none;
    animation: coinFall 3s ease-out forwards;
}

/* CONFETTI */
.confetti {
    position: fixed;
    font-size: 2em;
    z-index: 9998;
    pointer-events: none;
    animation: confettiFall 2s ease-out forwards;
}

@keyframes jackpotAnim {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    30% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    70% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
}

@keyframes bananaPartyAnim {
    0% { 
        transform: translate(-50%, -50%) scale(0.4) rotate(-15deg); 
        opacity: 0; 
    }
    20% { 
        transform: translate(-50%, -50%) scale(1.25) rotate(5deg); 
        opacity: 1; 
    }
    40% { 
        transform: translate(-50%, -50%) scale(0.95) rotate(-3deg); 
        opacity: 1; 
    }
    60% { 
        transform: translate(-50%, -50%) scale(1.1) rotate(2deg); 
        opacity: 1; 
    }
    85% { 
        transform: translate(-50%, -50%) scale(1) rotate(0deg); 
        opacity: 1; 
    }
    100% { 
        transform: translate(-50%, -50%) scale(0.7) rotate(0deg); 
        opacity: 0; 
    }
}

@keyframes cherryJackpotAnim {
    0% { 
        transform: translate(-50%, -50%) scale(0.3) rotate(-10deg); 
        opacity: 0; 
    }
    15% { 
        transform: translate(-50%, -50%) scale(1.3) rotate(5deg); 
        opacity: 1; 
    }
    30% { 
        transform: translate(-50%, -50%) scale(0.95) rotate(-2deg); 
        opacity: 1; 
    }
    45% { 
        transform: translate(-50%, -50%) scale(1.05) rotate(1deg); 
        opacity: 1; 
    }
    85% { 
        transform: translate(-50%, -50%) scale(1) rotate(0deg); 
        opacity: 1; 
    }
    100% { 
        transform: translate(-50%, -50%) scale(0.7) rotate(0deg); 
        opacity: 0; 
    }
}

@keyframes coinFall {
    0% {
        transform: translateY(-100vh) rotate(0deg) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
        transform: translateY(-80vh) rotate(180deg) scale(1);
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg) scale(0.5);
        opacity: 0;
    }
}

@keyframes confettiFall {
    0% {
        transform: translateY(-100vh) rotate(0deg) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
        transform: translateY(-80vh) rotate(120deg) scale(1);
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(540deg) scale(0.7);
        opacity: 0;
    }
}

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

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* MOBILE OPTIMIZATIONS */
@media (max-width: 600px) {
    .game-container {
        padding: 15px;
    }
    
    .game-header h1 {
        font-size: 1.6em;
        gap: 8px;
        margin-bottom: 12px;
    }
    
    .game-stats {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 6px;
    }
    
    .stat-box {
        padding: 8px 4px;
    }
    
    .stat-label {
        font-size: 0.65em;
        margin-bottom: 2px;
    }
    
    .stat-value {
        font-size: 1.2em;
    }
    
    .timer-value {
        font-size: 1.3em;
    }
    
    .timer-bar-container {
        margin-top: 4px;
        height: 4px;
    }
    
    .reset-high-score {
        width: 20px;
        height: 20px;
        font-size: 0.9em;
        top: 4px;
        right: 4px;
    }
    
    .grid {
        gap: 5px;
        padding: 12px;
    }
    
    .cell {
        font-size: 1.4em;
    }
    
    .rules-panel {
        padding: 12px;
    }
    
    .rules-grid {
        grid-template-columns: 1fr;
    }
    
    .jackpot {
        font-size: 1.8em;
        padding: 20px 40px;
    }
    
    .banana-party {
        font-size: 2em;
        padding: 20px 45px;
    }
    
    .cherry-jackpot {
        font-size: 2em;
        padding: 25px 50px;
    }
    
    .coin, .confetti {
        font-size: 1.8em;
    }
    
    .modal-content {
        max-width: 90%;
        padding: 30px 20px;
    }
    
    .modal-close {
        font-size: 2em;
        width: 35px;
        height: 35px;
    }
}