/* Punk Apestrong — Apple IIe site
   v1 scaffold */

:root {
  /* Phosphor themes (View menu switches data-theme on body) */
  --crt-bg: #039e4b;
  --crt-fg: #062a13;
  --crt-fg-soft: #94ffa8;
  --menubar-bg: #c9ffd6;
  --menubar-fg: #062a13;
  --window-bg: #062a13;
  --window-fg: #94ffa8;
  --accent: #ff4a4a;
  --canvas-bg: #1a1a1a;
}

[data-theme="amber"] {
  --crt-bg: #1a0a00;
  --crt-fg: #ffb000;
  --crt-fg-soft: #ffd66e;
  --menubar-bg: #2a1500;
  --menubar-fg: #ffb000;
  --window-bg: #1a0a00;
  --window-fg: #ffb000;
}

[data-theme="bw"] {
  --crt-bg: #000000;
  --crt-fg: #ffffff;
  --crt-fg-soft: #cccccc;
  --menubar-bg: #ffffff;
  --menubar-fg: #000000;
  --window-bg: #000000;
  --window-fg: #ffffff;
}

/* SEO/AI crawlable content — visually hidden but in the DOM for search engines,
   AI crawlers (GPTBot, ClaudeBot, PerplexityBot…), and screen readers. Not
   display:none because some crawlers skip that. Uses the standard sr-only
   pattern: 1px clipped, off-flow. */
.seo-content {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: normal;
  border: 0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  color: #fff;
  font-family: "Chicago", "Charcoal", "Helvetica Neue", system-ui, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

html { background: var(--canvas-bg); }

body {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    url("../img/desk.png") center/cover no-repeat fixed,
    var(--canvas-bg);
}

/* Stage holds the computer image and the CRT overlay.
   Sized to fit the viewport on desktop: width is min(100vw, 100vh × art-aspect). */
.stage {
  position: relative;
  width: min(100vw, calc(100vh * 1854 / 2034));
  aspect-ratio: 1854 / 2034;
  margin: 0 auto;
}

.computer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* Click hotspots over the painted bottom-row brand keys.
   Invisible by default; subtle highlight on hover so they feel pressable.
   Positions are eyeballed — nudge each one if a key looks off. */
.hotspot {
  position: absolute;
  display: block;
  border-radius: 14%;
  text-decoration: none;
  transition: background-color 0.12s ease, transform 0.12s ease;
}

.hotspot:hover,
.hotspot:focus-visible {
  background: rgba(255, 255, 255, 0.18);
  outline: 2px dashed rgba(255, 255, 255, 0.5);
  outline-offset: -3px;
}

.hotspot:active {
  transform: translateY(1px);
}

/* Bottom row of keys — y ≈ 86%–90% of canvas height */
.hotspot-spotify   { left: 16.4%; top: 87.0%; width: 6.0%; height: 3.6%; }
.hotspot-apple     { left: 22.7%; top: 87.0%; width: 6.0%; height: 3.6%; }
.hotspot-youtube   { left: 67.5%; top: 87.0%; width: 6.0%; height: 3.6%; }
.hotspot-instagram { left: 73.8%; top: 87.0%; width: 6.0%; height: 3.6%; }

/* Hide hotspots on mobile (cartoon is hidden there; mobile uses the floating key bar) */
@media (max-width: 768px) {
  .hotspot { display: none; }
}

/* CRT screen — positioned over the green area in the image.
   Bounds detected via flood-fill of the painted green region. */
.crt {
  position: absolute;
  left: 16.99%;
  top: 12.73%;
  width: 56.90%;
  height: 31.12%;
  background: var(--crt-bg);
  color: var(--crt-fg);
  font-family: "Monaco", "Menlo", "Courier New", monospace;
  font-size: clamp(10px, 1.2vw, 16px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* Match the CRT's rounded corners so the overlay stays inside the
     painted green and doesn't bleed into the bezel at the corners. */
  border-radius: 4% / 7%;
  /* Subtle CRT glow */
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.35),
    inset 0 0 8px rgba(255, 255, 255, 0.1);
}

/* CRT scanlines */
.crt::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.06) 0px,
    rgba(0, 0, 0, 0.06) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: multiply;
}

