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

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

body {
    font-family: 'Press Start 2P', monospace;
    background: #1a1a1a;
    color: #e0e0e0;
    font-size: 8px;
    overflow: hidden;
    user-select: none;
}

.app-container {
    display: grid;
    grid-template-rows: 60px 1fr 150px;
    height: 100vh;
    width: 100vw;
}

/* Header */
.header {
    background: #2d2d2d;
    display: grid;
    grid-template-columns: 300px 1fr auto;
    align-items: center;
    padding: 8px;
    border-bottom: 2px solid #00ff41;
}

.app-title {
    font-size: 12px;
    color: #00ff41;
    text-shadow: 0 0 10px #00ff41;
}

.main-nav {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.nav-tab {
    background: #1a1a1a;
    border: 1px solid #404040;
    color: #e0e0e0;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-tab:hover {
    background: #404040;
    border-color: #00ff41;
}

.nav-tab.active {
    background: #00ff41;
    color: #1a1a1a;
    border-color: #00ff41;
    box-shadow: 0 0 10px #00ff41;
}

.user-actions {
    display: flex;
    gap: 4px;
}

.action-btn {
    background: #404040;
    border: 1px solid #808080;
    color: #e0e0e0;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: #00ff41;
    color: #1a1a1a;
    border-color: #00ff41;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 200px 1fr 250px;
    height: 100%;
    overflow: hidden;
}

/* Left Sidebar */
.left-sidebar {
    background: #2d2d2d;
    border-right: 1px solid #404040;
    padding: 8px;
    overflow-y: auto;
}

.tool-section {
    margin-bottom: 16px;
}

.tool-section h3 {
    color: #00ff41;
    font-size: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid #404040;
    padding-bottom: 4px;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.tool-btn {
    background: #1a1a1a;
    border: 1px solid #404040;
    color: #e0e0e0;
    padding: 8px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.tool-btn:hover {
    border-color: #00ff41;
}

.tool-btn.active {
    background: #00ff41;
    color: #1a1a1a;
    border-color: #00ff41;
    box-shadow: 0 0 5px #00ff41;
}

.brush-size {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.brush-size label {
    font-size: 8px;
    color: #808080;
}

.size-btn {
    background: #1a1a1a;
    border: 1px solid #404040;
    color: #e0e0e0;
    padding: 4px 8px;
    font-family: inherit;
    font-size: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.size-btn:hover {
    border-color: #00ff41;
}

.size-btn.active {
    background: #00ff41;
    color: #1a1a1a;
    border-color: #00ff41;
}

.animation-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.animation-controls button {
    background: #1a1a1a;
    border: 1px solid #404040;
    color: #e0e0e0;
    padding: 8px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.animation-controls button:hover {
    background: #00ff41;
    color: #1a1a1a;
}

.frame-info {
    font-size: 8px;
    color: #808080;
    text-align: center;
}

.timing-control {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.timing-control label {
    font-size: 8px;
    color: #808080;
}

.timing-control input {
    background: #1a1a1a;
    border: 1px solid #404040;
    color: #e0e0e0;
    padding: 4px;
    font-family: inherit;
    font-size: 8px;
}

/* Canvas Container */
.canvas-container {
    background: #1a1a1a;
    padding: 8px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.canvas-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.zoom-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}

.zoom-controls label {
    font-size: 8px;
    color: #808080;
    margin-right: 8px;
}

.zoom-btn, .toggle-btn {
    background: #2d2d2d;
    border: 1px solid #404040;
    color: #e0e0e0;
    padding: 4px 8px;
    font-family: inherit;
    font-size: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.zoom-btn:hover, .toggle-btn:hover {
    border-color: #00ff41;
}

.zoom-btn.active, .toggle-btn.active {
    background: #00ff41;
    color: #1a1a1a;
    border-color: #00ff41;
}

.canvas-wrapper {
    position: relative;
    flex: 1;
    border: 2px solid #00ff41;
    overflow: hidden;
    background: #1a1a1a;
}

#mainCanvas, #gridCanvas {
    position: absolute;
    top: 0;
    left: 0;
    image-rendering: pixelated;
    transform-origin: top left;
    background: transparent;
}

#mainCanvas {
    background: #1a1a1a;
}

.preview-window {
    position: absolute;
    top: 60px;
    right: 8px;
    background: #2d2d2d;
    border: 1px solid #404040;
    padding: 8px;
    width: 220px;
}

.preview-window h4 {
    font-size: 8px;
    color: #00ff41;
    margin-bottom: 8px;
    text-align: center;
}

#previewCanvas {
    width: 192px;
    height: 192px;
    border: 1px solid #404040;
    background: #1a1a1a;
    image-rendering: pixelated;
    display: block;
    margin: 0 auto;
}

/* Right Sidebar */
.right-sidebar {
    background: #2d2d2d;
    border-left: 1px solid #404040;
    padding: 8px;
    overflow-y: auto;
}

.asset-section {
    margin-bottom: 16px;
}

.asset-section h3 {
    color: #00ff41;
    font-size: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid #404040;
    padding-bottom: 4px;
}

.color-palette {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    margin-bottom: 8px;
}

.color-swatch {
    aspect-ratio: 1;
    border: 1px solid #404040;
    cursor: pointer;
    transition: all 0.2s;
}

.color-swatch:hover {
    border-color: #00ff41;
    box-shadow: 0 0 5px #00ff41;
}

.custom-color {
    display: flex;
    gap: 4px;
}

#colorPicker {
    width: 32px;
    height: 32px;
    border: 1px solid #404040;
    background: transparent;
    cursor: pointer;
}

#hexInput {
    flex: 1;
    background: #1a1a1a;
    border: 1px solid #404040;
    color: #e0e0e0;
    padding: 4px;
    font-family: inherit;
    font-size: 8px;
}

.layer-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.layer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1a1a1a;
    border: 1px solid #404040;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.layer-item:hover {
    border-color: #00ff41;
}

.layer-item.active {
    background: #00ff41;
    color: #1a1a1a;
    border-color: #00ff41;
}

.layer-toggle {
    background: transparent;
    border: none;
    font-size: 12px;
    cursor: pointer;
    color: inherit;
}

.asset-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2px;
    margin-bottom: 8px;
}

.asset-tab {
    background: #1a1a1a;
    border: 1px solid #404040;
    color: #e0e0e0;
    padding: 6px;
    font-family: inherit;
    font-size: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.asset-tab:hover {
    border-color: #00ff41;
}

.asset-tab.active {
    background: #00ff41;
    color: #1a1a1a;
    border-color: #00ff41;
}

.asset-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.asset-item {
    background: #1a1a1a;
    border: 1px solid #404040;
    padding: 4px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.asset-item:hover {
    border-color: #00ff41;
    box-shadow: 0 0 5px #00ff41;
}

.asset-item img {
    width: 100%;
    height: 64px;
    object-fit: contain;
    margin-bottom: 4px;
    background: #404040;
}

.asset-label {
    font-size: 6px;
    color: #808080;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.generate-section {
    border-top: 1px solid #404040;
    padding-top: 8px;
}

.generate-section h4 {
    font-size: 8px;
    color: #00ff41;
    margin-bottom: 8px;
}

#generatePrompt {
    width: 100%;
    background: #1a1a1a;
    border: 1px solid #404040;
    color: #e0e0e0;
    padding: 8px;
    font-family: inherit;
    font-size: 8px;
    margin-bottom: 8px;
    resize: vertical;
    min-height: 40px;
}

#generateAsset {
    width: 100%;
    background: #00ff41;
    border: 1px solid #00ff41;
    color: #1a1a1a;
    padding: 8px;
    font-family: inherit;
    font-size: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

#generateAsset:hover {
    box-shadow: 0 0 10px #00ff41;
}

/* Bottom Panel */
.bottom-panel {
    background: #2d2d2d;
    border-top: 1px solid #404040;
    padding: 8px;
    overflow: hidden;
}

.timeline-section h3 {
    color: #00ff41;
    font-size: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid #404040;
    padding-bottom: 4px;
}

.frame-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-bottom: 8px;
    max-height: 80px;
    overflow-y: auto;
}

