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

body {
    font-family: 'Press Start 2P', monospace;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    min-height: 100vh;
    padding: 20px;
}

#container {
    max-width: 1600px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #293c96 0%, #1e2a6b 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.pixel-title {
    font-size: 32px;
    margin-bottom: 10px;
    text-shadow: 4px 4px 0 rgba(0, 0, 0, 0.3);
}

.tagline {
    font-size: 12px;
    opacity: 0.9;
    font-family: 'VT323', monospace;
}

#main-content {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 20px;
    padding: 20px;
    min-height: 700px;
}

aside {
    overflow-y: auto;
    max-height: 80vh;
}

.panel {
    background: #f5f5f5;
    border: 3px solid #293c96;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.panel h3 {
    font-size: 12px;
    margin-bottom: 12px;
    color: #293c96;
    border-bottom: 2px solid #293c96;
    padding-bottom: 8px;
}

.panel h4 {
    font-size: 10px;
    margin: 15px 0 10px;
    color: #555;
}

label {
    display: block;
    font-size: 9px;
    margin-bottom: 12px;
    color: #555;
}

input[type="text"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 8px;
    border: 2px solid #293c96;
    border-radius: 4px;
    font-family: 'VT323', monospace;
    font-size: 14px;
    margin-top: 5px;
    background: white;
}

textarea {
    min-height: 60px;
    resize: vertical;
}

input[type="range"] {
    width: 100%;
    margin-top: 5px;
}

input[type="file"] {
    width: 100%;
    padding: 8px;
    border: 2px solid #293c96;
    border-radius: 4px;
    font-size: 10px;
    margin-bottom: 10px;
    background: white;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.sub-headline-group {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px dashed #ccc;
}

.sub-headline-group:last-child {
    border-bottom: none;
}

.template-buttons,
.palette-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.template-btn,
.palette-btn {
    padding: 8px;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    border: 2px solid #293c96;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.template-btn:hover,
.palette-btn:hover {
    background: #293c96;
    color: white;
    transform: translateY(-2px);
}

.palette-btn.active {
    background: #293c96;
    color: white;
}

#pixel-library {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 10px 0;
}

.pixel-art-item {
    width: 100%;
    height: 60px;
    object-fit: contain;
    border: 2px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    background: white;
    transition: all 0.2s;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.pixel-art-item:hover {
    border-color: #293c96;
    transform: scale(1.05);
}

#canvas-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

#canvas {
    border: 5px solid #293c96;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    background: white;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(41, 60, 150, 0.9);
    color: white;
    padding: 20px 40px;
    border-radius: 8px;
    font-size: 12px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

#action-bar {
    background: #f5f5f5;
    border-top: 3px solid #293c96;
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    align-items: center;
}

.action-left,
.action-right {
    display: flex;
    gap: 10px;
}

.action-right {
    justify-content: flex-end;
}

.action-center {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

.action-btn {
    padding: 12px 24px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    border: 3px solid #293c96;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.action-btn:hover {
    background: #293c96;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.action-btn.primary {
    background: #c83232;
    color: white;
    border-color: #a02020;
}

.action-btn.primary:hover {
    background: #a02020;
    border-color: #801010;
}

.credits {
    text-align: center;
    padding: 20px;
    font-size: 9px;
    color: #666;
    background: #f5f5f5;
    border-top: 2px solid #ddd;
}

.credits a {
    color: #293c96;
    text-decoration: none;
}

.credits a:hover {
    text-decoration: underline;
}

.collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.collapsible-header:hover {
    color: #1e2a6b;
}

.toggle {
    font-size: 10px;
}

.collapsible-content.hidden {
    display: none;
}

.hidden {
    display: none !important;
}

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

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    border: 3px solid #293c96;
    max-width: 500px;
    width: 90%;
}

.modal-content h3 {
    font-size: 14px;
    margin-bottom: 15px;
    color: #293c96;
}

.modal-content p {
    font-size: 10px;
    margin-bottom: 10px;
    font-family: 'VT323', monospace;
}

#pixel-art-prompt {
    margin-bottom: 15px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

#pixel-art-loading {
    text-align: center;
    margin-top: 15px;
    font-size: 10px;
    color: #293c96;
}

/* Responsive */
@media (max-width: 1200px) {
    #main-content {
        grid-template-columns: 1fr;
    }
    
    aside {
        max-height: none;
    }
    
    #action-bar {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .action-left,
    .action-right,
    .action-center {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .pixel-title {
        font-size: 20px;
    }
    
    .tagline {
        font-size: 10px;
    }
    
    #canvas {
        max-width: 100%;
        height: auto;
    }
    
    .template-buttons,
    .palette-buttons {
        grid-template-columns: 1fr;
    }
    
    #pixel-library {
        grid-template-columns: repeat(3, 1fr);
    }
}