/* Menu bar */
.menubar {
  display: flex;
  background: var(--menubar-bg);
  color: var(--menubar-fg);
  border-bottom: 1px solid var(--menubar-fg);
  flex: 0 0 auto;
  position: relative;
  z-index: 3;
}

.menu {
  background: transparent;
  border: 0;
  color: inherit;
  padding: 0.4em 0.9em;
  font: inherit;
  font-weight: bold;
  cursor: pointer;
}

.menu[data-menu="apple"] {
  font-size: 1.2em;
  padding-inline: 0.6em;
}

.menu-user { margin-left: auto; font-weight: normal; }

.menu:hover, .menu[aria-expanded="true"] {
  background: var(--menubar-fg);
  color: var(--menubar-bg);
}

/* Dropdown */
.dropdown {
  position: absolute;
  top: 100%;
  background: var(--menubar-bg);
  color: var(--menubar-fg);
  border: 1px solid var(--menubar-fg);
  min-width: 12em;
  z-index: 10;
  font-family: "Monaco", "Menlo", monospace;
}

.dropdown[hidden] { display: none; }

.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0.35em 0.9em;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.dropdown-item:hover {
  background: var(--menubar-fg);
  color: var(--menubar-bg);
}

.dropdown-sep {
  height: 1px;
  background: var(--menubar-fg);
  opacity: 0.3;
  margin: 0.2em 0;
}

/* Desktop with icons */
.desktop {
  flex: 1 1 auto;
  position: relative;
  padding: 1em;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5em, 1fr));
  gap: 0.5em 1.2em;
  align-content: start;
  z-index: 1;
}

.icon {
  background: transparent;
  border: 0;
  color: var(--crt-fg);
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  padding: 0.4em 0.3em;
  font: inherit;
}

.icon:hover, .icon:focus-visible {
  background: var(--crt-fg);
  color: var(--crt-bg);
  outline: none;
}

/* Hover: invert the SVG "white" cutouts to match (so the floppy label cutout
   stays readable when the icon background flips) */
.icon:hover .icon-glyph rect[fill="var(--crt-bg)"],
.icon:focus-visible .icon-glyph rect[fill="var(--crt-bg)"] {
  fill: var(--crt-fg);
}

.icon-glyph {
  width: 2.6em;
  height: 2.6em;
  display: block;
  margin-bottom: 0.3em;
  shape-rendering: crispEdges;
  color: var(--crt-fg);
}

.icon:hover .icon-glyph,
.icon:focus-visible .icon-glyph {
  color: var(--crt-bg);
}

.icon-label {
  font-size: 0.85em;
  letter-spacing: 0.02em;
}

/* Window (opens when an icon is clicked) */
.window {
  position: absolute;
  top: 2.4em;
  left: 1em;
  right: 1em;
  bottom: 4.2em;  /* leave room for player */
  background: var(--window-bg);
  color: var(--window-fg);
  border: 1px solid var(--window-fg);
  display: flex;
  flex-direction: column;
  z-index: 2;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.4);
}

.window[hidden] { display: none; }

.window-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--window-fg);
  color: var(--window-bg);
  padding: 0.15em 0.5em;
  font-weight: bold;
  /* Mouse Desk-style title pattern */
  background-image: repeating-linear-gradient(
    to bottom,
    var(--window-fg) 0,
    var(--window-fg) 1px,
    transparent 1px,
    transparent 3px
  );
}

.window-title {
  background: var(--window-fg);
  color: var(--window-bg);
  padding: 0 0.5em;
}

.window-close {
  background: var(--window-bg);
  color: var(--window-fg);
  border: 1px solid var(--window-fg);
  width: 1.4em;
  height: 1.4em;
  cursor: pointer;
  font-weight: bold;
  line-height: 1;
  font-size: 0.9em;
}

