:root {
  --phosphor: #9dffb0;
  --xp-blue: #245edb;
  --xp-blue-hi: #3f8cf3;
  --xp-blue-dk: #0a3fb0;
  --xp-face: #ece9d8;
  --xp-edge: #0831d9;
  --xp-green: #3c9a3c;
  --xp-green-hi: #5cc35c;
  --ink: #111;
  --mono: "VT323", ui-monospace, Menlo, Consolas, monospace;
  --ui: Tahoma, "Segoe UI", Verdana, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --taskbar-h: calc(34px + env(safe-area-inset-bottom, 0px));
}

@font-face {
  font-family: "VT323";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/VT323.woff2") format("woff2");
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: #040a22;
  color: var(--ink);
  font: 13px/1.45 var(--ui);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ───────────────────────── The opening shot ───────────────────────── */

/* Film grain: a tiny SVG noise tile. */
:root {
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .55 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  /* Y2K chrome: bands of light and dark, like a 3D render from 2001. */
  --chrome: linear-gradient(180deg, #f7f9fb 0%, #d7dce2 14%, #9aa3ad 34%, #e3e7ec 48%, #7d858f 66%, #c3c9d0 82%, #5e656e 100%);
  --chrome-soft: linear-gradient(180deg, #eef1f4, #b9c0c8 40%, #e2e6ea 55%, #8a929b);
}

#stage {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 38%, #2d57b5 0%, #15307f 35%, #0a1a4e 62%, #040a22 100%);
  transform-origin: 50% 50%;
  transition: transform 900ms cubic-bezier(.6, 0, .25, 1), opacity 200ms;
  will-change: transform;
}
body.desk #stage { opacity: 0; pointer-events: none; }
/* A glossy floor the render sits on. */
.floor {
  position: absolute; left: 0; right: 0; bottom: 0; height: 32%;
  background: linear-gradient(180deg, rgba(40, 80, 170, 0) 0%, rgba(60, 110, 210, .35) 40%, rgba(10, 25, 70, .7) 100%);
}

.pc {
  --u: min(1vw, 1.25vh);              /* one "unit": the PC scales with the viewport */
  position: relative;
  width: calc(var(--u) * 64);
  margin-top: calc(var(--u) * -6);
  display: flex; flex-direction: column; align-items: center;
  /* CCD look: a touch of colour fringing and a soft bloom. */
  filter: drop-shadow(calc(var(--u) * .12) 0 0 rgba(255, 40, 40, .35)) drop-shadow(calc(var(--u) * -.12) 0 0 rgba(0, 200, 255, .35)) contrast(1.05) saturate(1.05);
  -webkit-box-reflect: below calc(var(--u) * .5) linear-gradient(transparent 60%, rgba(0, 0, 0, .3));
}
@media (max-width: 640px) { .pc { --u: min(1.45vw, 1.1vh); margin-top: calc(var(--u) * -14); } }

/* The shell: a thick chrome front with a slot strip across the top and a
   grooved panel down the right side. */
.shell {
  position: relative;
  width: 100%;
  padding: calc(var(--u) * 6) calc(var(--u) * 8.5) calc(var(--u) * 3.5) calc(var(--u) * 3.5);
  background: var(--chrome);
  border-radius: calc(var(--u) * 4.5);
  box-shadow:
    inset 0 calc(var(--u) * .5) calc(var(--u) * .4) rgba(255, 255, 255, .9),
    inset 0 calc(var(--u) * -1) calc(var(--u) * 1) rgba(0, 0, 0, .35),
    inset calc(var(--u) * 1) 0 calc(var(--u) * 1) rgba(255, 255, 255, .35),
    inset calc(var(--u) * -1) 0 calc(var(--u) * 1) rgba(0, 0, 0, .3),
    0 calc(var(--u) * 2) calc(var(--u) * 4) rgba(0, 0, 0, .6);
}
.shell::after {
  /* window glare across the chrome */
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(108deg, transparent 38%, rgba(255, 255, 255, .28) 44%, rgba(255, 255, 255, .06) 52%, transparent 58%);
}
.topstrip {
  position: absolute; top: calc(var(--u) * 1.6); left: calc(var(--u) * 3.5); right: calc(var(--u) * 10);
  height: calc(var(--u) * 2.8);
  display: flex; align-items: center; gap: calc(var(--u) * .8); padding: 0 calc(var(--u) * 1);
  background: linear-gradient(180deg, #1d2127, #3b4047 60%, #262a30);
  border-radius: calc(var(--u) * .6);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .8), 0 1px 0 rgba(255, 255, 255, .5);
}
.topstrip i {
  width: calc(var(--u) * 3); height: calc(var(--u) * 1.5);
  background: var(--chrome-soft); border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}
.side {
  position: absolute; top: calc(var(--u) * 6); bottom: calc(var(--u) * 4); right: calc(var(--u) * 1.8);
  width: calc(var(--u) * 5);
  display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * .5);
  padding-top: calc(var(--u) * 1.2);
  background: linear-gradient(90deg, #8d959e, #dfe3e8 30%, #b5bcc4 60%, #6f777f);
  border-radius: calc(var(--u) * 1.2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5), inset 0 0 calc(var(--u) * .8) rgba(0, 0, 0, .4);
}
.side i {
  width: 60%; height: calc(var(--u) * 7);
  background: repeating-linear-gradient(180deg, #2c3137 0 2px, #596069 2px 4px, transparent 4px 7px);
  border-radius: 2px; opacity: .8;
}
.sidebtn {
  margin-top: auto; margin-bottom: calc(var(--u) * 1.2);
  width: calc(var(--u) * 2.6); height: calc(var(--u) * 2.6); border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #c9cfd6 35%, #5d646c 80%, #2a2f35);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .7);
}
.bezel {
  padding: calc(var(--u) * 1.3);
  background: linear-gradient(180deg, #14171b, #2c3138 50%, #1a1e23);
  border-radius: calc(var(--u) * 2);
  box-shadow: inset 0 calc(var(--u) * .6) calc(var(--u) * 1) rgba(0, 0, 0, .8), 0 1px 0 rgba(255, 255, 255, .45);
}
.tube {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #06090f;
  border-radius: 7% / 9%;
  overflow: hidden;
  box-shadow: inset 0 0 calc(var(--u) * 4) rgba(0, 0, 0, .95);
}
body.on .tube { box-shadow: inset 0 0 calc(var(--u) * 4) rgba(0, 0, 0, .95), 0 0 calc(var(--u) * 6) rgba(90, 150, 255, .35); }
/* Curved glass: scanlines, an RGB shadow mask, a glare streak and a vignette. */
.glass {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(112deg, transparent 30%, rgba(255, 255, 255, .06) 38%, rgba(255, 255, 255, .14) 44%, rgba(255, 255, 255, .04) 50%, transparent 56%),
    radial-gradient(ellipse at 28% 18%, rgba(255, 255, 255, .14), transparent 35%),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .34) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(255, 60, 60, .06) 0 1px, rgba(60, 255, 60, .05) 1px 2px, rgba(60, 60, 255, .06) 2px 3px),
    radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, .7));
  animation: flicker 4s steps(1) infinite;
}
@keyframes flicker { 0%, 92%, 100% { opacity: 1; } 93% { opacity: .9; } 95% { opacity: 1; } 97% { opacity: .93; } }

