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

:root {
  --font-sans: 'Outfit', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
  /* BUG FIX: JetBrains Mono has patchy coverage of box-drawing/block-element
     glyphs (U+2500–259F), which is exactly what the ASCII art banners are
     built from. When a font is missing a glyph, the browser silently falls
     back to a different font mid-line — and that fallback font almost never
     shares the exact same character-cell width, so every "█"/"╗"/"═" lands
     slightly off from the regular characters around it. At ASCII-art scale
     that's enough to visibly melt the letters together. This stack sticks to
     fonts with solid, consistent box-drawing coverage across platforms.  */
  --font-ascii: 'Cascadia Mono', 'Cascadia Code', Consolas, Menlo, Monaco, 'DejaVu Sans Mono', 'Liberation Mono', 'Courier New', monospace;
  --radius: 14px;
  --radius-sm: 8px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --topbar-h: 64px;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text-primary);
  background: var(--bg-base);
}

.hidden { display: none !important; }

#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

#stars-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.sun {
  position: absolute;
  top: 9%;
  right: 10%;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fffdf0, #ffd76a 42%, #ffab3d 72%, rgba(255, 171, 61, 0) 100%);
  box-shadow: 0 0 70px 22px rgba(255, 200, 110, 0.45), 0 0 140px 50px rgba(255, 180, 90, 0.16);
  opacity: 0;
  transition: opacity 0.8s ease;
  animation: sunPulse 6s ease-in-out infinite;
}

/* Soft radiating rays behind the disc — a ring of conic segments, masked
   down to an annulus so it reads as rays rather than a solid pinwheel,
   rotating slowly for a little life without being distracting. */
.sun::before {
  content: '';
  position: absolute;
  inset: -55px;
  border-radius: 50%;
  background: repeating-conic-gradient(
    from 0deg,
    rgba(255, 210, 130, 0.4) 0deg 4deg,
    transparent 4deg 18deg
  );
  -webkit-mask-image: radial-gradient(circle, transparent 58%, black 63%, black 78%, transparent 85%);
  mask-image: radial-gradient(circle, transparent 58%, black 63%, black 78%, transparent 85%);
  animation: sunRotate 100s linear infinite;
  z-index: -1;
}

@keyframes sunPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.035); }
}

@keyframes sunRotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .sun, .sun::before { animation: none; }
}

@media (max-width: 640px) {
  .sun {
    width: 90px;
    height: 90px;
    top: 6%;
    right: 6%;
  }
  .sun::before {
    inset: -38px;
  }
}

/* Ground/horizon — an oversized flattened ellipse mostly parked below the
   viewport, so only its top arc peeks up as a gentle horizon curve across
   the full width. Cheap, responsive, no image assets. Present in both day
   and night (colors come from theme variables); hidden in retro. */
