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

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

body {
    font-family: 'Press Start 2P', cursive;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #4facfe 75%, #00f2fe 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    background-attachment: fixed;
    position: relative;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        repeating-linear-gradient(0deg, transparent, transparent 4px, rgba(255,255,255,.1) 4px, rgba(255,255,255,.1) 8px),
        repeating-linear-gradient(90deg, transparent, transparent 4px, rgba(255,255,255,.1) 4px, rgba(255,255,255,.1) 8px);
    pointer-events: none;
    z-index: 0;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.container {
    background: rgba(255, 255, 255, 0.95);
    border: 4px solid #6366f1;
    box-shadow: 
        0 0 0 2px #a5b4fc,
        12px 12px 0 0 rgba(67, 56, 202, 0.8),
        0 0 60px rgba(99, 102, 241, 0.4);
    padding: 25px;
    max-width: 95%;
    width: 100%;
    position: relative;
    z-index: 1;
}

h1 {
    text-align: center;
    background: linear-gradient(45deg, #6366f1, #8b5cf6, #ec4899, #f59e0b);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientText 3s ease infinite;
    margin-bottom: 8px;
    font-size: 1.5em;
    text-shadow: none;
    letter-spacing: 2px;
    filter: drop-shadow(3px 3px 0px rgba(99, 102, 241, 0.3));
}

@keyframes gradientText {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.subtitle {
    text-align: center;
    color: #8b5cf6;
    margin-bottom: 25px;
    font-size: 0.5em;
    letter-spacing: 1px;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #f0f9ff 0%, #faf5ff 50%, #fef3c7 100%);
    border: 3px solid #6366f1;
    position: relative;
}

.controls::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(99,102,241,.05) 3px, rgba(99,102,241,.05) 6px),
        repeating-linear-gradient(90deg, transparent, transparent 3px, rgba(139,92,246,.05) 3px, rgba(139,92,246,.05) 6px);
    pointer-events: none;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-size: 0.5em;
    color: #6366f1;
    text-transform: uppercase;
    letter-spacing: 1px;
}

select, input[type="color"], input[type="text"], input[type="number"] {
    padding: 8px 12px;
    border: 3px solid #6366f1;
    background: #ffffff;
    color: #4338ca;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.5em;
    cursor: pointer;
    box-shadow: 4px 4px 0 0 #c7d2fe;
}

select:hover, input[type="color"]:hover, input[type="text"]:hover, input[type="number"]:hover {
    border-color: #8b5cf6;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 0 #c7d2fe;
}

select:active, input[type="color"]:active, input[type="text"]:active, input[type="number"]:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 0 #c7d2fe;
}

input[type="color"] {
    width: 70px;
    height: 45px;
    cursor: pointer;
    padding: 4px;
}

input[type="text"] {
    min-width: 150px;
}

input[type="number"] {
    width: 80px;
}

.tools {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tool-btn {
    padding: 10px 15px;
    background: #ffffff;
    border: 3px solid #6366f1;
    color: #6366f1;
    cursor: pointer;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.5em;
    box-shadow: 4px 4px 0 0 #c7d2fe;
    transition: all 0.1s;
}

.tool-btn:hover {
    border-color: #8b5cf6;
    color: #8b5cf6;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 0 #c7d2fe;
}

.tool-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 0 #c7d2fe;
}

.tool-btn.active {
    background: #6366f1;
    color: #fff;
    border-color: #6366f1;
}

.action-btn {
    padding: 10px 18px;
    background: #6366f1;
    color: #fff;
    border: 3px solid #4338ca;
    cursor: pointer;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.5em;
    box-shadow: 4px 4px 0 0 #c7d2fe;
    transition: all 0.1s;
}

.action-btn:hover {
    background: #8b5cf6;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 0 #c7d2fe;
}

.action-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 0 #c7d2fe;
}

.action-btn.danger {
    background: #ef4444;
    border-color: #dc2626;
}

.action-btn.danger:hover {
    background: #f87171;
}

.canvas-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #ddd6fe 0%, #fbcfe8 50%, #fde68a 100%);
    border: 3px solid #6366f1;
    overflow: auto;
    position: relative;
}

.canvas-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255,255,255,.2) 10px, rgba(255,255,255,.2) 20px);
    pointer-events: none;
}

#pixelCanvas {
    border: 4px solid #6366f1;
    cursor: crosshair;
    background: #fff;
    box-shadow: 
        0 0 0 2px #a5b4fc,
        8px 8px 0 0 #4338ca;
    display: block;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.color-palette {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(35px, 1fr));
    gap: 6px;
    margin-top: 10px;
}

.color-swatch {
    width: 35px;
    height: 35px;
    border: 3px solid #6366f1;
    cursor: pointer;
    box-shadow: 3px 3px 0 0 #c7d2fe;
    transition: all 0.1s;
}

.color-swatch:hover {
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0 0 #c7d2fe;
    border-color: #8b5cf6;
}

.color-swatch:active {
    transform: translate(1px, 1px);
    box-shadow: 2px 2px 0 0 #c7d2fe;
}

.color-swatch.active {
    border: 3px solid #8b5cf6;
    box-shadow: 
        0 0 0 2px #6366f1,
        5px 5px 0 2px #c7d2fe;
}

.info {
    text-align: center;
    color: #4338ca;
    font-size: 0.45em;
    margin-top: 15px;
    padding: 12px;
    background: linear-gradient(135deg, #e0e7ff 0%, #fae8ff 100%);
    border: 3px solid #6366f1;
    line-height: 1.6;
}

/* Pixel icons using CSS */
.tool-btn::before {
    display: inline-block;
    margin-right: 8px;
}

.tool-btn[data-tool="draw"]::before {
    content: "▓";
}

.tool-btn[data-tool="erase"]::before {
    content: "░";
}

.tool-btn[data-tool="fill"]::before {
    content: "▒";
}

.tool-btn[data-tool="line"]::before {
    content: "─";
}

.tool-btn[data-tool="rectangle"]::before {
    content: "□";
}

.tool-btn[data-tool="circle"]::before {
    content: "○";
}

.action-btn:nth-child(1)::before {
    content: "↓ ";
}

.action-btn:nth-child(2)::before {
    content: "☆ ";
}

.action-btn.danger::before {
    content: "✕ ";
}

@media (max-width: 768px) {
    h1 {
        font-size: 1em;
    }

    .subtitle {
        font-size: 0.4em;
    }

    .controls {
        flex-direction: column;
    }

    .tool-btn, .action-btn, select {
        font-size: 0.45em;
    }

    .control-group label {
        font-size: 0.45em;
    }

    .info {
        font-size: 0.4em;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: linear-gradient(135deg, #e0e7ff 0%, #fae8ff 100%);
    border: 2px solid #6366f1;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: 2px solid #a5b4fc;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
}
