/* Roboto Mono, self-hosted (variable font: one file per script covers weights 300 to 700) */
@font-face {
  font-family: "Roboto Mono";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("assets/fonts/roboto-mono-cyrillic-ext.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: "Roboto Mono";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("assets/fonts/roboto-mono-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Roboto Mono";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("assets/fonts/roboto-mono-greek.woff2") format("woff2");
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
@font-face {
  font-family: "Roboto Mono";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("assets/fonts/roboto-mono-vietnamese.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: "Roboto Mono";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("assets/fonts/roboto-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Roboto Mono";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("assets/fonts/roboto-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}

/* `hidden` always wins, even over rules that set display (like the footer's flex items) */
[hidden] {
  display: none !important;
}

:root {
  --accent-rgb: 0, 170, 0;
  --accent-hi-rgb: 51, 255, 51;
  --accent: rgb(var(--accent-rgb));
  --accent-glow: rgba(var(--accent-rgb), 0.6);
  --accent-glow-strong: rgba(var(--accent-hi-rgb), 0.9);
  --bg: #222222;
  --bg-dark: #0d0f0d;
  --bg-tint: #002b00;
  --text: #cccccc;
  --dim: #97a297;
  color-scheme: dark;
  /* Scrollbars in the theme colour. scrollbar-color is inherited, so this covers
     the page, windows and the terminal; the WebKit rules below are for Safari. */
  scrollbar-color: rgba(var(--accent-rgb), 0.55) var(--bg-dark);
}

/* Terminal themes (switch with `theme` in the shell) */
:root[data-theme="amber"] {
  --accent-rgb: 255, 176, 0;
  --accent-hi-rgb: 255, 204, 80;
  --bg-tint: #2b1c00;
  --dim: #a69b85;
}
:root[data-theme="blue"] {
  --accent-rgb: 0, 170, 255;
  --accent-hi-rgb: 110, 210, 255;
  --bg-tint: #001a2b;
  --dim: #8c9ca8;
}
:root[data-theme="pink"] {
  --accent-rgb: 255, 90, 200;
  --accent-hi-rgb: 255, 150, 225;
  --bg-tint: #2b0020;
  --dim: #a68b9e;
}
:root[data-theme="mono"] {
  --accent-rgb: 220, 220, 220;
  --accent-hi-rgb: 255, 255, 255;
  --bg-tint: #1a1a1a;
  --dim: #9c9c9c;
}
:root.rgb body {
  animation: rgb-cycle 4s linear infinite;
}
@keyframes rgb-cycle {
  from { filter: hue-rotate(0deg); }
  to   { filter: hue-rotate(360deg); }
}

/* CRT power on (head.js, once per session) and off (shutdown, reboot).
   Same specificity as the RGB rule above, so these win by coming after it. */
:root.crt-on,
:root.crt-off,
:root.off {
  background: #000;
  /* The animation briefly overshoots the viewport; don't flash a scrollbar */
  overflow: hidden;
}
:root.crt-on body {
  animation: crt-on 0.7s ease-out both;
  transform-origin: 50% 50vh;
}
:root.crt-off body {
  animation: crt-off 0.6s ease-in forwards;
  transform-origin: 50% 50vh;
}
/* While "off", only the boot screen, scanlines and toasts are visible */
:root.off body {
  background: #000;
}
:root.off body > :not(.boot):not(.overlay):not(#toasts) {
  visibility: hidden;
}
@keyframes crt-on {
  0%   { transform: scale(0, 0.003); filter: brightness(6); opacity: 0; }
  10%  { opacity: 1; }
  40%  { transform: scale(1, 0.003); filter: brightness(6); }
  75%  { transform: scale(1, 1.03); filter: brightness(1.5); }
  100% { transform: scale(1, 1); filter: brightness(1); }
}
@keyframes crt-off {
  0%   { transform: scale(1, 1); filter: brightness(1); }
  40%  { transform: scale(1, 0.003); filter: brightness(5); }
  75%  { transform: scale(0.004, 0.003); filter: brightness(8); opacity: 1; }
  100% { transform: scale(0, 0); filter: brightness(0); opacity: 0; }
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: "Roboto Mono", monospace;
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-tint), var(--bg));
  background-attachment: fixed;
  color: var(--text);
  font-size: 17px;
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

::selection {
  background: var(--accent);
  color: var(--bg-dark);
}

* {
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
  background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
  background: rgba(var(--accent-rgb), 0.55);
  box-shadow: 0 0 6px var(--accent-glow);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.container {
  max-width: 680px;
  margin: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 3rem 1rem 2rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 15px rgba(var(--accent-hi-rgb), 0.4);
  animation: fade-in 0.5s ease-out both;
}

/* Scales from the centre instead of sliding up: sliding pushed the page 8px past
   the bottom of the window and flashed a scrollbar */
@keyframes fade-in {
  from { opacity: 0; transform: scale(0.985); }
  to   { opacity: 1; transform: scale(1); }
}

main {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Background layers */
.cyn {
  pointer-events: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -1;
  opacity: 0.12;
  transition: opacity 0.4s ease;
}
div.cyn {
  background: url("assets/cyn-poster.jpg") center / cover no-repeat;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: -1;
  opacity: 0.05;
  animation: noise 0.6s steps(6) infinite;
}

@keyframes noise {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-7%, 4%); }
  40%  { transform: translate(5%, -9%); }
  60%  { transform: translate(-3%, 8%); }
  80%  { transform: translate(8%, 3%); }
  100% { transform: translate(0, 0); }
}

.overlay {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%),
    repeating-linear-gradient(
      180deg,
      rgba(0, 0, 0, 0) 0,
      rgba(0, 0, 0, 0.3) 50%,
      rgba(0, 0, 0, 0) 100%
    );
  background-size: auto, auto 4px;
  /* Topmost layer: scanlines cover windows, toasts and effects too */
  z-index: 2147483647;
  animation: flicker 5s steps(1) infinite;
}

/* Switched off in the BIOS setup (head.js sets these before the first paint) */
:root.no-scanlines .overlay,
:root.no-drone .cyn {
  display: none;
}

/* A faint bright band rolling down the screen */
.overlay::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 25vh;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.03) 50%, transparent);
  transform: translateY(-25vh);
  animation: roll 9s linear infinite;
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  41% { opacity: 0.9; }
  42% { opacity: 1; }
  73% { opacity: 0.94; }
  74% { opacity: 1; }
}

