@font-face {
  font-family: "Abar";
  src: url("assets/fonts/AbarMidNoEn-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Abar";
  src: url("assets/fonts/AbarMidNoEn-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #05060a;
  --panel: rgba(7, 10, 18, 0.72);
  --text: #e9ecf5;
  --muted: #9dadc9;
  --accent: #5ee7b2;
  --accent-strong: #28c184;
  --error: #ff4d6d;
  --glow-1: rgba(76, 116, 255, 0.24);
  --glow-2: rgba(165, 94, 255, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Abar", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: radial-gradient(circle at 12% 18%, rgba(120, 150, 255, 0.12), transparent 30%),
    radial-gradient(circle at 82% 8%, rgba(255, 168, 255, 0.08), transparent 28%),
    radial-gradient(circle at 18% 80%, rgba(120, 255, 199, 0.08), transparent 35%),
    var(--bg);
  color: var(--text);
  overflow: hidden;
}

.background {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.background::before {
  content: "";
  position: absolute;
  inset: -20%;
  background: conic-gradient(
    from 120deg,
    rgba(80, 140, 255, 0.12),
    rgba(40, 200, 150, 0.16),
    rgba(180, 140, 255, 0.1),
    rgba(10, 15, 30, 0.28),
    rgba(80, 140, 255, 0.12)
  );
  filter: blur(70px);
  opacity: 0.9;
  animation: swirl 18s linear infinite;
}

.background::after {
  content: "";
  position: absolute;
  inset: -15%;
  background-image:
    radial-gradient(1px 1px at 12% 20%, rgba(255, 255, 255, 0.5), transparent 60%),
    radial-gradient(1px 1px at 42% 65%, rgba(180, 230, 255, 0.45), transparent 60%),
    radial-gradient(1px 1px at 76% 32%, rgba(255, 220, 255, 0.4), transparent 60%),
    radial-gradient(1px 1px at 24% 82%, rgba(180, 255, 210, 0.42), transparent 60%),
    radial-gradient(1px 1px at 55% 48%, rgba(255, 255, 255, 0.35), transparent 60%),
    radial-gradient(1px 1px at 80% 75%, rgba(160, 200, 255, 0.35), transparent 60%);
  background-size: 140px 140px;
  opacity: 0.38;
  mix-blend-mode: screen;
  filter: blur(0.3px);
  animation: drift 16s linear infinite reverse;
}

.bokeh {
  position: absolute;
  inset: -10%;
  background-repeat: repeat;
  mix-blend-mode: screen;
  opacity: 0.28;
  filter: blur(1px);
}

.bokeh-1 {
  background-image:
    radial-gradient(18px 18px at 15% 25%, rgba(94, 231, 178, 0.22), transparent 60%),
    radial-gradient(22px 22px at 70% 60%, rgba(140, 180, 255, 0.18), transparent 60%),
    radial-gradient(14px 14px at 45% 80%, rgba(255, 255, 255, 0.16), transparent 60%),
    radial-gradient(24px 24px at 80% 30%, rgba(180, 140, 255, 0.18), transparent 60%);
  background-size: 280px 280px;
  animation: floatbokeh 14s ease-in-out infinite;
}

.bokeh-2 {
  background-image:
    radial-gradient(16px 16px at 25% 55%, rgba(255, 214, 255, 0.2), transparent 60%),
    radial-gradient(20px 20px at 60% 25%, rgba(94, 231, 178, 0.2), transparent 60%),
    radial-gradient(18px 18px at 78% 72%, rgba(160, 220, 255, 0.18), transparent 60%);
  background-size: 260px 260px;
  animation: floatbokeh 18s ease-in-out infinite reverse;
}

.dust {
  position: absolute;
  inset: -20%;
  background-repeat: repeat;
  mix-blend-mode: screen;
  filter: blur(0.4px);
  opacity: 0.36;
  animation: drift 14s linear infinite;
}

.dust-1 {
  background-image: radial-gradient(1px 1px at 20% 30%, #ffffff33 0, transparent 60%),
    radial-gradient(1px 1px at 70% 60%, #b0f5ff33 0, transparent 55%),
    radial-gradient(1px 1px at 40% 80%, #ffe1ff33 0, transparent 60%);
  background-size: 220px 220px;
  animation-duration: 18s;
}

.dust-2 {
  background-image: radial-gradient(1px 1px at 15% 70%, #dfffee33 0, transparent 60%),
    radial-gradient(1px 1px at 80% 25%, #c8d6ff33 0, transparent 60%),
    radial-gradient(1px 1px at 55% 55%, #ffffff33 0, transparent 60%);
  background-size: 180px 180px;
  animation-direction: reverse;
  animation-duration: 20s;
}

.glow {
  position: absolute;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, #ffffff11 0, transparent 60%);
  filter: blur(60px);
  opacity: 0.45;
}

.glow-1 {
  top: -10%;
  left: -10%;
  background: radial-gradient(circle at 30% 30%, var(--glow-1), transparent 65%);
  animation: pulse 12s ease-in-out infinite;
}

.glow-2 {
  right: -12%;
  bottom: -10%;
  background: radial-gradient(circle at 70% 70%, var(--glow-2), transparent 70%);
  animation: pulse 14s ease-in-out infinite reverse;
}

.frame {
  position: relative;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 60px 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 32px;
  z-index: 1;
  align-items: center;
  text-align: center;
}

.typewriter,
.stage-context,
.input-zone {
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

.header-hint {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 0.5px;
  text-align: center;
  opacity: 0.8;
}

.typewriter {
  min-height: 58px;
  font-size: 28px;
  line-height: 1.6;
  color: var(--text);
  letter-spacing: 1px;
  text-shadow: 0 0 20px rgba(94, 231, 178, 0.15);
  white-space: pre-wrap;
}

.stage-context {
  color: var(--muted);
  min-height: 32px;
  font-size: 15px;
  text-align: center;
}

.input-zone {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  padding: 24px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), 0 0 30px rgba(94, 231, 178, 0.08);
  backdrop-filter: blur(8px);
  min-height: 120px;
  text-align: center;
  margin: 0 auto;
}

.code-form {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
}

.code-input {
  width: 64px;
  text-align: center;
  font-size: 22px;
  padding: 12px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  transition: all 0.25s ease;
  outline: none;
}

.code-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(94, 231, 178, 0.2);
}

.ghost-btn {
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(94, 231, 178, 0.35), rgba(40, 193, 132, 0.35));
  border: 1px solid rgba(94, 231, 178, 0.5);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.ghost-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(94, 231, 178, 0.2);
}

.ghost-btn:active {
  transform: translateY(0);
}

.hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.text-form {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.text-input {
  flex: 1;
  font-size: 18px;
  padding: 14px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  transition: all 0.25s ease;
  outline: none;
}

.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(94, 231, 178, 0.2);
}

.book-floating {
  text-align: center;
  padding: 24px 10px;
  animation: float 6s ease-in-out infinite;
}

.book-title {
  font-size: 30px;
  letter-spacing: 1px;
  margin-bottom: 12px;
  color: #d6f7ff;
  text-shadow: 0 0 35px rgba(94, 231, 178, 0.2), 0 0 20px rgba(255, 255, 255, 0.1);
}

.book-number {
  font-size: 22px;
  color: var(--muted);
  letter-spacing: 4px;
}

.final-clue {
  text-align: center;
  display: grid;
  gap: 8px;
  font-size: 22px;
  color: #d3f5e8;
}

.final-clue strong {
  font-weight: 600;
}

.final-question {
  margin-top: 18px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.8;
  text-align: center;
}

.flash {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(94, 231, 178, 0.45), transparent 65%);
  mix-blend-mode: screen;
  backdrop-filter: blur(9px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
  z-index: 2;
}

.flash.active {
  opacity: 0.95;
  animation: fadeout 1.6s ease forwards;
}

.error {
  border-color: var(--error) !important;
  color: var(--error);
  box-shadow: 0 0 0 3px rgba(255, 77, 109, 0.15);
}

.error::placeholder {
  color: rgba(255, 77, 109, 0.8);
}

.fade-out {
  opacity: 0;
  transition: opacity 0.8s ease;
}

.soft {
  color: var(--muted);
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  to {
    transform: translate3d(-10%, -6%, 0) rotate(1deg);
  }
}

@keyframes swirl {
  from {
    transform: rotate(0deg) scale(1);
  }
  to {
    transform: rotate(360deg) scale(1.05);
  }
}

@keyframes pulse {
  0% {
    opacity: 0.38;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.08);
  }
  100% {
    opacity: 0.38;
    transform: scale(1);
  }
}

@keyframes float {
  0% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
  100% {
    transform: translateY(0px);
  }
}

@keyframes floatbokeh {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: 0.3;
  }
  50% {
    transform: translate3d(-4%, -3%, 0) scale(1.05);
    opacity: 0.42;
  }
  100% {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: 0.3;
  }
}

@keyframes fadeout {
  0% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
  }
}

@media (max-width: 640px) {
  .frame {
    padding: 36px 18px;
    gap: 22px;
    align-items: center;
    text-align: center;
  }

  .typewriter {
    font-size: 21px;
    min-height: 52px;
  }

  .input-zone {
    padding: 18px 16px;
    width: 100%;
    max-width: 560px;
  }

  .code-input {
    width: 58px;
  }

  .code-form {
    gap: 10px;
  }

  .text-form {
    flex-direction: column;
  }

  .text-input {
    width: 100%;
  }

  body {
    background: radial-gradient(circle at 18% 12%, rgba(120, 150, 255, 0.14), transparent 32%),
      radial-gradient(circle at 82% 20%, rgba(255, 168, 255, 0.1), transparent 30%),
      radial-gradient(circle at 22% 82%, rgba(120, 255, 199, 0.1), transparent 38%),
      var(--bg);
  }
}
