:root {
  --bg: #120c09;
  --ink: #f3e8d6;
  --ink-soft: rgba(243, 232, 214, 0.72);
  --pill: rgba(24, 16, 12, 0.62);
  --pill-strong: rgba(58, 36, 22, 0.86);
  --edge: rgba(255, 214, 160, 0.22);
  --warm: #e8b77a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}

body {
  position: fixed;
  inset: 0;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
  cursor: grab;
}

#scene:active {
  cursor: grabbing;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(8, 4, 2, 0.55) 100%);
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding: calc(14px + var(--safe-t)) calc(16px + var(--safe-r)) calc(18px + var(--safe-b)) calc(16px + var(--safe-l));
}

#phase-slot {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#phase-slot > * {
  pointer-events: auto;
}

.pill {
  font: 500 15px/1.3 var(--sans);
  color: var(--ink);
  background: var(--pill);
  border: 1px solid var(--edge);
  border-radius: 999px;
  padding: 10px 18px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.hint {
  position: absolute;
  top: calc(14px + var(--safe-t));
  left: 50%;
  transform: translate(-50%, -6px);
  max-width: calc(100% - 32px - var(--safe-l) - var(--safe-r));
  text-align: center;
  text-wrap: balance;
  color: var(--ink-soft);
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.hint.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.fps {
  position: absolute;
  top: calc(12px + var(--safe-t));
  right: calc(12px + var(--safe-r));
  padding: 4px 10px;
  font: 600 12px/1.2 ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--warm);
}

.actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(22px + var(--safe-b));
  display: flex;
  justify-content: center;
  gap: 12px;
}

.btn {
  pointer-events: none;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.45s ease, transform 0.45s ease, background 0.2s ease;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
}

.btn.show {
  pointer-events: auto;
  opacity: 1;
  transform: none;
}

.btn.primary {
  font: 600 18px/1.2 var(--serif);
  letter-spacing: 0.01em;
  padding: 14px 30px;
  min-height: 52px;
  background: var(--pill-strong);
  border-color: rgba(255, 200, 140, 0.45);
  box-shadow: 0 0 0 0 rgba(232, 183, 122, 0.4), 0 6px 24px rgba(0, 0, 0, 0.35);
}

.btn.primary.show {
  animation: breathe 3.2s ease-in-out infinite;
}

.btn.quiet {
  font-size: 14px;
  padding: 9px 18px;
  min-height: 40px;
}

.btn:hover {
  background: rgba(80, 50, 30, 0.9);
}

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

@keyframes breathe {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(232, 183, 122, 0.35), 0 6px 24px rgba(0, 0, 0, 0.35);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(232, 183, 122, 0), 0 6px 24px rgba(0, 0, 0, 0.35);
  }
}

/* seat/stand buttons only (entry button is always visible) */
#stand-btn:not(.show),
#seat-btn:not(.show) {
  position: absolute;
}

/* ---------- entry overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-t)) calc(16px + var(--safe-r)) calc(24px + var(--safe-b)) calc(16px + var(--safe-l));
  background: radial-gradient(ellipse at 50% 40%, rgba(40, 24, 14, 0.55), rgba(10, 6, 4, 0.88));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  cursor: pointer;
  transition: opacity 0.7s ease;
  z-index: 5;
}

.overlay.leaving {
  opacity: 0;
  pointer-events: none;
}

.entry-card {
  text-align: center;
  max-width: 420px;
}

.entry-card h1 {
  margin: 0 0 26px;
  font: italic 500 clamp(40px, 11vw, 64px) / 1.05 var(--serif);
  letter-spacing: 0.01em;
  color: var(--ink);
  text-shadow: 0 2px 24px rgba(232, 150, 70, 0.25);
}

.entry-card .btn {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.entry-hint {
  margin: 20px auto 0;
  max-width: 30ch;
  text-wrap: balance;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink-soft);
}

@media (prefers-reduced-motion: reduce) {
  .btn.primary.show {
    animation: none;
  }
}