.ground {
  position: absolute;
  left: 50%;
  bottom: -30vh;
  width: 160vw;
  height: 42vh;
  min-height: 140px;
  border-radius: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, var(--ground-top, #0c0c1c), var(--ground-bottom, #030308));
  pointer-events: none;
}

.tree {
  position: absolute;
  left: 7%;
  bottom: 9vh;
  width: 70px;
  height: 110px;
  pointer-events: none;
}

.tree-trunk {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 9px;
  height: 42px;
  transform: translateX(-50%);
  background: var(--tree-trunk, #0a0a10);
  border-radius: 2px;
}

/* Three overlapping circles (one real, two via box-shadow) reads as a
   fuller, more natural canopy than a single perfect circle would. */
.tree-canopy {
  position: absolute;
  bottom: 34px;
  left: 50%;
  width: 56px;
  height: 56px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--tree-canopy, #0a1a12);
  box-shadow:
    -17px 9px 0 -7px var(--tree-canopy, #0a1a12),
     17px 9px 0 -7px var(--tree-canopy, #0a1a12);
}

@media (max-width: 640px) {
  .tree { display: none; }
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* Boot Screen */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #050510;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.boot-screen.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-content {
  width: min(480px, 90vw);
  text-align: center;
}

.boot-logo {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, #a78bfa, #60a5fa, #34d399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 2rem;
}

.boot-bar {
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.boot-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #818cf8, #38bdf8);
  border-radius: 99px;
  transition: width 0.3s ease;
}

.boot-log {
  list-style: none;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: rgba(255,255,255,0.45);
  max-height: 160px;
  overflow: hidden;
}

.boot-log li {
  padding: 0.15rem 0;
  opacity: 0;
  animation: bootLineIn 0.3s ease forwards;
}

@keyframes bootLineIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* App Layout */
.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  border-radius: 0;
  border-top: none;
  border-left: none;
  border-right: none;
}

.topbar-left {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.logo {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  user-select: none;
  -webkit-user-select: none;
}

.version {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  opacity: 0.5;
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--glass-border);
  border-radius: 4px;
  cursor: default;
  user-select: none;
}

.topbar-nav {
  display: flex;
  gap: 0.35rem;
}

.nav-btn {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.45rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.nav-btn:hover {
  color: var(--text-primary);
  background: var(--hover-bg);
}

.nav-btn.active {
  color: var(--accent);
  background: var(--accent-dim);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.clock {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  min-width: 5.5rem;
  text-align: right;
}

.icon-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--hover-bg);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.icon-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* Emoji glyphs render as pre-colored bitmap/vector fonts, so CSS `color`
   can't tint them — a distinct background tint per button is the only way
   to make the topbar read as differentiated controls at a glance instead
   of a row of identical grey squares. Skipped in retro themes, which
   intentionally keep one uniform flat button face as part of their own
   look (see [data-theme^="retro"] rules elsewhere in this file). */
html:not([data-theme^="retro"]) #install-toggle      { background: rgba(16,185,129,.16); border-color: rgba(16,185,129,.4); }
html:not([data-theme^="retro"]) #sound-toggle         { background: rgba(59,130,246,.16); border-color: rgba(59,130,246,.4); }
html:not([data-theme^="retro"]) #music-toggle         { background: rgba(139,92,246,.16); border-color: rgba(139,92,246,.4); }
html:not([data-theme^="retro"]) #theme-toggle         { background: rgba(245,158,11,.16); border-color: rgba(245,158,11,.4); }
html:not([data-theme^="retro"]) #retro-toggle         { background: rgba(217,70,239,.16); border-color: rgba(217,70,239,.4); }
html:not([data-theme^="retro"]) #retro-variant-toggle { background: rgba(99,102,241,.16); border-color: rgba(99,102,241,.4); }
html:not([data-theme^="retro"]) #desktop-toggle       { background: rgba(6,182,212,.16); border-color: rgba(6,182,212,.4); }
html:not([data-theme^="retro"]) #a11y-toggle          { background: rgba(20,184,166,.16); border-color: rgba(20,184,166,.4); }
html:not([data-theme^="retro"]) #shortcuts-toggle     { background: rgba(244,63,94,.16); border-color: rgba(244,63,94,.4); }
html:not([data-theme^="retro"]) [data-dnd-toggle]:not(.active) { background: rgba(249,115,22,.16); border-color: rgba(249,115,22,.4); }
html:not([data-theme^="retro"]) #notif-toggle         { background: rgba(239,68,68,.16); border-color: rgba(239,68,68,.4); }

.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 0.65rem;
  font-weight: 700;
  font-family: var(--font-mono);
  background: var(--accent);
  color: #fff;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.view {
  display: none;
  animation: viewIn 0.35s ease;
}

.view.active {
  display: block;
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.dashboard-header {
  margin-bottom: 1.75rem;
}

.dashboard-header h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  cursor: default;
  user-select: none;
}

/* Notifications Panel */
.notif-panel {
  position: fixed;
  top: calc(var(--topbar-h) + 0.75rem);
  right: 1rem;
  width: min(360px, calc(100vw - 2rem));
  max-height: calc(100vh - var(--topbar-h) - 2rem);
  border-radius: var(--radius);
  z-index: 200;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--glass-border);
}

.notif-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
}

.text-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.8rem;
  cursor: pointer;
  font-family: var(--font-sans);
}

.text-btn:hover { text-decoration: underline; }

.notif-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.notif-item {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--glass-border);
  font-size: 0.85rem;
  animation: notifIn 0.3s ease;
}

.notif-item.unread {
  border-left: 3px solid var(--accent);
}

.notif-item time {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-family: var(--font-mono);
}