.frame-cell {
    background: #1a1a1a;
    border: 1px solid #404040;
    padding: 4px;
    cursor: pointer;
    transition: all 0.2s;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.frame-cell:hover {
    border-color: #00ff41;
}

.frame-cell.active {
    background: #00ff41;
    border-color: #00ff41;
    box-shadow: 0 0 5px #00ff41;
}

.frame-cell canvas {
    max-width: 100%;
    max-height: 100%;
    image-rendering: pixelated;
}

.timeline-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.timeline-controls button {
    background: #1a1a1a;
    border: 1px solid #404040;
    color: #e0e0e0;
    padding: 6px 12px;
    font-family: inherit;
    font-size: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.timeline-controls button:hover {
    background: #00ff41;
    color: #1a1a1a;
    border-color: #00ff41;
}

.timeline-controls label {
    font-size: 8px;
    color: #808080;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Tab Content */
.tab-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1a1a1a;
    z-index: 10;
}

.level-designer, .game-tester {
    display: grid;
    grid-template-columns: 1fr 200px;
    height: 100%;
}

.level-canvas-wrapper, .game-canvas-wrapper {
    padding: 8px;
    border-right: 1px solid #404040;
}

#levelCanvas, #gameCanvas {
    border: 2px solid #00ff41;
    image-rendering: pixelated;
    background: #87CEEB;
}

.level-controls, .game-controls {
    background: #2d2d2d;
    padding: 8px;
    overflow-y: auto;
}

.level-controls h4, .game-controls h4 {
    color: #00ff41;
    font-size: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid #404040;
    padding-bottom: 4px;
}

.level-tool {
    display: block;
    width: 100%;
    background: #1a1a1a;
    border: 1px solid #404040;
    color: #e0e0e0;
    padding: 8px;
    font-family: inherit;
    font-size: 8px;
    cursor: pointer;
    margin-bottom: 4px;
    transition: all 0.2s;
}

.level-tool:hover {
    background: #00ff41;
    color: #1a1a1a;
    border-color: #00ff41;
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    padding: 8px;
    background: #1a1a1a;
    border: 1px solid #404040;
}

.game-info div {
    font-size: 8px;
    color: #808080;
}

.game-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
}

