:root {
  --ink: #fffaf0;
  --ink-soft: rgba(255, 250, 240, 0.72);
  --glass: rgba(12, 16, 30, 0.42);
  --glass-line: rgba(255, 255, 255, 0.12);
  --open: #7be0a0;
  --pre: #ffd27a;
  --closed: #ff8f8f;
  --display: 'Fredoka', system-ui, sans-serif;
  --body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; }
body { background: #0b0f1a; color: var(--ink); font-family: var(--body); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { opacity: 0.4; cursor: default; }
svg { width: 20px; height: 20px; fill: currentColor; }

/* ---- stage ---- */
#stage, .layer, #fx, .vignette { position: fixed; inset: 0; }
.layer { opacity: 0; transition: opacity 2.5s ease; overflow: hidden; }
.layer.on { opacity: 1; }
.layer > img, .layer > canvas {
  width: 100%; height: 100%; object-fit: cover; display: block;
  animation: drift 90s ease-in-out infinite alternate;
}
@keyframes drift { from { transform: scale(1.02) translate(0, 0); } to { transform: scale(1.1) translate(-1.5%, -1%); } }
#fx { width: 100%; height: 100%; pointer-events: none; }
/* edge vignette + soft scrims behind the title and the quote/controls so white text holds up on bright scenes */
.vignette {
  pointer-events: none;
  background:
    radial-gradient(ellipse 45% 22% at 50% 47%, rgba(0, 0, 0, 0.28), transparent),
    linear-gradient(to top, rgba(0, 0, 0, 0.4), transparent 32%),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.45));
}

/* ---- hero ---- */
.hero {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 0 16px; pointer-events: none;
}
.hero > * { pointer-events: auto; }
h1 {
  font-family: var(--display); font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase;
  font-size: clamp(2.4rem, 8vw, 6.5rem); line-height: 1;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15), 0 6px 30px rgba(0, 0, 0, 0.35);
  transition: opacity 0.6s ease;
  /* full-width own layer: Safari otherwise repaints only the new, narrower title and leaves the old title's edges behind */
  align-self: stretch; will-change: opacity;
}
.subtitle {
  font-family: var(--display); font-weight: 500; text-transform: uppercase; letter-spacing: 0.35em;
  font-size: clamp(0.9rem, 2vw, 1.4rem); margin-top: 0.8rem; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55), 0 2px 16px rgba(0, 0, 0, 0.45);
}
.tune-in {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 2.2rem;
  padding: 14px 28px 14px 22px; border-radius: 999px;
  background: var(--ink); color: #141826; font-weight: 500; font-size: 1.05rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35); transition: transform 0.2s ease, opacity 0.6s ease;
}
.tune-in:hover { transform: scale(1.04); }
.started .tune-in { opacity: 0; pointer-events: none; }

.quote {
  position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%);
  width: min(720px, calc(100% - 32px)); text-align: center; transition: opacity 0.9s ease;
}
.quote blockquote {
  font-family: var(--display); font-weight: 500; font-size: clamp(1rem, 2.2vw, 1.45rem); line-height: 1.4;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
}
.quote figcaption { margin-top: 6px; font-size: 0.8rem; color: var(--ink-soft); text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5); }
.fade { opacity: 0 !important; }

/* ---- chrome ---- */
.chrome { position: fixed; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; transition: opacity 0.8s ease; }
.top { top: 0; }
.bottom { bottom: 0; }
.idle.playing .chrome { opacity: 0; }
.idle.playing { cursor: none; }

.brand { font-family: var(--display); font-weight: 600; font-size: 1.5rem; letter-spacing: 0.02em; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4); }
.brand span { color: var(--open); }
.brand .by { font-family: var(--mono, ui-monospace, monospace); font-weight: 500; font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: inherit; opacity: 0.7; text-decoration: none; margin-left: 0.6rem; vertical-align: middle; }
.brand .by:hover { opacity: 1; text-decoration: underline; }
.market {
  font-size: 0.85rem; padding: 8px 14px 8px 12px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--glass-line); backdrop-filter: blur(12px);
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.market::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--closed); }
.market[data-state='open']::before { background: var(--open); box-shadow: 0 0 10px var(--open); }
.market[data-state='pre']::before, .market[data-state='post']::before { background: var(--pre); }

.player, .scene-nav, .tools {
  display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--glass-line); backdrop-filter: blur(12px);
}
.player button, .scene-nav button, .tools button { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; }
.player button:not(:disabled):hover, .scene-nav button:hover, .tools button:hover { background: rgba(255, 255, 255, 0.12); }
#play .i-pause, .playing #play .i-play { display: none; }
.playing #play .i-pause { display: block; }
.scene-nav svg, .tools svg, .line svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.timer {
  display: inline-flex; align-items: center; gap: 8px; height: 54px; padding: 0 16px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--glass-line); backdrop-filter: blur(12px);
  font-variant-numeric: tabular-nums; font-size: 0.9rem; white-space: nowrap;
}
.timer:hover { background: rgba(255, 255, 255, 0.12); }
.timer[data-phase='focus'] { border-color: rgba(123, 224, 160, 0.5); }
.timer[data-phase='break'] { border-color: rgba(255, 210, 122, 0.5); }
.timer.ring { animation: ring 1.2s ease 3; }
@keyframes ring { 50% { background: rgba(255, 255, 255, 0.35); } }
.market[data-state='power']::before { background: var(--pre); box-shadow: 0 0 10px var(--pre); }
.now { padding: 0 14px 0 6px; min-width: 0; }
#trackName { font-weight: 500; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#trackMeta { font-size: 0.75rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dots { display: flex; gap: 6px; padding: 0 4px; }
.dots button { width: 8px !important; height: 8px !important; padding: 0; background: rgba(255, 255, 255, 0.35) !important; }
.dots button.on { background: var(--ink) !important; width: 22px !important; border-radius: 999px; }
.tools input { width: 100px; accent-color: var(--ink); margin: 0 6px 0 10px; }

@media (max-width: 720px) {
  .dots, .tools { display: none; }
  .timer { padding: 0 14px; }
  .timer:not([data-phase]) span { display: none; }
  /* two rows: player full width so the track name has room, scene arrows + timer below */
  .bottom { flex-wrap: wrap; row-gap: 8px; }
  .player { flex: 1 1 100%; min-width: 0; }
  .quote { bottom: 160px; }
  .chrome { padding: 12px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .layer > img, .layer > canvas { animation: none; }
}