.window-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.8em 1em;
  line-height: 1.5;
}

.window-body h2 {
  font-size: 1.1em;
  margin: 0 0 0.6em;
  text-decoration: underline;
}

.window-body p { margin: 0 0 0.7em; }
.window-body a { color: inherit; }

/* Video embed wrapper — green-monochrome filter + tint overlay
   for the "watching it on a CRT" effect */
.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  margin: 0.4em 0;
  overflow: hidden;
}

.video-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  /* Green-monochrome look. Sepia desaturates → saturate boosts → hue-rotate
     pushes the brown of sepia toward green. Tweak hue-rotate / saturation
     to taste. */
  filter: sepia(1) saturate(2.2) hue-rotate(70deg) brightness(1.05) contrast(1.15);
}

.video-tint {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(3, 158, 75, 0.22);
  mix-blend-mode: screen;
}

/* Inline button that looks like a link/menu item */
.link-btn {
  background: transparent;
  color: inherit;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.link-btn:hover { background: var(--window-fg); color: var(--window-bg); }

/* Gallery — California Redemption shows list */
.show-list {
  list-style: none;
  padding: 0;
  margin: 0.5em 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.15em;
}

.show-list li { margin: 0; }

.show-item {
  display: grid;
  grid-template-columns: 5em 1fr auto;
  gap: 0.6em;
  align-items: baseline;
  width: 100%;
  text-align: left;
  background: transparent;
  color: inherit;
  border: 0;
  padding: 0.3em 0.4em;
  font: inherit;
  cursor: pointer;
}

.show-item:hover {
  background: var(--window-fg);
  color: var(--window-bg);
}

.show-date { font-variant-numeric: tabular-nums; opacity: 0.75; }
.show-title { font-weight: bold; }
.show-count { font-size: 0.8em; opacity: 0.6; }

.show-desc {
  font-size: 0.85em;
  opacity: 0.85;
  font-style: italic;
}

/* Thumbnails grid */
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 4px;
  margin-top: 0.5em;
}

.thumb {
  background: transparent;
  border: 1px solid var(--window-fg);
  padding: 0;
  cursor: pointer;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}

.thumb:hover {
  border-color: var(--crt-fg-soft, var(--window-fg));
  box-shadow: 0 0 0 1px var(--window-fg);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ----- Lightbox (inside the CRT) ----- */
.lightbox {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 50;  /* above menubar, desktop, window, player */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1em 2.5em;
}

.lightbox[hidden] { display: none; }

.lb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  /* Slight phosphor glow */
  box-shadow: 0 0 12px rgba(0, 200, 100, 0.25);
}

.lb-caption {
  position: absolute;
  bottom: 0.4em;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--crt-fg-soft, #94ffa8);
  font-size: 0.75em;
  letter-spacing: 0.05em;
}

