:root {
  --stage-scale: 0.5;
  --ink: #170c08;
  --paper: #f5e9c3;
  --cinnabar: #a3130e;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #020709;
  font-family: "FZKai-Z03", "STKaiti", "KaiTi", "Songti SC", serif;
  touch-action: manipulation;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.screen {
  position: fixed;
  inset: 0;
  overflow: hidden;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  background: #020709;
  transition: opacity 280ms ease, visibility 280ms step-end;
}

.screen.is-active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 280ms ease, visibility 0ms step-start;
}

.design-stage {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 750px;
  height: 1500px;
  overflow: hidden;
  transform: translate(-50%, -50%) scale(var(--stage-scale));
  transform-origin: center;
  background: #071319;
}

.full-layer {
  position: absolute;
  inset: 0;
  width: 750px;
  height: 1500px;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.placeholder-layer {
  transition: opacity 160ms ease;
}

.placeholder-layer[hidden] {
  display: block;
  opacity: 0;
}

.art-input {
  position: absolute;
  left: 160px;
  z-index: 3;
  width: 432px;
  height: 120px;
  padding: 8px 28px 0;
  border: 0;
  outline: 0;
  border-radius: 4px;
  color: var(--ink);
  background: transparent;
  text-align: center;
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 5px;
  caret-color: var(--cinnabar);
  appearance: none;
}

.art-input:focus {
  filter: drop-shadow(0 0 16px rgba(255, 239, 185, 0.45));
}

.name-input {
  top: 535px;
}

.phone-input {
  top: 724px;
  font-size: 39px;
  letter-spacing: 2px;
}

.art-button {
  position: absolute;
  z-index: 4;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: transparent;
}

.input-confirm {
  top: 966px;
  left: 205px;
  width: 340px;
  height: 86px;
}

.art-button:active {
  transform: translateY(3px) scale(0.985);
}

.form-message {
  position: absolute;
  top: 865px;
  left: 150px;
  z-index: 5;
  width: 450px;
  min-height: 48px;
  margin: 0;
  color: #fff5d3;
  text-align: center;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: 2px;
  text-shadow: 0 2px 8px #3c0905, 0 0 2px #3c0905;
}

.video-stage {
  background: #000;
}

.name-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
  object-fit: cover;
  pointer-events: none;
}

.animated-name {
  position: absolute;
  top: 673px;
  left: 110px;
  z-index: 2;
  width: 530px;
  min-height: 92px;
  color: #6e350a;
  text-align: center;
  font-size: 58px;
  font-weight: 700;
  letter-spacing: 9px;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(18px) scale(0.94);
  filter: blur(5px);
  text-shadow: 0 1px 0 rgba(255, 230, 160, 0.45);
  transition: opacity 420ms ease, transform 600ms cubic-bezier(0.2, 0.8, 0.2, 1), filter 450ms ease;
}

.animated-name.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
}

.video-fallback {
  position: absolute;
  top: 1050px;
  left: 250px;
  z-index: 4;
  width: 250px;
  height: 72px;
  border: 1px solid rgba(247, 212, 131, 0.76);
  border-radius: 2px;
  color: #f8e4aa;
  background: rgba(54, 22, 5, 0.72);
  font-size: 30px;
  letter-spacing: 5px;
}

.selection-frame {
  position: absolute;
  top: 367px;
  left: 116px;
  z-index: 3;
  width: 238px;
  height: 423px;
  pointer-events: none;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  contain: layout paint style;
  will-change: transform;
}

.talisman-hit {
  position: absolute;
  z-index: 4;
  width: 238px;
  height: 423px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.talisman-hit:nth-child(1) {
  top: 367px;
  left: 116px;
}

.talisman-hit:nth-child(2) {
  top: 367px;
  left: 400px;
}

.talisman-hit:nth-child(3) {
  top: 817px;
  left: 116px;
}

.talisman-hit:nth-child(4) {
  top: 817px;
  left: 400px;
}

.select-confirm {
  top: 1300px;
  left: 205px;
  width: 340px;
  height: 90px;
}

.result-screen,
.result-stage {
  background: #000;
}

.result-image {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  display: block;
  max-width: none;
  user-select: auto;
  -webkit-user-select: auto;
  -webkit-touch-callout: default;
}

.result-image[hidden] {
  display: none;
}

.result-loading {
  position: absolute;
  top: 710px;
  left: 175px;
  width: 400px;
  color: #f4d995;
  text-align: center;
  font-size: 36px;
  letter-spacing: 8px;
  animation: breathe 1.1s ease-in-out infinite alternate;
}

.toast {
  position: fixed;
  bottom: calc(28px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 20;
  max-width: min(84vw, 420px);
  padding: 11px 18px;
  border: 1px solid rgba(236, 201, 113, 0.38);
  border-radius: 4px;
  color: #faecc6;
  background: rgba(11, 13, 12, 0.86);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  text-align: center;
  font-size: 15px;
  letter-spacing: 1px;
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes breathe {
  from { opacity: 0.52; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .screen,
  .animated-name,
  .selection-frame {
    transition-duration: 1ms;
  }
}
