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

* {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

body {
    font-family: 'Courier New', monospace;
    position: relative;
}

.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.05) 0px,
        rgba(0, 0, 0, 0.05) 1px,
        transparent 1px,
        transparent 2px
    );
    z-index: 9999;
}

.pixel-text {
    font-family: 'Press Start 2P', cursive;
    text-shadow: 3px 3px 0px rgba(0, 0, 0, 0.2);
}

.pixel-header {
    animation: float 3s ease-in-out infinite;
}

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

.pixel-card {
    border: 4px solid #000;
    box-shadow: 8px 8px 0px rgba(0, 0, 0, 0.3);
    position: relative;
}

.pixel-card::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    background: linear-gradient(45deg, transparent 48%, #fff 48%, #fff 52%, transparent 52%);
    background-size: 8px 8px;
    pointer-events: none;
}

.pixel-border {
    border: 3px solid #000;
    box-shadow: 4px 4px 0px rgba(0, 0, 0, 0.3);
}

.pixel-border-thin {
    border: 2px solid #000;
}

.game-button {
    position: relative;
    transition: all 0.1s;
}

.game-button:hover:not(:disabled) {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.3);
}

.game-button:active:not(:disabled) {
    transform: translate(4px, 4px);
    box-shadow: none;
}

.checkerboard {
    background-image: 
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

.pixel-render {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    background: #ddd;
    border: 2px solid #000;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #FFE135;
    border: 2px solid #000;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #FFE135;
    border: 2px solid #000;
    cursor: pointer;
}

textarea, input {
    font-family: 'Courier New', monospace;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .pixel-text {
        font-size: 1.25rem;
        line-height: 1.4;
    }
    
    .pixel-card {
        border-width: 3px;
        box-shadow: 4px 4px 0px rgba(0, 0, 0, 0.3);
    }
    
    .pixel-card::before {
        background-size: 6px 6px;
    }
    
    /* Reduce padding on mobile */
    .container {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    /* Make buttons more touch-friendly */
    .game-button {
        min-height: 44px;
    }
    
    /* Better spacing for mobile */
    .space-y-4 > * + * {
        margin-top: 0.75rem !important;
    }
    
    /* Optimize canvas size for mobile */
    .checkerboard {
        width: 160px !important;
        height: 160px !important;
        margin: 0 auto;
    }
    
    canvas {
        width: 160px !important;
        height: 160px !important;
    }
    
    /* Better grid layout on mobile */
    .grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0.375rem !important;
    }
    
    /* Adjust text sizes */
    .text-5xl {
        font-size: 1.75rem !important;
    }
    
    .text-xl {
        font-size: 1rem !important;
    }
    
    /* Make preset buttons smaller on mobile */
    .grid-cols-2 button {
        font-size: 0.75rem;
        padding: 0.5rem;
    }
    
    /* Compact template editor */
    textarea {
        font-size: 0.875rem;
    }
    
    /* Better frame grid on mobile */
    .lg\:col-span-1:last-child .grid-cols-4 > div {
        aspect-ratio: 1;
    }
    
    .lg\:col-span-1:last-child .grid-cols-4 img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }
}

/* Tablet optimizations */
@media (min-width: 768px) and (max-width: 1023px) {
    .pixel-text {
        font-size: 2rem;
    }
    
    .lg\:col-span-3 {
        grid-column: span 2 / span 2;
    }
    
    .lg\:col-span-1 {
        grid-column: span 1 / span 1;
    }
}

/* Small mobile phones */
@media (max-width: 375px) {
    .pixel-text {
        font-size: 1rem;
    }
    
    .text-xl {
        font-size: 0.875rem !important;
    }
    
    .checkerboard {
        width: 140px !important;
        height: 140px !important;
    }
    
    canvas {
        width: 140px !important;
        height: 140px !important;
    }
    
    .grid-cols-4 {
        gap: 0.25rem !important;
    }
    
    .game-button {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }
}