@keyframes roll {
  to { transform: translateY(100vh); }
}

/* Lists and nav */
ul {
  list-style-type: none;
  text-align: center;
}

nav {
  width: 100%;
  max-width: 420px;
  margin-bottom: 1.5rem;
}

nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  justify-content: space-around;
  align-items: center;
}

nav button,
nav a {
  all: unset;
  color: var(--accent);
  cursor: pointer;
  position: relative;
  padding-bottom: 2px;
}

nav button::after,
nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  transition: width 0.2s ease;
}

nav button:hover::after,
nav a:hover::after,
nav button:focus-visible::after,
nav a:focus-visible::after {
  width: 100%;
}

h1 {
  color: var(--accent);
  font-size: clamp(28px, 7vw, 52px);
  letter-spacing: -4px;
  margin-bottom: 20px;
  text-align: center;
  min-height: 1.3em;
  white-space: nowrap;
}

h2 {
  font-size: 1.17em;
  margin-bottom: 10px;
  text-align: center;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: text-shadow 0.2s ease;
}

a[href]:hover {
  text-shadow: 0 0 8px var(--accent-glow-strong), 0 0 20px var(--accent-glow);
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

.dim {
  color: var(--dim);
}

.links li {
  margin: 2px 0;
}

.links .sep {
  color: var(--text);
}

p {
  margin: 20px 0;
}

.cursor {
  font: inherit;
  font-weight: 700;
  background: none;
  border: none;
  color: var(--accent);
  cursor: text;
  padding: 0;
  animation: 1s blink step-end infinite;
}

@keyframes blink {
  from, to { color: transparent; }
  50% { color: var(--accent); }
}

/* Projects */
.project-list {
  text-align: left;
}

.project {
  padding: 0.75rem 0;
  border-top: 1px dashed rgba(var(--accent-rgb), 0.25);
}

.project:first-child {
  border-top: none;
  padding-top: 0;
}

.project-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0 1rem;
}

.project-head strong {
  color: var(--accent);
}

.project .meta {
  color: var(--dim);
  font-size: 0.85em;
  text-shadow: none;
}

.project .meta .stars,
.project .meta .downloads {
  color: var(--text);
}

.lang::before {
  content: '';
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  margin-right: 0.35em;
  background: #b07219;
}

.win-body .project p {
  margin: 0.2rem 0 0;
  font-size: 0.95em;
  text-shadow: none;
}

