* {
  box-sizing: border-box;
}

html {
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow: hidden;
  background: #000;
  color: #f7f1df;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", Arial, sans-serif;
}

.app {
  min-height: 100dvh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: opacity 220ms ease, visibility 220ms ease;
}

.app.is-app-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.comic-panel {
  --choices-height: clamp(72px, 14dvh, 92px);
  position: relative;
  width: 100%;
  max-width: 520px;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #000;
}

.comic-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
}

.comic-panel .image-frame {
  transition: opacity 120ms ease, transform 120ms ease;
}

.comic-panel.is-changing .image-frame {
  opacity: 0;
  transform: scale(0.992);
}

.comic-panel.transition-flash::after {
  animation: camera-flash 360ms ease-out both;
}

.comic-panel.transition-white-slow::after {
  animation: slow-white-fade 1300ms ease-in-out both;
}

.comic-panel.transition-shake .image-frame {
  opacity: 1;
  animation: image-shake 250ms steps(2, end) both;
}

.image-frame {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.comic-image {
  display: block;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  margin: 0 auto;
  background: #000;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  opacity: 1;
  transition: opacity 120ms ease;
}

.comic-image.is-loading-image {
  opacity: 0;
}

.story-box {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(var(--choices-height) + 12px);
  z-index: 1;
  max-height: clamp(88px, 18dvh, 142px);
  overflow-y: auto;
  margin: 0;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.58);
  color: #f6f1e8;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(10px);
  font-size: 0.92rem;
  line-height: 1.36;
  opacity: 1;
  transition: opacity 180ms ease, transform 180ms ease;
}

.story-box::-webkit-scrollbar {
  display: none;
}

.story-box {
  scrollbar-width: none;
}

.story-box p {
  margin: 0;
  white-space: pre-line;
}

.story-box p.is-typing::after {
  content: "";
  display: inline-block;
  width: 0.5em;
}

.story-box .impact {
  font-weight: 900;
  color: #fff;
}

.story-box .weak {
  color: rgba(246, 241, 232, 0.72);
}

.story-box .shake {
  font-weight: 800;
}

.story-box .effect-letter {
  display: inline-block;
}

.story-box .pending-effect-letter {
  display: inline-block;
  opacity: 0;
}

.story-box .impact .effect-letter {
  animation: text-impact 260ms steps(3, end) both;
  animation-delay: 0ms;
}

.story-box .weak .effect-letter {
  animation: text-weak 1.45s ease-in-out infinite;
  animation-delay: calc(var(--letter-index) * -80ms);
}

.story-box .shake .effect-letter {
  animation: text-shake 190ms steps(2, end) infinite;
  animation-delay: calc(var(--letter-index) * -22ms);
}

.choices {
  position: relative;
  z-index: 1;
  flex: 0 0 var(--choices-height);
  height: var(--choices-height);
  overflow-y: auto;
  display: grid;
  align-content: safe center;
  gap: 8px;
  margin-top: 0;
  padding: 10px 10px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.78), #000 48%);
  box-shadow: 0 -14px 34px rgba(0, 0, 0, 0.58);
  scrollbar-width: none;
}

.choices::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -34px;
  height: 34px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.78));
}

.choices::-webkit-scrollbar {
  display: none;
}

.choice-button {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #f8f4ec;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.26;
  overflow-wrap: anywhere;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 180ms ease, transform 180ms ease, background 180ms ease;
}

.choice-button.is-hidden-choice {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.choice-button.is-revealing {
  animation: choice-reveal 220ms ease both;
}

.choice-button.restart-button {
  border-color: rgba(255, 255, 255, 0.88);
  background: rgba(255, 255, 255, 0.9);
  color: #070707;
  box-shadow: 0 10px 28px rgba(255, 255, 255, 0.12);
}

.choice-button.restart-button:active {
  background: #fff;
}

.code-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  width: 100%;
}

.code-input {
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: #f8f4ec;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
  font: inherit;
  font-size: 0.92rem;
  outline: none;
}

.code-input::placeholder {
  color: rgba(248, 244, 236, 0.48);
}

.code-input:focus {
  border-color: rgba(255, 255, 255, 0.58);
}

.code-submit-button {
  width: auto;
  min-width: 76px;
}

.paid-code-home-button {
  margin-top: 10px;
}

.paid-code-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(2px);
}

.paid-code-card {
  width: min(100%, 380px);
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(8, 8, 8, 0.78);
  color: #f8f4ec;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(14px);
}

.paid-code-title {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 900;
  text-align: center;
}

.paid-code-message {
  margin: 0 0 14px;
  color: rgba(248, 244, 236, 0.82);
  font-size: 0.9rem;
  line-height: 1.48;
  text-align: center;
}

.paid-code-error {
  min-height: 1.25em;
  margin: 8px 0 0;
  color: #ffb4b4;
  font-size: 0.82rem;
  text-align: center;
}

