/* =========================================================
   WIN95.CSS — the Windows 95 look (loads AFTER style.css)
   Plan: docs/PLAN-win95-revamp.md
   Step 1: tokens, bevels, pixel font, window chrome, taskbar,
           Start menu, scrollbars, context menus.
   Step 2: controls (buttons, fields, checkbox/radio, tabs, tooltips).
   ---------------------------------------------------------
   Bevels are 4 stacked INSET box-shadows (no blur, no border), the
   same trick Win95 itself draws: light/dark outer line + light/dark
   inner line. Elements that use these set `border:0` and make up the
   2px with padding, so their size does not change.
   ========================================================= */

/* UI font: smooth Arial (owner, Nov 15: back to the original look).
   The code names "MS Sans Serif" in ~200 places (inline styles, CSS injected from JS,
   canvas fonts). That family is mapped to the system's Arial here, so all of them
   render as smooth Arial everywhere, even on Windows machines that have the old
   bitmap MS Sans Serif installed. (The bitmap woff2 files in webFiles/fonts are
   no longer loaded.)
   Display text only (Piano Tires title, Start banner, boot bar): Tiny5 (SIL OFL,
   webFiles/fonts/Tiny5-OFL.txt) at its crisp sizes 16/24/32px, via --w95-display. */
@font-face {
  font-family: 'MS Sans Serif';
  src: local('Arial'), local('ArialMT'), local('Arimo'), local('Liberation Sans'), local('Helvetica');
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: 'MS Sans Serif';
  src: local('Arial Bold'), local('Arial-BoldMT'), local('Arimo Bold'), local('Liberation Sans Bold'), local('Helvetica Bold');
  font-weight: 700;
  font-style: normal;
}
@font-face {
  font-family: 'Tiny5';
  src: url('../webFiles/fonts/tiny5-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --w95-face:   #c0c0c0;
  --w95-white:  #ffffff;
  --w95-light:  #dfdfdf;
  --w95-shadow: #808080;
  --w95-black:  #0a0a0a;
  --w95-navy:   #000080;
  --w95-teal:   #008080;
  --w95-font:    Arial, 'Helvetica Neue', Helvetica, sans-serif;
  --w95-display: 'Tiny5', 'MS Sans Serif', Arial, sans-serif;

  /* the five Win95 edges */
  --w95-raised:  inset -1px -1px #0a0a0a, inset 1px 1px #ffffff, inset -2px -2px #808080, inset 2px 2px #dfdfdf;
  --w95-pressed: inset -1px -1px #ffffff, inset 1px 1px #0a0a0a, inset -2px -2px #dfdfdf, inset 2px 2px #808080;
  --w95-field:   inset -1px -1px #ffffff, inset 1px 1px #808080, inset -2px -2px #dfdfdf, inset 2px 2px #0a0a0a;
  --w95-status:  inset -1px -1px #ffffff, inset 1px 1px #808080;
  --w95-window:  inset -1px -1px #0a0a0a, inset 1px 1px #dfdfdf, inset -2px -2px #808080, inset 2px 2px #ffffff;
  --w95-group:   inset -1px -1px #ffffff, inset 1px 1px #808080;  /* used with an outline for the etched box */

  /* the old tokens, brought in line (outer light edge is pure white) */
  --border-light: #ffffff;
  --border-dark:  #808080;
}

/* ── Font + crisp text ──────────────────────────────────── */
html, body, button, input, select, textarea {
  font-family: var(--w95-font);
}
body { text-rendering: auto; -webkit-font-smoothing: antialiased; font-smooth: auto; }   /* smooth text */
/* Desktop: every UI text is 11px (the font's pixel grid). Inline sizes written
   in JS are matched by their text, both spellings ("font-size:10px" as written,
   "font-size: 10px" as the browser re-serialises it). Phones get 12px below. */
#wins [style*="font-size:9px"],  #wins [style*="font-size: 9px"],
#wins [style*="font-size:10px"], #wins [style*="font-size: 10px"],
#wins [style*="font-size:12px"], #wins [style*="font-size: 12px"],
#wins [style*="font-size:13px"], #wins [style*="font-size: 13px"],
.wk-menu [style*="font-size:9px"], .wk-menu [style*="font-size:10px"], .wk-menu [style*="font-size:12px"], .wk-menu [style*="font-size:13px"],
.taskbar [style*="font-size:9px"], .taskbar [style*="font-size:10px"], .taskbar [style*="font-size:12px"], .taskbar [style*="font-size:13px"],
#start-menu-panel [style*="font-size:9px"], #start-menu-panel [style*="font-size:10px"],
#start-menu-panel [style*="font-size:12px"], #start-menu-panel [style*="font-size:13px"] {
  font-size: 11px !important;
}
button, .btn, a.btn, input, select, textarea { font: inherit; font-size: 11px; }
/* display text: Tiny5 at a crisp size */
.pt-title span, #start-menu-panel .sm-banner span, #boot-progress-label { font-family: var(--w95-display) !important; font-size: 16px !important; }
/* fields written as font-family:inherit already follow the above */
/* Pixel-crisp ONLY for pixel art (desktop/menu icons, the wkIcon set). Photos, gallery
   drawings stay smooth: forcing pixelated on everything made downscaled photos
   jagged. Dialog icons are pixel art SVGs with shape-rendering=crispEdges. */