.project-links {
  margin-top: 0.25rem;
  font-size: 0.9em;
  display: flex;
  gap: 1rem;
}

/* One line; only the Discord status shrinks when space runs out */
footer {
  margin-top: 2rem;
  max-width: 100%;
  font-size: 0.8rem;
  color: var(--text);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  white-space: nowrap;
}

footer > * {
  flex: none;
}

footer > [data-presence] {
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
}

/* Separators only between the items that are showing */
footer > :not([hidden]) ~ :not([hidden])::before {
  content: "|";
  color: var(--dim);
  margin-right: 0.75rem;
}

.presence-status {
  flex: none;
}

/* Room for at least a few letters of a long song, but never more than the text
   itself (script.js sets --text-w), or a short status leaves a gap after it */
.presence-text {
  min-width: min(4em, var(--text-w, 4em));
  margin-left: 0.4em;
  overflow: hidden;
  white-space: nowrap;
}

.presence-text > span {
  display: inline-block;
}

/* Spotify: a thin line under the song that fills up as it plays (script.js sets --track) */
footer > [data-end] .presence-text {
  padding-bottom: 3px;
  background:
    linear-gradient(var(--accent), var(--accent)) 0 100% / var(--track, 0%) 1px no-repeat,
    linear-gradient(var(--dim), var(--dim)) 0 100% / 100% 1px no-repeat;
  transition: background-size 1s linear;
}