.back-button {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  min-width: 58px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid rgba(247, 241, 223, 0.5);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #f7f1df;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  backdrop-filter: blur(4px);
  transition: background 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.back-button:disabled {
  opacity: 0.34;
  cursor: default;
}

.hide-text-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  min-width: 58px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid rgba(247, 241, 223, 0.5);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #f7f1df;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  backdrop-filter: blur(4px);
  transition: background 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.hide-text-button.is-holding {
  background: rgba(0, 0, 0, 0.78);
  border-color: rgba(247, 241, 223, 0.72);
  transform: scale(0.96);
}

.story-box.is-hidden-for-view {
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
}

.back-button[hidden] {
  display: none;
}

.choice-button:active {
  transform: scale(0.985);
  background: rgba(255, 255, 255, 0.2);
}

.choice-button:focus-visible,
.back-button:focus-visible,
.hide-text-button:focus-visible {
  outline: 3px solid #5ad7ff;
  outline-offset: 3px;
}

@keyframes choice-reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes text-impact {
  0% {
    opacity: 0;
    transform: translate3d(var(--impact-x), var(--impact-y), 0) rotate(var(--impact-r)) scale(1.24);
  }

  12% {
    opacity: 1;
    transform: translate3d(calc(var(--impact-x) * -1), calc(var(--impact-y) * -1), 0) rotate(calc(var(--impact-r) * -1)) scale(1.12);
  }

  28% {
    transform: translate3d(calc(var(--impact-x) * 0.72), calc(var(--impact-y) * -0.64), 0) rotate(calc(var(--impact-r) * 0.72)) scale(1.08);
  }

  48% {
    transform: translate3d(calc(var(--impact-x) * -0.34), calc(var(--impact-y) * 0.34), 0) rotate(calc(var(--impact-r) * -0.34)) scale(1.03);
  }

  70% {
    transform: translate3d(calc(var(--impact-x) * 0.18), calc(var(--impact-y) * -0.18), 0) rotate(calc(var(--impact-r) * 0.18)) scale(1.02);
  }

  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
  }
}

@keyframes text-weak {
  0%,
  100% {
    transform: translateY(0) skewX(0deg);
    opacity: 0.76;
  }

  50% {
    transform: translateY(2px) skewX(-4deg);
    opacity: 0.52;
  }
}

@keyframes text-shake {
  0% {
    transform: translate3d(0, 0, 0);
  }

  33% {
    transform: translate3d(-1px, 1px, 0);
  }

  66% {
    transform: translate3d(1px, -1px, 0);
  }

  100% {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes camera-flash {
  0% {
    opacity: 0;
    background: #fff;
  }

  22% {
    opacity: 0.96;
    background: #fff;
  }

  100% {
    opacity: 0;
    background: #fff;
  }
}

@keyframes slow-white-fade {
  0% {
    opacity: 0;
    background: #fff;
  }

  35% {
    opacity: 0.95;
    background: #fff;
  }

  55% {
    opacity: 0.95;
    background: #fff;
  }

  100% {
    opacity: 0;
    background: #fff;
  }
}

@keyframes image-shake {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg) scale(1.012);
  }

  12% {
    transform: translate3d(-11px, 6px, 0) rotate(-1.7deg) scale(1.018);
  }

  25% {
    transform: translate3d(10px, -7px, 0) rotate(1.5deg) scale(1.02);
  }

  38% {
    transform: translate3d(-8px, -5px, 0) rotate(-1.1deg) scale(1.018);
  }

  52% {
    transform: translate3d(7px, 6px, 0) rotate(1deg) scale(1.016);
  }

  70% {
    transform: translate3d(-5px, 2px, 0) rotate(-0.6deg) scale(1.01);
  }

  100% {
    transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
  }
}

@keyframes start-ready {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.title-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #000;
  transition: opacity 260ms ease, visibility 260ms ease;
}

.title-screen.is-hidden,
.prologue-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.title-content {
  width: 100%;
  max-width: 520px;
  text-align: center;
}

.title-kicker {
  margin: 0 0 12px;
  color: rgba(246, 241, 232, 0.56);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.title-content h1 {
  margin: 0 0 24px;
  color: #f6f1e8;
  font-size: 2.25rem;
  font-weight: 800;
}

.preload-panel {
  width: 100%;
  max-width: 320px;
  max-height: 112px;
  overflow: hidden;
  margin: 0 auto 18px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 46px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(14px);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 260ms ease, transform 260ms ease, max-height 320ms ease, margin 320ms ease, padding 320ms ease, border-color 320ms ease;
}

.preload-panel.is-complete {
  max-height: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-color: rgba(255, 255, 255, 0);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

.preload-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: rgba(248, 244, 236, 0.86);
  font-size: 0.82rem;
  font-weight: 800;
}

.preload-track {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.36);
}

.preload-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.92));
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.2);
  transition: width 220ms ease;
}

.preload-count {
  margin: 9px 0 0;
  color: rgba(248, 244, 236, 0.56);
  font-size: 0.76rem;
  font-weight: 700;
}

.start-button {
  width: 100%;
  max-width: 320px;
  min-height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.13);
  color: #f8f4ec;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 260ms ease, transform 260ms ease, background 160ms ease;
}

.start-button.is-waiting {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.start-button.is-ready {
  animation: start-ready 320ms ease both;
}

.start-button:active {
  transform: scale(0.985);
  background: rgba(255, 255, 255, 0.2);
}

.start-button:focus-visible {
  outline: 3px solid #5ad7ff;
  outline-offset: 3px;
}

.prologue-screen {
  position: fixed;
  inset: 0;
  z-index: 11;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #000;
  transition: opacity 260ms ease, visibility 260ms ease;
}

.prologue-content {
  width: 100%;
  max-width: 520px;
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.prologue-content p {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0 0 28px;
  color: #f6f1e8;
  font-size: 1.05rem;
  line-height: 1.65;
  text-align: center;
  white-space: pre-line;
  scrollbar-width: none;
}

.prologue-content p::-webkit-scrollbar {
  display: none;
}

@media (min-width: 700px) {
  .app {
    padding: 0 24px;
  }

  .story-box {
    font-size: 1rem;
  }
}
