/* PrintBuddy Streams viewer. Dark camera-wall theme with game-HUD accents. */

@property --spin {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

:root {
  color-scheme: dark;
  --bg: #07090c;
  --bg-2: #0c1015;
  --panel: rgb(14 19 25 / 0.78);
  --line: #1c242d;
  --line-2: #2a3440;
  --text: #eaf0f4;
  --muted: #8a97a4;
  --dim: #5b6874;
  --printing: #19e38a;
  --cyan: #3ad6ff;
  --paused: #ffb347;
  --error: #ff5d6c;
  --finished: #b78cff;
  --idle: #7b8a99;
  --offline: #ff5d6c;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.5, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgb(25 227 138 / 0.07), transparent 60%),
    radial-gradient(900px 500px at 110% 0%, rgb(58 214 255 / 0.06), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
html[data-layout="fit"] body,
html[data-layout="spotlight"] body { overflow-y: hidden; }

svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------ HUD bar ---- */

.hud {
  position: relative;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  background: linear-gradient(to bottom, rgb(7 9 12 / 0.95), rgb(7 9 12 / 0.75));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  transition: transform 0.35s var(--ease-out), opacity 0.35s;
}

.hud-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hud h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Logo mark: three stacked "layers" that keep building. */
.mark { display: grid; gap: 2px; width: 20px; }
.mark i {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: var(--printing);
  transform-origin: left;
  animation: layer-build 2.4s var(--ease-out) infinite;
}
.mark i:nth-child(1) { animation-delay: 0.8s; width: 70%; margin-left: 15%; background: var(--finished); }
.mark i:nth-child(2) { animation-delay: 0.4s; width: 85%; margin-left: 7.5%; background: var(--cyan); }
@keyframes layer-build {
  0% { transform: scaleX(0); opacity: 0.3; }
  35%, 80% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0.3; }
}

.hud-stats {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.hud-stats::-webkit-scrollbar { display: none; }

.stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 0.02);
  white-space: nowrap;
}
.stat .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.stat .v { font: 600 14px/1 var(--mono); font-variant-numeric: tabular-nums; }
.stat[data-stat="printing"] .v { color: var(--printing); }
.stat[data-stat="next"] .v { color: var(--cyan); }
.stat[data-level="good"] .v { color: var(--printing); }
.stat[data-level="warn"] .v { color: var(--paused); }
.stat[data-level="bad"] .v { color: var(--error); }
.stat.bump .v { animation: bump 0.5s var(--ease-spring); }
@keyframes bump { 40% { transform: scale(1.25); } }

.hud-controls { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.modes {
  display: flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgb(255 255 255 / 0.02);
}
.modes button, .icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: 600 12px/1 system-ui, sans-serif;
  cursor: pointer;
  text-transform: capitalize;
  transition: background 0.15s, color 0.15s;
}
.modes button svg, .icon-btn svg { font-size: 15px; flex: none; }
.modes button:hover, .icon-btn:hover { color: var(--text); background: rgb(255 255 255 / 0.05); }
.modes button[aria-pressed="true"] { color: #04130c; background: var(--printing); }
.modes button.resolved { color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.icon-btn { padding: 0 8px; border: 1px solid var(--line); }
button:focus-visible, a:focus-visible, .tile:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.manage {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 8px;
}
.manage:hover { color: var(--text); }

.fleet-xp {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: transparent;
}
.fleet-xp i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--printing), var(--cyan), var(--finished));
  box-shadow: 0 0 12px rgb(58 214 255 / 0.6);
  transition: width 1.2s var(--ease-out);
}

/* Narrow screens: icon-only layout buttons, stats on their own row. */
@media (max-width: 860px) {
  .modes button span { display: none; }
  .hud-stats { order: 3; flex-basis: 100%; }
}
@media (max-width: 560px) {
  .hud-controls { flex-basis: 100%; margin-left: 0; }
  .manage { margin-left: auto; }
}
@media (max-width: 420px) {
  .stat[data-stat="layers"] { display: none; }
  .manage { padding: 6px 2px; }
}

/* Kiosk: the HUD floats over the wall and hides when the pointer rests. */
html.kiosk .hud {
  position: fixed;
  inset: 0 0 auto 0;
}
html.kiosk.idle .hud { transform: translateY(-100%); opacity: 0; }
html.kiosk.idle, html.kiosk.idle * { cursor: none !important; }
html.kiosk main { padding-top: 12px; }

