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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.header {
    background-color: #ff8c00;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
}

.header-left {
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    color: white;
    font-weight: bold;
    font-size: 16px;
    gap: 8px;
}

.logo i {
    font-size: 20px;
}

.header-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.tabs {
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    overflow: hidden;
}

.tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.tab:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.tab.active {
    background-color: rgba(255, 255, 255, 0.3);
}

.tab-dropdown {
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: white;
    cursor: pointer;
    border-left: 1px solid rgba(255, 255, 255, 0.3);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 5px;
}

.header-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: white;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
}

.header-icon:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.user-icon {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background-color: #5fbcd3;
    display: flex;
    flex-direction: column;
    position: relative;
}

.game-preview {
    padding: 15px;
}

.preview-screen {
    background-color: #000;
    border-radius: 10px;
    aspect-ratio: 160/128;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #444;
    position: relative;
    overflow: hidden;
}

#game-canvas {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    display: none;
}

#game-canvas.running {
    display: block;
}

.play-button {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid white;
    background: transparent;
    color: white;
    font-size: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background-color 0.2s;
    position: absolute;
    z-index: 10;
}

.play-button.hidden {
    display: none;
}

.play-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.play-button i {
    margin-left: 5px;
}

/* Controller Preview */
.controller-preview {
    background-color: #e8e0d5;
    border-radius: 15px;
    padding: 10px 15px;
    margin-top: 10px;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.controller-left {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.menu-label {
    font-size: 8px;
    color: #666;
    margin-bottom: 5px;
    background-color: #ccc;
    padding: 2px 8px;
    border-radius: 3px;
}

.dpad {
    position: relative;
    width: 50px;
    height: 50px;
}

.dpad-up, .dpad-down, .dpad-left, .dpad-right {
    position: absolute;
    width: 16px;
    height: 16px;
    background-color: #333;
}

.dpad-up {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 3px 3px 0 0;
}

.dpad-down {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 0 0 3px 3px;
}

.dpad-left {
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 3px 0 0 3px;
}

.dpad-right {
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 0 3px 3px 0;
}

.dpad-center {
    position: absolute;
    width: 16px;
    height: 16px;
    background-color: #333;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.controller-right {
    display: flex;
    align-items: center;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: flex-end;
}

.btn-a, .btn-b {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    font-weight: bold;
    font-size: 12px;
    cursor: pointer;
}

.btn-a {
    background-color: #4a9f4a;
    color: white;
}

.btn-b {
    background-color: #e74c3c;
    color: white;
}

.controller-brand {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 8px;
    color: #888;
}

/* Control Buttons */
.control-buttons {
    display: flex;
    gap: 5px;
    padding: 10px 15px;
    flex-wrap: wrap;
}

.control-btn {
    width: 32px;
    height: 32px;
    border-radius: 5px;
    border: none;
    background-color: #3d9bb3;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.control-btn:hover {
    background-color: #2d8aa3;
}

.control-btn.play {
    background-color: #2d8aa3;
}

.control-btn.stop {
    background-color: #e74c3c;
}

/* Sidebar Content */
.sidebar-content {
    flex: 1;
    position: relative;
}

.collapse-handle {
    position: absolute;
    right: -15px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 60px;
    background-color: #5fbcd3;
    border-radius: 0 5px 5px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    font-size: 10px;
}

/* Editor Area */
.editor-area {
    flex: 1;
    background-color: #f5f0e6;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* Asset Preview Panel */
.asset-preview-panel {
    width: 150px;
    padding: 15px;
    border-right: 1px solid #ddd;
}

.asset-preview-panel h3 {
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
}

.preview-box {
    width: 100%;
    aspect-ratio: 1;
    background-color: #e8e0d5;
    border-radius: 5px;
    margin-bottom: 10px;
}

.no-asset {
    font-size: 11px;
    color: #888;
    text-align: center;
    margin-bottom: 15px;
}

.colors-btn {
    width: 100%;
    padding: 10px 15px;
    background-color: #3d9bb3;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.2s;
}

.colors-btn:hover {
    background-color: #2d8aa3;
}

/* Assets Panel */
.assets-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.assets-tabs {
    display: flex;
    padding: 10px 15px 0;
    gap: 10px;
}

.assets-tab {
    padding: 8px 15px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.assets-tab:hover {
    color: #333;
}

.assets-tab.active {
    color: #333;
    font-weight: 600;
    border-bottom-color: #ff8c00;
}

.assets-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(55px, 1fr));
    gap: 8px;
    padding: 15px;
    overflow-y: auto;
    align-content: start;
}

.add-asset-btn {
    width: 55px;
    height: 55px;
    background-color: #3d9bb3;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.add-asset-btn:hover {
    background-color: #2d8aa3;
}

.asset-cell {
    width: 55px;
    height: 55px;
    background-color: #e0d8cc;
    border-radius: 5px;
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    right: 10px;
    bottom: 50%;
    transform: translateY(50%);
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.zoom-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid #ccc;
    background: white;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.zoom-btn:hover {
    background-color: #f0f0f0;
}

/* Footer */
.footer {
    height: 50px;
    background-color: #f5f0e6;
    border-top: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.download-btn {
    padding: 10px 25px;
    background-color: #4caf50;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
}

.download-btn:hover {
    background-color: #45a049;
}

.more-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background-color: #ff8c00;
    color: white;
    cursor: pointer;
    font-size: 14px;
}

.footer-center {
    display: flex;
    align-items: center;
    gap: 10px;
}

.project-name {
    padding: 8px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    width: 150px;
}

.save-btn, .github-btn {
    width: 36px;
    height: 36px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
}

.save-btn {
    background-color: #3d9bb3;
    color: white;
}

.save-btn:hover {
    background-color: #2d8aa3;
}

.github-btn {
    background-color: #333;
    color: white;
}

.github-btn:hover {
    background-color: #222;
}

.sync-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #ddd;
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 5px;
}

.footer-icon {
    width: 36px;
    height: 36px;
    border-radius: 5px;
    border: none;
    background-color: #3d9bb3;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.footer-icon:hover {
    background-color: #2d8aa3;
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .sidebar {
        width: 180px;
    }

    .asset-preview-panel {
        width: 120px;
    }
}

@media (max-width: 700px) {
    .sidebar {
        width: 150px;
    }

    .asset-preview-panel {
        display: none;
    }
}

/* ============================================
   CODE EDITOR (Lunipix)
   ============================================ */
.code-editor-area {
    background-color: #1e1e1e;
    flex-direction: column;
}

.code-editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

.code-editor-header {
    background-color: #2d2d2d;
    padding: 8px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #444;
}

.file-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background-color: #1e1e1e;
    color: #ccc;
    border-radius: 5px 5px 0 0;
    font-size: 13px;
}

.file-tab.active {
    background-color: #1e1e1e;
    color: #fff;
}

.file-tab i {
    color: #6a9955;
}

.new-file-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #888;
    cursor: pointer;
    border-radius: 5px;
    font-size: 14px;
}