/* Too long to fit (a long song name): scroll back and forth, car stereo style */
/* The left padding replaces the usual gap, so the text starts in the same spot */
.presence-text.marquee {
  margin-left: 0;
  mask-image: linear-gradient(90deg, transparent, #000 0.4em, #000 calc(100% - 0.75em), transparent);
}

.presence-text.marquee > span {
  padding: 0 0.75em 0 0.4em;
  animation: marquee var(--dur) ease-in-out infinite alternate;
}

@keyframes marquee {
  0%, 12%   { transform: translateX(0); }
  88%, 100% { transform: translateX(calc(-1 * var(--shift))); }
}

/* Reduced motion: cut it off instead */
.presence-text.clipped {
  text-overflow: ellipsis;
}

.presence-text.clipped > span {
  display: inline;
}

/* Discord status dot, in Discord's colours */
.dot {
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  margin-right: 0.4em;
  background: #80848e;
  vertical-align: 0.05em;
  flex: none;
}
.dot[data-status="online"] { background: #23a55a; box-shadow: 0 0 6px #23a55a; }
.dot[data-status="idle"]   { background: #f0b232; box-shadow: 0 0 6px #f0b232; }
.dot[data-status="dnd"]    { background: #f23f43; box-shadow: 0 0 6px #f23f43; }

.win-body [data-presence] {
  color: var(--dim);
  font-size: 0.85em;
}

/* Sound on/off, top right */
.sound-toggle {
  all: unset;
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 150;
  font-size: 0.85rem;
  color: var(--dim);
  cursor: pointer;
}

.sound-toggle:hover,
.sound-toggle:focus-visible {
  color: var(--accent);
}

/* Windows */
.window {
  position: fixed;
  width: min(480px, 94vw);
  /* script.js lowers --max-h to keep a window from covering the nav */
  max-height: var(--max-h, calc(100vh - 32px));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--accent);
  box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.35), 0 0 2px var(--accent);
  background: var(--bg-dark);
  animation: modal-in 0.15s ease-out;
}

.window.focused {
  box-shadow: 0 0 32px var(--accent-glow), 0 0 2px var(--accent);
}

.window.closing {
  animation: modal-out 0.12s ease-in forwards;
}

.window.term-window {
  width: min(680px, 94vw);
  resize: both;
  overflow: hidden;
  min-width: min(320px, 94vw);
  min-height: 160px;
}

/* Double-click a title bar to maximize */
.window.maximized {
  left: 0 !important;
  top: 0 !important;
  width: 100vw;
  height: 100vh;
  max-height: none;
  resize: none;
}

.window.wide {
  width: min(560px, 94vw);
}

/* In the page flow instead of floating (error pages) */
.window.static {
  position: relative;
  width: 100%;
  margin-top: 0.5rem;
  text-align: left;
  text-shadow: none;
}

.window.static .term {
  height: auto;
  min-height: 9em;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes modal-out {
  to { opacity: 0; transform: scale(0.97); }
}

.titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--accent);
  font-size: 14px;
  text-shadow: 0 0 8px var(--accent-glow);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.titlebar:active {
  cursor: grabbing;
}

.win-close {
  background: none;
  border: 1px solid transparent;
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  padding: 2px 6px;
  transition: border-color 0.15s ease, text-shadow 0.15s ease;
}

.win-close:hover,
.win-close:focus-visible {
  border-color: var(--accent);
  text-shadow: 0 0 8px var(--accent-glow-strong);
}

.win-body {
  padding: 20px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
  overflow: auto;
}

.win-body p {
  margin: 0 0 12px;
}

.copy {
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  font: inherit;
  font-size: 0.85em;
  margin-left: 0.25rem;
}

.copy:hover,
.copy:focus-visible {
  color: var(--accent);
}

.specs {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 1rem;
}

.specs dt {
  color: var(--accent);
  font-weight: 700;
}

/* Terminal */
.term {
  font-size: 14px;
  line-height: 1.5;
  height: min(380px, 60vh);
  overflow-y: auto;
  cursor: text;
  padding: 12px 14px;
  text-shadow: 0 0 6px rgba(var(--accent-hi-rgb), 0.18);
}

/* The terminal fills its window, so resizing or maximizing it grows the screen */
.term-window .win-body {
  padding: 0;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.term-window .term {
  flex: 1 1 auto;
  min-height: 0;
}

.term-out > div {
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 1.5em;
}

.term-out pre {
  font-family: inherit;
  white-space: pre;
  overflow-x: auto;
}

.term .prompt {
  color: var(--accent);
  white-space: nowrap;
}

.term-line {
  position: relative;
  display: flex;
  gap: 0.6em;
}

.term-line input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font: inherit;
  caret-color: transparent;
}

/* Block cursor over the character it's on; solid while typing, blinking when idle,
   hollow when the terminal isn't focused */
.term-caret {
  position: absolute;
  pointer-events: none;
  white-space: pre;
  background: var(--accent);
  color: var(--bg-dark);
  box-shadow: 0 0 8px var(--accent-glow);
  text-shadow: none;
  animation: caret-blink 1.06s steps(1) infinite;
}

.term-caret.typing {
  animation: none;
}

.term:not(.focused) .term-caret {
  background: transparent;
  color: inherit;
  box-shadow: none;
  outline: 1px solid var(--accent);
  outline-offset: -1px;
  animation: none;
}

@keyframes caret-blink {
  50% { opacity: 0; }
}

/* Measures one character, for placing the cursor */
.term-probe {
  position: absolute;
  visibility: hidden;
  white-space: pre;
}

/* Hidden but still focusable while a full-screen program (top) runs */
.term-line.fg-hidden {
  position: absolute;
  height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

.term-out pre.top-screen {
  font-size: 12px;
  line-height: 1.35;
}

.t-accent { color: var(--accent); }
.t-dim    { color: var(--dim); }
.t-err    { color: #ff5f56; }
.t-ok     { color: rgb(var(--accent-hi-rgb)); }
.t-bold   { font-weight: 700; }
.t-hl     { background: var(--accent); color: var(--bg-dark); }

/* Toasts */
#toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10001;
  pointer-events: none;
}

.toast {
  background: var(--bg-dark);
  border: 1px solid var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
  padding: 8px 14px;
  font-size: 13px;
  max-width: min(320px, calc(100vw - 32px));
  animation: toast-in 0.25s ease-out, toast-out 0.3s ease-in 3.7s forwards;
}

.toast strong {
  color: var(--accent);
  display: block;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateX(20px); }
}

/* Easter egg effects */
.fx-layer {
  position: fixed;
  inset: 0;
  z-index: 10000;
}

.screensaver {
  background: #000;
  cursor: none;
}

.screensaver span {
  position: absolute;
  top: 0;
  left: 0;
  font-size: clamp(20px, 4vw, 36px);
  font-weight: 700;
  white-space: nowrap;
  text-shadow: 0 0 12px currentColor;
}

/* Boot screens: kernel panic, BIOS POST, boot menu, kernel log, standby */
.boot {
  display: flex;
  flex-direction: column;
  background: #000;
  color: #aaa;
  font-size: clamp(10px, 1.7vw, 15px);
  line-height: 1.4;
  padding: 24px 28px;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.2);
  user-select: none;
}

.boot.power-on {
  animation: crt-on 0.7s ease-out both;
}

.boot.setup {
  background: #0000aa;
  color: #fff;
  padding: 0;
  text-shadow: none;
}

.boot.setup .boot-skip {
  display: none;
}

/* BIOS setup utility: blue and grey, like the ones that came with every board */
.bios {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  font-size: clamp(11px, 1.55vw, 15px);
  line-height: 1.55;
}

.bios-title,
.bios-foot {
  text-align: center;
  padding: 0.35em 1em;
  color: #fff;
}

.bios-tabs {
  display: flex;
  flex-wrap: wrap;
  padding: 0 1em;
}

.boot .bios-tabs button {
  padding: 0 0.9em;
  color: #fff;
}

.boot .bios-tabs button.active {
  background: #aaa;
  color: #0000aa;
}

.bios-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(12em, 32%);
  margin: 0 1em;
  background: #aaa;
  color: #0000aa;
}

