/* ===== Desktop (hero) ===== */
.desktop {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 600px;
  overflow: hidden;
  background: var(--desk);
  color: var(--ui-text);
  isolation: isolate;
  transition: background-color 1.2s steps(6, end);
}

.wallpaper {
  position: absolute; inset: 0; z-index: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background:
    repeating-conic-gradient(rgba(0, 0, 0, .07) 0 25%, transparent 0 50%) 0 0 / 4px 4px,
    radial-gradient(ellipse at 50% 46%, color-mix(in srgb, var(--desk) 78%, #fff 22%) 0%, var(--desk) 48%, var(--desk-2) 100%);
  transition: background 1.2s steps(6, end);
  padding-bottom: var(--tb-h);
}
.wp-logo {
  position: relative;
  font: clamp(30px, 8.4vw, 118px)/1 var(--font-pixel);
  color: color-mix(in srgb, var(--accent) 30%, transparent);
  text-shadow: 6px 6px 0 rgba(0, 0, 0, .22);
  letter-spacing: .02em;
  user-select: none;
}
.wp-logo::before, .wp-logo::after {
  content: attr(data-text);
  position: absolute; inset: 0;
  opacity: 0;
}
.wp-logo::before { color: rgba(255, 43, 214, .55); }
.wp-logo::after { color: rgba(0, 229, 255, .5); }
.wp-logo.glitching::before { opacity: 1; transform: translate(-6px, 2px); clip-path: inset(10% 0 55% 0); }
.wp-logo.glitching::after { opacity: 1; transform: translate(6px, -2px); clip-path: inset(55% 0 8% 0); }
.wp-tag {
  font: clamp(20px, 3vw, 32px)/1 var(--font-term);
  letter-spacing: .35em;
  color: rgba(255, 255, 255, .55);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, .35);
}
.wp-tag b { color: var(--accent); font-weight: 400; }

.corruption {
  position: absolute; inset: 0; z-index: 1;
  width: 100%; height: 100%;
  opacity: .62;
  pointer-events: none;
  mix-blend-mode: screen;
}
html[data-chaos="low"] .corruption { opacity: .38; }
html[data-chaos="high"] .corruption { opacity: .8; }

/* Icons */
.icons {
  position: absolute; z-index: 2;
  top: 10px; left: 6px; bottom: calc(var(--tb-h) + 8px);
  display: flex; flex-direction: column; flex-wrap: wrap; align-content: flex-start; gap: 4px;
}
.icon {
  position: relative;
  width: 92px;
  padding: 6px 2px 4px;
  background: none; border: 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: #fff; cursor: pointer;
  font-size: 13px; text-align: center;
  touch-action: manipulation;
}
.icon img { width: 40px; height: 40px; filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, .35)); }
.icon .lbl { padding: 1px 3px; text-shadow: 1px 1px 0 #000; line-height: 1.15; word-break: break-word; }
.icon:hover .lbl { background: rgba(0, 0, 0, .25); }
.icon:focus-visible { outline: none; }
.icon:focus-visible .lbl, .icon.sel .lbl { background: var(--title-a); outline: 1px dotted #fff; }
.icon:active img { transform: translate(1px, 1px); }
.icon.infected img { filter: hue-rotate(75deg) saturate(2.2) drop-shadow(0 0 6px var(--accent)); animation: icon-glitch 2.8s steps(1) infinite; }
.icon.infected .lbl { color: var(--accent); }
.icon.infected::after {
  content: ''; position: absolute; top: 30px; left: calc(50% + 6px);
  width: 16px; height: 12px;
  background:
    radial-gradient(circle at 40% 40%, var(--accent) 0 4px, transparent 5px),
    radial-gradient(circle at 80% 80%, var(--accent) 0 2px, transparent 3px);
  image-rendering: pixelated;
}
@keyframes icon-glitch { 0%, 92% { transform: none; } 93% { transform: translate(-3px, 1px); } 96% { transform: translate(2px, -1px); } }

/* HUD gadget */
.hud {
  position: absolute; z-index: 3;
  top: 12px; right: 12px; width: 290px;
  background: var(--ui-face);
  box-shadow: var(--bevel-out), 6px 8px 0 rgba(0, 0, 0, .3);
  padding: 3px;
}
.hud-title {
  display: flex; align-items: center; gap: 6px;
  background: linear-gradient(90deg, var(--title-a), var(--title-b));
  color: #fff; padding: 3px 4px 3px 6px;
  font-size: 13px; font-weight: 600; letter-spacing: .04em;
}
.hud-title img { width: 18px; height: 18px; }
.hud-title span:nth-child(2) { flex: 1; }
.hud-body { padding: 8px; display: grid; gap: 8px; }
.hud-stage { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.hud-stage .lbl { font-size: 12px; color: #444; white-space: nowrap; }
.hud-stage strong { font: 13px/1.2 var(--font-pixel); text-align: right; }
.hud-stats { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.hud-stats div { background: var(--screen); color: var(--phosphor); box-shadow: var(--bevel-in); padding: 4px 7px; }
.hud-stats dt { font-size: 11px; color: #6c9; text-transform: uppercase; letter-spacing: .06em; }
.hud-stats dd { margin: 0; font: 22px/1 var(--font-term); color: var(--accent); white-space: nowrap; }
.hud-stats small { font-size: 15px; color: var(--phosphor); }
.hud-err { display: none; margin: 0; padding: 6px; background: var(--danger); color: #fff; font-size: 13px; align-items: center; justify-content: space-between; gap: 6px; }
body.is-error .hud-err { display: flex; }
.hud-actions { display: flex; gap: 6px; }
.btn-feed {
  flex: 1;
  font-weight: 600; font-size: 15px; letter-spacing: .03em;
  min-height: 40px;
  background: color-mix(in srgb, var(--accent) 55%, var(--ui-face));
  animation: feed-pulse 2.2s steps(2, end) infinite;
}
.btn-feed small { font-weight: 400; font-size: 12px; color: inherit; display: inline; letter-spacing: 0; }
.btn-feed:hover { background: color-mix(in srgb, var(--accent) 70%, var(--ui-face)); }
@keyframes feed-pulse { 50% { box-shadow: var(--bevel-out), 0 0 0 3px var(--accent-glow); } }
body.is-error .btn-feed, body.is-loading .btn-feed { animation: none; filter: grayscale(1); }

/* Windows + popups layers */
.win-layer, .popup-layer { position: absolute; inset: 0 0 var(--tb-h) 0; pointer-events: none; }
.win-layer { z-index: 10; }
.popup-layer { z-index: 700; }
.win-layer > *, .popup-layer > * { pointer-events: auto; }

/* The virus */
.virus {
  --vsize: 256px;
  position: absolute; left: 0; top: 0; z-index: 500;
  width: var(--vsize); height: var(--vsize);
  pointer-events: none;
  will-change: transform;
}
.virus canvas {
  width: 100%; height: 100%;
  transform-origin: 50% 84%;
  filter: drop-shadow(0 0 14px var(--accent-glow));
}
.virus[data-mood="dominant"] canvas { filter: drop-shadow(0 0 22px var(--accent-glow)) drop-shadow(0 0 4px #fff); }
.virus[data-mood="mutating"] canvas { filter: drop-shadow(0 0 30px #fff) drop-shadow(0 0 16px var(--accent)); }
.virus[data-mood="dormant"] canvas { filter: drop-shadow(0 0 6px rgba(0, 0, 0, .3)); }
.virus-hit {
  position: absolute; left: 24%; right: 24%; top: 26%; bottom: 14%;
  pointer-events: auto;
  background: transparent; border: 0; padding: 0;
  cursor: pointer; border-radius: 40%;
  touch-action: manipulation;
}
.virus-hit:focus-visible { outline: 2px dashed var(--accent); outline-offset: 4px; }
.bubble {
  position: absolute; bottom: 80%; left: 52%;
  max-width: 230px; width: max-content;
  background: #fff; color: #000;
  border: 2px solid #000;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, .35);
  padding: 4px 9px;
  font: 22px/1.05 var(--font-term);
  opacity: 0; transform: scale(.6) translateY(8px); transform-origin: 0 100%;
  transition: opacity .12s steps(2), transform .12s steps(2);
}
.bubble::after {
  content: ''; position: absolute; bottom: -10px; left: 12px;
  width: 10px; height: 10px; background: #fff;
  border-right: 2px solid #000; border-bottom: 2px solid #000;
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}
.bubble.left { left: auto; right: 52%; transform-origin: 100% 100%; }
.bubble.left::after { left: auto; right: 12px; clip-path: polygon(0 0, 100% 0, 0 100%); border-right: 0; border-left: 2px solid #000; }
.bubble.show { opacity: 1; transform: none; }

/* Food, fx */
.food { position: absolute; left: 0; top: 0; z-index: 550; width: 48px; pointer-events: none; display: flex; flex-direction: column; align-items: center; }
.food img { width: 48px; height: 48px; filter: drop-shadow(0 0 8px #ff8a00); }
.food b { font: 18px/1 var(--font-term); color: #fff; background: #000; padding: 1px 4px; font-weight: 400; }
.fx { position: absolute; inset: 0; z-index: 600; pointer-events: none; width: 100%; height: 100%; }
.float-text {
  position: absolute; z-index: 620; pointer-events: none;
  transform: translateX(-50%);
  font: 15px/1 var(--font-pixel);
  color: #ffd84a; white-space: nowrap;
  text-shadow: 2px 2px 0 #000, 0 0 10px #ff6a00;
  animation: float-up 1.9s steps(12, end) forwards;
}
@keyframes float-up { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -70px); } }
.flash { position: absolute; inset: 0; z-index: 1100; pointer-events: none; opacity: 0; }
.flash.on { animation: flash .6s steps(4, end); }
@keyframes flash { 0% { opacity: .85; } 100% { opacity: 0; } }
html[data-motion="reduced"] .flash.on { animation: none; }
.tear {
  position: absolute; left: 0; right: 0; z-index: 1050; pointer-events: none;
  backdrop-filter: invert(.85) hue-rotate(110deg);
  -webkit-backdrop-filter: invert(.85) hue-rotate(110deg);
  animation: tear .4s steps(4, end) forwards;
}
@keyframes tear { 0% { transform: translateX(var(--dx)); } 50% { transform: translateX(calc(var(--dx) * -1)); } 100% { transform: none; opacity: 0; } }
.desktop.shake { animation: shake .5s steps(8, end); }
.desktop.mutating.shake { animation: shake .3s steps(6, end) 8; }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translate(-6px, 3px); } 40% { transform: translate(5px, -4px); } 60% { transform: translate(-4px, -2px); } 80% { transform: translate(3px, 4px); } }

.scroll-cue {
  position: absolute; z-index: 4; left: 50%; bottom: calc(var(--tb-h) + 10px);
  transform: translateX(-50%);
  background: rgba(0, 0, 0, .45); color: #fff; border: 1px solid rgba(255, 255, 255, .35);
  font: 20px/1 var(--font-term); letter-spacing: .12em;
  padding: 5px 12px; cursor: pointer;
  animation: bob 1.8s steps(2, end) infinite;
}
.scroll-cue:hover { background: rgba(0, 0, 0, .7); }
@keyframes bob { 50% { transform: translate(-50%, -4px); } }

/* Taskbar */
.taskbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 900;
  height: var(--tb-h);
  background: var(--ui-face);
  box-shadow: inset 0 1px var(--ui-hi), inset 0 2px #fff;
  display: flex; align-items: center; gap: 4px;
  padding: 4px 4px 3px;
}
.start-btn { font-weight: 600; min-height: 32px; padding: 3px 10px 3px 6px; flex: none; }
.start-btn img { width: 22px; height: 22px; }
.tasks { flex: 1; min-width: 0; display: flex; gap: 3px; overflow-x: auto; scrollbar-width: none; }
.tasks::-webkit-scrollbar { display: none; }
.task { justify-content: flex-start; min-width: 0; max-width: 170px; flex: 0 1 170px; font-size: 13px; min-height: 32px; padding: 3px 6px; }
.task img { width: 16px; height: 16px; flex: none; }
.task span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray {
  flex: none; display: flex; align-items: center; gap: 4px;
  box-shadow: var(--bevel-in); padding: 2px 6px; min-height: 32px;
}
.tray .src-badge { font-size: 9px; }
.tray-btn { background: none; border: 0; padding: 2px 4px; min-height: 28px; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: #000; font-size: 13px; }
.tray-btn:hover { background: rgba(0, 0, 0, .08); }
.tray-btn img { width: 18px; height: 18px; }
.tray-dot { width: 8px; height: 8px; background: var(--accent); box-shadow: 0 0 0 1px #000; animation: blink-badge 1s steps(1) infinite; }
.tray-pop { background: var(--danger); color: #fff; font-weight: 600; }
.clock { font-size: 13px; padding: 0 2px; }

/* Start menu */
.startmenu {
  position: absolute; z-index: 950;
  left: 4px; bottom: calc(var(--tb-h) - 2px);
  width: 270px;
  max-height: calc(100% - var(--tb-h) - 8px);
  background: var(--ui-face);
  box-shadow: var(--bevel-out), 4px 4px 0 rgba(0, 0, 0, .35);
  display: flex; padding: 3px;
}
.sm-side {
  width: 30px; flex: none;
  background: linear-gradient(0deg, var(--title-a), var(--title-b));
  color: #fff;
  writing-mode: vertical-rl; transform: rotate(180deg);
  font: 13px/30px var(--font-pixel);
  padding: 10px 0;
}
.sm-side b { color: var(--accent); font-weight: 400; }
.sm-items { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; }
.sm-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 5px 8px; min-height: 36px;
  background: none; border: 0; text-align: left; cursor: pointer; color: #000; font-size: 15px;
}
.sm-item img { width: 24px; height: 24px; }
.sm-item:hover, .sm-item:focus-visible { background: var(--title-a); color: #fff; outline: none; }
.sm-sep { height: 2px; margin: 3px 2px; box-shadow: inset 0 1px var(--ui-shadow), inset 0 -1px #fff; }

/* CRT */
.crt {
  position: absolute; inset: 0; z-index: 1000; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .16) 0 1px, transparent 1px 3px);
}
.crt::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(0, 0, 0, .42) 100%);
}
html[data-crt="off"] .crt { display: none; }
html[data-chaos="low"] .crt { opacity: .55; }
html[data-chaos="high"] .crt { animation: crt-flicker 5s steps(1) infinite; }
@keyframes crt-flicker { 0%, 96% { opacity: 1; } 97% { opacity: .6; } 98% { opacity: 1; } 99% { opacity: .75; } }

/* Shutdown overlay */
.shutdown {
  position: absolute; inset: 0; z-index: 1200;
  background: #000; display: grid; place-items: center; align-content: center; gap: 14px;
  text-align: center; transition: opacity .35s steps(3);
}
.shutdown.out { opacity: 0; }
.sd-msg { margin: 0; font: clamp(18px, 3vw, 28px)/1.5 var(--font-pixel); color: #c3c3c3; padding: 0 16px; }
.sd-safe { color: #ff9a2e; }
.sd-no { color: var(--accent); }
.sd-virus { width: 192px; height: 192px; }

/* Window contents */
.explorer { display: flex; flex-direction: column; gap: 8px; }
.ex-bar { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.ex-addr { flex: 1; min-width: 140px; background: #fff; box-shadow: var(--bevel-in); padding: 4px 8px; font: 18px/1 var(--font-term); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-list {
  list-style: none; margin: 0; padding: 8px;
  background: #fff; box-shadow: var(--bevel-in);
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 4px;
  min-height: 150px; align-content: start;
}
.ex-item { width: 100%; background: none; border: 0; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; font-size: 13px; color: #000; text-align: center; word-break: break-word; }
.ex-item img { width: 36px; height: 36px; }
.ex-item:hover span, .ex-item:focus-visible span { background: var(--title-a); color: #fff; }
.ex-item:focus-visible { outline: none; }
.ex-item.sick img { filter: hue-rotate(75deg) saturate(2); }
.ex-item.sick span { color: #0b7a1a; }
.ex-status { font-size: 13px; box-shadow: var(--bevel-in); padding: 2px 6px; }

.photo { display: grid; gap: 8px; justify-items: center; }
.photo-cv { width: 100%; max-width: 320px; height: auto; aspect-ratio: 3 / 2; box-shadow: var(--bevel-in); padding: 2px; background: #fff; }
.photo-cap { margin: 0; font-size: 14px; }

.quarantine .q-head { display: flex; gap: 10px; align-items: center; }
.quarantine .q-head img { width: 32px; height: 32px; }
.quarantine .q-head p { margin: 0; }
.q-list { list-style: none; margin: 10px 0; padding: 4px; background: #fff; box-shadow: var(--bevel-in); max-height: 220px; overflow: auto; }
.q-list li { display: flex; align-items: center; gap: 8px; padding: 5px; }
.q-list li + li { border-top: 1px dotted #aaa; }
.q-list img { width: 24px; height: 24px; filter: hue-rotate(75deg) saturate(2); }
.q-list span { flex: 1; display: flex; flex-direction: column; }
.q-list small { color: #666; }
.q-empty { color: #555; font-size: 14px; }
.q-scan { display: flex; gap: 8px; align-items: center; }
.q-scan .meter { flex: 1; }
.q-scan .meter span { font-size: 16px; }
.q-note { font-size: 12px; color: #555; margin: 8px 0 0; }

.sm-top { display: flex; gap: 10px; align-items: center; padding: 6px 10px; margin-bottom: 8px; }
.sm-top canvas { width: 96px; height: 96px; flex: none; }
.sm-top div { display: grid; gap: 3px; font-size: 20px; }
.sm-top small { font-size: 16px; color: #6c9; }
.sm-top strong { font: 14px/1.3 var(--font-pixel); color: var(--accent); }
.sm-row { display: grid; grid-template-columns: 80px 1fr; align-items: center; gap: 8px; margin: 6px 0; font-size: 14px; }
.sm-stats { margin: 8px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 14px; }
.sm-stats dt { color: #555; font-size: 12px; }
.sm-stats dd { margin: 0; font-weight: 600; }
.sm-cap { margin: 8px 0 2px; font-size: 12px; letter-spacing: .08em; color: #333; }
.sm-graph { width: 100%; height: 64px; box-shadow: var(--bevel-in); }
.procs { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14px; background: #fff; box-shadow: var(--bevel-in); }
.procs th, .procs td { text-align: left; padding: 3px 6px; }
.procs th { font-weight: 600; background: var(--ui-face); box-shadow: var(--bevel-out); font-size: 12px; }
.procs td:last-child { text-align: right; }

.win fieldset { border: 1px solid var(--ui-shadow); box-shadow: 1px 1px #fff, inset 1px 1px #fff; margin: 0 0 10px; padding: 6px 10px 8px; }
.win legend { padding: 0 4px; font-size: 13px; }
.win fieldset label { display: flex; align-items: center; gap: 8px; min-height: 30px; font-size: 15px; cursor: pointer; }
.win input[type="checkbox"], .win input[type="radio"] { width: 18px; height: 18px; accent-color: var(--title-a); margin: 0; }
.cp-src { margin: 0; font-size: 14px; }
.win .log-list { max-height: 360px; }

/* ===== Stage-driven takeover ===== */
body[data-stage="3"] .wp-logo, body[data-stage="4"] .wp-logo { color: color-mix(in srgb, var(--accent) 38%, transparent); }
body[data-stage="5"] .wp-logo, body[data-stage="6"] .wp-logo { color: color-mix(in srgb, var(--accent) 50%, transparent); text-shadow: 6px 6px 0 rgba(0, 0, 0, .3), 0 0 30px var(--accent-glow); }
body[data-stage="5"] .taskbar, body[data-stage="6"] .taskbar { background: color-mix(in srgb, var(--ui-face) 82%, var(--accent)); }
body[data-stage="6"] .wallpaper {
  background:
    repeating-linear-gradient(0deg, rgba(255, 42, 72, .08) 0 2px, transparent 2px 6px),
    repeating-conic-gradient(rgba(0, 0, 0, .12) 0 25%, transparent 0 50%) 0 0 / 4px 4px,
    radial-gradient(ellipse at 50% 46%, #5a0614 0%, var(--desk) 50%, #000 100%);
}
body[data-stage="6"] .wp-tag::after { content: ' → TAKEOVER'; color: var(--accent); }
body[data-stage="6"] .start-btn { background: var(--accent); color: #fff; }
html:not([data-motion="reduced"]) body[data-stage="6"] .wp-logo { animation: god-pulse 2s steps(2, end) infinite; }
@keyframes god-pulse { 50% { transform: scale(1.02); filter: brightness(1.3); } }

/* ===== Mobile desktop ===== */
@media (max-width: 699px) {
  :root { --tb-h: 50px; }
  .desktop { min-height: 560px; }
  .wallpaper { justify-content: flex-start; padding-top: 38vh; padding-top: 38svh; gap: 10px; }
  .wp-tag { letter-spacing: .2em; }
  .icons {
    top: 6px; left: 4px; right: 4px; bottom: auto;
    flex-direction: row; flex-wrap: wrap; justify-content: flex-start; gap: 0;
  }
  .icon { width: 20%; padding: 4px 1px; font-size: 11.5px; gap: 2px; }
  .icon img { width: 34px; height: 34px; }
  .icon.infected::after { top: 22px; }
  .hud { top: auto; left: 6px; right: 6px; width: auto; bottom: calc(var(--tb-h) + 6px); }
  .hud-title { font-size: 11px; padding: 2px 4px; }
  .hud-body { padding: 6px; gap: 6px; grid-template-columns: 1fr 1fr; }
  .hud-stage { grid-column: 1 / -1; }
  .hud-body > .meter { grid-column: 1 / -1; }
  .hud-stats { grid-column: 1 / -1; }
  .hud-err { grid-column: 1 / -1; }
  .hud-actions { grid-column: 1 / -1; }
  .hud-stats dd { font-size: 20px; }
  .btn-feed { min-height: 44px; }
  .scroll-cue { display: none; }
  .win:not(.popup) { left: 6px !important; width: auto !important; right: 6px; top: 28% !important; bottom: 6px; max-height: none; }
  .win.max:not(.popup) { top: 6px !important; height: auto; }
  .win-title { min-height: 36px; }
  .wc { width: 34px; height: 30px; }
  .wc-min::before { left: 12px; bottom: 9px; }
  .wc-max::before { left: 11px; top: 9px; }
  .wc-close::before, .wc-close::after { left: 11px; top: 14px; }
  .task { max-width: 44px; flex-basis: 44px; justify-content: center; }
  .task span { display: none; }
  .tray { gap: 2px; padding: 2px 4px; }
  .tray .src-badge { display: none; }
  .clock { display: none; }
  .startmenu { width: min(300px, calc(100% - 8px)); }
  .sm-item { min-height: 42px; }
  .bubble { font-size: 20px; max-width: 180px; }
  }
@media (max-width: 699px) and (max-height: 640px) {
  .hud-stats { display: none; }
}
