/* The desktop — floating windows, menu bar, dock */
body {
  display: grid;
  grid-template-rows: 28px minmax(0, 1fr) auto;
  height: 100%;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
input, .sh-out, .readme-body, .txt-body, .vw-post { user-select: text; -webkit-user-select: text; }
[hidden] { display: none !important; }

/* ---------- menu bar ---------- */
.menubar {
  position: relative;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--abyss);
  border-bottom: 1px solid #000;
  padding: 0 8px;
  font-size: 12px;
  white-space: nowrap;
}
.mb-btn {
  background: none; border: 0; color: var(--text); cursor: pointer;
  height: 24px; padding: 0 9px; border-radius: 2px; display: inline-flex; align-items: center; gap: 6px;
}
.mb-btn:hover, .mb-btn[aria-expanded="true"] { background: var(--ink); }
.mb-logo img { width: 18px; height: 18px; }
.mb-app { font-weight: 700; }
.mb-right { margin-left: auto; display: flex; align-items: center; gap: 2px; color: var(--muted); }
.mb-right .mb-btn { color: var(--muted); }
.menu {
  position: absolute;
  top: 27px;
  min-width: 230px;
  background: var(--night);
  border: 1px solid var(--border);
  box-shadow: 0 12px 30px rgb(0 0 0 / .5);
  padding: 4px;
  display: grid;
}
.menu.ctx { position: fixed; top: 0; z-index: 9500; min-width: 210px; outline: none; }
.menu button {
  display: flex; justify-content: space-between; gap: 24px;
  background: none; border: 0; text-align: left; cursor: pointer;
  padding: 5px 10px; color: var(--text); font-size: 12px;
}
.menu button:hover, .menu button:focus-visible { background: var(--shell); color: #fff; outline: none; }
.menu button:disabled { color: var(--muted); cursor: default; background: none; }
.menu kbd { font: inherit; color: var(--muted); }
.menu button:hover kbd, .menu button:focus-visible kbd { color: #fff; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 2px; }
.menu .check { display: inline-block; width: 1.5ch; color: var(--shell); }

/* ---------- desk ---------- */
.desk {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 80% 110%, rgb(200 53 76 / .10), transparent 55%),
    var(--deep-night);
}
/* the primary (square, three-line) logo, faded into the wallpaper */
.wallpaper {
  position: absolute; left: 32px; bottom: 24px;
  font: clamp(72px, min(14vh, 13vw), 190px)/0.8 var(--display);
  letter-spacing: -0.075em;
  color: var(--ink);
  white-space: pre;
  pointer-events: none;
}
.wallpaper .s { color: color-mix(in srgb, var(--shell) 45%, var(--deep-night)); }

/* desktop icons */
.icons { position: absolute; inset: 0; list-style: none; margin: 0; padding: 0; pointer-events: none; }
.icons li { position: absolute; pointer-events: auto; }
.dicon { user-select: none; -webkit-user-select: none; touch-action: none; }
.dicon img { -webkit-user-drag: none; }
.icons li.dragging { z-index: 1; opacity: .85; }
.icons li.dragging .dicon { cursor: grabbing; }
.dicon {
  width: 92px;
  display: grid; justify-items: center; gap: 4px;
  background: none; border: 1px solid transparent; border-radius: 2px;
  padding: 6px 4px; cursor: default; color: var(--text); font-size: 12px;
}
.dicon img { width: 48px; height: 48px; image-rendering: pixelated; }
.dicon img.smooth { image-rendering: auto; }
.dicon span { padding: 0 4px; border-radius: 2px; text-shadow: 0 1px 2px #000; }
.dicon.sel { background: rgb(65 78 120 / .45); border-color: var(--border); }
.dicon.sel span { background: var(--shell); color: #fff; text-shadow: none; }

/* Lobby & Bobby live on the desktop */
.lobsters { position: absolute; right: 24px; bottom: 8px; display: flex; gap: 4px; align-items: flex-end; }
.lobsters { pointer-events: none; }
.lobster img { width: 56px; display: block; image-rendering: pixelated; }
.lobster.bobby img { transform: scaleX(-1); }

/* ---------- windows ---------- */
.windows { position: absolute; inset: 0; pointer-events: none; }
.w {
  position: absolute;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--night);
  border: 2px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgb(0 0 0 / .35);
  animation: w-in .16s ease-out;
}
.w:focus-visible { outline: none; }
.w.focused { border-color: var(--shell); box-shadow: 0 22px 60px rgb(0 0 0 / .55); }
.w.max { border-radius: 0; border-width: 0 0 0 0; box-shadow: none; }
.w.max.focused { border-width: 0; box-shadow: inset 0 0 0 2px var(--shell); }
.w.closing { animation: w-out .14s ease-in forwards; }
.w.minimizing { transition: transform .22s ease-in, opacity .22s ease-in; transform: translate(var(--to-x), var(--to-y)) scale(.1); opacity: 0; }
.w.restoring { animation: w-restore .22s ease-out; }
.w.dragging { transition: none; cursor: grabbing; }
@keyframes w-in { from { opacity: 0; transform: scale(.96); } }
@keyframes w-out { to { opacity: 0; transform: scale(.96); } }
@keyframes w-restore { from { opacity: 0; transform: translate(var(--to-x), var(--to-y)) scale(.1); } }

.w-bar {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  height: 28px; padding: 0 4px 0 8px;
  background: var(--raised); color: var(--muted);
  font-size: 12px;
  cursor: grab;
  touch-action: none;
}
.w.focused .w-bar { background: var(--shell); color: #fff; }
.w-bar img { width: 16px; height: 16px; image-rendering: pixelated; flex: none; }
.w-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-btns { display: flex; gap: 2px; }
.w-btns button {
  width: 26px; height: 22px; background: none; border: 0; color: inherit; cursor: pointer;
  font-size: 13px; line-height: 1; border-radius: 2px;
}
.w-btns button:hover { background: rgb(0 0 0 / .22); }
.w-btns .x:hover { background: var(--night); color: var(--light-red); }
.w-body { position: relative; flex: 1; min-height: 0; overflow: hidden; container-type: inline-size; }
.w-grip {
  position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize; touch-action: none;
  background: linear-gradient(135deg, transparent 50%, var(--border) 50% 60%, transparent 60% 70%, var(--border) 70% 80%, transparent 80%);
}
.w.max .w-grip, .w.fixed .w-grip { display: none; }
.snap-ghost {
  position: absolute; z-index: 8000; pointer-events: none;
  background: rgb(200 53 76 / .12); border: 2px dashed var(--shell); border-radius: 6px;
  transition: all .12s ease-out;
}

/* terminal window */
.w-body > .sh { height: 100%; }

/* projects folder & trash */
.fm { display: flex; flex-direction: column; height: 100%; }
.fm-bar { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-bottom: 1px solid var(--border); font-size: 12px; }
.fm-bar .sp { flex: 1; }
.fm-bar button { background: var(--raised); border: 1px solid var(--border); color: var(--text); padding: 2px 10px; cursor: pointer; font-size: 12px; }
.fm-bar button:hover { border-color: var(--shell); }
.fm-grid {
  flex: 1; min-height: 0; overflow: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  align-content: start; gap: 8px; padding: 12px;
}
.fm-item {
  display: grid; justify-items: center; gap: 6px; padding: 8px 4px;
  background: none; border: 1px solid transparent; border-radius: 2px; cursor: default; color: var(--text);
  font-size: 12px; text-align: center;
}
.fm-item img { width: 96px; height: 72px; border: 1px solid var(--border); object-fit: cover; }
.fm-item img.icon { width: 48px; height: 48px; border: 0; margin: 12px 0; }
.fm-item .nm { color: var(--light-red); word-break: break-all; }
.fm-item.opened .nm, .fm-item.plain .nm { color: var(--pale-ink); }
.fm-item .yr { color: var(--muted); font-size: 11px; margin-top: -4px; }
.fm-item.sel { background: rgb(65 78 120 / .45); border-color: var(--border); }
.fm-item.sel .nm { background: var(--shell); color: #fff; padding: 0 4px; }
.fm-status { padding: 4px 12px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; }

/* project window: the artwork, then the post, scrolling together */
.vw { height: 100%; overflow-y: auto; scrollbar-color: var(--border) transparent; }
.vw:focus-visible { outline: none; }
.vw-img { position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: 480px; background: var(--abyss); }
.vw-img .dl-frame { aspect-ratio: auto; height: 100%; background: var(--abyss); }
.vw-img .dl-frame img { object-fit: contain; }
.vw-img .dither {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  image-rendering: pixelated; opacity: 0; transition: opacity .35s ease; pointer-events: none;
}
.w:not(.focused) .vw-img .dither { opacity: 1; }
.w:not(.focused) .vw-img .dl-frame { visibility: hidden; transition: visibility 0s .35s; }
.vw-img .dl-bar {
  position: absolute; left: 8px; bottom: 8px; margin: 0;
  background: rgb(14 19 34 / .85); color: var(--pale-ink); padding: 2px 8px; font-size: 12px;
  transition: opacity .4s .6s; max-width: calc(100% - 16px); overflow: hidden;
}
.vw-img .dl-frame.done + .dl-bar { opacity: 0; }
.vw-post { max-width: 64ch; margin: 0 auto; padding: 22px 24px 40px; font-size: 14px; line-height: 1.7; }
.vw-title { font: 40px/1 var(--display); letter-spacing: -0.05em; margin: 0 0 8px; font-weight: 400; }
.vw-meta { color: var(--muted); font-size: 12px; margin: 0; }
.vw-meta .tags { color: var(--gold); margin-left: 1ch; }
.vw-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.vw-links a {
  color: var(--text); text-decoration: none; font-size: 12px;
  background: var(--raised); border: 1px solid var(--border); padding: 3px 10px;
}
.vw-links a:hover { border-color: var(--shell); }
.vw-body { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 6px; }
.vw-body h2, .vw-body h3, .vw-body h4 { font: 24px/1.15 var(--display); letter-spacing: -0.04em; font-weight: 400; margin: 28px 0 8px; }
.vw-body h3 { font-size: 19px; }
.vw-body h4 { font-size: 16px; }
.vw-body p, .vw-body ul, .vw-body ol, .vw-body blockquote, .vw-body pre { margin: 12px 0; }
.vw-body ul, .vw-body ol { padding-left: 2.4ch; }
.vw-body li { margin: 4px 0; }
.vw-body li::marker { color: var(--shell); }
.vw-body strong { color: var(--pale-ink); font-weight: 700; }
.vw-body em { color: var(--mist); }
.vw-body a { color: var(--light-red); }
.vw-body code { background: var(--raised); padding: 0 4px; font-size: 13px; }
.vw-body pre { background: var(--abyss); padding: 10px 12px; overflow-x: auto; }
.vw-body pre code { background: none; padding: 0; }
.vw-body blockquote { border-left: 3px solid var(--shell); padding-left: 12px; color: var(--mist); }
.vw-body img { max-width: 100%; display: block; border: 1px solid var(--border); }
.vw-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 32px; padding-top: 14px; border-top: 1px solid var(--border); }
.vw-nav button {
  display: grid; gap: 2px; text-align: left; padding: 8px 12px; cursor: pointer;
  background: var(--raised); border: 1px solid var(--border); color: var(--text);
  font: 18px/1.1 var(--display); letter-spacing: -0.04em;
}
.vw-nav button:last-child { text-align: right; }
.vw-nav button .muted { font: 11px var(--mono); letter-spacing: 0; }
.vw-nav button:hover { border-color: var(--shell); }
@container (max-width: 480px) {
  .vw-post { padding: 16px 14px 32px; }
  .vw-title { font-size: 30px; }
}

/* text windows */
.readme-body, .txt-body { height: 100%; overflow: auto; padding: 16px 18px; margin: 0; font: 13px/1.6 var(--mono); white-space: pre-wrap; }
.readme-body h1 { font: 30px/0.85 var(--display); letter-spacing: -0.075em; margin: 0 0 14px; font-weight: 400; white-space: normal; }
.readme-body .s { color: var(--shell); }
.readme-body .x { color: var(--gold); }
.readme-body kbd, .help-body kbd { font: inherit; color: var(--gold); }

/* about */
.about { display: grid; justify-items: center; align-content: center; text-align: center; gap: 4px; padding: 20px 18px; height: 100%; overflow: auto; }
.about .wm { font: 32px/0.8 var(--display); letter-spacing: -0.075em; white-space: pre; margin: 8px 0 6px; text-align: left; }
.about .wm .s { color: var(--shell); }
.copy { margin: 0; font: 11px/1.4 var(--mono); color: var(--muted); }
.about .copy { margin-top: 14px; }
.bootscreen .copy { margin-top: 28px; }
.noscript .copy { margin-top: 1.5em; }
.about button { margin-top: 16px; background: var(--raised); border: 1px solid var(--border); color: var(--text); padding: 4px 12px; cursor: pointer; }

/* help */
.help-body { padding: 14px 18px; overflow: auto; height: 100%; font-size: 13px; }
.help-body table { border-collapse: collapse; width: 100%; }
.help-body td { padding: 3px 8px 3px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.help-body table { table-layout: fixed; }
.help-body td:first-child { width: 42%; white-space: nowrap; color: var(--gold); }
.help-body h3 { font-size: 12px; color: var(--muted); font-weight: 400; margin: 14px 0 4px; }
.help-body h3:first-child { margin-top: 0; }

/* game window */
.w-body > .play { border: 0; height: 100%; overflow: hidden; max-width: none; padding: 8px 10px; gap: 6px; }
.w-body .play-main { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; }
.w-body .play-mapbox { flex: 1; min-height: 0; }
.w-body .play-map { height: 100%; aspect-ratio: auto; }
.w-body .play-log .old { display: none; }

/* ---------- dock ---------- */
.dock-wrap { display: flex; justify-content: center; padding: 4px 8px 6px; background: var(--deep-night); border-top: 1px solid #000; }
.dock {
  display: flex; align-items: flex-end; gap: 4px;
  padding: 4px 8px;
  background: var(--night);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 100%;
  overflow-x: auto;
}
.dock .sep { width: 1px; align-self: stretch; background: var(--border); margin: 4px 4px; }
.dk {
  position: relative;
  width: 46px; height: 46px; display: grid; place-items: center;
  background: none; border: 0; border-radius: 4px; cursor: pointer;
  transition: transform .12s ease-out;
}
.dk:hover { transform: translateY(-4px); background: var(--raised); }
.dk img { width: 34px; height: 34px; image-rendering: pixelated; }
.dk img.thumb { width: 38px; height: 29px; border: 1px solid var(--border); image-rendering: auto; object-fit: cover; }
.dk.running::after {
  content: ""; position: absolute; bottom: 1px; left: 50%; width: 4px; height: 4px; margin-left: -2px;
  background: var(--pale-ink); border-radius: 50%;
}
.dk.front::after { background: var(--shell); }
.dk.minimized img { opacity: .55; }
.dk .tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--night); border: 1px solid var(--border); color: var(--text);
  font-size: 11px; padding: 2px 8px; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .1s;
}
.dk:hover .tip, .dk:focus-visible .tip { opacity: 1; }

/* ---------- toasts ---------- */
.toasts { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 8500; display: grid; gap: 6px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--night); border: 1px solid var(--gold); color: var(--text);
  padding: 8px 14px; font-size: 12px; border-radius: 4px;
  box-shadow: 0 10px 30px rgb(0 0 0 / .45);
  animation: toast-in .2s ease-out;
}
.toast b { color: var(--gold); font-weight: 400; }
.toast.out { animation: toast-out .25s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }

/* without JavaScript */
.noscript { position: absolute; top: 24px; left: 32px; max-width: 52ch; color: var(--text); }
.noscript a { color: var(--light-red); }

/* ---------- boot ---------- */
.bootscreen {
  position: fixed; inset: 0; z-index: 10000;
  display: grid; place-items: center; text-align: center;
  background: var(--abyss); color: var(--muted);
  transition: opacity .35s ease;
}
.bootscreen.gone { opacity: 0; pointer-events: none; }
.bootscreen img { width: 72px; height: 72px; }
.bootscreen .wm { font: 44px/0.8 var(--display); letter-spacing: -0.075em; color: var(--pale-ink); margin: 16px 0 22px; white-space: pre; text-align: left; display: inline-block; }
.bootscreen .wm .s { color: var(--shell); }
.bootscreen pre { font: 12px var(--mono); margin: 0; }
.bootscreen pre .hash { color: var(--pale-ink); }

@media (max-width: 700px) {
  .icons { inset: 8px 8px auto auto; display: grid; gap: 6px; grid-template-columns: repeat(2, auto); }
  .icons li { position: static; }
  .dicon { width: 76px; }
  .wallpaper { display: none; }
  .mb-menus .mb-btn:not(:first-child) { display: none; }
  .lobsters { display: none; }
  #clock { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .w, .w.closing, .w.restoring, .toast, .toast.out { animation: none; }
  .w.minimizing { transition: none; }
}