/* -------------------------------------------------------------- stage ---- */

main {
  --stage-pad: 16px;
  padding: var(--stage-pad) max(var(--stage-pad), env(safe-area-inset-right)) var(--stage-pad) max(var(--stage-pad), env(safe-area-inset-left));
}
@media (min-width: 1400px) { main { --stage-pad: 22px; } }
@media (max-width: 600px) { main { --stage-pad: 8px; } }

.stage {
  position: relative;
  width: 100%;
  transition: height 0.5s var(--ease-out);
}

/* ------------------------------------------------------------- tiles ---- */

.tile {
  --accent: var(--idle);
  position: absolute;
  top: 0;
  left: 0;
  container: tile / size;
  border-radius: var(--radius);
  background: #000;
  overflow: hidden;
  cursor: pointer;
  isolation: isolate;
  box-shadow: 0 0 0 1px var(--line), 0 18px 40px -24px rgb(0 0 0 / 0.9);
  transition:
    transform 0.6s var(--ease-out),
    width 0.6s var(--ease-out),
    height 0.6s var(--ease-out),
    box-shadow 0.3s;
  will-change: transform;
}
.tile.no-anim, html.resizing .tile, html.resizing .stage { transition: none !important; }
.tile.enter { animation: tile-in 0.6s var(--ease-spring) both; }
.tile.leave { animation: tile-out 0.35s ease-in forwards; pointer-events: none; }
@keyframes tile-in { from { opacity: 0; scale: 0.85; filter: blur(6px); } }
@keyframes tile-out { to { opacity: 0; scale: 0.9; filter: blur(4px); } }

.tile[data-state="printing"] { --accent: var(--printing); }
.tile[data-state="paused"] { --accent: var(--paused); }
.tile[data-state="error"] { --accent: var(--error); }
.tile[data-state="finished"] { --accent: var(--finished); }
.tile[data-state="offline"] { --accent: var(--offline); }

.tile:hover { box-shadow: 0 0 0 1px var(--line-2), 0 18px 40px -20px rgb(0 0 0 / 0.9); }

/* Animated border for printers that are working. */
.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  padding: 1.5px;
  background: conic-gradient(from var(--spin), transparent 0 60%, var(--accent) 80%, var(--cyan) 90%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}
.tile[data-state="printing"]::before { opacity: 1; animation: spin 4s linear infinite; }
.tile[data-state="finished"]::before {
  opacity: 1;
  background: conic-gradient(from var(--spin), var(--finished), var(--cyan), var(--printing), var(--paused), var(--finished));
  animation: spin 6s linear infinite;
}
@keyframes spin { to { --spin: 360deg; } }

.tile.featured { box-shadow: 0 0 0 1px var(--line-2), 0 30px 80px -30px color-mix(in srgb, var(--accent) 45%, transparent); }
.tile.shake { animation: shake 0.5s; }
@keyframes shake {
  20%, 60% { translate: -6px 0; }
  40%, 80% { translate: 6px 0; }
}

.screen { position: absolute; inset: 0; background: #000; }
.screen img {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
  opacity: 0;
  transition: opacity 0.5s;
}
.tile[data-signal="live"] .screen img { opacity: 1; }

/* Connecting: a scan beam over a dark screen. */
.fx { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.4s; }
.fx-scan {
  background:
    linear-gradient(to bottom, transparent, rgb(58 214 255 / 0.18) 48%, rgb(58 214 255 / 0.5) 50%, transparent 52%) 0 0 / 100% 220% no-repeat,
    repeating-linear-gradient(to bottom, rgb(255 255 255 / 0.025) 0 1px, transparent 1px 4px);
}
.tile[data-signal="connecting"] .fx-scan { opacity: 1; animation: scan 1.8s linear infinite; }
@keyframes scan { from { background-position: 0 120%, 0 0; } to { background-position: 0 -120%, 0 0; } }

/* Signal lost: TV static. */
.fx-static {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.6 0 0 0 0 0.65 0 0 0 0 0.7 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px;
}
.tile[data-signal="lost"] .fx-static { opacity: 0.55; animation: static 0.25s steps(4) infinite; }
@keyframes static {
  0% { background-position: 0 0; }
  25% { background-position: -40px 30px; }
  50% { background-position: 50px -20px; }
  75% { background-position: -20px -50px; }
}

.signal-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 4px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.signal-msg b { font: 700 13px/1 var(--mono); letter-spacing: 0.18em; text-transform: uppercase; }
.signal-msg span { font: 12px/1.3 var(--mono); color: var(--muted); }
.tile[data-signal="connecting"] .signal-msg { opacity: 1; }
.tile[data-signal="connecting"] .signal-msg b { color: var(--cyan); animation: blink 1.1s steps(2) infinite; }
.tile[data-signal="lost"] .signal-msg { opacity: 1; }
.tile[data-signal="lost"] .signal-msg b { color: var(--error); text-shadow: 2px 0 var(--cyan), -2px 0 var(--error); }
@keyframes blink { 50% { opacity: 0.35; } }

/* Top HUD row */
.hud-top {
  position: absolute;
  z-index: 2;
  inset: 0 0 auto 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px;
  background: linear-gradient(to bottom, rgb(0 0 0 / 0.55), transparent);
  pointer-events: none;
}
.hud-top .spacer { flex: 1; }
.live, .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  background: rgb(0 0 0 / 0.55);
  backdrop-filter: blur(6px);
  font: 700 10.5px/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}
