:root {
  --fade: 700ms;
  --hud-bg: rgba(0, 0, 0, 0.55);
  --hud-fg: #fff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: #fff;
  overflow: hidden;
  font-family: Calibri, Carlito, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#viewport {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
}

/* 16:9 stage, letterboxed. Container units let text scale with the slide. */
#stage {
  position: relative;
  width: min(100vw, 100dvh * 16 / 9);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  container-type: size;
  background: #000;
}

.slide {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--fade) ease;
  pointer-events: none;
}
.slide.active { opacity: 1; z-index: 2; pointer-events: auto; }
.slide.leaving { opacity: 0; z-index: 1; }
.slide.cut { transition: none; }

.el {
  position: absolute;
  overflow: hidden;
}
.el > .mv, .el .sc { position: absolute; inset: 0; }
.el.visible-overflow { overflow: visible; }

.el img, .el video {
  position: absolute;
  display: block;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}

.txt {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: visible;
}
.txt.anchor-t { justify-content: flex-start; }
.txt.anchor-ctr { justify-content: center; }
.txt.anchor-b { justify-content: flex-end; }

/* 1pt = slide height / 540 */
.txt p {
  margin: 0;
  line-height: 1.2;
  position: relative;
}
.txt p.title { line-height: 0.9; }
.txt p.bullet::before {
  content: "•";
  position: absolute;
  margin-left: calc(-228600 / 12192000 * 100cqw);
}
.txt p.gap-before { margin-top: calc(10 * 100cqh / 540); }
.font-title { font-family: "Calibri Light", Carlito, Calibri, sans-serif; }
.font-titillium { font-family: "Titillium Web", sans-serif; }

/* HUD */
#hud {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px;
  border-radius: 999px;
  background: var(--hud-bg);
  backdrop-filter: blur(8px);
  color: var(--hud-fg);
  font: 13px/1 system-ui, sans-serif;
  z-index: 20;
  opacity: 0;
  transition: opacity 300ms;
}
body.show-hud #hud, #hud:hover, #hud:focus-within { opacity: 1; }
#hud button {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  font-size: 16px;
  cursor: pointer;
}
#hud button:hover { background: rgba(255, 255, 255, 0.15); }
#counter { min-width: 56px; text-align: center; font-variant-numeric: tabular-nums; }

#progress {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  z-index: 19;
  opacity: 0;
  transition: opacity 300ms;
}
body.show-hud #progress { opacity: 1; }
#progress > div { height: 100%; background: rgba(255, 255, 255, 0.7); width: 0; transition: width 300ms; }

/* Start overlay */
#start {
  position: fixed;
  inset: auto 0 0 0;
  padding: 0 16px 9vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  z-index: 30;
  pointer-events: none;
  transition: opacity 500ms;
}
#start.gone { opacity: 0; }
#start-btn {
  pointer-events: auto;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  color: #fff;
  font: 600 18px/1 "Titillium Web", sans-serif;
  letter-spacing: 0.02em;
  padding: 14px 28px;
  border-radius: 999px;
  cursor: pointer;
}
#start-btn:hover { background: rgba(255, 255, 255, 0.15); }
#start p {
  margin: 0;
  font: 13px/1.4 system-ui, sans-serif;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
}

/* Overview grid */
#grid {
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.92);
  padding: 24px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  align-content: start;
}
#grid[hidden] { display: none; }
#grid button {
  appearance: none;
  border: 2px solid transparent;
  padding: 0;
  background: #111;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  color: #fff;
}
#grid button.current { border-color: #fff; }
#grid button img { width: 100%; height: 100%; object-fit: cover; display: block; }
#grid button span {
  position: absolute;
  left: 6px; bottom: 4px;
  font: 600 12px/1.2 system-ui, sans-serif;
  text-shadow: 0 1px 3px #000;
  text-align: left;
}

@media (max-width: 600px) {
  #hud { right: 8px; bottom: 8px; }
  #hud button { width: 28px; height: 28px; font-size: 14px; }
}
