:root {
  --cream: #f1e6cc;
  --ink: #0b1224;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #03050b;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#stage { position: fixed; inset: 0; display: block; width: 100vw; height: 100vh; cursor: pointer; }
#ui { position: fixed; inset: 0; pointer-events: none; font-family: var(--serif); color: var(--cream); }

#loading {
  position: fixed; inset: 0; display: grid; place-items: center;
  font-family: var(--serif); font-style: italic; color: #8ea0c4; letter-spacing: 0.08em;
  transition: opacity 0.8s ease;
}
body.ready #loading { opacity: 0; pointer-events: none; }

#caption {
  position: absolute; left: 50%; bottom: max(4.2rem, calc(env(safe-area-inset-bottom) + 3.6rem));
  transform: translate(-50%, 8px);
  width: min(36rem, 86vw); margin: 0;
  text-align: center; font-size: clamp(1.05rem, 1.6vw + 0.4rem, 1.45rem); line-height: 1.45;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9), 0 0 18px rgba(3, 6, 16, 0.95), 0 0 40px rgba(3, 6, 16, 0.8);
  opacity: 0; transition: opacity 1.1s ease, transform 1.1s ease;
  text-wrap: balance;
}
#caption.show { opacity: 1; transform: translate(-50%, 0); }

#hint {
  position: absolute; left: 50%; bottom: max(1.7rem, calc(env(safe-area-inset-bottom) + 1.2rem));
  transform: translateX(-50%); margin: 0;
  font-size: 0.78rem; letter-spacing: 0.22em; text-transform: lowercase; font-style: italic;
  color: rgba(241, 230, 204, 0.75); text-shadow: 0 0 12px rgba(3, 6, 16, 1);
  opacity: 0; transition: opacity 0.9s ease; white-space: nowrap;
}
#hint.show { opacity: 1; animation: breathe 2.6s ease-in-out infinite; }
#hint.pulse { animation: nudge 0.5s ease, breathe 2.6s ease-in-out 0.5s infinite; }
@keyframes breathe { 0%, 100% { opacity: 0.45; } 50% { opacity: 0.95; } }
@keyframes nudge { 0% { transform: translateX(-50%); } 30% { transform: translateX(calc(-50% - 6px)); } 60% { transform: translateX(calc(-50% + 6px)); } 100% { transform: translateX(-50%); } }

#ring {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; transform: translate(-50%, -50%);
  border-radius: 50%; opacity: 0; transition: opacity 0.4s ease;
  background: conic-gradient(rgba(255, 196, 120, 0.95) calc(var(--p, 0) * 360deg), rgba(241, 230, 204, 0.14) 0);
  -webkit-mask: radial-gradient(circle, transparent 21px, #000 22px);
  mask: radial-gradient(circle, transparent 21px, #000 22px);
  filter: drop-shadow(0 0 8px rgba(255, 170, 80, 0.6));
}
#ring.show { opacity: 1; }
body[data-page="lighthouse"] #caption { bottom: max(4.2rem, calc(env(safe-area-inset-bottom) + 3.6rem)); }

#ending {
  position: absolute; left: 50%; top: 18%; transform: translate(-50%, 10px); margin: 0;
  font-style: italic; font-size: clamp(1.6rem, 3vw + 0.6rem, 2.6rem); letter-spacing: 0.04em;
  text-shadow: 0 0 24px rgba(3, 6, 16, 1), 0 1px 2px rgba(0, 0, 0, 0.9);
  opacity: 0; transition: opacity 2s ease, transform 2s ease; white-space: nowrap;
}
#ending::after { content: "\2026"; }
#ending.show { opacity: 1; transform: translate(-50%, 0); }

#dots {
  position: absolute; right: max(1.1rem, env(safe-area-inset-right)); bottom: max(1.1rem, env(safe-area-inset-bottom));
  display: flex; gap: 7px;
}
#dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(241, 230, 204, 0.25); transition: background 0.5s, transform 0.5s; }
#dots i.on { background: rgba(255, 200, 130, 0.95); transform: scale(1.25); box-shadow: 0 0 8px rgba(255, 170, 80, 0.8); }

#version {
  position: absolute; left: max(1rem, env(safe-area-inset-left)); bottom: max(0.9rem, env(safe-area-inset-bottom));
  font-family: ui-monospace, Menlo, monospace; font-size: 0.66rem; letter-spacing: 0.08em; color: rgba(241, 230, 204, 0.38);
}

body.portrait #caption { width: 88vw; bottom: max(4.6rem, calc(env(safe-area-inset-bottom) + 4rem)); font-size: 1.08rem; }
body.portrait #ending { top: 14%; }