.live { display: none; }
.live::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--error);
  box-shadow: 0 0 0 0 rgb(255 93 108 / 0.7);
  animation: pulse 1.6s infinite;
}
.tile[data-signal="live"] .live { display: inline-flex; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgb(255 93 108 / 0); } 100% { box-shadow: 0 0 0 0 rgb(255 93 108 / 0); } }

.chip { color: var(--accent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); }
.tile[data-state="printing"] .chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }

.pinned { display: none; color: var(--paused); font-size: 15px; }
.pinned svg { fill: currentColor; stroke: none; }
.tile.is-pinned .pinned { display: inline-flex; }

.fs {
  pointer-events: auto;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: rgb(0 0 0 / 0.55);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}
.tile:hover .fs, .tile:focus-within .fs { opacity: 1; }
@media (hover: none) { .fs { opacity: 0.8; } }

/* Bottom HUD */
.hud-bottom {
  position: absolute;
  z-index: 2;
  inset: auto 0 0 0;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 28px 14px 12px;
  background: linear-gradient(to top, rgb(0 0 0 / 0.85), rgb(0 0 0 / 0.5) 60%, transparent);
  pointer-events: none;
}
.info { flex: 1; min-width: 0; display: grid; gap: 4px; }
.title-row { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 8px rgb(0 0 0 / 0.8); }
.lvl {
  flex: none;
  margin-left: auto;
  font: 700 11px/1 var(--mono);
  color: var(--cyan);
  letter-spacing: 0.06em;
}
.quest { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile[data-state="printing"] .quest, .tile[data-state="paused"] .quest { color: #c9d3db; }

.xp {
  position: relative;
  height: 6px;
  margin-top: 4px;
  border-radius: 99px;
  background: rgb(255 255 255 / 0.1);
  overflow: hidden;
}
/* Segment marks every 10%, like a game XP bar. */
.xp::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgb(0 0 0 / 0.55) calc(10% - 1px) 10%);
}
.xp i {
  position: relative;
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 60%, #000), var(--accent));
  box-shadow: 0 0 10px var(--accent);
  transition: width 1s var(--ease-out);
  overflow: hidden;
}
.xp i::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgb(255 255 255 / 0.55) 50%, transparent 80%) -100% 0 / 50% 100% no-repeat;
  animation: shimmer 2.4s ease-in-out infinite;
}
.tile:not([data-state="printing"]) .xp i::after { animation: none; }
@keyframes shimmer { to { background-position: 200% 0; } }
.tile:not([data-state="printing"]):not([data-state="paused"]):not([data-state="finished"]) .xp { display: none; }

.stats { display: flex; gap: 12px; font: 600 12px/1 var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); }
.stats .pct { color: var(--accent); }
.stats .eta { color: var(--text); }
.stats span:empty { display: none; }