.lb-btn {
  position: absolute;
  background: rgba(0, 0, 0, 0.5);
  color: var(--crt-fg-soft, #fff);
  border: 1px solid rgba(255, 255, 255, 0.3);
  width: 1.8em;
  height: 1.8em;
  font-size: 1.2em;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  padding: 0;
}

.lb-btn:hover { background: rgba(255, 255, 255, 0.18); }

.lb-close { top: 0.4em; right: 0.4em; }
.lb-prev  { left: 0.4em;  top: 50%; transform: translateY(-50%); }
.lb-next  { right: 0.4em; top: 50%; transform: translateY(-50%); }

/* Game screen — full-CRT takeover when a game launches */
.game-screen {
  position: absolute;
  inset: 0;
  background: var(--window-bg);
  color: var(--window-fg);
  z-index: 20;
  padding: 0.6em 0.9em;
  display: flex;
  flex-direction: column;
}
.game-screen[hidden] { display: none; }
.game-screen .snake-wrap,
.game-screen .ms-wrap { height: 100%; }

.snake-close {
  width: 28px;
  height: 28px;
  padding: 0;
  background: var(--window-bg);
  color: var(--window-fg);
  border: 1px solid var(--window-fg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 1.05em;
  line-height: 1;
}
.snake-close:hover { background: var(--window-fg); color: var(--window-bg); }

.snake-controls {
  display: inline-flex;
  gap: 0.3em;
  align-items: center;
}

/* Message Board */
.mb-form {
  display: flex;
  flex-direction: column;
  gap: 0.35em;
  margin-bottom: 0.6em;
}

.mb-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
  font-size: 0.95em;
}

.mb-label {
  flex: 0 0 5em;
  padding-top: 0.2em;
}

.mb-form input,
.mb-form textarea {
  flex: 1;
  background: var(--window-bg);
  color: var(--window-fg);
  border: 1px solid var(--window-fg);
  font: inherit;
  padding: 0.2em 0.4em;
}

.mb-form textarea {
  resize: vertical;
  min-height: 3em;
  line-height: 1.3;
}

.mb-form input:focus,
.mb-form textarea:focus {
  outline: 1px solid var(--crt-fg-soft, var(--window-fg));
  outline-offset: -2px;
}

.mb-actions { display: flex; align-items: center; gap: 0.8em; }

.mb-status { font-size: 0.85em; opacity: 0.85; }

.mb-sep {
  border: 0;
  border-top: 1px dashed var(--window-fg);
  margin: 0.6em 0;
}

.mb-list {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}

.mb-post {
  border-bottom: 1px dashed var(--window-fg);
  padding-bottom: 0.45em;
}

.mb-post:last-child { border-bottom: 0; }

.mb-meta {
  font-size: 0.85em;
  opacity: 0.8;
}

.mb-body {
  margin-top: 0.15em;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Slightly smaller type inside the Message Board window. */
.window-body.forum-mode { font-size: 0.9em; }

/* Forum (threads + auth) */
.forum-actions { margin: 0.4em 0; display: flex; gap: 1em; }
.forum-hint { font-size: 0.85em; opacity: 0.85; }

.thread-list { list-style: none; padding: 0; margin: 0; }
.thread-list li { margin: 0; }
.thread-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 0.4em 1em;
  width: 100%;
  background: transparent;
  color: inherit;
  border: 0;
  border-bottom: 1px dashed var(--window-fg);
  padding: 0.4em 0;
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.thread-item:hover { background: var(--window-fg); color: var(--window-bg); }
.thread-title { font-weight: bold; }
.thread-meta { font-size: 0.8em; opacity: 0.85; white-space: nowrap; }

.thread-h { margin: 0.3em 0 0.6em; }

.post-list { display: flex; flex-direction: column; gap: 0.6em; }

.forum-post {
  border-bottom: 1px dashed var(--window-fg);
  padding-bottom: 0.5em;
}
.forum-post:last-child { border-bottom: 0; }

/* Snake — game-over overlay with leaderboard */
.snake-canvas-fit { position: relative; }

.snake-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1;
}
.snake-overlay[hidden] { display: none; }

.snake-overlay-inner {
  background: var(--window-bg);
  color: var(--window-fg);
  border: 1px solid var(--window-fg);
  padding: 0.8em 1.2em;
  text-align: center;
  max-width: min(90%, 28em);
  max-height: 90%;
  overflow-y: auto;
  font-size: 0.95em;
}
.snake-overlay-inner h3 { margin: 0 0 0.3em; letter-spacing: 0.08em; }
.snake-overlay-inner h4 { margin: 0.4em 0 0.3em; opacity: 0.9; }

.snake-board { margin: 0.5em 0; text-align: left; }

.snake-board-list {
  list-style: decimal;
  padding-left: 2em;
  margin: 0;
  font-family: "Monaco", "Menlo", "Courier New", monospace;
  font-size: 0.9em;
  line-height: 1.5;
}
.snake-board-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6em;
}
.snake-board-list li.you {
  color: var(--crt-fg-soft, var(--window-fg));
  font-weight: bold;
}

