:root {
    --bg-color: #f3f0e7;
    --sidebar-bg: #e4e1d8;
    --header-bg: #dfdbd0;
    --border-color: #c6c2b5;
    --text-primary: #2d2d2d;
    --text-secondary: #666666;
    --accent-color: #f54e00;
    --selection-bg: #eaddd0;
    --tab-active-bg: #f3f0e7;
    --tab-inactive-bg: #d8d4c8;
    --status-bar-bg: #f54e00;
    --status-bar-text: #ffffff;
    --code-font: 'Fira Code', monospace;
    --ui-font: 'Inter', sans-serif;
    --line-height: 1.6;
}

.dark-mode {
    --bg-color: #1e1e1e;
    --sidebar-bg: #252526;
    --header-bg: #333333;
    --border-color: #3e3e42;
    --text-primary: #d4d4d4;
    --text-secondary: #858585;
    --accent-color: #f54e00;
    --selection-bg: #37373d;
    --tab-active-bg: #1e1e1e;
    --tab-inactive-bg: #2d2d2d;
    --status-bar-bg: #007acc;
}

.retro-mode {
    --bg-color: #002b00; /* Terminal Green Background */
    --sidebar-bg: #001a00;
    --header-bg: #003300;
    --border-color: #00ff00;
    --text-primary: #00ff00;
    --text-secondary: #00cc00;
    --accent-color: #00ff00;
    --selection-bg: #004400;
    --tab-active-bg: #002b00;
    --tab-inactive-bg: #001a00;
    --status-bar-bg: #00ff00;
    --status-bar-text: #000000;
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 2px #00ff00;
}

/* Retro Mode CRT Effect */
.retro-mode::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 9999;
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
}

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

body {
    font-family: var(--ui-font);
    background-color: #000;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    color: var(--text-primary);
}

.desktop {
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    position: relative;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.3s;
}

/* Menu Bar */
.menu-bar {
    height: 30px;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    font-size: 13px;
    user-select: none;
}

.menu-left {
    display: flex;
    gap: 4px;
    align-items: center;
}

.mobile-menu-toggle {
    display: none;
    padding: 6px 8px; /* Symmetric padding, fit within 30px height */
    margin-left: -8px; /* Pull back to align icon but keep click target large */
    font-size: 18px;
    cursor: pointer;
    border-radius: 4px;
}

.mobile-menu-toggle:hover {
    background-color: rgba(0,0,0,0.1);
}

.menu-dropdown-wrapper {
    position: relative;
}

.menu-item {
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
}

.menu-item:hover, .menu-item.active {
    background-color: rgba(0,0,0,0.1);
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--sidebar-bg);
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    z-index: 100;
    border-radius: 0 0 4px 4px;
}

.menu-dropdown-wrapper:hover .dropdown-content {
    display: block;
}

.dropdown-item {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
}

.dropdown-item:hover {
    background-color: var(--accent-color);
    color: white;
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 4px 0;
}

.apple-logo {
    font-size: 14px;
    margin-right: 12px;
    display: flex;
    align-items: center;
}

/* Workspace & Sidebar */
.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 250px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    font-family: var(--ui-font);
    font-size: 13px;
}

.sidebar-header {
    height: 40px;
    display: flex;
    align-items: center;
    padding-left: 16px;
    gap: 8px;
}

