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

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

body {
    font-family: 'Press Start 2P', monospace;
    min-height: 100vh;
    padding: 20px;
    color: #fff;
    overflow-x: auto;
    position: relative;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Game Boy LCD scanlines effect */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(0, 0, 0, 0.05) 2px,
        rgba(0, 0, 0, 0.05) 4px
    );
    pointer-events: none;
    z-index: 1000;
    animation: scanlineFlicker 0.1s linear infinite;
    opacity: 0.3;
}

@keyframes scanlineFlicker {
    0% { opacity: 0.3; }
    98% { opacity: 0.3; }
    100% { opacity: 0.1; }
}

/* Gen 2 Pokemon Themed Backgrounds */
.bg-celadon {
    background: linear-gradient(135deg, #4a7c59 0%, #2d5540 100%);
}

.bg-johto {
    background: linear-gradient(135deg, #6b4e9d 0%, #3e2a5c 100%);
}

.bg-gamecorner {
    background: linear-gradient(135deg, #d4af37 0%, #8b7500 100%);
}

.bg-night {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.bg-crystal {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* Animated 8-bit background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.15;
    background-image: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 4px,
            rgba(255, 255, 255, 0.03) 4px,
            rgba(255, 255, 255, 0.03) 8px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 4px,
            rgba(255, 255, 255, 0.03) 4px,
            rgba(255, 255, 255, 0.03) 8px
        );
    animation: pixelShift 20s linear infinite;
    pointer-events: none;
    z-index: -2;
}

@keyframes pixelShift {
    0% { transform: translate(0, 0); }
    25% { transform: translate(2px, 0); }
    50% { transform: translate(0, 2px); }
    75% { transform: translate(-2px, 0); }
    100% { transform: translate(0, -2px); }
}

/* Pokemon sprite animations */
.pokemon-sprite {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 64px;
    height: 64px;
    background: var(--pokemon-sprite);
    animation: pokemonFloat 8s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
    image-rendering: pixelated;
    opacity: 0.7;
}

@keyframes pokemonFloat {
    0%, 100% { 
        transform: translate(0, 0) scale(1);
        opacity: 0.7;
    }
    25% { 
        transform: translate(-10px, -5px) scale(1.1);
        opacity: 0.9;
    }
    50% { 
        transform: translate(0, -10px) scale(1);
        opacity: 0.8;
    }
    75% { 
        transform: translate(10px, -5px) scale(0.9);
        opacity: 0.6;
    }
}

/* Moving pixel clouds */
.pixel-cloud {
    position: fixed;
    width: 32px;
    height: 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0;
    animation: cloudDrift var(--drift-duration, 15s) linear infinite;
    pointer-events: none;
    z-index: -1;
    image-rendering: pixelated;
}

.pixel-cloud::before {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.15);
    top: -4px;
    left: 8px;
}

.pixel-cloud::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 8px;
    background: rgba(255, 255, 255, 0.12);
    top: -2px;
    right: 4px;
}

@keyframes cloudDrift {
    0% { transform: translateX(-50px); }
    100% { transform: translateX(calc(100vw + 50px)); }
}

/* 8-bit sparkle effects */
.pixel-sparkle {
    position: fixed;
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.8);
    animation: sparklePixel 2s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
    image-rendering: pixelated;
}

@keyframes sparklePixel {
    0%, 100% { 
        opacity: 0;
        transform: scale(0.5);
    }
    50% { 
        opacity: 1;
        transform: scale(1.5);
        box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
    }
}

.game-container {
    max-width: 800px;
    margin: 0 auto;
    background: #8b956d;
    border: 8px solid #5a6b3b;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    position: relative;
    animation: subtleGlow 4s ease-in-out infinite alternate;
}

@keyframes subtleGlow {
    0% { box-shadow: 0 0 20px rgba(0, 0, 0, 0.5), 0 0 30px rgba(120, 119, 198, 0.2); }
    100% { box-shadow: 0 0 25px rgba(0, 0, 0, 0.6), 0 0 40px rgba(255, 177, 153, 0.3); }
}

/* Floating Pokemon decorations */
.game-container::after {
    content: '⚡💫⭐';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 20px;
    animation: floatAround 8s ease-in-out infinite;
    pointer-events: none;
    opacity: 0.7;
}