.snake-extra { font-size: 0.85em; opacity: 0.85; margin: 0.4em 0 0; }
.snake-overlay-hint { font-size: 0.8em; opacity: 0.8; margin: 0.4em 0 0; }

/* Games */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5em, 1fr));
  gap: 0.5em 1.2em;
  align-content: start;
  margin-top: 0.4em;
}

/* Game icons live in a window (dark bg) instead of the desktop (light bg),
   so they need the inverted color treatment. */
.games-grid .icon,
.games-grid .icon .icon-glyph { color: var(--window-fg); }

.games-grid .icon:hover,
.games-grid .icon:focus-visible {
  background: var(--window-fg);
  color: var(--window-bg);
}

.games-grid .icon:hover .icon-glyph,
.games-grid .icon:focus-visible .icon-glyph { color: var(--window-bg); }

.games-grid .icon:hover .icon-glyph rect[fill="var(--window-bg)"],
.games-grid .icon:focus-visible .icon-glyph rect[fill="var(--window-bg)"] {
  fill: var(--window-fg);
}

.snake-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.3em;
}

.snake-hud {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85em;
  gap: 0.6em;
  flex-wrap: wrap;
}

.snake-music {
  display: inline-flex;
  gap: 0.3em;
  align-items: center;
}

.snake-music-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  color: var(--window-fg);
  border: 1px solid var(--window-fg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.snake-music-btn svg { width: 16px; height: 16px; display: block; }

.snake-music-btn:hover,
.snake-music-btn.active {
  background: var(--window-fg);
  color: var(--window-bg);
}

/* Cutouts (e.g. the P inside the punk button's torn rectangle) need to flip
   when the button inverts, so the cutout stays contrasted with the fill. */
.snake-music-btn:hover [fill="var(--window-bg)"],
.snake-music-btn.active [fill="var(--window-bg)"] {
  fill: var(--window-fg);
}

.snake-canvas-fit {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.snake-canvas {
  display: block;
  image-rendering: pixelated;
  border: 1px solid var(--window-fg);
}

.snake-hint {
  flex: 0 0 auto;
  font-size: 0.8em;
  opacity: 0.85;
  text-align: center;
  min-height: 1.2em;
}

/* Music player — pinned to bottom of CRT */
.player {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.6em;
  padding: 0.4em 0.6em;
  background: var(--crt-fg);
  color: var(--crt-bg);
  border-top: 1px solid var(--crt-fg);
  font-size: 0.85em;
  z-index: 3;
}

.player-btn {
  background: var(--crt-bg);
  color: var(--crt-fg);
  border: 1px solid var(--crt-bg);
  width: 2em;
  height: 2em;
  cursor: pointer;
  font-size: 0.9em;
  line-height: 1;
}

.player-track { min-width: 0; }

.player-meta {
  display: flex;
  gap: 0.5em;
  align-items: baseline;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-title { font-weight: bold; }
.player-artist { opacity: 0.85; font-size: 0.9em; }

.player-progress {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin-top: 0.15em;
}

.player-bar {
  flex: 1;
  height: 4px;
  background: var(--crt-bg);
  border: 1px solid var(--crt-bg);
  position: relative;
}

.player-fill {
  position: absolute;
  inset: 0;
  width: 0;
  background: var(--crt-bg);
  /* visual indicator inverted */
  background: var(--crt-fg-soft, var(--crt-fg));
}

.player-time { font-size: 0.8em; white-space: nowrap; }

.player-sides {
  display: flex;
  gap: 0.3em;
}

.side {
  background: transparent;
  color: var(--crt-bg);
  border: 1px solid var(--crt-bg);
  padding: 0.25em 0.5em;
  font: inherit;
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.side.active {
  background: var(--crt-bg);
  color: var(--crt-fg);
}

/* Mobile-only function-key floater (hidden on desktop) */
.mobilekeys {
  display: none;
}

/* ---- MOBILE LAYOUT ---- */
/* When viewport is portrait and narrow, hide the cartoon and show CRT full-bleed */
@media (max-width: 768px) {
  body {
    background: #000;
  }

  .stage {
    aspect-ratio: auto;
    max-width: none;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 0;
  }

  /* Hide the painted computer body */
  .computer {
    display: none;
  }

  /* CRT goes full-bleed at the top */
  .crt {
    position: relative;
    left: 0;
    top: 0;
    width: 100%;
    height: calc(100dvh - 4em);
    font-size: 14px;
  }

  /* Make space for the floating key bar at the bottom */
  .mobilekeys {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4em;
    background: #1a1a1a;
    border-top: 2px solid #444;
    align-items: center;
    justify-content: space-around;
    padding: 0 1em;
    z-index: 100;
  }

  .mkey {
    color: #ddd;
    text-decoration: none;
    width: 3em;
    height: 3em;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 4px;
    font-size: 1.4em;
  }

  .mkey[data-key="spotify"] { color: #1db954; }
  .mkey[data-key="instagram"] { color: #e4405f; }
  .mkey[data-key="youtube"] { color: #ff0000; }

  .mkey svg { width: 1.5em; height: 1.5em; }

  /* Compact player on mobile */
  .player {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    gap: 0.3em 0.6em;
  }
  .player-sides {
    grid-column: 1 / -1;
    justify-content: center;
  }
}

/* Larger desktop — preserve cartoon. (No body padding so it can fully center.) */

/* JobSweeper — Minesweeper, briefcases-for-bombs, CRT styling */
.ms-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
}

.ms-hud {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6em;
  flex-wrap: wrap;
  font-size: 0.85em;
}

.ms-diff {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--window-fg);
}
.ms-diff-btn {
  padding: 0.2em 0.6em;
  background: transparent;
  color: var(--window-fg);
  border: 0;
  border-right: 1px solid var(--window-fg);
  cursor: pointer;
  font: inherit;
  font-size: 0.85em;
  letter-spacing: 0.05em;
}
.ms-diff-btn:last-child { border-right: 0; }
.ms-diff-btn:hover { background: var(--window-fg); color: var(--window-bg); }
.ms-diff-btn.active {
  background: var(--window-fg);
  color: var(--window-bg);
}

.ms-stats {
  display: inline-flex;
  gap: 1em;
  align-items: center;
  font-family: "Monaco", "Menlo", "Courier New", monospace;
}
.ms-stat { display: inline-flex; align-items: center; gap: 0.3em; }
.ms-stat b { font-weight: 700; }

.ms-board-fit {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ms-board-fit.shake {
  animation: jsw-shake 0.6s cubic-bezier(0.38, 0.06, 0.22, 0.95) both;
}

@keyframes jsw-shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-3px, 0, 0); }
  40%, 60% { transform: translate3d(2px, 0, 0); }
}

.ms-grid {
  display: grid;
  grid-template-columns: repeat(var(--ms-cols, 10), 1fr);
  grid-template-rows:    repeat(var(--ms-cols, 10), 1fr);
  gap: 1px;
  background: var(--window-fg);
  border: 1px solid var(--window-fg);
  /* Square, bounded by the shorter axis of its container. */
  aspect-ratio: 1 / 1;
  width: min(100%, calc(var(--ms-cols, 10) * 2.2em));
  max-height: 100%;
}

.ms-tile {
  background: var(--window-bg);
  color: var(--window-fg);
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  font-family: "Monaco", "Menlo", "Courier New", monospace;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Fill the grid cell; the cell itself is forced square by the equal-fr tracks
     plus the grid's 1:1 aspect-ratio. */
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
  font-size: clamp(8px, 1.6vmin, 18px);
  line-height: 1;
}
.ms-tile:hover:not(.revealed):not(.flagged) {
  background: var(--crt-fg-soft, var(--window-fg));
  color: var(--window-bg);
}
.ms-tile.revealed {
  background: var(--window-fg);
  color: var(--window-bg);
  cursor: default;
}
.ms-tile.flagged {
  /* unrevealed but marked — keep window-bg with a slightly nudged glyph color */
  color: var(--window-fg);
}
.ms-tile.bomb,
.ms-tile.boom {
  background: var(--window-fg);
  color: var(--window-bg);
}
.ms-tile.boom { outline: 2px solid var(--window-bg); outline-offset: -3px; }
.ms-tile.miss { /* flagged a non-bomb — show a strikethrough flag */
  position: relative;
}
.ms-tile.miss::after {
  content: '';
  position: absolute;
  inset: 35% 12% auto 12%;
  border-top: 2px solid var(--window-fg);
  transform: rotate(-22deg);
}

.ms-tile .jsw-case {
  width: 70%;
  height: 70%;
  display: block;
}

.ms-hint {
  flex: 0 0 auto;
  font-size: 0.8em;
  opacity: 0.85;
  text-align: center;
  min-height: 1.2em;
}

/* JobSweeper end-of-game overlay (re-uses snake-board-list inside) */
.ms-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1;
}
.ms-overlay[hidden] { display: none; }
.ms-overlay-inner {
  background: var(--window-bg);
  color: var(--window-fg);
  border: 1px solid var(--window-fg);
  padding: 0.8em 1.2em;
  text-align: center;
  max-width: min(90%, 30em);
  max-height: 90%;
  overflow-y: auto;
  font-size: 0.95em;
}
.ms-overlay-inner h3 { margin: 0 0 0.3em; letter-spacing: 0.08em; }
.ms-overlay-inner h4 { margin: 0.4em 0 0.3em; opacity: 0.9; }
.ms-overlay-line { margin: 0.2em 0 0.4em; opacity: 0.9; }
.ms-overlay-hint { font-size: 0.8em; opacity: 0.8; margin: 0.4em 0 0; }
.ms-board { margin: 0.5em 0; text-align: left; }

/* Games — leaderboards aggregate view inside the Games window */
.lb-block { margin: 0 0 1em; }
.lb-block h3 {
  margin: 0.4em 0 0.3em;
  font-size: 1em;
  border-bottom: 1px dashed var(--window-fg);
  padding-bottom: 0.15em;
}
.lb-empty { margin: 0.2em 0 0; opacity: 0.85; font-size: 0.9em; }

/* Music — discography list inside the Music window */
.window-body .mu-intro,
.window-body .mu-album,
.window-body .mu-lyric-meta { font-size: 0.85em; }

.mu-intro { opacity: 0.85; margin: 0 0 1em; }

.mu-album { margin: 0 0 1em; }
.mu-album-h {
  display: flex;
  align-items: baseline;
  gap: 0.6em;
  flex-wrap: wrap;
  border-bottom: 1px dashed var(--window-fg);
  padding-bottom: 0.1em;
  margin-bottom: 0.25em;
}
.mu-album-h h3 { margin: 0.1em 0; font-size: 1em; }
.mu-album-meta { font-size: 0.85em; opacity: 0.8; }

.mu-tracks {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}
.mu-track {
  display: grid;
  grid-template-columns: 1.4em 1.5em 1fr auto;
  align-items: center;
  gap: 0.4em;
  padding: 0.12em 0;
}
.mu-track.is-playing {
  background: var(--window-fg);
  color: var(--window-bg);
}
.mu-track.is-playing .link-btn { color: inherit; }

.mu-play {
  padding: 0 0.15em;
  background: transparent;
  color: inherit;
  border: 0;
  font: inherit;
  font-size: 1em;
  line-height: 1;
  cursor: pointer;
  text-align: left;
}
.mu-play:hover { opacity: 0.7; }

.mu-num { font-variant-numeric: tabular-nums; opacity: 0.7; font-size: 0.85em; text-align: right; }
.mu-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mu-no-lyrics { opacity: 0.4; font-size: 0.85em; padding: 0 0.3em; }
.mu-lyric-btn { font-size: 0.9em; }

/* Lyrics view */
.mu-lyric-title { margin: 0.2em 0 0.1em; }
.mu-lyric-meta { margin: 0 0 0.6em; opacity: 0.8; }
.mu-lyrics {
  font-family: inherit;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: transparent;
  border: 1px dashed var(--window-fg);
  padding: 0.7em 0.9em;
  line-height: 1.4;
  margin: 0;
  font-size: 0.9em;
}

/* Hide the SIDE A / SIDE B chooser when a specific discography track has
   taken over the bottom player. */
.player.track-mode .player-sides { display: none; }

/* Admin window (artist-only) */
.admin-meta { font-size: 0.85em; opacity: 0.8; margin: 0 0 1em; }
.admin-stats {
  list-style: none;
  padding: 0;
  margin: 0.4em 0 1em;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.3em 1.2em;
}
.admin-stats li { line-height: 1.5; }
.admin-stats b { font-size: 1.05em; }
.admin-stats .hint { opacity: 0.6; font-size: 0.85em; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.4em 0 1.2em;
  font-size: 0.9em;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 0.3em 0.6em;
  border-bottom: 1px dashed var(--window-fg);
}
.admin-table th { font-weight: 700; opacity: 0.85; }
.admin-table td em { opacity: 0.6; }

/* News */
.news-post {
  padding: 0.6em 0 0.8em;
  border-bottom: 1px dashed var(--window-fg);
}
.news-post:last-child { border-bottom: 0; }
.news-title { margin: 0 0 0.15em; }
.news-meta { margin: 0 0 0.5em; font-size: 0.8em; opacity: 0.7; }
.news-body { white-space: normal; }
.news-actions { margin: 0.5em 0 0; font-size: 0.85em; opacity: 0.85; }
.news-actions .link-btn { margin-right: 0.8em; }

/* ===== Newsletter signup overlay (Substack-style, first visit) ===== */
.newsletter-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1em;
  background: rgba(0, 0, 0, 0.8);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: nl-fade 0.25s ease;
}
.newsletter-overlay[hidden] { display: none; }

@keyframes nl-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes nl-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.newsletter-modal {
  width: 100%;
  max-width: 520px;
  background: var(--window-bg);
  color: var(--window-fg);
  border: 1px solid var(--window-fg);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.5), 0 0 24px rgba(3, 158, 75, 0.25);
  font-family: "Monaco", "Menlo", "Courier New", monospace;
  animation: nl-pop 0.3s ease both;
}