.ring { position: relative; flex: none; width: 46px; height: 46px; display: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { stroke-width: 3.5; fill: none; }
.ring .track { stroke: rgb(255 255 255 / 0.12); }
.ring .fill {
  stroke: var(--accent);
  stroke-dasharray: 106.8;
  stroke-dashoffset: 106.8;
  filter: drop-shadow(0 0 4px var(--accent));
  transition: stroke-dashoffset 1s var(--ease-out);
}
.ring-pct { position: absolute; inset: 0; display: grid; place-items: center; font: 700 12px/1 var(--mono); }

/* Finished: a burst of light that plays once. */
.burst {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: radial-gradient(circle at 50% 55%, color-mix(in srgb, var(--accent) 55%, transparent), transparent 60%);
  opacity: 0;
}
.burst.go { animation: burst 1.4s var(--ease-out); }
@keyframes burst { 0% { opacity: 0; scale: 0.6; } 20% { opacity: 1; } 100% { opacity: 0; scale: 1.6; } }

.tile[data-state="offline"] .screen img { filter: grayscale(1) brightness(0.5); }
.tile[data-state="idle"] .screen img { filter: saturate(0.75); }

/* ---- Tile density, by the tile's own size (container queries) ---- */

/* Medium and up: progress ring for active printers. */
@container tile (min-width: 360px) and (min-height: 200px) {
  .tile[data-state="printing"] .ring,
  .tile[data-state="paused"] .ring,
  .tile[data-state="finished"] .ring { display: block; }
}

/* Large: a full stat panel. */
@container tile (min-width: 620px) and (min-height: 340px) {
  .hud-top { padding: 14px; }
  .live, .chip { height: 26px; font-size: 11.5px; padding: 0 10px; }
  .hud-bottom { padding: 60px 22px 20px; gap: 18px; }
  .name { font-size: 20px; }
  .lvl { font-size: 13px; }
  .quest { font-size: 14px; }
  .xp { height: 9px; }
  .stats { font-size: 14px; gap: 18px; }
  .ring { width: 74px; height: 74px; }
  .ring-pct { font-size: 18px; }
}

/* Huge (spotlight on a big screen): the HUD goes cinematic. */
@container tile (min-width: 1100px) and (min-height: 600px) {
  .hud-bottom { padding: 90px 32px 28px; }
  .name { font-size: 28px; }
  .quest { font-size: 16px; }
  .stats { font-size: 17px; }
  .ring { width: 96px; height: 96px; }
  .ring-pct { font-size: 24px; }
}

/* Small: one line of text, no stats. */
@container tile (max-width: 300px) {
  .hud-top { padding: 6px; }
  .live { font-size: 0; padding: 0 6px; gap: 0; }
  .chip { height: 20px; font-size: 9.5px; padding: 0 6px; }
  .hud-bottom { padding: 18px 8px 7px; }
  .name { font-size: 12.5px; }
  .quest, .stats .done { display: none; }
  .lvl { font-size: 10px; }
  .stats { font-size: 11px; gap: 8px; }
  .xp { height: 4px; margin-top: 2px; }
}

/* Short and wide tiles, like a bottom rail. */
@container tile (max-height: 150px) {
  .hud-top { padding: 6px; }
  .hud-bottom { padding: 14px 8px 6px; }
  .quest, .stats .done, .lvl { display: none; }
  .name { font-size: 12.5px; }
}

/* Fullscreen single stream. */
.tile:fullscreen {
  transform: none !important;
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0;
  cursor: default;
}
.tile.sideways:fullscreen .screen img { width: 100vh !important; height: 100vw !important; }

/* ------------------------------------------------------- empty state ---- */

.empty {
  position: relative;
  height: calc(100dvh - var(--hud-h, 70px) - 2 * var(--stage-pad));
  min-height: 420px;
  border-radius: calc(var(--radius) + 4px);
  overflow: hidden;
  border: 1px solid var(--line);
  background: radial-gradient(ellipse at 50% 40%, #0e1720, #05070a 70%);
}
html.kiosk .empty { height: calc(100dvh - 2 * var(--stage-pad)); }
.empty canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.empty::after {
  /* CRT scanlines and vignette */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgb(255 255 255 / 0.018) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgb(0 0 0 / 0.6));
}

.empty-sim {
  position: absolute;
  top: 14px;
  left: 16px;
  z-index: 1;
  font: 11px/1 var(--mono);
  color: var(--dim);
  letter-spacing: 0.04em;
}

.empty-copy {
  position: absolute;
  z-index: 1;
  inset: auto 0 0 0;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 24px 20px clamp(24px, 6vh, 56px);
  text-align: center;
  background: linear-gradient(to top, rgb(5 7 10 / 0.95) 30%, transparent);
}
.kicker { margin: 0; font: 600 12px/1 var(--mono); color: var(--cyan); letter-spacing: 0.2em; text-transform: uppercase; }
.empty[data-kind="error"] .kicker { color: var(--error); }

.glitch {
  position: relative;
  margin: 0;
  font: 800 clamp(26px, 5.4vw, 64px)/1 var(--mono);
  letter-spacing: 0.04em;
  text-shadow: 0 0 24px rgb(58 214 255 / 0.35);
}
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.glitch::before { color: var(--cyan); animation: glitch-a 3.2s infinite steps(1); clip-path: inset(0 0 60% 0); }
.glitch::after { color: var(--error); animation: glitch-b 2.7s infinite steps(1); clip-path: inset(55% 0 0 0); }
@keyframes glitch-a {
  0%, 88%, 100% { transform: none; opacity: 0; }
  89% { transform: translate(-3px, -1px); opacity: 0.9; }
  92% { transform: translate(3px, 1px); opacity: 0.9; }
  95% { transform: translate(-1px, 0); opacity: 0.6; }
}
@keyframes glitch-b {
  0%, 84%, 100% { transform: none; opacity: 0; }
  85% { transform: translate(3px, 1px); opacity: 0.9; }
  89% { transform: translate(-3px, 0); opacity: 0.8; }
}

.sub { margin: 0; max-width: 52ch; color: var(--muted); font-size: clamp(13px, 1.6vw, 16px); }

.start {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid rgb(25 227 138 / 0.5);
  background: rgb(25 227 138 / 0.08);
  color: var(--printing);
  font: 700 13px/1 var(--mono);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-decoration: none;
  animation: press-start 1.2s steps(2) infinite;
  transition: background 0.2s, transform 0.2s var(--ease-spring);
}
.start:hover { background: rgb(25 227 138 / 0.16); transform: translateY(-2px); animation-play-state: paused; }
@keyframes press-start { 50% { opacity: 0.45; } }

.tip { margin: 4px 0 0; color: var(--dim); font: 12px/1.3 var(--mono); min-height: 1.3em; }

/* ------------------------------------------------------------ toasts ---- */

.toasts {
  position: fixed;
  z-index: 30;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  --c: var(--cyan);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgb(12 16 21 / 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid color-mix(in srgb, var(--c) 40%, var(--line));
  box-shadow: 0 16px 40px -16px rgb(0 0 0 / 0.9), 0 0 24px -8px color-mix(in srgb, var(--c) 50%, transparent);
  animation: toast-in 0.5s var(--ease-spring) both;
}
.toast.out { animation: toast-out 0.35s ease-in forwards; }
.toast-finish { --c: var(--finished); }
.toast-milestone { --c: var(--paused); }
.toast-start, .toast-resume, .toast-online { --c: var(--printing); }
.toast-error, .toast-offline { --c: var(--error); }
.toast-icon { font-size: 22px; flex: none; }
.toast b { display: block; font-size: 13.5px; color: var(--c); }
.toast span { font-size: 13px; color: var(--muted); }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px) scale(0.95); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(40px); } }