@keyframes floatAround {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(-10px, -5px) rotate(90deg); }
    50% { transform: translate(-5px, -10px) rotate(180deg); }
    75% { transform: translate(5px, -5px) rotate(270deg); }
}

/* Add sparkle effects */
.game-container::before {
    content: '✨';
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 16px;
    animation: sparkle 3s ease-in-out infinite;
    pointer-events: none;
    opacity: 0.6;
}

@keyframes sparkle {
    0%, 100% { opacity: 0.6; transform: scale(1) rotate(0deg); }
    50% { opacity: 1; transform: scale(1.2) rotate(180deg); }
}

.game-header {
    text-align: center;
    margin-bottom: 20px;
    background: #2c3e50;
    padding: 15px;
    border-radius: 10px;
    border: 4px solid #34495e;
}

.game-header h1 {
    color: #f1c40f;
    font-size: 24px;
    text-shadow: 2px 2px 0px #e67e22;
    margin-bottom: 10px;
}

.subtitle {
    color: #ecf0f1;
    font-size: 12px;
}

.slot-machine {
    background: #34495e;
    border: 6px solid #2c3e50;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
}

.machine-top {
    background: #1a252f;
    border: 3px solid #34495e;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
}

.display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #0f1419;
    border: 2px solid #27ae60;
    border-radius: 5px;
    padding: 10px;
    color: #27ae60;
    font-size: 12px;
}

.coins-display, .bet-display {
    display: flex;
    align-items: center;
    gap: 10px;
}

.label {
    color: #95a5a6;
}

#coin-count, #bet-amount {
    color: #f1c40f;
    font-weight: bold;
}

.reels-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 30px 0;
    background: #2c3e50;
    padding: 20px;
    border-radius: 10px;
    border: 4px solid #1a252f;
}

.reel {
    width: 120px;
    height: 120px;
    background: #ecf0f1;
    border: 4px solid #34495e;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
}

.symbol {
    font-size: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    transition: transform 0.1s ease-in-out;
}

.reel.spinning .symbol {
    animation: spin 0.1s linear infinite;
}

@keyframes spin {
    0% { transform: translateY(0px) scale(1); }
    50% { transform: translateY(-60px) scale(0.8); }
    100% { transform: translateY(-120px) scale(1); }
}

/* Enhanced spinning effect with blur */
.reel.spinning {
    box-shadow: 
        inset 0 0 10px rgba(0, 0, 0, 0.3),
        0 0 15px rgba(241, 196, 15, 0.4);
    animation: reelGlow 0.2s linear infinite;
}

@keyframes reelGlow {
    0%, 100% { box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3), 0 0 15px rgba(241, 196, 15, 0.4); }
    50% { box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.4), 0 0 20px rgba(241, 196, 15, 0.6); }
}

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

.control-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    padding: 12px 20px;
    border: 4px solid #2c3e50;
    border-radius: 8px;
    background: #3498db;
    color: white;
    cursor: pointer;
    text-shadow: 1px 1px 0px #2980b9;
    box-shadow: 0 4px 0 #2980b9;
    transition: all 0.1s ease;
}

.control-btn:hover {
    background: #5dade2;
    transform: translateY(1px);
    box-shadow: 0 3px 0 #2980b9;
}

.control-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #2980b9;
}

.control-btn:disabled {
    background: #7f8c8d;
    color: #bdc3c7;
    cursor: not-allowed;
    box-shadow: 0 4px 0 #95a5a6;
}

.spin-btn {
    background: #e74c3c;
    box-shadow: 0 4px 0 #c0392b;
    text-shadow: 1px 1px 0px #c0392b;
    animation: pulseButton 2s ease-in-out infinite;
}