@keyframes notifIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Achievements */
.achievements-panel {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 150;
  border-radius: var(--radius);
  overflow: visible;
}

.achievements-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  width: 100%;
}

.achievements-drawer {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  right: 0;
  width: 280px;
  max-height: 320px;
  overflow-y: auto;
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

.achievements-drawer h3 {
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
}

#achievements-list {
  list-style: none;
}

.ach-item {
  display: flex;
  gap: 0.6rem;
  padding: 0.5rem 0;
  font-size: 0.8rem;
  opacity: 0.35;
  transition: opacity 0.3s;
}

.ach-item.unlocked {
  opacity: 1;
}

.ach-icon { font-size: 1.2rem; }

.ach-info strong {
  display: block;
  font-weight: 500;
}

.ach-info span {
  color: var(--text-muted);
  font-size: 0.72rem;
}

/* Toast */
.toast-container {
  position: fixed;
  /* BUG FIX: this used to be a hardcoded `top: 1rem`, which put every toast
     directly on top of the topbar's icon-button cluster (sound, theme,
     notifications, etc). Each .toast has pointer-events: auto, so it
     silently ate clicks meant for those buttons — worse with notifications
     queued back to back, since the strip stayed occupied continuously.
     .notif-panel already avoids this by offsetting past --topbar-h; this
     now does the same. */
  top: calc(var(--topbar-h) + 0.75rem);
  right: 1rem;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  width: min(22rem, calc(100vw - 2rem));
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  font-size: 0.82rem;
  animation: toastIn 0.38s cubic-bezier(.2,.8,.2,1), toastOut 0.38s cubic-bezier(.4,0,1,1) 3.85s forwards;
  pointer-events: auto;
  line-height: 1.35;
  box-shadow: 0 10px 30px rgba(0,0,0,.28);
}

.toast-title { display: block; color: var(--text-primary); margin-bottom: 0.15rem; font-weight: 600; }
.toast-message { display: block; color: var(--text-secondary); }

.toast.achievement {
  border-color: #fbbf24;
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.15);
}

.toast.hint {
  border-color: #818cf8;
  box-shadow: 0 0 20px rgba(129, 140, 248, 0.15);
}

.toast.online {
  border-color: var(--success);
  box-shadow: 0 0 20px rgba(52, 211, 153, 0.15);
}

.toast.offline {
  border-color: var(--danger);
  box-shadow: 0 0 20px rgba(248, 113, 113, 0.15);
}

.toast.system { border-color: var(--accent); box-shadow: 0 0 20px var(--accent-glow); }

/* New-version banner — unlike toasts, this doesn't auto-dismiss: it's
   asking for an action (a hard reload), not just reporting something, so it
   stays until the visitor either reloads or dismisses it themselves. Pinned
   bottom-center rather than joining the toast stack so it reads as its own
   distinct thing, not one more notification to skim past. */
.version-banner {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translate(-50%, 0.5rem);
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  max-width: min(30rem, calc(100vw - 2rem));
  padding: 0.75rem 0.9rem 0.75rem 1.05rem;
  border-radius: 999px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--accent);
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
  font-size: 0.82rem;
  color: var(--text-primary);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  animation: versionPulse 2.2s ease-in-out infinite;
}

.version-banner.show {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.version-banner-icon { font-size: 1.1rem; flex-shrink: 0; }
.version-banner-text { line-height: 1.35; }
.version-banner-text strong { color: var(--accent); white-space: nowrap; }

.version-banner-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.3rem;
  margin-left: 0.2rem;
}
.version-banner-close:hover { color: var(--text-primary); }

@keyframes versionPulse {
  0%, 100% { box-shadow: 0 10px 30px rgba(0,0,0,.3), 0 0 0 0 var(--accent-glow); }
  50%      { box-shadow: 0 10px 30px rgba(0,0,0,.3), 0 0 0 8px transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .version-banner { animation: none; }
}

@media (max-width: 480px) {
  .version-banner { bottom: 0.75rem; }
}

/* button[...] (not just [...]) for extra specificity — otherwise this tied
   with [data-theme="day"] .icon-btn in themes.css and lost on source
   order, so a muted DND looked identical to an unmuted one in day theme. */
button[data-dnd-toggle].active { color: var(--warning); border-color: var(--warning); background: rgba(251,191,36,.12); }

@media (max-width: 480px) {
  .toast {
    white-space: normal;
    max-width: 85vw;
  }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(calc(100% + 1.5rem)); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(calc(100% + 1.5rem)); }
}

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}

