* {
    box-sizing: border-box;
    font-family: 'MS Sans Serif', 'Tahoma', Geneva, sans-serif;
    font-size: 11px;
    -webkit-user-select: none; user-select: none;
    -webkit-tap-highlight-color: transparent;
}
input, textarea, select { -webkit-user-select: text; user-select: text; }

html, body { margin: 0; padding: 0; overflow: hidden; height: 100%; }
body { background: #008080; cursor: default; }

/* ---------- Boot Screen ---------- */
#boot-screen {
    position: fixed; inset: 0; z-index: 9999;
    background: #000; color: #fff;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    transition: opacity 0.6s ease;
}
#boot-screen.fade-out { opacity: 0; }
.boot-logo { text-align: center; margin-bottom: 40px; }
.boot-flag {
    display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
    width: 90px; height: 90px; gap: 6px; margin: 0 auto 18px;
    transform: perspective(200px) rotateY(-18deg) skewY(-6deg);
}
.boot-flag.small { width: 44px; height: 44px; gap: 3px; transform: none; }
.boot-flag span { border-radius: 3px; }
.flag-red { background: #ff2b2b; } .flag-green { background: #35c72e; }
.flag-blue { background: #2b7bff; } .flag-yellow { background: #ffd21a; }
.boot-text { font-size: 20px; letter-spacing: 1px; }
.boot-text sub { font-size: 10px; vertical-align: super; }
.boot-title { font-size: 56px; font-weight: 900; letter-spacing: -2px; font-family: 'Tahoma', sans-serif; }
.boot-95 { color: #ffd21a; font-size: 30px; vertical-align: super; margin-left: 4px; }
.boot-bar { width: 260px; height: 16px; border: 2px inset #888; background: #111; overflow: hidden; }
.boot-bar-fill { height: 100%; width: 0; background: repeating-linear-gradient(90deg,#2b7bff 0 12px,#111 12px 16px); animation: bootfill 3s linear forwards; }
@keyframes bootfill { to { width: 100%; } }
.boot-hint { margin-top: 24px; font-size: 11px; color: #888; }

/* ---------- Desktop ---------- */
#desktop { position: relative; width: 100vw; height: 100vh; }
#desktop-canvas { position: absolute; top: 0; left: 0; z-index: 1; }

.desktop-icon { position: absolute; width: 70px; text-align: center; cursor: pointer; z-index: 2; padding: 4px 2px; }
.desktop-icon:hover .icon-label { background: #000080; color: #fff; outline: 1px dotted #fff; }
.icon-image { display: flex; justify-content: center; align-items: center; height: 34px; margin-bottom: 3px; }
.icon-image img { width: 32px; height: 32px; image-rendering: pixelated; }
.icon-label { color: #fff; font-size: 11px; text-shadow: 1px 1px 1px #000; word-wrap: break-word; padding: 1px 3px; display: inline-block; }

/* ---------- Windows ---------- */
.window {
    position: absolute; background: #c0c0c0;
    border: 2px solid; border-color: #ffffff #000 #000 #ffffff;
    box-shadow: inset -1px -1px 0 #808080, inset 1px 1px 0 #dfdfdf, 2px 2px 6px rgba(0,0,0,0.4);
    z-index: 100; display: flex; flex-direction: column;
}
.window-title-bar {
    background: linear-gradient(to right, #808080, #b0b0b0);
    color: #e0e0e0; padding: 3px 3px 3px 6px;
    display: flex; justify-content: space-between; align-items: center; cursor: move;
    height: 22px; flex-shrink: 0;
}
.window-title-bar.active { background: linear-gradient(to right, #000080, #1084d0); color: #fff; }
.window-title { font-weight: bold; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.window-controls { display: flex; gap: 2px; flex-shrink: 0; }
.window-control {
    width: 17px; height: 15px; background: #c0c0c0;
    border: 1px solid; border-color: #ffffff #000 #000 #ffffff;
    box-shadow: inset -1px -1px 0 #808080, inset 1px 1px 0 #dfdfdf;
    font-size: 10px; font-weight: bold; cursor: pointer; padding: 0; line-height: 1; color: #000;
}
.window-control:active { border-color: #000 #ffffff #ffffff #000; box-shadow: inset 1px 1px 0 #808080; }
.window-content { padding: 3px; flex: 1; overflow: hidden; }
.window-content canvas { display: block; border: 2px inset #c0c0c0; background: #000; image-rendering: pixelated; }

.resize-handle { position: absolute; z-index: 10; }
.resize-n { top: -3px; left: 8px; right: 8px; height: 6px; cursor: n-resize; }
.resize-s { bottom: -3px; left: 8px; right: 8px; height: 6px; cursor: s-resize; }
.resize-e { top: 8px; right: -3px; bottom: 8px; width: 6px; cursor: e-resize; }
.resize-w { top: 8px; left: -3px; bottom: 8px; width: 6px; cursor: w-resize; }
.resize-ne { top: -3px; right: -3px; width: 9px; height: 9px; cursor: ne-resize; }
.resize-nw { top: -3px; left: -3px; width: 9px; height: 9px; cursor: nw-resize; }
.resize-se { bottom: -3px; right: -3px; width: 9px; height: 9px; cursor: se-resize; }
.resize-sw { bottom: -3px; left: -3px; width: 9px; height: 9px; cursor: sw-resize; }

/* ---------- Taskbar ---------- */
#taskbar {
    position: fixed; bottom: 0; left: 0; right: 0; height: 40px;
    background: #c0c0c0; border-top: 2px solid #dfdfdf;
    display: flex; align-items: center; padding: 3px 4px; z-index: 1000; gap: 4px;
}
#start-button {
    height: 30px; padding: 2px 10px 2px 6px; font-weight: bold;
    display: flex; align-items: center; font-size: 12px;
}
.mini-flag { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; width: 16px; height: 16px; gap: 1px; }
.mini-flag i { display: block; }
.mf-r { background: #ff2b2b; } .mf-g { background: #35c72e; } .mf-b { background: #2b7bff; } .mf-y { background: #ffd21a; }
.taskbar-divider { width: 2px; align-self: stretch; margin: 4px 2px; border-left: 1px solid #808080; border-right: 1px solid #fff; }
#taskbar-buttons { flex: 1; display: flex; gap: 3px; overflow: hidden; }
.taskbar-button {
    height: 30px; padding: 2px 8px; max-width: 160px; min-width: 100px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left;
    background: #c0c0c0; border: 2px solid; border-color: #dfdfdf #808080 #808080 #dfdfdf; cursor: pointer; font-size: 11px;
}
.taskbar-button.active { border-color: #808080 #dfdfdf #dfdfdf #808080; background: #d8d4c8; font-weight: bold; }
#system-tray {
    display: flex; align-items: center; gap: 8px; padding: 3px 8px;
    border: 1px solid; border-color: #808080 #fff #fff #808080;
}
#tray-vol { cursor: pointer; font-size: 13px; }
#clock { font-size: 11px; }

/* ---------- Win95 Buttons ---------- */
.win95-button {
    background: #c0c0c0; color: #000; padding: 4px 14px; cursor: pointer; font-size: 11px;
    border: 2px solid; border-color: #dfdfdf #808080 #808080 #dfdfdf;
    box-shadow: inset -1px -1px 0 #808080, inset 1px 1px 0 #fff;
}
.win95-button:active { border-color: #808080 #dfdfdf #dfdfdf #808080; box-shadow: inset 1px 1px 0 #808080; }

/* ---------- Start Menu ---------- */
#start-menu {
    position: absolute; bottom: 40px; left: 4px; width: 210px;
    background: #c0c0c0; border: 2px solid; border-color: #dfdfdf #808080 #808080 #dfdfdf;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.4); z-index: 1001; display: flex;
}
.start-banner {
    width: 30px; background: linear-gradient(to top, #000080, #1084d0); color: #c0c0c0;
    writing-mode: vertical-rl; transform: rotate(180deg); text-align: right;
    font-size: 20px; font-weight: 900; padding: 8px 4px; letter-spacing: 1px; flex-shrink: 0;
}
.start-banner span { color: #fff; }
.start-menu-items { flex: 1; padding: 2px 0; }
.start-menu-item { padding: 6px 20px 6px 8px; cursor: pointer; display: flex; align-items: center; gap: 8px; position: relative; }
.start-menu-item:hover { background: #000080; color: #fff; }
.start-arrow { position: absolute; right: 6px; font-size: 9px; }
.menu-icon { width: 18px; height: 18px; image-rendering: pixelated; }
.start-menu-separator { height: 2px; margin: 3px 6px; border-top: 1px solid #808080; border-bottom: 1px solid #fff; }

/* ---------- Submenus ---------- */
.programs-submenu {
    position: fixed; width: 200px; max-height: 70vh; overflow-y: auto;
    background: #c0c0c0; border: 2px solid; border-color: #dfdfdf #808080 #808080 #dfdfdf;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.4); z-index: 1002; max-width: calc(100vw - 10px);
}
.submenu-item { padding: 6px 12px; cursor: pointer; font-size: 11px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.submenu-item:hover { background: #000080; color: #fff; }
.submenu-item-content { display: flex; align-items: center; gap: 8px; flex: 1; }
.submenu-icon { width: 16px; height: 16px; image-rendering: pixelated; flex-shrink: 0; }
.submenu-arrow { font-size: 9px; }
.submenu-separator { height: 2px; margin: 3px 6px; border-top: 1px solid #808080; border-bottom: 1px solid #fff; }
.submenu-custom-app { background: #ffffcc; font-weight: bold; color: #000080; }
.submenu-custom-app:hover { background: #ffff80; color: #000080; }

/* ---------- Dialogs ---------- */
#modal-overlay, #settings-modal, #about-modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.35);
    display: flex; justify-content: center; align-items: flex-start; padding-top: 8vh; z-index: 2000;
}
.win95-dialog {
    background: #c0c0c0; border: 2px solid; border-color: #dfdfdf #808080 #808080 #dfdfdf;
    box-shadow: inset -1px -1px 0 #808080, inset 1px 1px 0 #fff, 4px 4px 10px rgba(0,0,0,0.5);
    min-width: 380px; max-width: 92vw; max-height: 82vh; overflow-y: auto;
}
.dialog-title-bar {
    background: linear-gradient(to right, #000080, #1084d0); color: #fff;
    padding: 3px 4px 3px 8px; display: flex; justify-content: space-between; align-items: center; font-weight: bold; height: 22px;
}
.dialog-close {
    width: 17px; height: 15px; background: #c0c0c0; color: #000;
    border: 1px solid; border-color: #fff #000 #000 #fff; font-size: 10px; font-weight: bold; cursor: pointer; padding: 0;
}
.dialog-content { padding: 16px; }
.dialog-content p { margin: 0 0 10px; }
.run-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.run-icon { width: 32px; height: 32px; image-rendering: pixelated; flex-shrink: 0; }
.win95-input, .win95-textarea, select.win95-input {
    width: 100%; padding: 4px; background: #fff; font-size: 11px;
    border: 2px solid; border-color: #808080 #fff #fff #808080;
}
.win95-textarea { resize: vertical; min-height: 60px; font-family: 'Courier New', monospace; }
.run-row .win95-input { margin: 0; }
.help-text { background: #ffffcc; border: 1px solid #c0c000; padding: 8px; margin: 8px 0; font-size: 10px; }
.help-text p { margin: 0; }
.help-text code { background: #eee; padding: 1px 3px; font-family: 'Courier New', monospace; }
.dialog-buttons { text-align: right; margin-top: 12px; }
.dialog-buttons .win95-button { margin-left: 8px; min-width: 72px; }
.settings-section { margin-bottom: 14px; }
.settings-section label { display: block; margin-bottom: 4px; font-weight: bold; color: #000080; }
.settings-section label input[type="checkbox"] { width: auto; margin-right: 6px; }
.about-content { display: flex; gap: 16px; align-items: flex-start; }
.about-content h3 { font-size: 14px; }
.about-content p { margin: 3px 0; }
.about-content hr { border: none; border-top: 1px solid #808080; border-bottom: 1px solid #fff; margin: 8px 0; }

/* ---------- Scanlines ---------- */
#scanline-overlay {
    position: fixed; inset: 0; pointer-events: none; z-index: 5000;
    background: repeating-linear-gradient(to bottom, rgba(0,0,0,0.12) 0 1px, transparent 1px 3px);
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 16px; height: 16px; }
::-webkit-scrollbar-track { background: #d8d4c8; }
::-webkit-scrollbar-thumb { background: #c0c0c0; border: 2px solid; border-color: #dfdfdf #808080 #808080 #dfdfdf; }
::-webkit-scrollbar-corner { background: #c0c0c0; }

.hidden { display: none !important; }

/* ---------- Footer ---------- */
.footer {
    position: fixed; bottom: 46px; right: 8px; z-index: 999;
    background: rgba(192,192,192,0.92); padding: 3px 8px;
    border: 2px solid; border-color: #dfdfdf #808080 #808080 #dfdfdf; font-size: 10px;
}
.footer a { color: #000080; text-decoration: none; }
.footer a:hover { text-decoration: underline; }

@media (max-width: 600px) {
    .desktop-icon { width: 60px; }
    #start-button { padding: 2px 6px; }
    .taskbar-button { min-width: 60px; max-width: 90px; }
    .win95-dialog { min-width: 0; width: 94vw; }
}