@keyframes pulseButton {
    0%, 100% { transform: scale(1); box-shadow: 0 4px 0 #c0392b; }
    50% { transform: scale(1.05); box-shadow: 0 6px 0 #c0392b, 0 0 15px rgba(231, 76, 60, 0.4); }
}

.spin-btn:hover {
    background: #ec7063;
    box-shadow: 0 3px 0 #c0392b;
    animation: none;
}

.spin-btn:active {
    box-shadow: 0 0 0 #c0392b;
    animation: none;
}

.spin-btn:disabled {
    animation: none;
}

.payout-info {
    background: #1a252f;
    border: 3px solid #34495e;
    border-radius: 10px;
    padding: 15px;
    margin: 20px 0;
}

.payout-info h3 {
    text-align: center;
    color: #f1c40f;
    margin-bottom: 15px;
    font-size: 14px;
}

.payout-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.payout-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2c3e50;
    padding: 8px 12px;
    border-radius: 5px;
    border: 2px solid #34495e;
    font-size: 10px;
}

.payout-row.special {
    background: #8e44ad;
    border-color: #9b59b6;
}

.payout-row.legendary {
    background: linear-gradient(45deg, #f1c40f, #e67e22);
    border-color: #d35400;
    animation: legendary-glow 2s ease-in-out infinite alternate;
}

.payout-row.epic {
    background: #e74c3c;
    border-color: #c0392b;
}

.payout-row.rare {
    background: #9b59b6;
    border-color: #8e44ad;
}

@keyframes legendary-glow {
    0% { box-shadow: 0 0 5px #f1c40f; }
    100% { box-shadow: 0 0 15px #e67e22, 0 0 25px #f1c40f; }
}

.combo {
    color: #ecf0f1;
    font-size: 16px;
}

.prize {
    color: #f1c40f;
    font-weight: bold;
}

.message-area {
    background: #0f1419;
    border: 2px solid #27ae60;
    border-radius: 5px;
    padding: 10px;
    text-align: center;
    margin: 15px 0;
}

#game-message {
    color: #27ae60;
    font-size: 11px;
    min-height: 20px;
}

.flavor-text {
    text-align: center;
    background: #2c3e50;
    border: 4px solid #34495e;
    border-radius: 10px;
    padding: 15px;
    font-size: 10px;
    line-height: 1.6;
}

.flavor-text p:first-child {
    color: #ecf0f1;
    margin-bottom: 8px;
}

.flavor-text p:last-child {
    color: #95a5a6;
    font-style: italic;
}

/* User System Styles */
.user-info {
    margin-top: 15px;
    padding: 10px;
    background: #1a252f;
    border: 2px solid #34495e;
    border-radius: 8px;
    text-align: center;
}

#user-display {
    color: #27ae60;
    font-size: 10px;
    display: block;
    margin-bottom: 10px;
}

.user-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.user-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    padding: 8px 12px;
    border: 2px solid #34495e;
    border-radius: 5px;
    background: #27ae60;
    color: white;
    cursor: pointer;
    text-shadow: 1px 1px 0px #229954;
    box-shadow: 0 3px 0 #229954;
    transition: all 0.1s ease;
}

.user-btn:hover {
    background: #2ecc71;
    transform: translateY(1px);
    box-shadow: 0 2px 0 #229954;
}

.user-btn:active {
    transform: translateY(3px);
    box-shadow: 0 0 0 #229954;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.3s ease;
}

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

.modal-content {
    font-family: 'Press Start 2P', monospace;
    background: #34495e;
    border: 4px solid #2c3e50;
    border-radius: 15px;
    margin: 15% auto;
    padding: 25px;
    width: 90%;
    max-width: 400px;
    color: #ecf0f1;
    animation: slideIn 0.3s ease;
}

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

.modal-content h3 {
    text-align: center;
    color: #f1c40f;
    margin-bottom: 20px;
    font-size: 14px;
}

.modal-content input {
    font-family: 'Press Start 2P', monospace;
    width: 100%;
    padding: 10px;
    margin: 8px 0;
    border: 2px solid #27ae60;
    border-radius: 5px;
    background: #2c3e50;
    color: #ecf0f1;
    font-size: 10px;
    box-sizing: border-box;
}

.modal-content input:focus {
    outline: none;
    border-color: #f1c40f;
    box-shadow: 0 0 5px #f1c40f;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: center;
}

.modal-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    padding: 10px 15px;
    border: 2px solid #2c3e50;
    border-radius: 5px;
    background: #3498db;
    color: white;
    cursor: pointer;
    text-shadow: 1px 1px 0px #2980b9;
    box-shadow: 0 3px 0 #2980b9;
    transition: all 0.1s ease;
}