.icon img, img.wk-ico, img[src*="images/icons/"], .task-btn img, .sm-row img, .sm-sub-item img,
.titlebar img, .file-item img, .tree-item img { image-rendering: pixelated; }
.tbtn svg { shape-rendering: crispEdges; }

/* ── Desktop: flat teal. Bliss is a Control Panel option ── */
html, body { background: #008080 !important; }
.desktop { background-color: #008080; }
.desktop.wp-photo { background-color: #000; }
/* labels on flat colour need no outline; on a photo they keep it */
html .desktop:not(.wp-photo) #icons .icon span { text-shadow: none !important; }

/* ── Utility classes ────────────────────────────────────── */
.w95-raised  { background: var(--w95-face); border: 0; box-shadow: var(--w95-raised); }
.w95-pressed { background: var(--w95-face); border: 0; box-shadow: var(--w95-pressed); }
.w95-sunken, .w95-field { background: #fff; border: 0; box-shadow: var(--w95-field); }
.w95-statusbar { border: 0; box-shadow: var(--w95-status); padding: 2px 4px; }
.w95-groupbox { border: 1px solid #808080; box-shadow: 1px 1px 0 #fff, inset 1px 1px 0 #fff; padding: 8px; position: relative; }
.w95-btn {
  background: var(--w95-face); color: #000; border: 0; box-shadow: var(--w95-raised);
  padding: 6px 14px; min-width: 75px; font-family: var(--w95-font); font-size: 12px;
}
.w95-btn:active, .w95-btn.is-down { box-shadow: var(--w95-pressed); padding: 7px 13px 5px 15px; }
/* toolbar row: gray face, etched bottom edge, raised buttons (Files admin bar) */
.w95-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 3px 4px;
  background: var(--w95-face); color: #000; border-bottom: 1px solid #808080; box-shadow: 0 1px 0 #fff;
  font-size: 11px; margin-bottom: 1px;
}
.w95-toolbar .btn, .btn.btn-tb { padding: 3px 8px; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.btn.btn-tb:active { padding: 4px 7px 2px 9px; }
.btn.mn-tb { min-width: 22px; height: 22px; padding: 0 6px; }
/* Raised box for message boxes, popups and floating panels: same edge as a window */
.w95-panel { background: var(--w95-face); color: #000; border: 0; box-shadow: var(--w95-window), 1px 1px 0 #0a0a0a; padding: 2px; font-family: var(--w95-font); }
.w95-toolbar-label { display: inline-flex; align-items: center; font-weight: bold; padding: 0 4px 0 2px; }
.w95-toolbar-hint { margin-left: auto; padding: 0 4px; color: #000; }

/* ── Windows ────────────────────────────────────────────── */
.win {
  border: 0;
  padding: 3px;
  background: var(--w95-face);
  box-shadow: var(--w95-window), 1px 1px 0 #0a0a0a;   /* hard 1px drop edge, no blur */
  resize: none;                                        /* edge-dragging is done in windows.js */
}
.titlebar {
  height: 18px;
  box-sizing: border-box;
  padding: 2px;
  background: #808080;
  color: #c0c0c0;
  font-weight: bold;
}
.win.active-win .titlebar { background: #000080; color: #fff; }
.title { padding: 0 0 0 2px; line-height: 14px; }
.tbtns { gap: 0; }
.tbtn {
  width: 16px; height: 14px; border: 0; padding: 0; box-sizing: border-box;
  background: var(--w95-face); color: #000; box-shadow: var(--w95-raised);
}
.tbtn[data-act="close"] { margin-left: 2px; }          /* the gap before the X */
.tbtn:active { box-shadow: var(--w95-pressed); padding: 1px 0 0 1px; }
.tbtn svg { width: 8px; height: 8px; display: block; }
.content { margin-top: 3px; }
.win .content { box-shadow: none; }

/* ── Taskbar ────────────────────────────────────────────── */
.taskbar {
  height: 28px;
  padding: 2px;
  background: var(--w95-face);
  border: 0;
  border-top: 1px solid #dfdfdf;
  box-shadow: inset 0 1px 0 #fff;
}
.start {
  height: 22px; padding: 0 6px 0 4px; border: 0; box-sizing: border-box;
  background: var(--w95-face); box-shadow: var(--w95-raised); color: #000;
}
.start:active, .start.start-down { box-shadow: var(--w95-pressed); padding: 1px 5px 0 5px; }
.start svg { image-rendering: pixelated; shape-rendering: crispEdges; }
.tasks, .task-list { padding-left: 4px; gap: 3px; }
.task-btn {
  height: 22px; border: 0; padding: 0 6px; box-sizing: border-box;
  background: var(--w95-face); box-shadow: var(--w95-raised); font-size: 11px;
}
.task-btn:active { box-shadow: var(--w95-pressed); }
.task-btn.active {
  font-weight: bold;
  box-shadow: var(--w95-pressed);
  /* the dithered checkerboard Win95 draws behind the active task */
  background: repeating-conic-gradient(#c0c0c0 0% 25%, #ffffff 0% 50%) 50% / 2px 2px;
}
/* the sunken tray holding the clock */
.tray {
  border: 0; margin-left: 4px; padding: 0 8px; height: 22px; box-sizing: border-box;
  box-shadow: var(--w95-status);
}
.clock {
  border: 0; box-shadow: none; margin: 0; padding: 0; height: auto; background: transparent;
  font-family: var(--w95-font); font-weight: normal; font-size: 12px;
}

/* ── Start menu ─────────────────────────────────────────── */
#start-menu-panel {
  border: 0 !important;
  padding: 3px;
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);   /* short screens: scroll, never cut off (#5) */
  overflow-y: auto;
  box-shadow: var(--w95-window), 1px 1px 0 #0a0a0a !important;
  font-family: var(--w95-font) !important;
}
#start-menu-panel .sm-banner {
  background: #808080 !important;      /* Win95 banner is flat dark gray, not the 98 blue gradient */
  color: #fff;
}
#start-menu-panel .sm-banner span { opacity: 1 !important; letter-spacing: 1px !important; }
#start-menu-panel .sm-sub { border: 0 !important; padding: 3px; box-shadow: var(--w95-window), 1px 1px 0 #0a0a0a !important; }
#start-menu-panel .sm-sep,
#start-menu-panel .sm-hr { height: 0 !important; background: none !important; border-top: 1px solid #808080; border-bottom: 1px solid #fff; margin: 3px 2px !important; }
#start-menu-panel .sm-row, #start-menu-panel .sm-sub-item { padding: 5px 8px; }
#start-menu-panel .sm-row.sm-kb, #start-menu-panel .sm-sub-item.sm-kb { background: #000080; color: #fff; }

/* ── Context / menu-bar menus (apps.js .wk-menu) ─────────── */
.wk-menu {
  border: 0 !important;
  padding: 3px !important;
  box-shadow: var(--w95-window), 1px 1px 0 #0a0a0a !important;
  font-family: var(--w95-font) !important;
}
.wk-sep { border-top: 1px solid #808080 !important; border-bottom: 1px solid #fff !important; }

/* ── Explorer bits that live in style.css ────────────────── */
.explorer-menubar { border-bottom: 0; box-shadow: inset 0 -1px 0 #808080, inset 0 -2px 0 #fff; }
.explorer-address { border-bottom: 0; }
.explorer-address select { border: 0; box-shadow: var(--w95-field); background: #fff; }
.explorer-content { border: 0; box-shadow: var(--w95-field); padding: 2px; }
.explorer-status { border: 0; box-shadow: var(--w95-status); }
.explorer-left { border-right: 1px solid #c0c0c0; }
.explorer-pane-title { border-bottom: 0; box-shadow: inset 0 -1px 0 #808080; }
.file-item:hover { background: transparent; border: 1px solid transparent; }
.file-item.file-selected { background: transparent; border: 1px solid transparent; color: #000; }
/* Win95 selection: navy label + white text, black dotted focus ring around the label (no yellow) */
.file-item.file-selected span { background: #000080; color: #fff !important; outline: 1px dotted #000; outline-offset: 0; }
.file-item.file-selected img { filter: brightness(.75) sepia(1) hue-rotate(185deg) saturate(3); }
.tree-active { background: #000080; color: #fff; outline: 1px dotted #000; outline-offset: 0; }

/* Helper text: Tiny5 has no italic (the browser fakes a slant) and gray reads badly. */
.muted { color: #404040; font-style: normal; }
#wins [style*="font-style:italic"], #wins [style*="font-style: italic"] { font-style: normal !important; }

/* ── Scrollbars (16px, Win95: dithered track, raised thumb + arrows) ── */
@supports selector(::-webkit-scrollbar) {
  ::-webkit-scrollbar { width: 16px; height: 16px; background: transparent; }
  ::-webkit-scrollbar-track {
    background: repeating-conic-gradient(#c0c0c0 0% 25%, #ffffff 0% 50%) 50% / 2px 2px;
  }
  ::-webkit-scrollbar-thumb { background: #c0c0c0; box-shadow: var(--w95-raised); }
  ::-webkit-scrollbar-corner { background: #c0c0c0; }
  ::-webkit-scrollbar-button:single-button {
    display: block; width: 16px; height: 16px; background-color: #c0c0c0; box-shadow: var(--w95-raised);
    background-repeat: no-repeat; background-position: center; background-size: 8px 8px;
  }
  ::-webkit-scrollbar-button:single-button:active { box-shadow: var(--w95-pressed); background-position: 5px 5px; }
  ::-webkit-scrollbar-button:single-button:vertical:decrement {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' shape-rendering='crispEdges'><path d='M0 6h8L4 2z' fill='black'/></svg>");
  }
  ::-webkit-scrollbar-button:single-button:vertical:increment {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' shape-rendering='crispEdges'><path d='M0 2h8L4 6z' fill='black'/></svg>");
  }
  ::-webkit-scrollbar-button:single-button:horizontal:decrement {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' shape-rendering='crispEdges'><path d='M6 0v8L2 4z' fill='black'/></svg>");
  }
  ::-webkit-scrollbar-button:single-button:horizontal:increment {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' shape-rendering='crispEdges'><path d='M2 0v8l4-4z' fill='black'/></svg>");
  }
}
/* Firefox can only colour its scrollbar */
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-color: #c0c0c0 #e8e8e8; }
}

/* ── Dotted keyboard focus ──────────────────────────────── */
button:focus-visible, .btn:focus-visible, .w95-btn:focus-visible, [role="button"]:focus-visible {
  outline: 1px dotted #000; outline-offset: -5px;
}
a:focus-visible { outline: 1px dotted #000; outline-offset: 1px; }

/* ── Phone: the pixel UI stays, only the targets grow ─────── */
@media (max-width: 768px), (pointer: coarse) and (max-height: 500px) {
  .taskbar { height: 32px; }
  .start, .task-btn, .tray { height: 26px; }
}

/* =========================================================
   STEP 2 — controls
   ========================================================= */

/* Buttons: the site's .btn, message-box buttons and the many JS buttons
   that carry an inline 2px bevel all get the real 2-layer bevel. */
.btn, button[id^="w95d-"]:not(#w95d-x),
button[style*="border-top:2px solid #fff"], button[style*="border-top: 2px solid #fff"],
button[style*="border:2px outset"], button[style*="border: 2px outset"] {
  background: var(--w95-face) !important;
  color: #000;
  border: 0 !important;
  box-shadow: var(--w95-raised) !important;
  font-family: var(--w95-font) !important;
  padding: 6px 14px;
  border-radius: 0;
}
/* the 75px Win95 minimum is for message-box buttons only (OK / Cancel), not every
   toolbar button — forcing it made Chat/DM and the ↻ refresh button long and skinny */
button[id^="w95d-"]:not(#w95d-x) { min-width: 75px; }
.btn:hover { background: var(--w95-face); }
.btn:active, button[id^="w95d-"]:not(#w95d-x):active,
button[style*="border-top:2px solid #fff"]:active, button[style*="border:2px outset"]:active {
  box-shadow: var(--w95-pressed) !important;
  padding: 7px 13px 5px 15px;
}
.btn:disabled, button:disabled { color: #808080; text-shadow: 1px 1px 0 #fff; }
/* default button gets the extra black frame */
.btn.default, #w95d-ok { outline: 1px solid #000; outline-offset: 0; }
#w95d-ok:focus-visible, .btn:focus-visible { outline: 1px dotted #000; outline-offset: -5px; }

/* Text fields / textareas / selects: sunken white */
input:not([type]), input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="search"], input[type="url"], textarea {
  background: #fff; color: #000; border: 0; border-radius: 0;
  box-shadow: var(--w95-field); padding: 3px 4px; font-family: var(--w95-font);
}
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 0; }
select {
  background-color: #fff; color: #000; border: 0 !important; border-radius: 0;
  box-shadow: var(--w95-field); padding: 2px 20px 2px 4px; font-family: var(--w95-font);
  -webkit-appearance: none; appearance: none;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' shape-rendering='crispEdges'><rect x='1' y='1' width='14' height='14' fill='%23c0c0c0'/><path d='M0 0h16v1H0zM0 0h1v16H0z' fill='%23dfdfdf'/><path d='M15 0h1v16h-1zM0 15h16v1H0z' fill='%230a0a0a'/><path d='M14 1h1v14h-1zM1 14h14v1H1z' fill='%23808080'/><path d='M4 6h8L8 10z' fill='black'/></svg>");
  background-repeat: no-repeat; background-position: right 2px center; background-size: 16px 16px;
}
select:disabled { color: #808080; }

/* Checkbox + radio: hand-drawn 13px boxes */
input[type="checkbox"], input[type="radio"] {
  -webkit-appearance: none; appearance: none; width: 13px; height: 13px; margin: 0 4px 0 0;
  background: #fff; border: 0; box-shadow: var(--w95-field); vertical-align: middle;
  position: relative; flex-shrink: 0;
}
input[type="radio"] { border-radius: 50%; box-shadow: inset 1px 1px #808080, inset -1px -1px #fff, inset 2px 2px #0a0a0a, inset -2px -2px #dfdfdf; }
input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 3px; top: 1px; width: 3px; height: 7px;
  border: solid #000; border-width: 0 2px 2px 0; transform: rotate(40deg);
}
input[type="radio"]:checked::after {
  content: ""; position: absolute; left: 4px; top: 4px; width: 5px; height: 5px; background: #000; border-radius: 50%;
}
input[type="checkbox"]:disabled, input[type="radio"]:disabled { background: #c0c0c0; }

/* Sliders (Control Panel + anywhere else): sunken groove, raised thumb */
input[type="range"], .cp-slider {
  -webkit-appearance: none; appearance: none; background: transparent !important; border: 0 !important;
  height: 22px; box-shadow: none !important;
}
input[type="range"]::-webkit-slider-runnable-track, .cp-slider::-webkit-slider-runnable-track {
  height: 4px; background: #fff; box-shadow: var(--w95-status);
}
input[type="range"]::-webkit-slider-thumb, .cp-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 11px; height: 21px; margin-top: -9px;
  background: var(--w95-face) !important; border: 0 !important; box-shadow: var(--w95-raised);
}
input[type="range"]::-moz-range-track { height: 4px; background: #fff; box-shadow: var(--w95-status); }
input[type="range"]::-moz-range-thumb { width: 11px; height: 21px; border: 0; border-radius: 0; background: var(--w95-face); box-shadow: var(--w95-raised); }

/* Control Panel tabs + group boxes */
/* Tab strip (Control Panel's): the one tab style for every tabbed window */
.cp-tabs { display: flex; gap: 0; margin-bottom: 8px; }
.cp-tab { padding: 4px 12px; font-size: 11px; background: var(--w95-face); margin-bottom: -2px; position: relative; cursor: var(--cur-pointer), pointer; }
.cp-tab.active { z-index: 1; font-weight: bold; }
.cp-tabs { border-bottom: 0 !important; box-shadow: 0 2px 0 #fff, 0 1px 0 #fff; padding-left: 2px; }
.cp-tab { border: 0 !important; box-shadow: inset 1px 1px #fff, inset -1px 0 #0a0a0a, inset -2px 0 #808080, inset 2px 2px #dfdfdf; padding: 4px 10px; }
.cp-tab:not(.active) { background: var(--w95-face) !important; top: 2px; }
.cp-tab.active { margin-top: -2px; padding-top: 6px; box-shadow: inset 1px 1px #fff, inset -1px 0 #0a0a0a, inset -2px 0 #808080, inset 2px 2px #dfdfdf; }
.cp-group { border: 1px solid #808080 !important; box-shadow: 1px 1px 0 #fff, inset 1px 1px 0 #fff; }

/* Tooltips: the yellow Win95 hint. Native title tooltips cannot be styled,
   so anything the site draws itself as .w95-tip gets the look. */
.w95-tip, [role="tooltip"] {
  background: #ffffe1; color: #000; border: 1px solid #000; padding: 2px 4px;
  font-family: var(--w95-font); font-size: 11px; box-shadow: none;
}

/* Message boxes (w95alert / w95confirm): raised window frame, no blur */
[id^="w95d"][style*="box-shadow"], #w95-dialog { box-shadow: var(--w95-window), 1px 1px 0 #0a0a0a !important; }

/* (grey helper text is handled per element at runtime, see js/win95-fix.js — a CSS substring
   match on inline styles also hits border-color:#808080 and blanked legit grey-on-black text) */

#w95d-x { border: 0 !important; box-shadow: var(--w95-raised) !important; width: 16px; height: 14px; padding: 0 !important; min-width: 0; }
#w95d-x:active { box-shadow: var(--w95-pressed) !important; }

/* =========================================================
   STEP 3 — phone shell (bigger targets, same 95 look)
   ========================================================= */
@media (max-width: 768px), (pointer: coarse) and (max-height: 500px) {
  .titlebar { height: 26px; padding: 3px; }
  .title { line-height: 20px; }
  .tbtn { width: 24px !important; height: 20px !important; min-width: 24px !important; min-height: 20px !important; }
  .tbtn[data-act="close"] { margin-left: 3px; }
  .tbtn svg { width: 10px; height: 10px; }
  .taskbar { height: 36px; }
  .start, .task-btn, .tray { height: 30px; }
  .start { padding: 0 8px 0 6px !important; }
  .task-btn { font-size: 11px; }

  /* Start menu: submenus unfold INLINE (accordion) instead of flying out
     sideways, because a 390px screen has no room to the right of a 220px menu. */
  #start-menu-panel {
    width: min(280px, 92vw) !important;
    max-height: calc(100vh - 46px); max-height: calc(100dvh - 46px);
    overflow-y: auto !important; bottom: 36px !important;
  }
  #start-menu-panel .sm-banner { position: sticky; top: 0; align-self: stretch; min-height: 100%; }
  #start-menu-panel .sm-sub, #start-menu-panel .sm-sub2 {
    position: static !important; left: auto !important; right: auto !important; top: auto !important;
    box-shadow: none !important; border: 0 !important; padding: 0 0 0 14px !important; min-width: 0;
    background: transparent;
  }
  #start-menu-panel .sm-sub-item, #start-menu-panel .sm-row { padding: 9px 8px; }
  #start-menu-panel .sm-sub-item > .sm-lb { max-width: none; white-space: normal; }
  #start-menu-panel .sm-arrow { transform: rotate(90deg); }
  #start-menu-panel .sm-has-sub.sm-open > .sm-arrow { transform: rotate(270deg); }
}

/* =========================================================
   STEP 4 — game pop-out buttons (phones). Layer sits ABOVE #wins.
   ========================================================= */
#game-popouts { position: fixed; inset: 0; z-index: 9000; pointer-events: none; }
#game-popouts > * { pointer-events: auto; position: fixed; display: none; touch-action: none; }
.gp-btn {
  background: var(--w95-face); color: #000; border: 0; border-radius: 0; padding: 0;
  box-shadow: var(--w95-raised), 2px 2px 0 #0a0a0a;
  font-family: var(--w95-font); font-size: 14px; letter-spacing: 1px; cursor: var(--cur-pointer), pointer;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.gp-btn:active { box-shadow: var(--w95-pressed); transform: translate(1px, 1px); }
.gp-again { position: fixed; font-weight: bold; }
.gp-dpad { /* positioned per frame by JS */ }
.gp-dpad .gp-btn { position: absolute; width: 48px; height: 48px; }
/* cross: ▲ centred on top row, ◀ ▼ ▶ on the bottom row (3 x 48 + 2 x 6 wide) */
.gp-cross .gp-up    { left: 54px; top: 0; }
.gp-cross .gp-left  { left: 0;    top: 54px; }
.gp-cross .gp-down  { left: 54px; top: 54px; }
.gp-cross .gp-right { left: 108px; top: 54px; }
/* split (landscape): ◀ ▶ hug the window's left edge, ▲ ▼ its right edge — mirror images */
.gp-split .gp-left  { left: var(--wl); top: 0; }
.gp-split .gp-right { left: calc(var(--wl) + 54px); top: 0; }
.gp-split .gp-up    { right: calc(var(--wr) + 54px); top: 0; }
.gp-split .gp-down  { right: var(--wr); top: 0; }
/* pixel arrows (square-ended, drawn with clip-path so they stay crisp) */
.gp-glyph { display: block; width: 18px; height: 18px; margin: auto; background: #000; }
.gp-up    { } .gp-up .gp-glyph    { clip-path: polygon(50% 0, 100% 60%, 70% 60%, 70% 100%, 30% 100%, 30% 60%, 0 60%); }
.gp-down .gp-glyph  { clip-path: polygon(50% 100%, 100% 40%, 70% 40%, 70% 0, 30% 0, 30% 40%, 0 40%); }
.gp-left .gp-glyph  { clip-path: polygon(0 50%, 60% 0, 60% 30%, 100% 30%, 100% 70%, 60% 70%, 60% 100%); }
.gp-right .gp-glyph { clip-path: polygon(100% 50%, 40% 0, 40% 30%, 0 30%, 0 70%, 40% 70%, 40% 100%); }
.gp-btn { display: flex; align-items: center; justify-content: center; }

/* 8-bit pop: four HARD frames (no tweening) 0 -> .6 -> 1.25 -> 1.1 -> 1 */
@keyframes gp-pop {
  0%   { transform: scale(0);    animation-timing-function: steps(1, jump-end); }
  25%  { transform: scale(.6);   animation-timing-function: steps(1, jump-end); }
  50%  { transform: scale(1.25); animation-timing-function: steps(1, jump-end); }
  75%  { transform: scale(1.1);  animation-timing-function: steps(1, jump-end); }
  100% { transform: scale(1); }
}
.gp-pop { animation: gp-pop .24s both; transform-origin: center; }
/* dust: little squares flung out in 3 steps */
@keyframes gp-dust { to { transform: translate(var(--dx), var(--dy)); opacity: 0; } }
.gp-dust { position: fixed !important; display: block !important; width: 4px; height: 4px; background: #fff; box-shadow: 1px 1px 0 #000;
  pointer-events: none; animation: gp-dust .4s steps(3, end) both; }
@media (prefers-reduced-motion: reduce) { .gp-pop, .gp-dust { animation: none !important; } }

/* Snake window in phone landscape: narrower, so the ◀▶ / ▲▼ pads have room beside it */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
  #win-snake-game { width: min(440px, 52vw) !important; left: calc(50vw - min(220px, 26vw)) !important; }
}
.gp-split { pointer-events: none !important; }
.gp-split .gp-btn { pointer-events: auto; }

/* =========================================================
   STEP 6 — sweep of inline bevels written in JS (apps, games, paint, piano tires…)
   Inline styles can't be edited from CSS, but their text can be matched.
   Only the exact bevel patterns the code uses are matched (no loose substrings).
   ========================================================= */
/* raised: border-top light + border-bottom dark, 2px and 1px */
/* (each pattern twice: as written in HTML strings, and as the browser re-serialises a
   style set through el.style.cssText, e.g. "border-top: 2px solid rgb(255, 255, 255)") */
:where(div, span, button, a, label, td, th, li)[style*="border-top:2px solid #fff"][style*="border-bottom:2px solid #0a0a0a"],
:where(div, span, button, a, label, td, th, li)[style*="border-top: 2px solid rgb(255, 255, 255)"][style*="border-bottom: 2px solid rgb(10, 10, 10)"] {
  border: 0 !important; box-shadow: var(--w95-raised) !important;
}
:where(div, span, button, a, label, td, th, li)[style*="border-top:1px solid #fff"][style*="border-bottom:1px solid #0a0a0a"],
:where(div, span, button, a, label, td, th, li)[style*="border-top: 1px solid rgb(255, 255, 255)"][style*="border-bottom: 1px solid rgb(10, 10, 10)"] {
  border: 0 !important; box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #fff, inset -2px -2px #808080 !important;
}
/* sunken: "border:2px inset …" / "1px inset" and the dark-top-left / light-bottom-right colour quartet */
:where(div, span, input, textarea, select, pre, ul, ol, table, section, iframe)[style*="2px inset"],
:where(div, span, input, textarea, select, pre, ul, ol, table, section, iframe)[style*="border-color:#808080 #dfdfdf #dfdfdf #808080"],
:where(div, span, input, textarea, select, pre, ul, ol, table, section)[style*="border-color:#808080 #fff #fff #808080"],
:where(div, span, input, textarea, select, pre, ul, ol, table, section)[style*="border-color: rgb(128, 128, 128) rgb(223, 223, 223) rgb(223, 223, 223) rgb(128, 128, 128)"],
:where(div, span, input, textarea, select, pre, ul, ol, table, section)[style*="border-top: 2px solid rgb(128, 128, 128)"][style*="border-bottom: 2px solid rgb(255, 255, 255)"],
:where(input, textarea)[style*="border-top:2px solid #808080"][style*="border-bottom:2px solid #fff"] {
  border: 0 !important; box-shadow: var(--w95-field) !important;
}
:where(div, span, input, textarea, select, pre, ul, ol, table, section, iframe)[style*="1px inset"] {
  border: 0 !important; box-shadow: var(--w95-status) !important;
}
:where(button, a)[style*="border-top:2px solid #fff"][style*="border-bottom:2px solid #0a0a0a"]:active,
:where(button, a)[style*="border-top: 2px solid rgb(255, 255, 255)"][style*="border-bottom: 2px solid rgb(10, 10, 10)"]:active { box-shadow: var(--w95-pressed) !important; }
:where(div, fieldset)[style*="2px groove"] { border: 1px solid #808080 !important; box-shadow: 1px 1px 0 #fff, inset 1px 1px 0 #fff !important; }

/* Win95 zoom rectangles (js/windows.js _wkZoom): dotted outline, 4 hard steps, no tween */
.wk-zoom { position: fixed; z-index: 99990; pointer-events: none; box-sizing: border-box;
  border: 2px dotted #fff; mix-blend-mode: difference; opacity: 0; animation: wk-zoom-blink .04s steps(1, end) forwards; }
@keyframes wk-zoom-blink { from { opacity: 1; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .wk-zoom { display: none; } }
#game-popouts, #game-popouts * { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* =========================================================
   UI POLISH (docs/PLAN-ui-polish.md) steps 4-5 — phone readability + tap targets.
   One block. Inline font sizes written in JS are matched by their text
   ("font-size:10px" as written, "font-size: 10px" as the browser re-serialises it).
   Body/labels 12px, status + helper lines 11px. Targets: 32px min, 44px primary.
   ========================================================= */
@media (max-width: 768px), (pointer: coarse) and (max-height: 500px) {
  body { -webkit-font-smoothing: auto; font-smooth: auto; text-rendering: auto; }
  /* ── readability ── */
  #wins [style*="font-size:8px"], #wins [style*="font-size: 8px"],
  #wins [style*="font-size:9px"], #wins [style*="font-size: 9px"],
  #wins [style*="font-size:10px"], #wins [style*="font-size: 10px"],
  #wins [style*="font-size:11px"], #wins [style*="font-size: 11px"],
  #wins .btn, #wins button, #wins input, #wins textarea, #wins select, #wins label,
  #wins .muted, #wins .wk-menubar, #wins .wk-mb, #wins .game-tile span,
  #wins .explorer-address, #wins .explorer-address span, #wins #exp-addr-text, #wins .explorer-pane-title,
  #wins .tree-li, #wins .tree-li span, #wins .pn-optl, #wins .gl-count, #wins .gl-empty,
  #wins .cp-tab, #wins .cp-group-label, #wins .cp-row label, #wins .cp-val, #wins #ttt-status,
  #wins .pt-panel, #wins .pt-panel *,
  #icons .icon span, .taskbar .task-btn, .wk-menu, .wk-mi {
    font-size: 12px !important;
  }
  /* status bars + one-line helper text */
  #wins .explorer-status, #wins .explorer-status span, #wins .pn-status, #wins .pn-status span,
  #wins #mem-msg, #wins #gb-status, #wins .muted[style*="font-size:10px"], #wins .gl-bar .gl-count {
    font-size: 11px !important;
  }
  #icons .icon span { line-height: 1.25; }
  /* games folder: tiles at least 96px so descriptions wrap between words */
  #wins .games-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)) !important; }
  #wins .game-tile span { word-break: normal !important; overflow-wrap: anywhere; }
  /* Memory: the message gets its own full-width row under Pairs / Restart, no truncation */
  #wins .mem-bar { flex-wrap: wrap; }
  #wins .mem-bar > :nth-child(2) { order: 3; flex: 1 1 100% !important; white-space: normal !important; overflow: visible !important; }

  /* ── tap targets ── */
  #wins button, #wins .btn, #wins select,
  #wins input:not([type]), #wins input[type="text"], #wins input[type="password"], #wins input[type="number"],
  #wins input[type="search"], #wins input[type="email"], #wins input[type="url"],
  #wins .cp-tab, #wins .pn-size, #wins .gl-draw, #wins .gl-refresh {
    min-height: 32px !important; box-sizing: border-box;
  }
  #wins button, #wins .btn { min-width: 32px; white-space: nowrap; }
  #wins div.btn, #wins span.btn, #wins a.btn { display: inline-flex; align-items: center; justify-content: center; }
  /* primary actions */
  #wins .btn-primary, #wins button[onclick^="gbSend"], #wins .pt-start, #wins .pt-again,
  #w95d-ok, #w95d-cancel, button[id^="w95d-"]:not(#w95d-x) {
    min-height: 44px !important; padding-left: 16px; padding-right: 16px;
  }
  #wins .pt-panel button { min-height: 32px; }
  #wins .pn-pick { min-width: 32px !important; min-height: 32px !important; }
  #wins .cp-slider, #wins input[type="range"] { height: 32px; }
  /* tree: 32px rows, roomy +/- box */
  #wins .tree-li { min-height: 32px; box-sizing: border-box; }
  #wins .tree-toggle { min-width: 24px; min-height: 24px; display: inline-flex !important; align-items: center; justify-content: center; }
  /* checkbox / radio: 24px box (the audit floor), the label around it is the 32px hit area */
  #wins input[type="checkbox"], #wins input[type="radio"] { width: 24px; height: 24px; }
  #wins input[type="checkbox"]:checked::after { left: 8px; top: 3px; width: 5px; height: 11px; }
  #wins input[type="radio"]:checked::after { left: 8px; top: 8px; width: 8px; height: 8px; }
  #wins label:has(> input[type="checkbox"]), #wins label:has(> input[type="radio"]) { min-height: 32px; display: inline-flex; align-items: center; }
  /* inline text links: padding grows the hit box without moving the text */
  #wins a { padding: 10px 0; }
  /* caption buttons stay 24x20 (Win95 proportions, plan decision); an invisible
     2px strip above and below makes the touch area 24x24 */
  .tbtn { position: relative; }
  .tbtn::before { content: ""; position: absolute; left: 0; right: 0; top: -2px; bottom: -2px; }
  /* message box caption X */
  #w95d-x { width: 24px !important; height: 24px !important; }
  .w95-toolbar { gap: 8px; }
}