.new-file-btn:hover {
    background-color: #444;
    color: #fff;
}

.code-editor-wrapper {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.line-numbers {
    background-color: #1e1e1e;
    color: #858585;
    padding: 15px 10px;
    text-align: right;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.5;
    min-width: 50px;
    user-select: none;
    border-right: 1px solid #333;
    overflow: hidden;
    white-space: pre-line;
}

.code-editor {
    flex: 1;
    background-color: #1e1e1e;
    color: #d4d4d4;
    border: none;
    padding: 15px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    overflow: auto;
}

.code-editor::placeholder {
    color: #6a9955;
}

/* ============================================
   SPRITE EDITOR MODAL
   ============================================ */
.sprite-editor-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.sprite-editor-modal.active {
    display: flex;
}

.sprite-editor {
    width: 95%;
    height: 95%;
    max-width: 1400px;
    max-height: 900px;
    background-color: #1a1a1a;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Sprite Editor Header */
.sprite-editor-header {
    background-color: #3366cc;
    padding: 0 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 45px;
}

.sprite-editor-tabs {
    display: flex;
    align-items: center;
    height: 100%;
}

.sprite-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 25px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 14px;
    height: 100%;
    transition: all 0.2s;
}

.sprite-tab:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.sprite-tab.active {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.sprite-close-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: white;
    cursor: pointer;
    font-size: 18px;
    border-radius: 5px;
    transition: background-color 0.2s;
}

.sprite-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Sprite Editor Main Area */
.sprite-editor-main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sprite Toolbar */
.sprite-toolbar {
    width: 70px;
    background-color: #2a2a2a;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    overflow-y: auto;
}

.tool-group {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    padding-bottom: 8px;
    border-bottom: 1px solid #444;
    margin-bottom: 5px;
}

.tool-group:last-of-type {
    border-bottom: none;
}

.tool-btn {
    width: 28px;
    height: 28px;
    border: none;
    background-color: transparent;
    color: #888;
    cursor: pointer;
    border-radius: 5px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.tool-btn:hover {
    background-color: #444;
    color: #fff;
}

.tool-btn.active {
    background-color: #3366cc;
    color: #fff;
}

.history-group {
    margin-top: auto;
}

/* Color Palette */
.color-palette {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #444;
}

.current-color {
    width: 50px;
    height: 50px;
    background-color: #ff88cc;
    border: 3px solid #fff;
    border-radius: 5px;
    margin-bottom: 5px;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border: 2px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    transition: transform 0.1s;
}

.color-swatch:hover {
    transform: scale(1.1);
    border-color: #fff;
}

.transparent-swatch {
    background: linear-gradient(45deg, #666 25%, transparent 25%),
                linear-gradient(-45deg, #666 25%, transparent 25%),
                linear-gradient(45deg, transparent 75%, #666 75%),
                linear-gradient(-45deg, transparent 75%, #666 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
    background-color: #999;
}

/* Sprite Canvas Area */
.sprite-canvas-area {
    flex: 1;
    background-color: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.canvas-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#sprite-canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: repeating-conic-gradient(#808080 0% 25%, #c0c0c0 0% 50%) 50% / 20px 20px;
    border: 2px solid #444;
    cursor: crosshair;
}

/* Sprite Editor Footer */
.sprite-editor-footer {
    background-color: #2a2a2a;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid #444;
}

.canvas-coords {
    color: #888;
    font-size: 12px;
    font-family: monospace;
    min-width: 60px;
}

.sprite-footer-center {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sprite-name-input {
    padding: 8px 15px;
    border: 1px solid #444;
    border-radius: 5px;
    background-color: #1a1a1a;
    color: #fff;
    font-size: 14px;
    width: 150px;
}

.sprite-name-input:focus {
    outline: none;
    border-color: #3366cc;
}

.sprite-footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sprite-footer-btn {
    width: 32px;
    height: 32px;
    border: none;
    background-color: #444;
    color: #fff;
    cursor: pointer;
    border-radius: 5px;
    font-size: 14px;
    transition: background-color 0.2s;
}

.sprite-footer-btn:hover {
    background-color: #555;
}

.sprite-done-btn {
    padding: 8px 25px;
    border: none;
    background-color: #3366cc;
    color: #fff;
    cursor: pointer;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.2s;
}

.sprite-done-btn:hover {
    background-color: #4477dd;
}

/* Asset Item (created assets) */
.asset-item {
    width: 55px;
    height: 55px;
    border-radius: 5px;
    cursor: pointer;
    border: 2px solid transparent;
    overflow: hidden;
    transition: border-color 0.2s;
}

.asset-item:hover {
    border-color: #3d9bb3;
}

.asset-item.selected {
    border-color: #ff8c00;
}

.asset-item canvas {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ============================================
   LARGE GAME SCREEN OVERLAY
   ============================================ */
.game-screen-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 999;
    justify-content: center;
    align-items: center;
}

.game-screen-overlay.active {
    display: flex;
}

.game-screen-container {
    width: 50%;
    min-width: 400px;
    max-width: 800px;
    background-color: #1a1a1a;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.game-screen-header {
    background-color: #ff8c00;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.game-title {
    color: white;
    font-weight: bold;
    font-size: 16px;
}

.game-close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    border-radius: 5px;
    font-size: 16px;
    transition: background-color 0.2s;
}

.game-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.game-screen-wrapper {
    background-color: #000;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#large-game-canvas {
    width: 100%;
    max-width: 640px;
    aspect-ratio: 320/256;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border: 3px solid #444;
    border-radius: 5px;
}

.game-screen-footer {
    background-color: #2a2a2a;
    padding: 15px 20px;
    display: flex;
    justify-content: center;
    gap: 15px;
}

.game-controls {
    display: flex;
    gap: 10px;
}

.game-ctrl-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
}

.game-ctrl-btn:first-child {
    background-color: #3d9bb3;
    color: white;
}

.game-ctrl-btn:first-child:hover {
    background-color: #2d8aa3;
}

.game-ctrl-btn:last-child {
    background-color: #e74c3c;
    color: white;
}

.game-ctrl-btn:last-child:hover {
    background-color: #c0392b;
}
