:root {
  --dusk-top: #2e1a36;
  --dusk-mid: #5a3058;
  --dusk-low: #8a4f6e;
  --beam: rgba(255, 210, 170, .12);
  --sparkle: #fff1d6;
  --paper: #fbeed7;
  --paper-line: #e7c9a0;
  --wood: #7a4b32;
  --wood-dark: #3d2418;
  --ink: #4a2a1e;
  --muted: #9a6b52;
  --hover: #f4d9bf;
  --field: #fffaf0;
  --heart: #e0679a;
  --error: #b8432f;
  --font-pixel: "VT323", monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 50% 115%, #c97a8e 0%, transparent 55%),
    linear-gradient(180deg, var(--dusk-top), var(--dusk-mid) 60%, var(--dusk-low));
  color: var(--ink);
  font-family: "Silkscreen", monospace;
}

button { font: inherit; cursor: pointer; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── Scenery: out-of-focus background ─────────────── */

.scenery { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }

.beam {
  position: absolute;
  inset: -20% -10% auto 20%;
  height: 140%;
  background: linear-gradient(115deg, transparent 30%, var(--beam) 42%, transparent 58%);
  filter: blur(8px);
}

.bokeh span {
  position: absolute;
  width: var(--size);
  height: var(--size);
  background: var(--color);
  opacity: .35;
  filter: blur(14px);
  animation: drift var(--speed) ease-in-out infinite alternate;
}

.dust span {
  position: absolute;
  width: 3px;
  height: 3px;
  background: var(--sparkle);
  box-shadow: 3px 0 0 var(--sparkle), -3px 0 0 var(--sparkle), 0 3px 0 var(--sparkle), 0 -3px 0 var(--sparkle);
  animation: twinkle var(--speed) ease-in-out infinite;
}

@keyframes drift { to { transform: translate(30px, -20px); } }

@keyframes twinkle {
  0%, 100% { opacity: 0; transform: scale(.4); }
  50% { opacity: .8; transform: scale(1); }
}

/* ── Stage ────────────────────────────────────────── */

.stage {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: center;
  justify-content: center;
  gap: 40px;
  padding: 24px 16px;
}

.device { position: relative; line-height: 0; }

.pixels { image-rendering: pixelated; display: block; }

.bloom {
  position: absolute;
  inset: 0;
  pointer-events: none;
  filter: blur(8px) contrast(1.8) brightness(.85);
  mix-blend-mode: screen;
  opacity: .4;
}

/* ── Video window: pixel CRT ──────────────────────── */

.tv { position: relative; line-height: 0; }

.tv-screen {
  position: absolute;
  background: #000;
  overflow: hidden;
}

.tv-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(180deg, rgba(0, 0, 0, .22) 0 2px, transparent 2px 4px);
}

.tv-screen iframe { width: 100%; height: 100%; display: block; }

/* ── Booklet: JRPG menu window ────────────────────── */

.booklet {
  width: min(92vw, 460px);
  max-height: 80vh;
  padding: 0;
  border: 4px solid var(--wood);
  outline: 3px solid var(--wood-dark);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: inset 0 0 0 3px var(--paper-line), 8px 8px 0 rgba(30, 8, 25, .45);
  display: none;
  flex-direction: column;
}

.booklet[open] { display: flex; }

.booklet::backdrop { background: rgba(40, 14, 36, .55); backdrop-filter: blur(4px); }

.booklet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px 0;
  margin: 0;
}

.tabs { display: flex; gap: 4px; }

.tab, .close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 6px 10px;
}

.tab { white-space: nowrap; }

.tab[aria-selected="true"] { color: var(--ink); }

.tab[aria-selected="true"]::before { content: "♥ "; color: var(--heart); }

.close { font-size: 14px; color: var(--ink); }

.search {
  border: 3px solid var(--paper-line);
  border-radius: 4px;
  background: var(--field);
  color: var(--ink);
  font-family: var(--font-pixel);
}

.search:focus { outline: 2px solid var(--heart); outline-offset: 1px; }

.search { margin: 10px 12px; padding: 8px 10px; font-size: 22px; }

.search::placeholder { color: var(--muted); }

.add { display: flex; flex-direction: column; }

.add-row { display: flex; gap: 8px; margin: 10px 12px 0; }

.add-row .search { flex: 1; min-width: 0; margin: 0; }

.genres { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 12px 10px; }

.chip {
  padding: 2px 8px;
  border: 2px solid var(--paper-line);
  border-radius: 999px;
  background: var(--field);
  color: var(--muted);
  font: 18px var(--font-pixel);
}

.chip[aria-pressed="true"] { border-color: var(--heart); background: var(--heart); color: var(--paper); }

.go {
  padding: 6px 12px;
  border: 3px solid var(--wood-dark);
  border-radius: 4px;
  background: var(--wood);
  color: var(--paper);
  font-size: 11px;
  box-shadow: inset 0 -3px 0 var(--wood-dark);
}

.go:hover, .go:focus-visible { background: var(--heart); outline: none; }

.go:active { box-shadow: none; transform: translateY(2px); }

.add-help { margin: 10px 14px 0; font: 18px var(--font-pixel); line-height: 1.1; color: var(--muted); }

.add-status { margin: 8px 14px 6px; font: 18px var(--font-pixel); color: var(--muted); }

.add-status[data-mood="error"] { color: var(--error); }

.add-status[data-mood="ok"] { color: var(--heart); }

.album:disabled { cursor: default; opacity: .6; }

.albums {
  list-style: none;
  margin: 0;
  padding: 0 6px 10px;
  overflow-y: auto;
}

.album {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.album:not(:disabled):hover, .album:focus-visible { background: var(--hover); outline: none; }

.album:not(:disabled):hover .album-title::before, .album:focus-visible .album-title::before { content: "♥ "; color: var(--heart); }

.album img {
  width: 48px;
  height: 48px;
  border: 2px solid var(--wood);
  flex: none;
}

.album-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.album-title { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.album-meta { font: 18px var(--font-pixel); color: var(--muted); }

.list-heading { padding: 10px 8px 4px; font: 18px var(--font-pixel); color: var(--muted); }

.empty { padding: 20px; text-align: center; font: 20px var(--font-pixel); color: var(--muted); }

@media (max-width: 560px) {
  .stage { gap: 24px; }
  .tab { padding: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .bokeh span, .dust span { animation: none; }
}

.tab[data-tab="add"] { display: none; }