.modal-btn:hover {
    background: #5dade2;
    transform: translateY(1px);
    box-shadow: 0 2px 0 #2980b9;
}

.modal-btn:active {
    transform: translateY(3px);
    box-shadow: 0 0 0 #2980b9;
}

.modal-btn.cancel {
    background: #e74c3c;
    box-shadow: 0 3px 0 #c0392b;
    text-shadow: 1px 1px 0px #c0392b;
}

.modal-btn.cancel:hover {
    background: #ec7063;
    box-shadow: 0 2px 0 #c0392b;
}

.modal-btn.cancel:active {
    box-shadow: 0 0 0 #c0392b;
}

/* Leaderboard Styles */
.modal-content.leaderboard {
    max-width: 500px;
}

.leaderboard-entry {
    background: #2c3e50;
    border: 2px solid #34495e;
    border-radius: 5px;
    padding: 10px;
    margin: 8px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 8px;
}

.leaderboard-entry.rank-1 {
    background: linear-gradient(45deg, #f1c40f, #e67e22);
    border-color: #d35400;
}

.leaderboard-entry.rank-2 {
    background: linear-gradient(45deg, #95a5a6, #bdc3c7);
    border-color: #7f8c8d;
}

.leaderboard-entry.rank-3 {
    background: linear-gradient(45deg, #e67e22, #d35400);
    border-color: #c0392b;
}

.leaderboard-rank {
    font-weight: bold;
    color: #f1c40f;
}

.leaderboard-stats {
    text-align: right;
    font-size: 7px;
    color: #bdc3c7;
}

/* Enhanced Mobile Responsiveness */
@media (max-width: 480px) {
    body {
        padding: 10px;
        font-size: 12px;
    }
    
    .game-container {
        padding: 10px;
        border-width: 4px;
        margin: 0;
    }
    
    .game-header h1 {
        font-size: 16px;
        margin-bottom: 8px;
    }
    
    .subtitle {
        font-size: 8px;
    }
    
    .user-info {
        padding: 8px;
        margin-top: 10px;
    }
    
    #user-display {
        font-size: 8px;
        margin-bottom: 8px;
    }
    
    .user-controls {
        flex-direction: column;
        gap: 4px;
    }
    
    .user-btn {
        width: 100%;
        margin: 2px 0;
        padding: 6px 10px;
        font-size: 7px;
    }
    
    .machine-top {
        padding: 10px;
        margin-bottom: 15px;
    }
    
    .display {
        padding: 8px;
        font-size: 10px;
    }
    
    .reels-container {
        gap: 8px;
        padding: 15px 10px;
        margin: 20px 0;
    }
    
    .reel {
        width: 70px;
        height: 70px;
        border-width: 3px;
    }
    
    .symbol {
        font-size: 28px;
    }
    
    .controls {
        gap: 8px;
        margin: 15px 0;
        flex-wrap: wrap;
    }
    
    .control-btn {
        padding: 8px 12px;
        font-size: 9px;
        min-width: 80px;
    }
    
    .payout-info {
        padding: 10px;
        margin: 15px 0;
    }
    
    .payout-info h3 {
        font-size: 10px;
        margin-bottom: 10px;
    }
    
    .payout-row {
        padding: 6px 8px;
        margin: 4px 0;
        font-size: 8px;
    }
    
    .combo {
        font-size: 12px;
    }
    
    .message-area {
        padding: 8px;
        margin: 10px 0;
    }
    
    #game-message {
        font-size: 9px;
    }
    
    .flavor-text {
        padding: 10px;
        font-size: 8px;
        line-height: 1.4;
    }
    
    .modal-content {
        margin: 5% auto;
        width: 95%;
        padding: 15px;
        max-width: none;
    }
    
    .modal-content h3 {
        font-size: 12px;
    }
    
    .modal-content input {
        font-size: 8px;
        padding: 8px;
    }
    
    .modal-btn {
        font-size: 8px;
        padding: 8px 12px;
    }
    
    .leaderboard-entry {
        font-size: 7px;
        padding: 8px;
    }
    
    .leaderboard-stats {
        font-size: 6px;
    }
    
    /* Mobile-specific animations */
    .pixel-cloud {
        width: 24px;
        height: 12px;
    }
    
    .pokemon-sprite {
        width: 48px;
        height: 48px;
        top: 10px;
        right: 10px;
    }
    
    .scanlines {
        opacity: 0.2;
    }
}

@media (max-width: 600px) and (min-width: 481px) {
    body {
        padding: 15px;
    }
    
    .game-container {
        padding: 15px;
        border-width: 6px;
    }
    
    .game-header h1 {
        font-size: 20px;
    }
    
    .user-controls {
        flex-wrap: wrap;
        gap: 6px;
        justify-content: center;
    }
    
    .user-btn {
        flex: 1;
        min-width: 100px;
        margin: 2px;
    }
    
    .reels-container {
        gap: 12px;
        padding: 18px;
    }
    
    .reel {
        width: 90px;
        height: 90px;
    }
    
    .symbol {
        font-size: 36px;
    }
    
    .control-btn {
        padding: 10px 16px;
        font-size: 10px;
    }
    
    .payout-info h3 {
        font-size: 12px;
    }
    
    .payout-row {
        font-size: 9px;
    }
    
    .combo {
        font-size: 14px;
    }
}

/* Landscape mobile orientation */
@media (max-height: 500px) and (orientation: landscape) {
    .game-container {
        max-width: none;
        margin: 0 auto;
    }
    
    .game-header {
        margin-bottom: 10px;
    }
    
    .reels-container {
        margin: 15px 0;
    }
    
    .payout-info {
        margin: 10px 0;
    }
    
    .flavor-text {
        margin-top: 10px;
    }
}

/* Touch-friendly improvements */
@media (pointer: coarse) {
    .control-btn, .user-btn, .modal-btn {
        min-height: 44px;
        touch-action: manipulation;
    }
    
    .control-btn:active, .user-btn:active, .modal-btn:active {
        transform: scale(0.98);
    }
}

.win-animation {
    animation: winFlash 0.5s ease-in-out 3;
}

@keyframes winFlash {
    0%, 100% { 
        background-color: #34495e; 
        box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
    }
    50% { 
        background-color: #f1c40f; 
        box-shadow: 
            inset 0 0 20px rgba(241, 196, 15, 0.8),
            0 0 30px rgba(241, 196, 15, 0.6);
        transform: scale(1.05);
    }
}

.big-win {
    animation: bigWinSpectacular 1.5s ease-in-out;
}

@keyframes bigWinSpectacular {
    0% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(2deg); }
    50% { 
        transform: scale(1.15) rotate(-2deg); 
        box-shadow: 
            0 0 30px rgba(241, 196, 15, 0.8),
            0 0 60px rgba(230, 126, 34, 0.6);
    }
    75% { transform: scale(1.1) rotate(1deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* Jackpot celebration effect */
.jackpot-celebration {
    animation: jackpotParty 2s ease-in-out;
}

@keyframes jackpotParty {
    0%, 100% { transform: scale(1) rotate(0deg); filter: hue-rotate(0deg); }
    10% { transform: scale(1.2) rotate(5deg); filter: hue-rotate(60deg); }
    20% { transform: scale(1.1) rotate(-3deg); filter: hue-rotate(120deg); }
    30% { transform: scale(1.15) rotate(4deg); filter: hue-rotate(180deg); }
    40% { transform: scale(1.05) rotate(-2deg); filter: hue-rotate(240deg); }
    50% { transform: scale(1.2) rotate(3deg); filter: hue-rotate(300deg); }
    60% { transform: scale(1.1) rotate(-4deg); filter: hue-rotate(360deg); }
    70% { transform: scale(1.15) rotate(2deg); filter: hue-rotate(60deg); }
    80% { transform: scale(1.05) rotate(-1deg); filter: hue-rotate(120deg); }
    90% { transform: scale(1.1) rotate(1deg); filter: hue-rotate(180deg); }
}

@media (max-width: 600px) {
    .game-container {
        padding: 15px;
        border-width: 4px;
    }
    
    .reels-container {
        gap: 10px;
        padding: 15px;
    }
    
    .reel {
        width: 80px;
        height: 80px;
    }
    
    .symbol {
        font-size: 32px;
    }
    
    .control-btn {
        padding: 10px 15px;
        font-size: 10px;
    }
    
    .game-header h1 {
        font-size: 18px;
    }
}