/* The pod: an elliptical chrome base with three domes, the big one a trackball. */
.pod {
  position: relative;
  width: 118%; height: calc(var(--u) * 17);
  margin-top: calc(var(--u) * -2.5);
  z-index: -1;
}
.pod-base {
  position: absolute; left: 0; right: 0; top: 38%; bottom: 0;
  border-radius: 50% / 60%;
  background: linear-gradient(180deg, #d9dee3, #a9b1ba 35%, #e6e9ed 50%, #6c747d 80%, #3f454c);
  box-shadow: inset 0 calc(var(--u) * .4) 0 rgba(255, 255, 255, .8), inset 0 calc(var(--u) * -1.2) calc(var(--u) * 1) rgba(0, 0, 0, .5), 0 calc(var(--u) * 1.5) calc(var(--u) * 2.5) rgba(0, 0, 0, .6);
}
.dome {
  position: absolute; border-radius: 50%;
  background: radial-gradient(circle at 38% 28%, #ffffff 0%, #e4e8ec 18%, #a3abb4 45%, #5a6168 72%, #2b3036 100%);
  box-shadow: inset calc(var(--u) * -.3) calc(var(--u) * -.6) calc(var(--u) * 1) rgba(0, 0, 0, .5), 0 calc(var(--u) * .6) calc(var(--u) * 1.2) rgba(0, 0, 0, .55);
}
.dome.big { left: 50%; top: 0; width: calc(var(--u) * 26); height: calc(var(--u) * 20); transform: translateX(-50%); border-radius: 50% / 55%; }
.dome.small { top: 34%; width: calc(var(--u) * 15); height: calc(var(--u) * 10.5); border-radius: 50% / 55%; }
.dome.left { left: 3%; }
.dome.right { right: 3%; }
.ball {
  position: absolute; left: 50%; top: 18%;
  width: calc(var(--u) * 11); height: calc(var(--u) * 9.5);
  transform: translateX(-50%); border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #cfd5db, #6d757e 50%, #23272c 90%);
  box-shadow: inset 0 calc(var(--u) * .4) calc(var(--u) * .6) rgba(255, 255, 255, .5), 0 calc(var(--u) * .3) calc(var(--u) * .8) rgba(0, 0, 0, .7);
}
.ball::after {
  content: ""; position: absolute; inset: 22%; border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #eef1f4, #8a929b 55%, #3a3f45);
}
.pbtn {
  position: absolute; width: calc(var(--u) * 3.2); height: calc(var(--u) * 1.6);
  background: var(--chrome-soft); border-radius: calc(var(--u) * .8);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .7), inset 0 1px 0 #fff;
}
.pbtn.b1 { left: 9%; top: 78%; } .pbtn.b2 { left: 22%; top: 84%; }
.pbtn.b3 { right: 22%; top: 84%; } .pbtn.b4 { right: 9%; top: 78%; }
.pod .led {
  position: absolute; left: 50%; bottom: 8%; transform: translateX(-50%);
  width: calc(var(--u) * 1); height: calc(var(--u) * 1); border-radius: 50%;
  background: #2b3a2b; box-shadow: inset 0 0 2px #000;
}
body.on .pod .led { background: #43ff5c; box-shadow: 0 0 calc(var(--u) * 1.2) #43ff5c; }

/* The CCD filter: grain, a vignette, a slight magenta/green cast, and the
   orange date stamp every compact camera burned into the corner. */
.ccd {
  position: absolute; inset: 0; pointer-events: none;
  background:
    var(--grain) 0 0 / 160px 160px,
    radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(0, 0, 10, .55)),
    linear-gradient(90deg, rgba(255, 0, 120, .035), transparent 30%, transparent 70%, rgba(0, 255, 120, .035));
  mix-blend-mode: overlay;
  opacity: .9;
}
.datestamp {
  position: absolute; right: 4%; bottom: 5%;
  font: clamp(16px, 2.2vw, 26px) / 1 var(--mono);
  color: #ff9a1f; letter-spacing: .08em;
  text-shadow: 0 0 6px rgba(255, 130, 0, .7), 0 0 1px #fff;
  opacity: .9;
}

/* ── Boot screen ── */
.boot {
  position: absolute; inset: 0;
  padding: 6% 7%;
  color: #d2d2c6;
  font: calc(var(--u) * 2.3) / 1.15 var(--mono);
  text-shadow: 0 0 calc(var(--u) * .5) rgba(180, 255, 190, .55), 1px 0 0 rgba(255, 80, 80, .25), -1px 0 0 rgba(80, 120, 255, .25);
}
.boot pre { margin: 0; font: inherit; white-space: pre-wrap; }
.boot .ok { color: var(--phosphor); }
body.on .boot { animation: crt-on 420ms ease-out both; }
@keyframes crt-on {
  0% { transform: scale(1, .004); filter: brightness(6); }
  40% { transform: scale(1, .004); filter: brightness(6); }
  70% { transform: scale(1, 1.05); filter: brightness(2); }
  100% { transform: none; filter: none; }
}
body.off .boot { animation: crt-off 380ms ease-in both; }
@keyframes crt-off {
  0% { transform: none; }
  60% { transform: scale(1, .004); filter: brightness(5); }
  100% { transform: scale(0, .004); filter: brightness(8); }
}
.bootlogo {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center; gap: calc(var(--u) * 3);
  background: #000;
}
.bootlogo-name {
  font: italic bold calc(var(--u) * 5) / 1 var(--ui);
  color: #fff; letter-spacing: -.02em;
}
.bootlogo-name span { color: #f28a1c; font-size: .6em; vertical-align: super; margin-left: .1em; }
.bootbar {
  width: calc(var(--u) * 18); height: calc(var(--u) * 2.2);
  border: 2px solid #b2b2b2; border-radius: 4px; padding: 2px;
  overflow: hidden; position: relative;
}
.bootbar i {
  position: absolute; top: 2px; bottom: 2px; width: calc(var(--u) * 1.3);
  background: linear-gradient(180deg, #2c5bff, #7fa2ff 50%, #2c5bff);
  border-radius: 1px;
  animation: bootbar 1.3s linear infinite;
}
.bootbar i:nth-child(2) { animation-delay: .1s; }
.bootbar i:nth-child(3) { animation-delay: .2s; }
@keyframes bootbar { from { left: -12%; } to { left: 108%; } }

.power-prompt {
  position: fixed; left: 50%; top: 40%; z-index: 50;
  transform: translate(-50%, -50%);
  padding: .4em .9em;
  font: clamp(18px, 2.6vw, 30px) / 1 var(--mono);
  color: var(--phosphor); background: transparent;
  border: 1px dashed var(--phosphor); cursor: pointer;
  animation: blink 1.1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: .35; } }

.skip {
  position: fixed; right: 16px; top: 16px; z-index: 50;
  padding: 8px 14px;
  font: 20px/1 var(--mono);
  color: var(--phosphor); background: rgba(0, 0, 0, .55);
  border: 1px solid rgba(157, 255, 176, .5); cursor: pointer;
}
.skip:hover, .skip:focus-visible { background: rgba(0, 0, 0, .8); outline: none; border-color: var(--phosphor); }
body.desk .skip, body.halted .skip { display: none; }

/* ───────────────────────── Desktop ───────────────────────── */

.desktop {
  position: fixed; inset: 0;
  overflow: hidden;
  animation: desk-in 260ms ease-out both;
}
@keyframes desk-in { from { opacity: 0; filter: brightness(2.5); } }
.wallpaper {
  position: absolute; inset: 0; width: 100%; height: 100%;
  background: #4f8fe9;
}
.crt-overlay {
  position: absolute; inset: 0; pointer-events: none; z-index: 900;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .07) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 62%, rgba(0, 0, 0, .35));
}
.dragon { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 800; }

