:root { --taskbar-h: 30px; --teal: #008080; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--teal); }
body { font-family: "Pixelated MS Sans Serif", Arial, sans-serif; font-size: 11px; -webkit-font-smoothing: none; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
#desktop { position: fixed; inset: 0 0 var(--taskbar-h) 0; overflow: hidden; }

/* ---- desktop icons ---- */
#icons { list-style: none; margin: 0; padding: 8px 4px; display: grid; grid-auto-flow: column; grid-template-rows: repeat(auto-fill, 78px); grid-auto-columns: 80px; height: 100%; gap: 2px 4px; }
button.icon, .icon { min-width: 0; min-height: 0; box-shadow: none !important; background: none; outline: none;
  width: 76px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 2px; cursor: default; color: #fff; text-align: center; border: 0; background: none; font: inherit; }
.icon img { width: 32px; height: 32px; image-rendering: pixelated; }
.icon span { max-width: 74px; overflow-wrap: anywhere; padding: 1px 2px; line-height: 1.2; text-shadow: none; border: 1px dotted transparent; }
.icon:focus { outline: none; }
.icon.selected img, .icon:focus-visible img { filter: brightness(.6) sepia(1) hue-rotate(190deg) saturate(5); }
.icon.selected span, .icon:focus-visible span { background: #000080; border-color: #ffff80; }

/* ---- windows ---- */
.window.app { position: absolute; display: flex; flex-direction: column; min-width: 200px; min-height: 90px; max-width: 100vw; }
.window.app[data-app=mines] .window-body { display: flex; justify-content: center; align-items: flex-start; }
.window.app .window-body { flex: 1; overflow: auto; margin: 3px; min-height: 0; position: relative; user-select: text; -webkit-user-select: text; }
.window.app.maximized { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; }
.window.app.minimized { display: none; }
.title-bar { cursor: default; touch-action: none; }
.title-bar-text { display: flex; align-items: center; gap: 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.title-bar-text img { width: 14px; height: 14px; image-rendering: pixelated; }
.window.app .resize-grip { position: absolute; right: 0; bottom: 0; width: 14px; height: 14px; cursor: nwse-resize; touch-action: none;
  background: linear-gradient(135deg, transparent 50%, #808080 50%, #808080 57%, #fff 57%, #fff 64%, transparent 64%, transparent 71%, #808080 71%, #808080 78%, #fff 78%, #fff 85%, transparent 85%); }
.window.app.maximized .resize-grip { display: none; }
.menubar { display: flex; gap: 2px; padding: 1px 2px; }
.menubar span { padding: 2px 6px; }
.menubar span:hover { box-shadow: inset -1px -1px #808080, inset 1px 1px #fff; }

/* ---- taskbar ---- */
#taskbar { position: fixed; left: 0; right: 0; bottom: 0; height: var(--taskbar-h); background: silver; box-shadow: inset 0 1px #dfdfdf, inset 0 2px #fff; display: flex; align-items: center; gap: 3px; padding: 3px 2px 2px; z-index: 100000; }
#start-button { display: flex; align-items: center; gap: 3px; min-width: 54px; height: 22px; padding: 0 5px; font-size: 11px; }
#start-button[aria-expanded="true"] { box-shadow: inset -1px -1px #fff, inset 1px 1px #0a0a0a, inset -2px -2px #dfdfdf, inset 2px 2px grey; }
#task-buttons { flex: 1; display: flex; gap: 3px; overflow: hidden; min-width: 0; }
#task-buttons button { flex: 0 1 160px; min-width: 32px; height: 22px; display: flex; align-items: center; gap: 4px; padding: 0 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; justify-content: flex-start; }
#task-buttons button img { width: 16px; height: 16px; flex: none; image-rendering: pixelated; }
#task-buttons button span { overflow: hidden; text-overflow: ellipsis; }
#task-buttons button.active { box-shadow: inset -1px -1px #fff, inset 1px 1px #0a0a0a, inset -2px -2px #dfdfdf, inset 2px 2px grey; background: repeating-conic-gradient(#c0c0c0 0% 25%, #fff 0% 50%) 50% / 2px 2px; font-weight: bold; }
#tray { height: 22px; display: flex; align-items: center; gap: 6px; padding: 0 8px; margin: 0; flex: none; }
#tray-cat { font-size: 12px; cursor: help; }

/* ---- start menu ---- */
#start-menu { position: fixed; left: 2px; bottom: calc(var(--taskbar-h) - 1px); z-index: 100001; display: flex; padding: 3px; min-width: 200px; }
#start-menu[hidden] { display: none; }
.start-side { width: 22px; background: linear-gradient(0deg, #000080, #1084d0); position: relative; }
.start-side span { position: absolute; left: 3px; bottom: 6px; writing-mode: vertical-rl; transform: rotate(180deg); color: #c0c0c0; font-size: 16px; font-weight: bold; letter-spacing: 1px; }
.start-side b { color: #fff; }
.start-items { list-style: none; margin: 0; padding: 0; flex: 1; }
.start-items li { display: flex; align-items: center; gap: 10px; padding: 4px 18px 4px 6px; cursor: default; font-size: 11px; white-space: nowrap; }
.start-items li img { width: 24px; height: 24px; image-rendering: pixelated; }
.start-items li:hover, .start-items li:focus { background: #000080; color: #fff; outline: none; }
.start-items li.sep { padding: 0; margin: 3px 2px; border-top: 1px solid #808080; border-bottom: 1px solid #fff; pointer-events: none; }
.start-items li u { text-decoration: underline; }

/* ---- app contents ---- */
.viewer { background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 100%; padding: 8px; }
.viewer img, .viewer video { max-width: 100%; height: auto; display: block; }
.viewer .meow { font-size: 28px; font-family: "Comic Sans MS", "Comic Sans", cursive; color: #000; }
.notepad textarea { width: 100%; height: 100%; resize: none; font-family: "Courier New", monospace; font-size: 13px; border: 0; box-shadow: none; padding: 4px; user-select: text; }
.window.app .window-body.flush { margin: 0 3px 3px; padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.music { display: flex; flex-direction: column; gap: 6px; padding: 6px; }
.music .lcd { background: #000; color: #0f0; font-family: "Courier New", monospace; padding: 6px; font-size: 13px; overflow: hidden; white-space: nowrap; }
.music .lcd marquee, .music .lcd .scroll { display: inline-block; animation: lcd 10s linear infinite; padding-left: 100%; }
@keyframes lcd { to { transform: translateX(-100%); } }
.music midi-player { display: block; width: 100%; }
.music midi-player::part(control-panel) { background: #c0c0c0; border-radius: 0; box-shadow: inset -1px -1px #fff, inset 1px 1px grey; }
.music midi-player::part(play-button) { border-radius: 0; background: #c0c0c0; box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #fff, inset -2px -2px grey, inset 2px 2px #dfdfdf; color: #000; }
.music .staff { background: #fff; overflow: auto; height: 170px; box-shadow: inset -1px -1px #fff, inset 1px 1px grey, inset -2px -2px #dfdfdf, inset 2px 2px #0a0a0a; }
.music .loading { padding: 20px; text-align: center; }
.doom-wrap { flex: 1; background: #000; position: relative; min-height: 0; }
.doom-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.toolbar { display: flex; gap: 4px; padding: 3px 2px; align-items: center; flex-wrap: wrap; }
.toolbar button { min-width: 0; padding: 0 8px; }
.explorer { background: #fff; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; padding: 8px; min-height: 100%; }
.explorer .icon { color: #000; }
.explorer .icon.selected span, .explorer .icon:focus-visible span { color: #fff; }
.dialog-body { display: flex; gap: 14px; padding: 10px 8px 4px; align-items: flex-start; }
.dialog-body img { width: 32px; height: 32px; flex: none; }
.dialog-buttons { display: flex; justify-content: center; gap: 6px; padding: 8px; }
.dialog-buttons button { min-width: 75px; }
.meridian { padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.meridian .banner { background: radial-gradient(circle at 75% 120%, #2050c0 0 30%, transparent 31%), #000018; color: #9cf; height: 96px; display: flex; align-items: center; justify-content: center; font: bold 26px/1 "Courier New", monospace; letter-spacing: 6px; text-shadow: 0 0 6px #39f; box-shadow: inset -1px -1px #fff, inset 1px 1px grey; }

/* ---- shutdown ---- */
#shutdown-screen { position: fixed; inset: 0; z-index: 200000; background: #000; color: #ff8a00; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font: bold 32px/1.3 "Courier New", monospace; cursor: pointer; }
#shutdown-screen[hidden] { display: none; }
#shutdown-screen small { font-size: 12px; color: #888; margin-top: 20px; }
.noscript { margin: 40px auto; width: 280px; }

/* ---- mobile ---- */
@media (max-width: 640px), (max-height: 480px) {
  :root { --taskbar-h: 36px; }
  #icons { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); grid-template-rows: none; grid-auto-rows: 84px; grid-auto-columns: auto; justify-items: center; overflow-y: auto; }
  .window.app { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; }
  .window.app .resize-grip, .title-bar-controls button[aria-label="Maximize"], .title-bar-controls button[aria-label="Restore"] { display: none; }
  .title-bar { padding: 4px 3px; }
  .title-bar-controls button { min-width: 22px; min-height: 20px; }
  #start-button, #task-buttons button { height: 28px; }
  #task-buttons button span { display: none; }
  #task-buttons button { flex: 0 0 34px; justify-content: center; }
  .start-items li { padding: 9px 18px 9px 6px; font-size: 13px; }
}