.newsletter-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--window-fg);
  color: var(--window-bg);
  padding: 0.2em 0.5em;
  font-weight: bold;
  background-image: repeating-linear-gradient(
    to bottom,
    var(--window-fg) 0, var(--window-fg) 1px,
    transparent 1px, transparent 3px
  );
}
.newsletter-title {
  background: var(--window-fg);
  color: var(--window-bg);
  padding: 0 0.5em;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.newsletter-close {
  background: var(--window-bg);
  color: var(--window-fg);
  border: 1px solid var(--window-fg);
  width: 1.5em;
  height: 1.5em;
  cursor: pointer;
  font-weight: bold;
  line-height: 1;
  font-size: 0.9em;
}

.newsletter-body { padding: 1em 1.1em 1.1em; }
.newsletter-blurb {
  margin: 0 0 0.9em;
  line-height: 1.5;
  color: var(--crt-fg-soft, var(--window-fg));
}
.newsletter-embed {
  display: block;
  width: 100%;
  border: none;
  border-radius: 16px;
}
.newsletter-decline {
  display: block;
  margin: 0.9em auto 0;
  background: none;
  border: none;
  color: var(--crt-fg-soft, var(--window-fg));
  font-family: inherit;
  font-size: 0.85em;
  cursor: pointer;
  opacity: 0.8;
  text-decoration: underline;
}
.newsletter-decline:hover { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .newsletter-overlay,
  .newsletter-modal { animation: none; }
}