.traffic-light {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.1);
}
.red { background-color: #ff5f56; }
.yellow { background-color: #ffbd2e; }
.green { background-color: #27c93f; }

.sidebar-content {
    padding: 10px 0;
    flex: 1;
    overflow-y: auto;
}

.section-title {
    padding: 0 16px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.mt-4 { margin-top: 24px; }

.folder-header {
    padding: 4px 16px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.folder-header:hover {
    background-color: rgba(0,0,0,0.05);
}

.folder-header i {
    font-size: 10px;
    width: 10px;
    transition: transform 0.2s;
}

.folder.open .folder-header i {
    transform: rotate(0deg);
}

.folder.closed .folder-header i {
    transform: rotate(-90deg);
}

.file-list {
    display: flex;
    flex-direction: column;
}

.file-item {
    padding: 6px 16px 6px 34px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    text-decoration: none;
}

.file-item:hover {
    background-color: rgba(0,0,0,0.05);
}

.file-item.active {
    background-color: var(--selection-bg);
    border-left: 2px solid var(--accent-color);
    padding-left: 32px;
}

.file-item i {
    width: 16px;
    text-align: center;
    color: var(--text-secondary);
}

.file-item.external-link {
    padding-left: 16px;
}

/* Editor */
.editor-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    width: calc(100% - 250px);
}

.tabs-bar {
    height: 36px;
    background-color: var(--sidebar-bg);
    display: flex;
    align-items: flex-end;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none; /* Hide scrollbar Firefox */
}

.tabs-bar::-webkit-scrollbar {
    display: none; /* Hide scrollbar Chrome/Safari */
}

.tab {
    height: 36px;
    padding: 0 12px 0 16px;
    background-color: var(--tab-inactive-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-secondary);
    min-width: 120px;
    max-width: 200px;
    /* Removed justify-content: space-between to let flex-grow handle spacing */
}

.tab-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0; /* Critical for flexbox truncation */
}

.tab.active {
    background-color: var(--tab-active-bg);
    color: var(--text-primary);
    border-top: 2px solid var(--accent-color);
}

.close-tab {
    font-size: 16px;
    line-height: 1;
    opacity: 0.6;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-tab:hover {
    opacity: 1;
    background-color: rgba(0,0,0,0.1);
}

.breadcrumbs {
    padding: 8px 20px;
    font-size: 12px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.separator {
    margin: 0 6px;
}

.editor-content {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    font-family: var(--code-font);
    font-size: 15px;
    line-height: 1.8;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.editor-textarea {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--code-font);
    font-size: 15px;
    resize: none;
    outline: none;
    line-height: 1.6;
}

/* Content Typography */
h1 { font-size: 2.5em; margin-bottom: 0.5em; font-weight: 700; letter-spacing: -1px; }
h2 { font-size: 1.5em; margin-top: 1.5em; margin-bottom: 0.75em; border-bottom: 1px solid var(--border-color); padding-bottom: 8px; }
h3 { font-size: 1.2em; margin-top: 1.2em; margin-bottom: 0.5em; }
p { margin-bottom: 1.2em; color: var(--text-primary); }
a { color: var(--accent-color); text-decoration: none; border-bottom: 1px solid transparent; }
a:hover { border-bottom: 1px solid var(--accent-color); }
ul { margin-bottom: 1.2em; padding-left: 20px; }
li { margin-bottom: 0.4em; }
code { background-color: rgba(0,0,0,0.06); padding: 2px 4px; border-radius: 4px; font-family: var(--code-font); font-size: 0.9em; }
pre { background-color: #282c34; color: #abb2bf; padding: 20px; border-radius: 6px; margin: 1.5em 0; overflow-x: auto; border: 1px solid var(--text-primary); box-shadow: 4px 4px 0px rgba(0,0,0,0.1); }
.comment { color: #7f848e; font-style: italic; }
.keyword { color: #c678dd; }
.string { color: #98c379; }
.function { color: #61afef; }
.number { color: #d19a66; }

/* Projects Grid */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin-top: 20px; }
.project-card { border: 2px solid var(--text-primary); padding: 20px; background: var(--tab-active-bg); transition: transform 0.1s; box-shadow: 4px 4px 0px rgba(0,0,0,0.1); }
.project-card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0px rgba(0,0,0,0.15); }
.project-title { font-weight: 700; font-size: 1.1em; margin-bottom: 8px; display: flex; justify-content: space-between; }
.project-desc { font-size: 0.9em; color: var(--text-secondary); margin-bottom: 16px; }
.tag { display: inline-block; font-size: 10px; padding: 2px 6px; border: 1px solid var(--border-color); border-radius: 10px; margin-right: 4px; margin-bottom: 4px; }

/* Games */
.game-container { display: flex; flex-direction: column; align-items: center; justify-content: center; margin-top: 20px; }
canvas { background-color: #282c34; border: 4px solid var(--text-primary); box-shadow: 8px 8px 0px rgba(0,0,0,0.1); }
.game-controls { margin-top: 20px; padding: 10px 20px; background: var(--tab-active-bg); border: 1px solid var(--border-color); border-radius: 4px; font-size: 0.9em; color: var(--text-secondary); }
.start-btn { margin-top: 20px; padding: 10px 20px; background-color: var(--accent-color); color: white; border: none; font-family: var(--ui-font); font-weight: 600; cursor: pointer; box-shadow: 2px 2px 0px rgba(0,0,0,0.2); transition: transform 0.1s; }
.start-btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0px rgba(0,0,0,0.25); }
.start-btn:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0px rgba(0,0,0,0.2); }

/* Modals */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex; justify-content: center; align-items: center;
    z-index: 1000;
}
.modal-window {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    width: 300px;
    border-radius: 6px;
    overflow: hidden;
}
.modal-header {
    background-color: var(--header-bg);
    padding: 8px 12px;
    font-size: 13px;
    font-weight: bold;
    border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center;
}
.close-modal { cursor: pointer; }
.modal-content { padding: 20px; text-align: center; }

/* Status Bar */
.status-bar { height: 24px; background-color: var(--status-bar-bg); color: var(--status-bar-text); display: flex; justify-content: space-between; align-items: center; padding: 0 12px; font-size: 11px; font-family: var(--ui-font); }
.status-left, .status-right { display: flex; gap: 16px; }
.status-left span, .status-right span { display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* Responsive */
canvas {
    max-width: 100%;
    height: auto;
}

@media (max-width: 768px) {
    .sidebar {
        display: flex;
        position: absolute;
        top: 30px;
        left: -250px;
        height: calc(100% - 54px); /* Menu bar + Status bar */
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 4px 0 10px rgba(0,0,0,0.2);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    /* Overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: absolute;
        top: 30px;
        left: 0;
        width: 100%;
        height: calc(100% - 54px);
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    
    .sidebar.open + .sidebar-overlay {
        display: block;
    }

    .editor-content { 
        padding: 20px; 
    }
    
    .editor-window { 
        width: 100%; 
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .apple-logo {
        display: none;
    }
    
    /* Adjust menu items for small screens */
    .menu-item {
        padding: 2px 4px;
    }
    
    .project-grid {
        grid-template-columns: 1fr;
    }
    
    .game-container {
        width: 100%;
    }
    
    .file-item {
        padding-top: 12px;
        padding-bottom: 12px;
        font-size: 14px;
    }
}