/* Mobile bottom navigation — hidden on desktop, where the header nav rules. */
.mobile-nav { display: none; }

@media (max-width: 768px) {
  /* The header's own nav is hidden here and replaced by the fixed bottom
     bar below. It previously just vanished with `display:none` and nothing
     took its place, which made the Terminal view completely unreachable on
     a phone — and with it most of the site. */
  .topbar-nav { display: none; }

  .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 60;
    display: flex;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-top: 1px solid var(--glass-border);
    /* Clears the iOS home indicator / Android gesture bar. */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .mobile-nav .nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    border: none;
    border-radius: 0;
    background: none;
    color: var(--text-secondary);
    padding: 0.55rem 0.5rem;
    font-size: 1.1rem;
    /* 44px is the minimum comfortable touch target on both platforms. */
    min-height: 52px;
    cursor: pointer;
  }

  .mobile-nav .nav-btn span {
    font-size: 0.68rem;
    font-family: var(--font-sans);
  }

  .mobile-nav .nav-btn.active {
    color: var(--accent);
    background: var(--accent-dim);
    box-shadow: inset 0 2px 0 var(--accent);
  }

  /* Content must clear the fixed bar, or the last card hides beneath it. */
  .main { padding: 1rem 1rem calc(5rem + env(safe-area-inset-bottom, 0px)); }
  .app-footer {
    flex-direction: column;
    gap: 0.25rem;
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  }

  .clock { display: none; }
  .achievements-drawer { width: calc(100vw - 2.5rem); right: -0.5rem; }

  /* The top bar gets crowded fast on a narrow screen — let the controls
     wrap rather than overflow off the edge. */
  .topbar { flex-wrap: wrap; gap: 0.5rem; }
  .topbar-right { flex-wrap: wrap; justify-content: flex-end; }
  .icon-btn { min-width: 40px; min-height: 40px; }

  /* BUG FIX: the floating achievements button is fixed at bottom-right and
     was landing directly on top of the new bottom nav, intercepting taps —
     the Terminal tab was literally unclickable on a phone (caught by an
     automated tap test, which timed out with the achievements toggle
     swallowing the event). Lifted above the bar, and its drawer height
     capped so it can't run off the top of a short screen either. */
  .achievements-panel {
    bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
    right: 0.75rem;
  }

  .achievements-drawer {
    max-height: calc(100vh - 14rem);
    overflow-y: auto;
  }
}

/* Retro theme keeps its hard edges on the mobile bar too. */
[data-theme^="retro"] .mobile-nav {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: var(--glass-bg);
  border-top: 2px solid var(--bevel-light);
}

/* Footer */
.app-footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.footer-sep {
  opacity: 0.4;
}

/* ------------------------------------------------------------------ *
 * Accessibility options panel
 * ------------------------------------------------------------------ */

.a11y-panel {
  width: min(320px, calc(100vw - 2rem));
}

.a11y-body {
  padding: 1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.a11y-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.85rem;
  cursor: default;
}

.a11y-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.a11y-size-buttons {
  display: flex;
  gap: 0.35rem;
}

.a11y-size-btn {
  background: var(--hover-bg);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem 0.6rem;
  font-family: var(--font-sans);
  line-height: 1;
}

.a11y-size-btn:nth-child(2) { font-size: 1.05em; }
.a11y-size-btn:nth-child(3) { font-size: 1.2em; }

.a11y-size-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.a11y-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ------------------------------------------------------------------ *
 * Accessibility effects — applied globally via classes on <html>
 * ------------------------------------------------------------------ */

html.a11y-reduced-motion *,
html.a11y-reduced-motion *::before,
html.a11y-reduced-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* Low-perf devices (perf-mode.js) get the same treatment as reduced-motion
   above (html.perf-severe is applied alongside — see boot.js — so this
   compounds with it, not replaces it), plus backdrop-filter specifically:
   blurring everything behind every glass card/window/toast is one of the
   more GPU-expensive things this site does, continuously, on every scroll
   and every open window, and costs nothing to a visitor who never sees it
   composited slowly in the first place. Falls back to each surface's own
   solid --glass-bg color, which was already translucent-on-blur — still
   reads as a distinct panel, just without the frosted-glass effect. */
