:root {
  color-scheme: dark;
  --space: #02030a;
  --yellow: #ffd83d;
  --blue: #58b9e9;
  --muted: #a8adbd;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  overflow-x: hidden;
  color: #fff;
  background: var(--space);
  font-family: Inter, "Noto Sans JP", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
}

button, input, textarea { font: inherit; }

#stars {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

main { position: relative; min-height: 100svh; }

.editor {
  position: relative;
  z-index: 2;
  width: min(720px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(52px, 8vh, 92px) 0 48px;
  transition: opacity .55s ease, transform .55s ease;
}

.editor::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 5%; left: 50%;
  width: 90vw; height: 70vh;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(57, 66, 136, .18), transparent 65%);
  filter: blur(20px);
  pointer-events: none;
}

.editor__eyebrow {
  margin-bottom: 18px;
  color: var(--yellow);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .28em;
}

h1 {
  margin: 0;
  font-size: clamp(38px, 7vw, 68px);
  line-height: 1.12;
  letter-spacing: -.045em;
}

.editor__lead {
  max-width: 580px;
  margin: 22px 0 36px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.8;
}

form {
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(19,22,43,.88), rgba(8,10,23,.76));
  box-shadow: 0 26px 70px rgba(0,0,0,.45), inset 0 1px rgba(255,255,255,.04);
  backdrop-filter: blur(14px);
}

label {
  display: block;
  margin-bottom: 9px;
  color: #d7d9e2;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .03em;
}

input[type="text"], input:not([type]), textarea {
  width: 100%;
  margin-bottom: 24px;
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px;
  outline: none;
  color: #fff;
  background: rgba(0,0,0,.3);
  transition: border-color .2s, box-shadow .2s;
}

textarea { resize: vertical; min-height: 180px; line-height: 1.7; }
input:focus, textarea:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(255,216,61,.12); }

.form-actions { display: flex; align-items: center; gap: 22px; }

.play-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 21px;
  border: 0;
  border-radius: 999px;
  color: #15120a;
  background: var(--yellow);
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(255,216,61,.18);
  transition: transform .2s, box-shadow .2s;
}

.play-button:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(255,216,61,.28); }
.play-button__icon { font-size: 11px; }

.sound-toggle { display: flex; align-items: center; gap: 9px; margin: 0; cursor: pointer; }
.sound-toggle input { position: absolute; opacity: 0; }
.sound-toggle span { position: relative; width: 36px; height: 20px; border-radius: 99px; background: #3a3e4f; transition: background .2s; }
.sound-toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s; }
.sound-toggle input:checked + span { background: var(--yellow); }
.sound-toggle input:checked + span::after { transform: translateX(16px); background: #17130a; }

.editor__note { margin-top: 16px; color: #6e7386; font-size: 12px; text-align: center; }

.experience {
  position: fixed;
  z-index: 3;
  inset: 0;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  background: transparent;
  transition: opacity .5s ease, visibility .5s;
}

body.is-playing .editor { opacity: 0; transform: scale(.96); pointer-events: none; }
body.is-playing .experience { opacity: 1; visibility: visible; }

.prologue {
  position: absolute;
  top: 50%; left: 50%;
  width: min(620px, 78vw);
  margin: 0;
  transform: translate(-50%, -50%);
  color: var(--blue);
  font-size: clamp(23px, 4vw, 40px);
  line-height: 1.55;
  opacity: 0;
}

.is-playing .prologue { animation: prologue 5.8s ease-in-out .45s both; }

.crawl-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  perspective: 520px;
  perspective-origin: 50% 120px;
  opacity: 0;
  -webkit-mask-image: linear-gradient(to bottom, transparent 3%, rgba(0,0,0,.18) 13%, #000 34%, #000 100%);
  mask-image: linear-gradient(to bottom, transparent 3%, rgba(0,0,0,.18) 13%, #000 34%, #000 100%);
}

.is-playing .crawl-stage { animation: appear .01s 6.55s forwards; }

.crawl {
  position: absolute;
  top: 108%; left: 50%;
  width: min(610px, 72vw);
  color: var(--yellow);
  font-weight: 750;
  transform-origin: 50% 0;
  transform: translate3d(-50%, 0, 120px) rotateX(52deg);
  text-align: justify;
  will-change: transform;
}

.is-playing .crawl { animation: crawl var(--crawl-duration, 42s) linear 6.55s both; }
.crawl__episode { margin: 0 0 12px; text-align: center; font-size: clamp(13px, 1.7vw, 21px); letter-spacing: .18em; }
.crawl h2 { margin: 0 0 42px; font-size: clamp(30px, 4.6vw, 56px); line-height: 1.14; text-align: center; text-wrap: balance; }
.crawl__body p { margin: 0 0 1.35em; font-size: clamp(19px, 2.6vw, 32px); line-height: 1.55; }

.exit-button, .replay-button {
  position: absolute;
  z-index: 4;
  border: 1px solid rgba(255,255,255,.16);
  color: #fff;
  background: rgba(5,7,16,.62);
  backdrop-filter: blur(8px);
  cursor: pointer;
}
.exit-button { top: 20px; right: 20px; width: 42px; height: 42px; border-radius: 50%; font-size: 26px; line-height: 1; }
.replay-button { left: 50%; bottom: 9vh; padding: 12px 20px; border-radius: 99px; transform: translateX(-50%); opacity: 0; pointer-events: none; }
.experience.is-finished .replay-button { opacity: 1; pointer-events: auto; transition: opacity .5s; }

.mobile-break { display: none; }

@keyframes prologue {
  0%, 8% { opacity: 0; }
  18%, 72% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes appear { to { opacity: 1; } }
@keyframes crawl {
  0% { transform: translate3d(-50%, 0, 120px) rotateX(52deg); }
  70% { transform: translate3d(-50%, calc(-100% - 38vh), -360px) rotateX(52deg); }
  100% { transform: translate3d(-50%, calc(-100% - 112vh), -1800px) rotateX(52deg); }
}

@media (max-width: 600px) {
  .editor { padding-top: 38px; }
  .form-actions { align-items: flex-start; flex-direction: column; }
  .mobile-break { display: block; }
  .crawl-stage { perspective: 390px; perspective-origin: 50% 96px; }
  .crawl { width: 80vw; }
}

@media (prefers-reduced-motion: reduce) {
  .play-button { transition: none; }
  .is-playing .prologue { animation-duration: .01ms; }
  .is-playing .crawl-stage { animation-delay: .1s; }
  .is-playing .crawl { animation-duration: 25s; animation-delay: .1s; }
}

