:root {
  --ink: #4c4239;
  --ink-soft: rgba(76, 66, 57, 0.62);
  --paper: #f6ede4;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #e9d8cf;
  font-family: "Avenir Next", "Hiragino Sans", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { position: fixed; inset: 0; }

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

/* ---- opening veil ---- */
#veil {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 120% at 50% 42%, #f6e6d8 0%, #eccfbe 58%, #dcb6a8 100%);
  opacity: 1;
  transition: opacity 2.4s ease;
  pointer-events: none;
  z-index: 30;
}
#veil.lifted { opacity: 0; }
.veil-inner { text-align: center; }
.veil-mark {
  font-size: clamp(2.4rem, 6vw, 4rem);
  letter-spacing: 0.35em;
  color: #9c7263;
  text-indent: 0.35em;
  font-weight: 400;
}

/* ---- minimal chrome ---- */
#chrome {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  z-index: 10;
  pointer-events: none;
}
.title {
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  color: rgba(83, 62, 54, 0.78);
  text-shadow: 0 1px 8px rgba(255, 244, 230, 0.55);
}
.title-sub {
  font-size: 0.62rem;
  letter-spacing: 0.34em;
  color: rgba(83, 62, 54, 0.5);
  vertical-align: 0.12em;
}

/* ---- hint ---- */
#hint {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 10;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  line-height: 1.75;
  color: var(--ink-soft);
  text-shadow: 0 1px 6px rgba(255, 246, 236, 0.6);
  opacity: 0.85;
  transition: opacity 1.6s ease;
  user-select: none;
}
#hint.quiet { opacity: 0.34; }
#hint:hover, #hint:focus-within { opacity: 0.9; }
.hint-line { display: block; }

#motion-toggle {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  background: none;
  border: none;
  border-bottom: 1px dotted rgba(76, 66, 57, 0.5);
  padding: 0 0 1px;
  cursor: pointer;
}
#motion-toggle:hover { color: var(--ink); }
#motion-toggle[aria-pressed="true"] { border-bottom-style: solid; }

/* ---- fallback ---- */
#fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 120% at 50% 40%, #f4e2d3 0%, #e3c3b2 60%, #cfa396 100%);
  z-index: 40;
}
#fallback[hidden] { display: none; }
.fallback-card {
  max-width: 30rem;
  padding: 2rem 2.4rem;
  text-align: center;
  color: #6b5347;
  font-size: 0.95rem;
  line-height: 1.8;
}
.fallback-mark {
  font-size: 2.2rem;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  margin-bottom: 1rem;
  color: #9c7263;
}

@media (max-width: 640px) {
  .title { font-size: 0.9rem; }
  #hint { font-size: 0.62rem; }
  .hint-keys { display: none; }
}