.bios-items {
  padding: 1em 1.5em;
  overflow: auto;
}

.bios-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.5em;
  min-height: 1.55em;
  white-space: nowrap;
}

.bios-item.info {
  color: #000;
}

.bios-item.selectable {
  cursor: pointer;
}

.bios-item.selected {
  color: #fff;
}

.bios-item > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.bios-help {
  display: flex;
  flex-direction: column;
  gap: 0.8em;
  padding: 1em;
  border-left: 2px solid #0000aa;
  overflow: auto;
}

.bios-help-title {
  text-align: center;
}

.bios-help p {
  flex: 1;
  margin: 0;
  color: #000;
  white-space: normal;
}

.bios-keys {
  border-top: 2px solid #0000aa;
  padding-top: 0.6em;
  white-space: pre;
}

.bios-dialog {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.bios-box {
  min-width: min(22em, 90%);
  max-width: 90%;
  background: #0000aa;
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0.6em 0.6em 0 #000;
}

.bios-box-title {
  background: #fff;
  color: #0000aa;
  text-align: center;
  padding: 0 1em;
}

.bios-box-body {
  padding: 0.8em 1.5em;
  text-align: center;
  white-space: pre-wrap;
}

.bios-box-body:empty {
  display: none;
}

.bios-box-choices {
  display: flex;
  justify-content: center;
  gap: 2em;
  padding: 0.6em 1.5em 0.8em;
}

.bios-box-choices.vertical {
  flex-direction: column;
  gap: 0;
  align-items: stretch;
}

.boot .bios-box-choices button {
  padding: 0 0.5em;
}

.boot .bios-box-choices button.selected {
  background: #fff;
  color: #0000aa;
}

.boot.glitching {
  animation: glitch 0.25s steps(2) infinite;
}

.boot-out {
  flex: 1;
  overflow: hidden;
}

.boot-out > div,
.boot-bottom {
  white-space: pre;
  min-height: 1.4em;
}

.boot-logo {
  position: absolute;
  top: 24px;
  right: 28px;
  white-space: pre;
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent-glow);
}

.boot button {
  all: unset;
  cursor: pointer;
}

.boot .boot-key {
  color: #fff;
  font-weight: 700;
}

.boot .boot-skip {
  position: absolute;
  right: 16px;
  bottom: 12px;
  color: #555;
}

.boot .boot-skip:hover {
  color: #aaa;
}

.boot-entry {
  cursor: pointer;
}

.standby {
  display: grid;
  place-items: center;
}

.standby button {
  color: #444;
  animation: fade-in 0.6s 1.2s both;
}