.langbar {
  position: absolute; top: 10px; right: 10px; z-index: 600;
  display: flex;
  border: 1px solid #003c74; border-radius: 3px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}
.langbar button {
  border: 0; padding: 4px 10px; cursor: pointer;
  background: linear-gradient(180deg, #fff, #e3e3db);
  font-size: 12px;
}
.langbar button + button { border-left: 1px solid #9aa6b5; }
.langbar button[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--xp-blue-hi), var(--xp-blue));
  color: #fff; font-weight: bold;
}

/* Icons */
.icons {
  list-style: none; margin: 0; padding: 12px 6px;
  position: absolute; inset: 0 0 var(--taskbar-h) 0;
  display: grid; grid-auto-flow: column; grid-template-rows: repeat(auto-fill, 92px);
  grid-auto-columns: max-content; justify-content: start;
  gap: 4px; align-content: start;
  pointer-events: none;
}
.icons li { pointer-events: auto; }
/* XP keeps the Recycle Bin alone in the bottom-right corner. */
.icons .li-bin { position: absolute; right: 12px; bottom: 12px; }
.icon {
  width: 92px; padding: 4px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: 1px solid transparent; cursor: default;
  color: #fff; text-align: center; font-size: 12px; line-height: 1.2;
}
.icon svg { width: 40px; height: 40px; filter: drop-shadow(1px 2px 0 rgba(0, 0, 0, .35)); }
.icon span { padding: 1px 3px; text-shadow: 1px 1px 1px #000, 0 0 2px #000; overflow-wrap: normal; }
.icon:focus-visible { outline: 1px dotted #fff; outline-offset: -1px; }
.icon.selected svg { filter: drop-shadow(1px 2px 0 rgba(0, 0, 0, .35)) sepia(1) hue-rotate(180deg) saturate(4) brightness(.8); }
.icon.selected span { background: #316ac5; text-shadow: none; }

/* ── Windows (XP Luna) ── */
.win {
  position: absolute;
  min-width: 280px;
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100% - var(--taskbar-h) - 16px);
  display: flex; flex-direction: column;
  background: var(--xp-face);
  border: 3px solid var(--xp-edge);
  border-top: 0;
  border-radius: 8px 8px 0 0;
  box-shadow: 2px 4px 14px rgba(0, 0, 0, .45);
  animation: win-in 160ms ease-out both;
}
@keyframes win-in { from { transform: scale(.92); opacity: 0; } }
.win.inactive .win-title { filter: saturate(.45) brightness(1.15); }
.win.min { display: none; }
.win.max { left: 0 !important; top: 0 !important; width: 100% !important; height: calc(100% - var(--taskbar-h)); max-height: none; border-radius: 0; }
.win-title {
  display: flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 4px 0 7px;
  background: linear-gradient(180deg, #0997ff 0%, #0053ee 8%, #0050ee 40%, #06f 88%, #06f 93%, #005bff 95%, #003dd7 96%, #003dd7);
  border-radius: 7px 7px 0 0;
  color: #fff; font-weight: bold; font-size: 13px;
  text-shadow: 1px 1px 0 #0a1883;
  cursor: move; user-select: none; touch-action: none;
}
.win-title svg { width: 16px; height: 16px; flex: none; }
.win-title-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-btns { display: flex; gap: 2px; }
.win-btns button {
  width: 22px; height: 22px; padding: 0;
  display: grid; place-items: center;
  border: 1px solid #fff; border-radius: 3px;
  background: linear-gradient(180deg, #4b8bff, #1f5ee0 60%, #1648c8);
  color: #fff; font: bold 13px/1 var(--ui); cursor: pointer;
}
.win-btns button.close { background: linear-gradient(180deg, #ec7a5c, #d5432b 60%, #b9301c); }
.win-btns button:hover { filter: brightness(1.15); }
.win-menu {
  display: flex; gap: 14px; padding: 2px 8px;
  border-bottom: 1px solid #d4d0c8; font-size: 12px; color: #222;
  user-select: none;
}
.win-body { flex: 1; overflow: auto; padding: 14px; background: #fff; border: 1px solid #a0a0a0; border-width: 1px 0; }
.win-status {
  display: flex; gap: 12px; padding: 3px 8px; font-size: 11px; color: #333;
  background: linear-gradient(180deg, #f2f0e4, var(--xp-face));
}

/* Project contents */
.flapboard {
  display: flex; flex-wrap: wrap; gap: 3px; margin: 0 0 12px;
}
.tile {
  position: relative;
  width: 1.15em; height: 1.45em;
  display: grid; place-items: center;
  font: 30px/1 var(--mono);
  color: #f6f1e3;
  background: linear-gradient(180deg, #2a2a2a 0 49%, #111 49% 51%, #232323 51%);
  border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 1px 0 rgba(0, 0, 0, .4);
}
.tile.blank { background: transparent; box-shadow: none; }
.tile.flip-a { animation: flip-a 55ms linear; }
.tile.flip-b { animation: flip-b 55ms linear; }
@keyframes flip-a { 50% { transform: perspective(80px) rotateX(-70deg); } }
@keyframes flip-b { 50% { transform: perspective(80px) rotateX(-70deg); } }

.media {
  position: relative; margin: 0 0 12px;
  background: #000; border: 2px inset #d4d0c8;
  aspect-ratio: 16 / 9;
}
.media video, .media canvas { display: block; width: 100%; height: 100%; object-fit: cover; }
.media canvas { image-rendering: pixelated; }
.media .ph-label {
  position: absolute; left: 8px; bottom: 6px;
  padding: 1px 6px;
  font: 18px/1.2 var(--mono); color: var(--phosphor);
  background: rgba(0, 0, 0, .65);
}
.desc { margin: 0 0 14px; font-size: 13px; line-height: 1.6; min-height: 3.2em; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.xp-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 14px; min-height: 26px;
  font-size: 12px; color: #000; text-decoration: none;
  background: linear-gradient(180deg, #fff, #ecebe6 80%, #d6d0c5);
  border: 1px solid #003c74; border-radius: 3px; cursor: pointer;
}
.xp-btn:hover { box-shadow: inset 0 0 0 2px #f8b636; }
.xp-btn:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }
.xp-btn[aria-disabled="true"] { color: #8f8f86; border-color: #c9c7ba; cursor: not-allowed; box-shadow: none; }

.about p { margin: 0 0 10px; }
.about .who { font: 34px/1 var(--mono); margin: 0 0 12px; }
.bin-list { margin: 0 0 10px; padding: 0; list-style: none; font-family: var(--mono); font-size: 18px; }
.bin-list li::before { content: "▸ "; color: #d6431f; }

/* ── Minesweeper ── */
.win-ms { width: max-content; min-width: 300px; }
.win-ms .win-body { background: var(--xp-face); padding: 8px; }
.ms { display: grid; gap: 6px; justify-items: start; }
.ms-menu { display: flex; gap: 10px; align-items: center; font-size: 12px; }
.ms-level { display: flex; gap: 5px; align-items: center; }
.ms-select { font: inherit; }
.ms-best { color: #444; }
.ms-flagbtn {
  margin-left: auto; padding: 1px 6px; font-size: 14px; line-height: 1;
  background: linear-gradient(180deg, #fff, #ecebe6 80%, #d6d0c5);
  border: 1px solid #003c74; border-radius: 3px; cursor: pointer;
}
.ms-flagbtn[aria-pressed="true"] { box-shadow: inset 1px 1px 3px rgba(0, 0, 0, .4); background: #ffe9a8; }
@media (hover: hover) and (pointer: fine) { .ms-flagbtn, .ms-hint { display: none; } }
.ms-hint { font-size: 11px; color: #555; }
.ms-panel {
  padding: 6px; background: #c0c0c0;
  border: 3px solid; border-color: #fff #808080 #808080 #fff;
}
.ms-top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 5px; margin-bottom: 6px;
  border: 2px solid; border-color: #808080 #fff #fff #808080;
}
.ms-led {
  min-width: 2.2em; padding: 0 2px; text-align: right;
  font: 30px/26px var(--mono); letter-spacing: .05em;
  color: #f00; background: #000; border: 1px solid; border-color: #808080 #fff #fff #808080;
}
.ms-face {
  width: 30px; height: 30px; padding: 2px;
  background: #c0c0c0; border: 3px solid; border-color: #fff #808080 #808080 #fff; cursor: pointer;
}
.ms-face:active { border-color: #808080 #fff #fff #808080; }
.ms-face svg { width: 100%; height: 100%; display: block; }
.ms-grid {
  display: grid; grid-template-columns: repeat(var(--cols), 24px);
  border: 3px solid; border-color: #808080 #fff #fff #808080;
}
.ms-grid.small { grid-template-columns: repeat(var(--cols), 20px); }
.ms-cell {
  width: 24px; height: 24px; padding: 0;
  display: grid; place-items: center;
  font: bold 16px/1 var(--ui);
  background: #c0c0c0; border: 3px solid; border-color: #fff #808080 #808080 #fff;
  cursor: default; user-select: none; touch-action: manipulation;
}
.ms-grid.small .ms-cell { width: 20px; height: 20px; font-size: 13px; border-width: 2px; }
.ms-cell:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }
.ms-cell.flag { font-size: 13px; }
.ms-cell.open { border: 1px solid #808080; border-width: 0 0 1px 1px; }
.ms-cell.mine { font-size: 14px; }
.ms-cell.boom { background: #f00; }
.ms-cell.wrong { background: #f88; }
.ms-cell.n1 { color: #0000ff; } .ms-cell.n2 { color: #008000; } .ms-cell.n3 { color: #ff0000; }
.ms-cell.n4 { color: #000080; } .ms-cell.n5 { color: #800000; } .ms-cell.n6 { color: #008080; }
.ms-cell.n7 { color: #000; }    .ms-cell.n8 { color: #808080; }

/* ── Start menu ── */
.startmenu {
  position: absolute; left: 0; bottom: var(--taskbar-h); z-index: 700;
  width: min(300px, 92vw);
  background: #fff;
  border: 2px solid #1854c8; border-bottom: 0;
  border-radius: 8px 8px 0 0;
  box-shadow: 3px -2px 10px rgba(0, 0, 0, .4);
  overflow: hidden;
}
.sm-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: linear-gradient(180deg, #1868ce, #0e60cb 15%, #2b74d6 85%, #1c63c8);
  color: #fff; font-weight: bold; font-size: 15px; text-shadow: 1px 1px 1px #0a1883;
}
.sm-avatar {
  width: 40px; height: 40px; border: 2px solid #fff; border-radius: 3px;
  background:
    linear-gradient(#e4b18f, #e4b18f) 12px 10px / 16px 16px no-repeat,
    linear-gradient(#2a1a12, #2a1a12) 10px 6px / 20px 8px no-repeat,
    linear-gradient(#d6431f, #d6431f) 8px 28px / 24px 10px no-repeat,
    #6fb43b;
  image-rendering: pixelated;
}
.sm-list { list-style: none; margin: 0; padding: 6px 0; border-top: 2px solid #f19a37; }
.sm-list button {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; border: 0; background: none; text-align: left; cursor: pointer;
  font-size: 12px;
}
.sm-list button svg { width: 24px; height: 24px; }
.sm-list button:hover, .sm-list button:focus-visible { background: #316ac5; color: #fff; outline: none; }
.sm-list hr { border: 0; border-top: 1px solid #ddd; margin: 4px 10px; }
.sm-foot {
  display: flex; justify-content: flex-end; padding: 6px 10px;
  background: linear-gradient(180deg, #4282d6, #3b7bd3 90%, #2865c4);
}
.sm-off {
  display: flex; align-items: center; gap: 6px;
  border: 0; background: none; color: #fff; cursor: pointer; font-size: 12px;
}
.sm-off svg { width: 22px; height: 22px; }
.sm-off:hover { text-decoration: underline; }

/* ── Taskbar ── */
.taskbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 650;
  height: var(--taskbar-h);
  display: flex; align-items: stretch;
  background: linear-gradient(180deg, #3168d5 0%, #4993e6 4%, #2157d7 12%, #2663e0 50%, #1941a5 100%);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.startbtn {
  display: flex; align-items: center; gap: 6px;
  padding: 0 18px 0 10px; margin-right: 8px;
  border: 0; border-radius: 0 12px 12px 0;
  background: linear-gradient(180deg, #3c9a3c, #5cc35c 10%, #3c9a3c 50%, #2e7d2e);
  box-shadow: inset -2px 0 3px rgba(0, 0, 0, .3), 2px 0 4px rgba(0, 0, 0, .3);
  color: #fff; font: italic bold 18px/1 var(--ui); text-shadow: 1px 1px 1px #1a4a1a;
  cursor: pointer;
}
.startbtn[aria-expanded="true"] { filter: brightness(.85); }
.flag { display: grid; grid-template-columns: 8px 8px; gap: 1px; transform: skewY(-6deg); }
.flag i { width: 8px; height: 8px; }
.flag i:nth-child(1) { background: #f4511e; }
.flag i:nth-child(2) { background: #7cb342; }
.flag i:nth-child(3) { background: #1e88e5; }
.flag i:nth-child(4) { background: #fdd835; }
.tasks { flex: 1; display: flex; gap: 3px; align-items: center; overflow: hidden; }
.task {
  max-width: 160px; min-width: 0; height: 26px; padding: 0 8px;
  display: flex; align-items: center; gap: 5px;
  border: 1px solid #1a3f9a; border-radius: 3px;
  background: linear-gradient(180deg, #3c81f3, #2a6be6);
  color: #fff; font-size: 12px; cursor: pointer;
  white-space: nowrap; overflow: hidden;
}
.task svg { width: 16px; height: 16px; flex: none; }
.task span { overflow: hidden; text-overflow: ellipsis; }
.task.active { background: linear-gradient(180deg, #1e4fc0, #1a48b5); box-shadow: inset 1px 1px 2px rgba(0, 0, 0, .4); }
.tray {
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px 0 8px;
  background: linear-gradient(180deg, #0c59b9, #139ee9 6%, #18b5f2 12%, #139beb 50%, #1290e8);
  border-left: 1px solid #092e7a;
  box-shadow: inset 1px 0 1px #18bbff;
  color: #fff; font-size: 12px;
}
.tray-btn { border: 0; background: none; padding: 2px; cursor: pointer; display: grid; }
.tray-btn svg { width: 16px; height: 16px; }
.tray-btn .mute { display: none; }
.tray-btn.muted .mute { display: block; }
.tray-btn.muted .wave { display: none; }
.clock { white-space: nowrap; }

/* ── Phones ── */
@media (max-width: 640px) {
  .icons { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, 92px); grid-template-rows: none; justify-content: center; padding-top: 48px; align-content: start; }
  .icons .li-bin { position: static; }
  .win { left: 6px !important; top: 46px !important; width: calc(100% - 12px) !important; height: calc(100% - var(--taskbar-h) - 52px); max-height: none; }
  .win-ms { height: auto; max-height: calc(100% - var(--taskbar-h) - 52px); }
  .win-ms .win-body { overflow: auto; }
  .win-title { cursor: default; }
  .tile { font-size: 22px; }
  .startbtn { font-size: 16px; padding-right: 14px; }
  .task { max-width: 90px; }
}

@media (prefers-reduced-motion: reduce) {
  #stage { transition: opacity 200ms; }
  .desktop, .win { animation: none; }
}