.confetti { position: fixed; inset: 0; z-index: 25; width: 100vw; height: 100vh; pointer-events: none; }

/* -------------------------------------------------------------- help ---- */

.help {
  max-width: 440px;
  width: calc(100vw - 32px);
  padding: 22px 24px;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  background: #0d1217;
  color: var(--text);
}
.help::backdrop { background: rgb(0 0 0 / 0.6); backdrop-filter: blur(3px); }
.help h2 { margin: 0 0 14px; font: 700 13px/1 var(--mono); letter-spacing: 0.18em; text-transform: uppercase; color: var(--cyan); }
.help dl { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0; font-size: 14px; }
.help dt { color: var(--text); white-space: nowrap; }
.help dd { margin: 0; color: var(--muted); }
.help kbd, .help code {
  font: 600 12px/1 var(--mono);
  padding: 3px 6px;
  border-radius: 5px;
  border: 1px solid var(--line-2);
  background: rgb(255 255 255 / 0.04);
}
.help-note { margin: 16px 0 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.help button {
  margin-top: 16px;
  padding: 9px 16px;
  border: 0;
  border-radius: 9px;
  background: var(--printing);
  color: #04130c;
  font-weight: 700;
  cursor: pointer;
}

/* -------------------------------------------------- reduced motion ---- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