html.perf-severe * {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Tier 3 (perf-mode.js) — genuinely ancient hardware. Blur is already gone
   from perf-severe above; this goes further and flattens the visual polish
   itself, not just the expensive-to-render parts of it: gradients (a plain
   fill paints faster than a computed blend), shadows (each one is its own
   compositing pass), and rounded corners (cheap individually, but this
   tier is about compounding every small saving, not any one of them
   mattering alone). The result is meant to look plain — that's the deal a
   visitor made when they clicked past perf-gate's warning: uglier in
   exchange for actually staying responsive. */
html.perf-extreme * {
  background-image: none !important;
  box-shadow: none !important;
  text-shadow: none !important;
  border-radius: 0 !important;
}

html.a11y-high-contrast {
  --text-secondary: var(--text-primary);
  --text-muted: var(--text-primary);
  --glass-border: currentColor;
}

html.a11y-high-contrast .glass {
  background: var(--bg-base);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-width: 2px;
}

html.a11y-underline-links a {
  text-decoration: underline !important;
}

html.a11y-text-large { font-size: 112.5%; }
html.a11y-text-xl { font-size: 125%; }

/* Keyboard shortcut key caps */
kbd {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: var(--hover-bg);
  border: 1px solid var(--glass-border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.15rem 0.45rem;
  color: var(--text-primary);
}

/* ------------------------------------------------------------------ *
 * Print — the starfield, buttons, and terminal cursor are meaningless
 * (and ink-wasting) on paper. Keep just the dashboard content.
 * ------------------------------------------------------------------ */
@media print {
  #starfield,
  .icon-btn,
  .nav,
  .toast-container,
  #rickroll-modal,
  .notif-panel,
  .terminal-cursor {
    display: none !important;
  }

  body {
    background: white !important;
    color: black !important;
  }

  .glass {
    background: white !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .module, .card {
    break-inside: avoid;
  }
}

/* ---- Achievement reset button (in the drawer) ---- */
.ach-reset-btn {
  display: block;
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.5rem;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.45);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  cursor: pointer;
}

.ach-reset-btn:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

/* ---- Full-screen destructive-action warning ---- */
.reset-warning {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(20, 0, 0, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: resetWarnIn 0.18s ease-out;
}

@keyframes resetWarnIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.reset-warning-inner {
  max-width: 560px;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
  background: #14070a;
  border: 3px solid #ef4444;
  border-radius: var(--radius);
  padding: 1.75rem 1.75rem 1.4rem;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.4), 0 24px 70px rgba(0, 0, 0, 0.7);
}

.reset-warning-flags {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
}

/* Staggered pulse so the row feels alive rather than blinking in unison. */
.reset-warning-flags span {
  animation: resetFlagPulse 1.4s ease-in-out infinite;
}
.reset-warning-flags span:nth-child(2) { animation-delay: 0.15s; }
.reset-warning-flags span:nth-child(3) { animation-delay: 0.30s; }
.reset-warning-flags span:nth-child(4) { animation-delay: 0.45s; }
.reset-warning-flags span:nth-child(5) { animation-delay: 0.60s; }

@keyframes resetFlagPulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50%      { transform: scale(1.18); opacity: 1; }
}

.reset-warning h1 {
  margin: 0 0 0.6rem;
  font-size: 1.5rem;
  letter-spacing: 0.14em;
  color: #ff6b6b;
  font-family: var(--font-mono);
  text-shadow: 0 0 22px rgba(239, 68, 68, 0.65);
}

/* Hazard stripe — the universal "do not proceed casually" signal. */
.reset-warning-stripe {
  height: 10px;
  margin: 0.5rem 0 1rem;
  border-radius: 2px;
  background: repeating-linear-gradient(
    45deg,
    #ef4444 0 12px,
    #14070a 12px 24px
  );
}

.reset-warning-lead {
  color: #ffe4e4;
  font-size: 0.95rem;
  margin: 0 0 0.75rem;
  line-height: 1.5;
}

.reset-warning-count {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: #ff9b9b;
  margin: 0 0 1rem;
  padding: 0.5rem;
  border: 1px dashed rgba(239, 68, 68, 0.5);
  border-radius: var(--radius-sm);
}

.reset-warning-list {
  text-align: left;
  margin: 0 auto 1rem;
  padding-left: 1.2rem;
  max-width: 25rem;
  color: #ffd5d5;
  font-size: 0.82rem;
  line-height: 1.7;
}

.reset-warning-note {
  font-size: 0.74rem;
  color: #c9a5a5;
  line-height: 1.5;
  margin: 0 0 1.2rem;
}

.reset-warning-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}

