:root {
  --bg: #1b1418;
  --bg-elevated: #241c21;
  --fg: #f4efe6;
  --fg-muted: #c4b8a8;
  --fg-subtle: #8a8078;
  --accent: #f4efe6;
  --accent-fg: #1b1418;
  --border: color-mix(in oklab, var(--fg) 14%, transparent);
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-body: "Segoe UI", system-ui, -apple-system, sans-serif;
  --motion-quick: 150ms;
  --motion-fast: 250ms;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --letterbox: #1b1418;
}

html,
body,
#venue-root,
.venue-host {
  margin: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  touch-action: none;
}

#venue-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#overlay-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
}

/*
 * Landing is a thin glass strip at the extreme bottom — never a centered
 * dashboard. The garden stays fully visible on desktop and phone.
 */
.landing {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  height: auto;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  pointer-events: none;
  background: transparent;
  padding: 0 var(--space-3) max(10px, env(safe-area-inset-bottom));
  z-index: 12;
}

.landing-card {
  pointer-events: auto;
  width: min(520px, calc(100% - 16px));
  padding: 8px 10px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--bg) 42%, transparent);
  border: 1px solid color-mix(in oklab, var(--fg) 18%, transparent);
  box-shadow: 0 6px 22px color-mix(in oklab, var(--bg) 28%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.landing-card .kicker,
.landing-card h1,
.landing-card .sub,
.landing-card .date,
.landing-card .hint,
.landing-card .kit-link {
  display: none !important;
}

.landing-card button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  flex: 1 1 0;
  min-width: 0;
  min-height: 40px;
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.15;
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
  transition: transform var(--motion-quick) var(--ease-out), opacity var(--motion-quick) var(--ease-out);
}

.landing-card button.ghost {
  background: color-mix(in oklab, var(--fg) 10%, transparent);
  color: var(--fg);
  border: 1px solid var(--border);
}

.landing-card button.text-link {
  flex: 1 0 100%;
  background: transparent;
  color: var(--fg-muted);
  min-height: 24px;
  padding: 0 4px 2px;
  font-size: 0.68rem;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
  border: 0;
}

.landing-card button:active {
  transform: scale(0.98);
}

.landing.is-hidden,
.hud.is-hidden,
.sky-toggle.is-hidden,
.prompt.is-hidden,
.album.is-hidden,
.guestbook.is-hidden,
.fallback-player.is-hidden,
.rotate-hint.is-hidden {
  display: none !important;
}

/* Hide touch pads while the bottom bar is up so they cannot cover it */
.landing:not(.is-hidden) ~ #touch-stick,
.landing:not(.is-hidden) ~ #touch-jump {
  display: none !important;
}

/* Sky period toggle — top centre, sibling of HUD */
.sky-toggle {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 14;
  pointer-events: auto;
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--bg) 55%, transparent);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.sky-toggle button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fg-muted);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 999px;
  min-height: 32px;
  cursor: pointer;
}

.sky-toggle button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-fg);
}

/* HUD */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hud-top-left {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.hud-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
}

.hud-diyas {
  font-size: 0.75rem;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.hud-walk {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  pointer-events: auto;
}

.hud-walk button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  background: color-mix(in oklab, var(--bg) 55%, transparent);
  color: var(--fg);
  border: 1px solid var(--border);
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Rotate hint — dismissible top banner, never a blocking gate */
.rotate-hint {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(420px, calc(100% - 24px));
  padding: 8px 12px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--bg) 72%, transparent);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--fg);
}

.rotate-hint button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fg-muted);
  font-size: 1rem;
  min-width: 32px;
  min-height: 32px;
  cursor: pointer;
}

/* Cinematic prompt */
.prompt {
  position: absolute;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: min(320px, calc(100% - 24px));
  padding: 12px 14px;
  border-radius: 16px;
  background: color-mix(in oklab, var(--bg) 72%, transparent);
  border: 1px solid var(--border);
  text-align: center;
}

.prompt p {
  margin: 0;
  font-size: 0.9rem;
}

.prompt button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  min-height: 44px;
  padding: 8px 18px;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
}

/* Letterbox bars while LIVE */
.letterbox {
  position: absolute;
  left: 0;
  right: 0;
  background: var(--letterbox);
  pointer-events: none;
  z-index: 9;
}
.letterbox.top {
  top: 0;
}
.letterbox.bottom {
  bottom: 0;
}

/* Touch controls */
#touch-stick {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(72px, calc(env(safe-area-inset-bottom) + 58px));
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: color-mix(in oklab, var(--fg) 12%, transparent);
  border: 1px solid var(--border);
  pointer-events: auto;
  z-index: 11;
  display: none;
}
#touch-stick .knob {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: color-mix(in oklab, var(--fg) 55%, transparent);
  left: 28px;
  top: 28px;
}
#touch-jump {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(72px, calc(env(safe-area-inset-bottom) + 58px));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg) 70%, transparent);
  color: var(--fg);
  pointer-events: auto;
  z-index: 11;
  display: none;
  font-size: 0.7rem;
}

@media (pointer: coarse) {
  #touch-stick,
  #touch-jump {
    display: block;
  }
}

/* Guestbook / album */
.guestbook,
.album,
.fallback-player {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: auto;
  background: color-mix(in oklab, var(--bg) 55%, transparent);
  z-index: 18;
}

.guestbook-card,
.album-card {
  width: min(420px, calc(100% - 24px));
  padding: 20px;
  border-radius: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.guestbook-card h2,
.album-card h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.guestbook-card textarea,
.guestbook-card input {
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
}

.guestbook-card button,
.album-card button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  min-height: 44px;
  padding: 8px 16px;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
}

.fallback-player video {
  width: min(960px, 100%);
  max-height: 80vh;
  background: #000;
}

.fallback-player .close {
  position: absolute;
  top: 12px;
  right: 12px;
  min-height: 40px;
}

/* Builder */
.is-builder body,
html.is-builder {
  overflow: auto;
  touch-action: auto;
}
#builder-root {
  position: absolute;
  inset: 0;
  overflow: auto;
  pointer-events: auto;
  z-index: 20;
  background: var(--bg);
  color: var(--fg);
  padding: 24px 16px 48px;
  font-family: var(--font-body);
}
#builder-root h1 {
  font-family: var(--font-display);
}
#builder-root label {
  display: block;
  margin: 8px 0 4px;
  color: var(--fg-muted);
  font-size: 0.85rem;
}
#builder-root input,
#builder-root textarea {
  width: min(480px, 100%);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--fg);
}
#builder-root .steps {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
#builder-root .steps button[aria-current="step"] {
  background: var(--accent);
  color: var(--accent-fg);
}

@media (max-width: 600px) {
  .landing {
    padding: 0 8px max(8px, env(safe-area-inset-bottom));
  }
  .landing-card {
    width: calc(100% - 8px);
    border-radius: 18px;
    padding: 8px;
    gap: 6px;
  }
  .landing-card button:not(.text-link) {
    min-height: 44px;
    font-size: 0.74rem;
    padding: 8px 10px;
  }
  .sky-toggle {
    top: max(56px, calc(env(safe-area-inset-top) + 48px));
    width: min(360px, calc(100% - 16px));
  }
  .sky-toggle button {
    flex: 1;
    padding: 8px 6px;
    font-size: 0.8rem;
  }
  .hud-walk {
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    bottom: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
