:root {
  color-scheme: dark;
  background: #030304;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body, #artwork {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #030304;
}

body { min-width: 320px; }

#field {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#camera { display: none; }

.entry-gate {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  color: #eeeeee;
  background: radial-gradient(ellipse at 50% 48%, rgb(20 20 22 / 91%), rgb(3 3 4 / 98%) 68%);
  transition: opacity 680ms ease, visibility 680ms ease;
}

.entry-gate[hidden] { display: none; }
.gate-loading[hidden], .verify-card[hidden] { display: none; }
.entry-gate.is-leaving { opacity: 0; visibility: hidden; }

.camera-prompt {
  position: fixed;
  z-index: 9;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(1.5rem, 5.8vh, 4.5rem) clamp(1.35rem, 5.7vw, 5rem);
  color: #eeeeee;
  background: rgb(3 3 4 / 64%);
  backdrop-filter: blur(2px);
}
.camera-prompt[hidden] { display: none; }
#artwork.is-camera-prompt .identity,
#artwork.is-camera-prompt .status,
#artwork.is-camera-prompt .controls {
  visibility: hidden;
  opacity: 0;
}
.camera-prompt__card {
  width: min(64rem, 100%);
  display: grid;
  justify-items: center;
  text-align: center;
}
.camera-prompt__brand,
.ritual-progress,
.camera-prompt__statement,
.camera-prompt__explanation,
.camera-prompt__actions {
  animation: ritual-arrive 700ms both;
}
.ritual-progress { animation-delay: 100ms; }
.camera-prompt__statement { animation-delay: 220ms; }
.camera-prompt__explanation { animation-delay: 330ms; }
.camera-prompt__actions { animation-delay: 440ms; }
@keyframes ritual-arrive {
  from { opacity: 0; transform: translateY(0.55rem); }
  to { opacity: 1; transform: translateY(0); }
}
.camera-prompt__brand {
  justify-self: start;
  color: rgb(238 238 238 / 74%);
  font-size: 0.68rem;
  letter-spacing: 0.28em;
}
.ritual-progress {
  position: relative;
  isolation: isolate;
  width: min(40rem, 88%);
  margin: clamp(2.2rem, 7.4vh, 5.3rem) 0 clamp(2rem, 6.5vh, 4.6rem);
  padding: 0;
  display: flex;
  justify-content: space-between;
  list-style: none;
  color: rgb(228 228 228 / 48%);
  font-size: 0.62rem;
  letter-spacing: 0.24em;
}
.ritual-progress::before {
  position: absolute;
  z-index: -1;
  top: 0.32rem;
  left: 0;
  right: 0;
  border-top: 1px solid rgb(230 230 230 / 35%);
  content: "";
}
.ritual-progress li {
  min-width: 5.8rem;
  display: grid;
  justify-items: center;
  gap: 0.72rem;
}
.ritual-progress__marker {
  width: 0.66rem;
  height: 0.66rem;
  border: 1px solid rgb(230 230 230 / 68%);
  border-radius: 50%;
  background: #080809;
}
.ritual-progress li[aria-current="step"] {
  color: #f4f1ea;
}
.ritual-progress li[aria-current="step"] .ritual-progress__marker {
  border-color: #f4f1ea;
  background: #f4f1ea;
  box-shadow: 0 0 0 0.28rem rgb(244 241 234 / 8%);
}
.camera-prompt__statement h2 {
  margin: 0;
  display: grid;
  color: #f2f0e9;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4.2vw, 3.8rem);
  font-weight: 400;
  line-height: 1.18;
  letter-spacing: 0.075em;
  text-transform: uppercase;
  text-wrap: balance;
}
.camera-prompt__explanation {
  max-width: 43rem;
  margin-top: clamp(1.3rem, 3.2vh, 2rem);
  color: rgb(224 224 224 / 76%);
  font-size: 0.84rem;
  line-height: 1.8;
  letter-spacing: 0.035em;
}
.camera-prompt__explanation p { margin: 0; }
.camera-prompt__explanation p + p {
  margin-top: 0.25rem;
  color: rgb(210 210 210 / 62%);
}
.camera-prompt__actions {
  margin-top: clamp(2rem, 5.3vh, 3.8rem);
  display: grid;
  justify-items: center;
  gap: 1.35rem;
}
.camera-prompt__actions button {
  min-height: 2.6rem;
  padding: 0.35rem 0.8rem;
  border: 0;
  color: #f4f4f4;
  background: transparent;
  font: inherit;
  letter-spacing: 0.24em;
  cursor: pointer;
}
.camera-prompt__actions button:first-child {
  min-width: min(27rem, 82vw);
  min-height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  border-bottom: 1px solid rgb(242 240 233 / 78%);
  font-size: 0.92rem;
  transition: background-color 220ms ease, letter-spacing 220ms ease;
}
.camera-prompt__arrow { font-size: 1.2rem; letter-spacing: 0; transition: transform 220ms ease; }
.camera-prompt__actions button:first-child:hover { background: rgb(245 245 245 / 7%); letter-spacing: 0.29em; }
.camera-prompt__actions button:first-child:hover .camera-prompt__arrow { transform: translateX(0.25rem); }
.camera-prompt__actions button:last-child {
  color: rgb(230 230 230 / 66%);
  font-size: 0.68rem;
  text-decoration: underline;
  text-decoration-color: rgb(230 230 230 / 42%);
  text-underline-offset: 0.48rem;
}
.camera-prompt__actions button:hover { color: #fff; }
.camera-prompt__actions button:focus-visible { outline: 1px solid #eeeeee; outline-offset: 5px; }

@media (max-width: 640px) {
  .camera-prompt { padding: 1.4rem 1.25rem; }
  .camera-prompt__brand { justify-self: center; font-size: 0.56rem; letter-spacing: 0.2em; }
  .ritual-progress { width: min(23rem, 100%); margin: 2.5rem 0 2.25rem; font-size: 0.54rem; }
  .ritual-progress li { min-width: 4.6rem; gap: 0.56rem; }
  .camera-prompt__statement h2 { font-size: clamp(1.5rem, 6.4vw, 2.25rem); letter-spacing: 0.035em; }
  .camera-prompt__explanation { margin-top: 1.25rem; font-size: 0.72rem; line-height: 1.65; }
  .camera-prompt__actions { margin-top: 1.7rem; gap: 0.8rem; }
}

.gate-loading, .verify-card {
  width: min(31rem, 100%);
  display: grid;
  justify-items: start;
}

.gate-kicker, .verify-note {
  color: rgb(220 220 220 / 52%);
  font-size: 0.63rem;
  letter-spacing: 0.2em;
}

.gate-loading { justify-items: center; text-align: center; }
.gate-loading h1, .verify-card h1 {
  margin: 1.25rem 0 0.45rem;
  font-size: clamp(1.2rem, 2.4vw, 1.65rem);
  font-weight: 400;
  letter-spacing: 0.035em;
}
.gate-loading p, .verify-card > p {
  margin: 0;
  color: rgb(220 220 220 / 60%);
  font-size: 0.8rem;
  line-height: 1.7;
}
.gate-loading p { letter-spacing: 0.12em; text-transform: uppercase; font-size: 0.65rem; }

.gate-spinner {
  width: 2.1rem;
  height: 2.1rem;
  margin-top: 2rem;
  border: 1px solid rgb(220 220 220 / 22%);
  border-top-color: rgb(240 240 240 / 82%);
  border-radius: 50%;
  animation: verify-spin 1.3s linear infinite;
}

@keyframes verify-spin { to { transform: rotate(360deg); } }

.verify-card {
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border: 1px solid rgb(220 220 220 / 20%);
  background: rgb(7 7 8 / 74%);
  box-shadow: 0 24px 90px rgb(0 0 0 / 45%);
  backdrop-filter: blur(14px);
}
.verify-card > p { margin-top: 0.3rem; max-width: 28rem; }
.verify-button {
  width: 100%;
  min-height: 4.1rem;
  margin-top: 1.6rem;
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.95rem;
  border: 1px solid rgb(220 220 220 / 30%);
  color: #f4f4f4;
  background: rgb(245 245 245 / 4%);
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.verify-button:hover { border-color: rgb(242 242 242 / 68%); background: rgb(245 245 245 / 8%); }
.verify-button:focus-visible { outline: 2px solid #eeeeee; outline-offset: 4px; }
.verify-button:disabled { cursor: wait; }
.verify-box {
  width: 1.35rem;
  height: 1.35rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid rgb(235 235 235 / 54%);
}
.verify-label { font-size: 0.93rem; letter-spacing: 0.025em; }
.verify-note { margin-top: 1rem; font-size: 0.53rem; }
.verify-button.is-verifying .verify-box { border-top-color: transparent; border-radius: 50%; animation: verify-spin 0.75s linear infinite; }
.verify-button.is-verified .verify-box { border-color: rgb(175 211 183 / 78%); color: #b5d8bd; }
.verify-mark { font-size: 1rem; line-height: 1; }

@media (prefers-reduced-motion: reduce) {
  .gate-spinner, .verify-button.is-verifying .verify-box { animation-duration: 3s; }
  .camera-prompt__brand, .ritual-progress, .camera-prompt__statement, .camera-prompt__explanation, .camera-prompt__actions { animation-duration: 1ms; animation-delay: 0ms; }
  .entry-gate { transition-duration: 0.01ms; }
}

.identity, .status, .controls {
  position: fixed;
  z-index: 1;
  color: rgb(241 241 241 / 78%);
  text-shadow: 0 1px 12px rgb(0 0 0 / 85%);
}

.identity {
  top: clamp(2.5rem, 8vh, 5rem);
  left: 50%;
  width: min(94vw, 58rem);
  display: grid;
  justify-items: center;
  gap: 1rem;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}

.identity__title {
  font-size: clamp(1.1rem, 2.5vw, 1.9rem);
  letter-spacing: clamp(0.16em, 0.42vw, 0.24em);
}
.identity__subtitle {
  max-width: 100%;
  color: rgb(213 213 213 / 72%);
  font-size: clamp(0.68rem, 1vw, 0.82rem);
  letter-spacing: 0.045em;
}

.status {
  left: 50%;
  bottom: clamp(0.55rem, 1.4vh, 1rem);
  margin: 0;
  max-width: 92vw;
  color: rgb(235 235 235 / 72%);
  font-size: 0.76rem;
  line-height: 1.5;
  letter-spacing: 0.035em;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}

.controls {
  left: 50%;
  right: auto;
  bottom: clamp(2.65rem, 5vh, 3.5rem);
  width: min(25rem, calc(100vw - 2rem));
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transform: translateX(-50%);
}

.controls button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 2.6rem;
  padding: 0.65rem 0.9rem;
  border: 1px solid rgb(228 228 228 / 24%);
  border-radius: 0;
  color: rgb(241 241 241 / 83%);
  background: rgb(5 5 7 / 44%);
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 260ms ease, color 260ms ease, background-color 260ms ease;
  backdrop-filter: blur(8px);
}

.controls button:hover {
  border-color: rgb(233 233 233 / 62%);
  color: #fff;
  background: rgb(13 13 13 / 66%);
}

.controls button:focus-visible {
  outline: none;
  border-color: rgb(235 235 235 / 72%);
}

.controls button.is-active {
  border-color: rgb(190 190 196 / 72%);
  color: #fff;
}

#debug {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  margin: 0;
  padding: 0.65rem 0.8rem;
  color: #e4e4e4;
  background: rgb(3 3 4 / 78%);
  border-left: 1px solid rgb(190 190 196 / 75%);
  font: 12px/1.5 ui-monospace, Consolas, monospace;
  white-space: pre-wrap;
  pointer-events: none;
}

#debug[hidden] { display: none; }

#fallback {
  position: fixed;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 2rem;
  color: #e6e6e6;
  text-align: center;
  background: #030304;
}

#fallback[hidden] { display: none; }
#fallback h1 { font-size: clamp(1.25rem, 3vw, 2rem); font-weight: 400; }
#fallback p { max-width: 34rem; color: #a8a8a8; line-height: 1.7; }

@media (max-width: 620px) {
  .status { bottom: 0.55rem; max-width: 92vw; font-size: 0.65rem; }
  .controls { left: 50%; right: auto; bottom: 2.5rem; width: calc(100vw - 2rem); gap: 0.45rem; }
  .controls button { min-height: 2.35rem; padding: 0.55rem 0.65rem; font-size: 0.66rem; }
}

@media (prefers-reduced-motion: reduce) {
  .controls button { transition-duration: 0.01ms; }
}
