:root {
  --bg: #0d0c10;
  --ink: #efe7da;
  --muted: #a79f93;
  --accent: #e8b36a;
  --panel: rgba(18, 16, 22, 0.72);
  --line: rgba(239, 231, 218, 0.14);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#life {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  transition: opacity 0.8s ease;
}
body:not([data-view="home"]) #life { opacity: 0.35; }

#app {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px 20px 96px;
  pointer-events: none;          /* clicks fall through to the game... */
}
.view { pointer-events: auto; text-align: center; animation: rise 0.5s ease both; } /* ...except on the UI */
.view[hidden] { display: none; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

h1 {
  font: 400 clamp(44px, 10vw, 112px)/1 var(--serif);
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  text-shadow: 0 0 40px rgba(13, 12, 16, 0.9);
}
h2 { font: 400 28px/1.2 var(--serif); margin: 0 0 20px; }

.hint { color: var(--muted); margin: 0 0 28px; text-shadow: 0 0 12px var(--bg); }

.actions { display: flex; gap: 14px; align-items: center; justify-content: center; }

/* a soft dark halo behind the home text so it stays readable over the cells */
.view[data-view="home"] {
  padding: 48px 72px;
  background: radial-gradient(closest-side, rgba(13, 12, 16, 0.92), rgba(13, 12, 16, 0.75) 60%, transparent);
}

.view[data-view="home"] .ghost { background: rgba(13, 12, 16, 0.6); transition: border-color 0.15s ease, background 0.15s ease; }
.view[data-view="home"] .ghost:hover { background: rgba(13, 12, 16, 0.85); }

.panel {
  width: min(440px, 100%);
  padding: 32px 28px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

button, input { font: inherit; color: inherit; }

.primary {
  background: var(--accent);
  color: #1a140b;
  border: 0;
  border-radius: 999px;
  padding: 10px 22px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.primary:hover { filter: brightness(1.08); }
.primary:active { transform: scale(0.97); }

.link {
  background: none;
  border: 0;
  padding: 4px 0;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  border-bottom: 1px solid transparent;
}
.link:hover { color: var(--ink); border-bottom-color: var(--line); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

form { display: flex; gap: 10px; margin-bottom: 14px; }
#code {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
#code::placeholder { color: #6d675f; }

.error { color: #f0a08a; margin: 0 0 14px; }
.shake { animation: shake 0.35s ease; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.songs { list-style: none; margin: 0 0 20px; padding: 0; text-align: left; counter-reset: n; }
.songs li { counter-increment: n; display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--line); }
.songs li:last-child { border-bottom: 1px solid var(--line); }
.songs .song {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 14px;
  align-items: baseline;
  background: none;
  border: 0;
  padding: 12px 6px;
  text-align: left;
  cursor: pointer;
}
.songs .song::before { content: counter(n, decimal-leading-zero); color: var(--muted); font-variant-numeric: tabular-nums; }
.songs .song:hover { color: var(--accent); }
.songs .song[aria-current="true"] { color: var(--accent); }
.songs .song[aria-current="true"]::after { content: "♪"; margin-left: auto; }
.songs .tool {
  flex: none;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.songs .tool:hover { color: var(--ink); background: rgba(239, 231, 218, 0.07); }
.songs .empty { color: var(--muted); padding: 12px 6px; }

/* long content (lyrics, many songs) scrolls inside the panel */
.panel { max-height: calc(100dvh - 140px); overflow-y: auto; overscroll-behavior: contain; }
.panel.wide { width: min(560px, 100%); }
.back { display: inline-block; margin-bottom: 10px; }
.lyrics-actions { display: flex; gap: 12px; justify-content: center; align-items: center; margin-bottom: 24px; }
.ghost {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid rgba(239, 231, 218, 0.45);
  border-radius: 999px;
  padding: 9px 22px;
}
.ghost:hover { border-color: var(--ink); }

.lyrics { text-align: center; font: 17px/1.65 var(--serif); }
.lyrics h3 {
  font: 600 11px/1 var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 28px 0 10px;
}
.lyrics h3:first-child { margin-top: 0; }
.lyrics p { margin: 0 0 14px; }
.lyrics .instrumental { color: var(--muted); font-style: italic; }

.row { display: flex; justify-content: space-between; }

#player {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(560px, calc(100% - 32px));
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px 10px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: rise 0.4s ease both;
}
#player[hidden] { display: none; }
#toggle {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #1a140b;
  cursor: pointer;
  font-size: 14px;
}
.track { flex: 1; min-width: 0; display: grid; gap: 2px; }
#now { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

#seek { width: 100%; height: 14px; margin: 0; accent-color: var(--accent); background: transparent; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  .view, #player { animation: none; }
}

/* =========================================================
   Home page party: intro → cake → finale, and words
   ========================================================= */

/* the normal home content only shows once the party is over */
body:not([data-scene="free"]) .view[data-view="home"] { display: none; }
body[data-scene="intro"] #player { display: none; }

/* --- intro: the "update 6.3" terminal --- */
#intro {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  justify-items: start;
  gap: 28px;
  padding: 24px;
  background: rgba(13, 12, 16, 0.96);
  cursor: default;
}
#intro[hidden] { display: none; }
.term {
  width: min(640px, 92vw);
  font: clamp(11.5px, 3.2vw, 15px)/1.75 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  white-space: pre;
  color: var(--ink);
}
.term .dim { color: var(--muted); }
.term .hi { color: var(--accent); }
.term .ok { color: #a8d8a0; }
.term .bar span { color: var(--accent); }
#launch { justify-self: center; font-size: 17px; padding: 12px 28px; animation: rise 0.4s ease both, pulse 2s ease-in-out 0.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(232, 179, 106, 0.12); } }
.skip { position: fixed; right: 24px; bottom: 20px; }

/* --- cake caption (top of the screen; clicks go through to the cake) --- */
#cake-ui {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  width: min(560px, calc(100% - 32px));
  text-align: center;
  pointer-events: none;
  display: none;
}
body[data-scene="cake"][data-view="home"] #cake-ui { display: block; animation: rise 0.5s ease both; }
.cake-title { font: 400 clamp(26px, 5vw, 40px)/1.1 var(--serif); margin: 0 0 6px; text-shadow: 0 0 24px var(--bg); }
.cake-count { color: var(--muted); margin: 0 0 12px; min-height: 1.5em; text-shadow: 0 0 12px var(--bg); }
.cake-actions { display: flex; gap: 16px; justify-content: center; align-items: center; }
.cake-actions button { pointer-events: auto; }
#cake-ui .ghost { background: rgba(13, 12, 16, 0.7); font-size: 14px; padding: 7px 16px; }
#mic.on { border-color: var(--accent); color: var(--accent); animation: pulse 1.2s ease-in-out infinite; }

/* --- finale --- */
#finale {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  justify-items: center;
  align-items: start;
  padding: max(20px, 6vh) 16px 24px;   /* above the cake, so both stay visible */
  pointer-events: none;
}
#finale[hidden] { display: none; }
body:not([data-view="home"]) #finale { display: none; }
.finale-box {
  pointer-events: auto;
  text-align: center;
  padding: 28px 36px 30px;
  max-width: 720px;
  background: rgba(13, 12, 16, 0.86);
  border: 1px solid var(--line);
  border-radius: 20px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: rise 0.6s ease both;
}
.finale-box h1 { font-size: clamp(36px, 7vw, 76px); margin-bottom: 14px; color: var(--accent); }
.finale-box p { margin: 0 0 8px; }
.finale-box .total { color: var(--muted); min-height: 1.5em; margin-bottom: 22px; }

/* --- words + relight on the free home page --- */
.word { display: flex; gap: 8px; justify-content: center; margin: 0 auto 22px; max-width: 360px; }
.word input {
  flex: 1;
  min-width: 0;
  background: rgba(13, 12, 16, 0.7);
  border: 1px solid rgba(239, 231, 218, 0.3);
  border-radius: 999px;
  padding: 9px 18px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.word input::placeholder { color: #6d675f; }
.word .ghost { cursor: pointer; background: rgba(13, 12, 16, 0.7); }
.relight { margin-top: 18px; font-size: 14px; }