.b-white  { color: #fff; font-weight: 700; }
.b-yellow { color: #ffff55; }
.b-ok     { color: #55ff55; }
.b-err    { color: #ff5555; }
.b-dim    { color: #666; }
.b-hl     { background: #aaa; color: #000; text-shadow: none; }

.falling {
  transition: transform 1.4s cubic-bezier(0.5, 0, 0.9, 0.4), opacity 1.4s ease-in;
}

body.glitch .container,
body.glitch .cyn {
  animation: glitch 0.25s steps(2) infinite;
}

body.glitch .cyn {
  opacity: 0.45;
}

@keyframes glitch {
  0%   { transform: translate(0); clip-path: inset(0 0 0 0); filter: none; }
  20%  { transform: translate(-6px, 2px); clip-path: inset(10% 0 60% 0); filter: hue-rotate(90deg); }
  40%  { transform: translate(5px, -3px); clip-path: inset(50% 0 20% 0); }
  60%  { transform: translate(-3px, 1px); clip-path: inset(30% 0 40% 0); filter: invert(1); }
  80%  { transform: translate(4px, 0); clip-path: inset(0 0 80% 0); }
  100% { transform: translate(0); clip-path: inset(0 0 0 0); filter: none; }
}

.solver {
  display: grid;
  place-items: center;
  pointer-events: none;
  color: #ffcc00;
  font-size: clamp(22px, 5vw, 44px);
  font-weight: 700;
  letter-spacing: 0.2em;
  text-shadow: 0 0 20px #ffcc00;
}

.barrel-roll {
  animation: barrel 1.2s ease-in-out;
}

@keyframes barrel {
  to { transform: rotate(360deg); }
}

/* Recovery menu: a whiptail box on the console, like Ubuntu's */
.whip {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
}

.whip-box {
  max-width: 100%;
  padding: 0.4em 1.4em 0.9em;
  background: #aaa;
  color: #000;
  text-shadow: none;
  border: 2px solid #fff;
  border-right-color: #555;
  border-bottom-color: #555;
}

.whip-title {
  width: fit-content;
  margin: -1.05em auto 0.7em;
  padding: 0 0.6em;
  background: #aaa;
  color: #000;
}

.whip-text {
  max-width: 34em;
  margin: 0.4em 0 0.8em;
  white-space: pre-wrap;
}

.whip-list {
  padding: 0.3em 0;
}

.whip-item {
  display: flex;
  gap: 2em;
  padding: 0 0.6em;
  white-space: pre;
  cursor: pointer;
}

.whip-tag {
  flex: none;
  width: 14ch;
}

.whip-item.selected,
.boot .whip-buttons button.selected {
  background: #a00;
  color: #fff;
}

.whip-buttons {
  display: flex;
  justify-content: center;
  gap: 3em;
  margin-top: 0.8em;
}

.boot .whip-buttons button {
  padding: 0 0.3em;
}

/* The recovery root shell: the normal terminal, full screen, plain console colours */
.recovery-console {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #000;
  user-select: text;
}

.recovery-console .term {
  flex: 1;
  height: auto;
  font-size: inherit;
  text-shadow: none;
}

.recovery-console .term .prompt {
  color: #fff;
  font-weight: 700;
}

@media (max-width: 480px) {
  body { font-size: 15px; }
  /* Longer headings (egg.html) wrap instead of running off a small phone */
  h1 { letter-spacing: -2px; white-space: normal; text-wrap: balance; }
  /* Name above the stats on every project, not just the ones with short names */
  .project-head { flex-direction: column; }
  .window:not(.static) { left: 3vw !important; width: 94vw; }
  footer { flex-direction: column; align-items: center; gap: 0.2rem; }
  footer > :not([hidden]) ~ :not([hidden])::before { content: none; }
  footer > [data-presence] { min-width: 0; max-width: 100%; }
}

@media (max-width: 640px) {
  .boot { padding: 16px; }
  .boot-logo { display: none; }
  .bios-main { grid-template-columns: 1fr; grid-template-rows: 1fr auto; margin: 0 0.5em; }
  .bios-help { border-left: 0; border-top: 2px solid #0000aa; }
  .bios-keys { display: none; }
}

/* Footer hint: the ~ key on a keyboard, the heading's cursor on a touch screen */
.hint-tap { display: none; }

@media (pointer: coarse) {
  .hint-key { display: none; }
  .hint-tap { display: inline; }
  /* iOS zooms the page into any text field under 16px, and stays zoomed */
  .term { font-size: 16px; }
}

/* Big screens: the windows grow with the page text */
@media (min-width: 1800px) and (min-height: 900px) {
  body { font-size: 21px; }
  .container { max-width: 840px; }
  h1 { font-size: 64px; }
  footer { font-size: 0.8em; }
  .sound-toggle { font-size: 1rem; }
  .window { width: min(600px, 94vw); }
  .window.wide { width: min(700px, 94vw); }
  .window.term-window { width: min(850px, 94vw); }
  .titlebar, .win-close { font-size: 17px; }
  .win-body { font-size: 18px; }
  .term { font-size: 17px; height: min(470px, 60vh); }
  .term-out pre.top-screen { font-size: 15px; }
  .toast { font-size: 16px; max-width: min(400px, calc(100vw - 32px)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .cursor { animation: none; }
  html { scroll-behavior: auto; }
}