.reset-cancel,
.reset-confirm {
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--font-sans);
  min-height: 44px;
}

.reset-cancel {
  background: #fff;
  border: 2px solid #fff;
  color: #14070a;
  font-weight: 600;
}

.reset-cancel:hover { background: #e8e8e8; }

.reset-confirm {
  background: transparent;
  border: 2px solid rgba(239, 68, 68, 0.4);
  color: #ff9b9b;
}

.reset-confirm:disabled { cursor: not-allowed; opacity: 0.65; }

.reset-confirm.armed {
  border-color: #ef4444;
  background: #ef4444;
  color: #fff;
  animation: resetArmed 1.1s ease-in-out infinite;
}

@keyframes resetArmed {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
  50%      { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

.reset-warning-hint {
  margin: 0.9rem 0 0;
  font-size: 0.7rem;
  color: #a98080;
  font-family: var(--font-mono);
}

/* Motion-sensitive users still get the full warning, just without the
   pulsing that's the whole point of prefers-reduced-motion. */
@media (prefers-reduced-motion: reduce) {
  .reset-warning,
  .reset-warning-flags span,
  .reset-confirm.armed {
    animation: none;
  }
}

/* ---- v2.0 release celebration ---- */
.v2-celebration {
  position: fixed;
  inset: 0;
  z-index: 10040;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(10, 6, 20, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: resetWarnIn 0.18s ease-out;
}

.v2-celebration-inner {
  max-width: 460px;
  width: 100%;
  text-align: center;
  background: var(--glass-bg);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 2rem 1.75rem 1.6rem;
  box-shadow: 0 0 0 1px var(--accent-glow), 0 24px 70px rgba(0, 0, 0, 0.6);
}

.v2-celebration-emoji {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 0.6rem;
  animation: v2EmojiPulse 1.8s ease-in-out infinite;
}

@keyframes v2EmojiPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}

.v2-celebration-inner h1 {
  margin: 0 0 0.5rem;
  font-size: 1.6rem;
  color: var(--accent);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.v2-celebration-sub {
  margin: 0 0 1rem;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.v2-celebration-hint {
  margin: 0 0 1.3rem;
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.v2-celebration-hint code {
  font-family: var(--font-mono);
  color: var(--accent);
}

.v2-celebration-close {
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #06110a;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--font-sans);
  min-height: 44px;
}

.v2-celebration-close:hover { filter: brightness(1.1); }

@media (prefers-reduced-motion: reduce) {
  .v2-celebration,
  .v2-celebration-emoji {
    animation: none;
  }
}

/* ---- DVD-logo idle screensaver ---- */
.dvd-screensaver {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(2, 2, 8, 0.94);
  overflow: hidden;
  cursor: pointer;
}

.dvd-logo {
  position: absolute;
  top: 0;
  left: 0;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.8rem;
  padding: 0.6rem 1rem;
  white-space: nowrap;
  user-select: none;
  will-change: transform;
}

.dvd-logo.dvd-static {
  position: static;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 2.2rem;
}

.dvd-logo.dvd-corner-hit {
  animation: dvdCornerFlash 0.9s ease-out;
}

@keyframes dvdCornerFlash {
  0%   { text-shadow: 0 0 0 rgba(255,255,255,0); }
  30%  { text-shadow: 0 0 30px currentColor, 0 0 60px currentColor; }
  100% { text-shadow: 0 0 0 rgba(255,255,255,0); }
}

.dvd-hint {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.35);
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

[data-theme^="retro"] .reset-warning-inner,
[data-theme^="retro"] .reset-cancel,
[data-theme^="retro"] .reset-confirm,
[data-theme^="retro"] .ach-reset-btn {
  border-radius: 0;
}