.game-buttons button {
    background: #1a1a1a;
    border: 1px solid #404040;
    color: #e0e0e0;
    padding: 8px;
    font-family: inherit;
    font-size: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.game-buttons button:hover {
    background: #00ff41;
    color: #1a1a1a;
    border-color: #00ff41;
}

.game-instructions {
    font-size: 8px;
    color: #808080;
    padding: 8px;
    background: #1a1a1a;
    border: 1px solid #404040;
    text-align: center;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 26, 26, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
    color: #00ff41;
}

.pixel-spinner {
    width: 32px;
    height: 32px;
    border: 4px solid #404040;
    border-top: 4px solid #00ff41;
    margin: 0 auto 16px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #404040;
    border: 1px solid #808080;
}

::-webkit-scrollbar-thumb:hover {
    background: #00ff41;
}

/* Retro CRT effect */
.canvas-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 255, 65, 0.03) 0px,
        rgba(0, 255, 65, 0.03) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 1;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 180px 1fr 220px;
    }
    
    .left-sidebar, .right-sidebar {
        font-size: 7px;
    }
}

@media (max-width: 1000px) {
    .app-title {
        font-size: 10px;
    }
    
    .main-nav {
        gap: 2px;
    }
    
    .nav-tab {
        padding: 6px 8px;
        font-size: 7px;
    }
}