:root {
  --ink: #1a1510;
  --paper: #c8b89a;
  --paper-dark: #a89472;
  --blood: #5c1f1f;
  --blood-bright: #8b2e2e;
  --mold: #2a3a2a;
  --amber: #b8860b;
  --shadow: rgba(0, 0, 0, 0.65);
  --font-body: "EB Garamond", Georgia, "Times New Roman", serif;
  --font-type: "Special Elite", "Courier New", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% 0%, #2a2218 0%, #0d0b08 55%, #050403 100%);
  overflow-x: hidden;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 100;
}

.vignette {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, transparent 35%, rgba(0, 0, 0, 0.75) 100%);
  z-index: 99;
}

.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.04) 2px,
    rgba(0, 0, 0, 0.04) 4px
  );
  z-index: 98;
}

.jumpscare {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.jumpscare img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: jumpscareZoom 3s ease-out forwards;
  transform-origin: center center;
}

.jumpscare-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  z-index: 2;
  animation: flashOut 0.35s ease-out forwards;
  pointer-events: none;
}

/* fade-out overlay that covers the image at the end */
.jumpscare::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #000;
  z-index: 3;
  opacity: 0;
  animation: jumpscareOut 3s ease-in-out forwards;
  pointer-events: none;
}

@keyframes jumpscareZoom {
  0%   { transform: scale(1.35); filter: brightness(2.5) contrast(1.6) saturate(0); }
  15%  { transform: scale(1.1);  filter: brightness(1.4) contrast(1.3) saturate(0.3); }
  60%  { transform: scale(1.02); filter: brightness(1)   contrast(1.1) saturate(0.5); }
  100% { transform: scale(1);    filter: brightness(0.7) contrast(1)   saturate(0.4); }
}

@keyframes flashOut {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes jumpscareOut {
  0%   { opacity: 0; }
  55%  { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes screenShake {
  0%   { transform: translate(0,0) rotate(0deg); }
  10%  { transform: translate(-8px, -6px) rotate(-1deg); }
  20%  { transform: translate(9px, 5px) rotate(1deg); }
  30%  { transform: translate(-7px, 8px) rotate(-0.5deg); }
  40%  { transform: translate(8px, -7px) rotate(1deg); }
  50%  { transform: translate(-5px, 5px) rotate(-1deg); }
  60%  { transform: translate(6px, -4px) rotate(0.5deg); }
  70%  { transform: translate(-4px, 6px) rotate(-0.5deg); }
  80%  { transform: translate(5px, -3px) rotate(0deg); }
  90%  { transform: translate(-3px, 3px) rotate(0deg); }
  100% { transform: translate(0,0) rotate(0deg); }
}

body.jumpscare-shake {
  animation: screenShake 0.55s cubic-bezier(.36,.07,.19,.97) both;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem 4rem;
}

.screen {
  display: none;
  width: 100%;
  max-width: 720px;
  animation: fadeIn 0.8s ease;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.paper {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, transparent 50%),
    var(--paper);
  border: 2px solid var(--paper-dark);
  box-shadow:
    0 0 0 1px #6b5a42,
    0 12px 40px var(--shadow),
    inset 0 0 80px rgba(80, 60, 30, 0.15);
  padding: 2rem 2.2rem;
  position: relative;
}

.paper::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(60, 45, 25, 0.25);
  pointer-events: none;
}

.paper.wide {
  max-width: 640px;
  margin: 0 auto;
}

h1,
h2 {
  font-family: var(--font-type);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 1rem;
  color: var(--blood);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
}

h1 {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
}

h2 {
  font-size: 1.35rem;
}

.lead {
  font-size: 1.15rem;
  font-style: italic;
  margin-bottom: 1rem;
}

.stamp {
  font-family: var(--font-type);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: var(--blood-bright);
  border: 2px solid var(--blood-bright);
  display: inline-block;
  padding: 0.25rem 0.5rem;
  margin-bottom: 1.5rem;
  transform: rotate(-2deg);
}

.warning {
  color: var(--blood);
  font-weight: 600;
}

.footnote {
  font-size: 0.85rem;
  opacity: 0.7;
  margin-top: 1.5rem;
}

.btn {
  font-family: var(--font-type);
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--paper);
  border: 2px solid #000;
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  margin-top: 1rem;
  transition: background 0.2s, color 0.2s;
}

.btn:hover {
  background: var(--blood);
  color: #f0e6d8;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}

.btn.ghost:hover {
  background: var(--ink);
  color: var(--paper);
}

.trial-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}

.trial-list li {
  margin-bottom: 0.75rem;
}

.trial-btn {
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--paper-dark);
  padding: 0.9rem 1rem;
  cursor: pointer;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.trial-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.08);
  border-color: var(--blood);
}

.trial-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.trial-btn .status {
  font-family: var(--font-type);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
}

.trial-btn.done .status {
  color: var(--mold);
}

.progress-note {
  font-family: var(--font-type);
  font-size: 0.8rem;
  opacity: 0.75;
}

.hub-reset-wrap {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--paper-dark);
  text-align: right;
}

.btn.danger {
  border-color: var(--blood);
  color: var(--blood);
}

.btn.danger:hover {
  background: var(--blood);
  color: #f0e6d8;
}

.btn.ghost.danger {
  background: transparent;
}

.reset-confirm {
  margin-top: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px dashed var(--blood);
  background: rgba(92, 31, 31, 0.08);
  text-align: left;
}

.reset-confirm-text {
  margin: 0 0 0.75rem;
  font-style: italic;
  color: var(--blood);
}

.reset-confirm-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.reset-confirm-actions .btn {
  margin-top: 0;
}

.trial-tag {
  font-family: var(--font-type);
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--blood);
  margin-bottom: 1rem;
}

blockquote {
  margin: 1rem 0 1.5rem;
  padding: 1rem 1.2rem;
  border-left: 4px solid var(--blood);
  background: rgba(0, 0, 0, 0.06);
  font-size: 1.2rem;
  font-style: italic;
}

.choices {
  display: grid;
  gap: 0.6rem;
}

.choice-btn {
  font-family: var(--font-body);
  text-align: left;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--paper-dark);
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-size: 1rem;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--blood);
  background: rgba(92, 31, 31, 0.08);
}

.choice-btn:disabled {
  cursor: default;
}

.choice-btn.correct {
  border-color: var(--mold);
  background: rgba(42, 58, 42, 0.2);
}

.choice-btn.wrong {
  border-color: var(--blood-bright);
  background: rgba(92, 31, 31, 0.15);
}

.feedback {
  min-height: 1.5rem;
  margin-top: 1rem;
  font-style: italic;
  color: var(--blood);
}

.feedback.good {
  color: var(--mold);
}

.hidden {
  display: none !important;
}

.memory-status {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-type);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  max-width: 360px;
  margin: 0 auto;
}

.memory-card {
  aspect-ratio: 1;
  font-family: var(--font-type);
  font-size: 1.4rem;
  background: var(--ink);
  color: var(--amber);
  border: 2px solid #000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.memory-card.hidden-face {
  color: transparent;
  background: #2a2218;
}

.memory-card.hidden-face:hover {
  background: #3a3028;
}

.memory-card.revealed,
.memory-card.matched {
  color: var(--amber);
  background: #1a1510;
}

.memory-card.matched {
  border-color: var(--mold);
  opacity: 0.6;
  cursor: default;
}

.memory-card.wrong-flash {
  animation: wrongFlash 0.4s ease;
}

@keyframes wrongFlash {
  50% {
    background: var(--blood);
    color: #f0e6d8;
  }
}

.whisper-phrase {
  font-family: var(--font-type);
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  background: rgba(0, 0, 0, 0.12);
  padding: 1rem;
  border: 1px dashed var(--paper-dark);
  margin: 1rem 0;
}

.field {
  width: 100%;
  font-family: var(--font-type);
  font-size: 1rem;
  padding: 0.75rem;
  border: 2px solid var(--ink);
  background: rgba(255, 255, 255, 0.15);
  color: var(--ink);
}

.field:focus {
  outline: none;
  border-color: var(--blood);
  box-shadow: 0 0 0 2px rgba(92, 31, 31, 0.2);
}

.whisper-bar-wrap {
  height: 6px;
  background: rgba(0, 0, 0, 0.2);
  margin-top: 0.75rem;
  border: 1px solid var(--paper-dark);
}

.whisper-bar {
  height: 100%;
  width: 100%;
  background: var(--blood);
  transition: width 0.05s linear;
}

.whisper-bar.danger {
  background: var(--blood-bright);
  box-shadow: 0 0 6px rgba(139, 46, 46, 0.6);
}

.blink-stage {
  position: relative;
  height: 220px;
  background: #0a0806;
  border: 3px solid #000;
  margin: 1.5rem 0 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.blink-eye {
  position: absolute;
  left: 50%;
  top: 50%;
  font-size: 3rem;
  line-height: 1;
  color: var(--blood-bright);
  cursor: crosshair;
  z-index: 2;
  animation: flicker 4s infinite;
  text-shadow: 0 0 20px rgba(139, 46, 46, 0.5);
  transform: translate(-50%, -50%);
  transition: left 0.65s ease, top 0.65s ease;
}

.blink-shadow {
  position: absolute;
  bottom: -60%;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 180px;
  background: radial-gradient(ellipse, #000 0%, transparent 70%);
  opacity: 0;
  transition: bottom 0.3s ease, opacity 0.3s ease;
  z-index: 1;
}

.blink-shadow.closer {
  bottom: -20%;
  opacity: 0.85;
}

.blink-shadow.dead {
  bottom: 10%;
  opacity: 1;
}

.blink-trail-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blood-bright);
  box-shadow: 0 0 6px rgba(139, 46, 46, 0.5);
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: opacity 0.2s ease, left 0.65s ease, top 0.65s ease;
  z-index: 1;
}

.blink-timer {
  font-family: var(--font-type);
  text-align: center;
  letter-spacing: 0.1em;
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

@keyframes flicker {
  0%,
  100% {
    opacity: 1;
  }
  41% {
    opacity: 1;
  }
  42% {
    opacity: 0.4;
  }
  43% {
    opacity: 1;
  }
  45% {
    opacity: 0.6;
  }
  46% {
    opacity: 1;
  }
}

.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-type);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: rgba(200, 184, 154, 0.35);
  padding: 0.75rem;
  z-index: 2;
}

body.glitch {
  animation: bodyGlitch 0.15s steps(2) 2;
}

@keyframes bodyGlitch {
  50% {
    filter: hue-rotate(20deg) contrast(1.2);
  }
}

.candle-stage {
  text-align: center;
  margin: 1.5rem 0 0.5rem;
  font-family: var(--font-type);
}

.candle-flame {
  font-size: 2.5rem;
  color: var(--amber);
  text-shadow: 0 0 12px rgba(184, 134, 11, 0.8);
  transition: opacity 0.15s ease, color 0.15s ease;
}

.candle-flame.dim {
  opacity: 0.35;
  color: #6b4e12;
  text-shadow: none;
}

.candle-flame.out {
  opacity: 0.1;
}

.candle-stick {
  font-size: 2rem;
  color: var(--ink);
  margin-top: -0.5rem;
}

.candle-state,
.candle-progress {
  font-family: var(--font-type);
  font-size: 0.85rem;
  text-align: center;
  letter-spacing: 0.08em;
}

.footstep-corridor {
  position: relative;
  height: 120px;
  background: #0a0806;
  border: 2px solid #000;
  margin: 1rem 0;
  overflow: hidden;
}

.footstep-line {
  position: absolute;
  bottom: 24px;
  left: 8%;
  right: 8%;
  height: 1px;
  background: rgba(200, 184, 154, 0.25);
}

.footstep-mark {
  position: absolute;
  bottom: 18px;
  font-family: var(--font-type);
  font-size: 1.2rem;
  color: var(--paper);
  opacity: 0;
  animation: stepFlash 0.45s ease forwards;
}

@keyframes stepFlash {
  0% {
    opacity: 0;
    transform: translateY(6px);
  }
  30% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0.2;
    transform: translateY(-2px);
  }
}

.footstep-status {
  font-family: var(--font-type);
  text-align: center;
  letter-spacing: 0.1em;
  min-height: 1.5rem;
}

.footstep-guess label {
  display: block;
  margin-bottom: 0.5rem;
  font-style: italic;
}

.footstep-guess .btn {
  margin-top: 0.75rem;
}

.binding-target {
  font-family: var(--font-type);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 0.5rem;
}

.binding-built {
  min-height: 2.5rem;
  padding: 0.75rem;
  border: 2px dashed var(--paper-dark);
  background: rgba(0, 0, 0, 0.08);
  font-family: var(--font-type);
  font-size: 1rem;
  margin-bottom: 1rem;
}

.binding-words {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.binding-word {
  font-family: var(--font-type);
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--paper-dark);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

.binding-word:hover:not(:disabled) {
  border-color: var(--blood);
}

.binding-word:disabled {
  opacity: 0.35;
  cursor: default;
}

@media (max-width: 520px) {
  .paper {
    padding: 1.5rem 1.2rem;
  }

  .memory-grid {
    gap: 0.35rem;
  }

  .memory-card {
    font-size: 1.1rem;
  }
}
.secret-instructions {
  font-style: italic;
  margin-bottom: 0.5rem;
}

.secret-hint-text {
  margin-top: 0.75rem;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--blood);
  border-left: 3px solid var(--blood);
  padding-left: 0.75rem;
}

/* ── HIDDEN CIPHER FRAGMENTS ── */
.fragment-glyph {
  position: absolute;
  font-family: var(--font-type);
  font-size: 2.4rem;
  line-height: 1;
  color: rgba(184, 134, 11, 0.4);
  text-shadow: 0 0 14px rgba(184, 134, 11, 0.3);
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.7s ease, transform 0.7s ease;
  user-select: text;
}

.fragment-glyph.show {
  opacity: 1;
  transform: translateY(0);
}

.fragment-glyph.watermark {
  font-size: 7rem;
  color: rgba(184, 134, 11, 0.1);
  text-shadow: none;
}

.memory-card.glyph-flash {
  color: rgba(184, 134, 11, 0.95) !important;
  text-shadow: 0 0 10px rgba(184, 134, 11, 0.7);
}

.footstep-mark.glyph-flash {
  color: var(--amber);
  text-shadow: 0 0 10px rgba(184, 134, 11, 0.7);
}

#secret-cipher-display {
  font-family: var(--font-type);
  letter-spacing: 0.3em;
  color: var(--blood);
}

.secret-fragments-row {
  font-family: var(--font-type);
  letter-spacing: 0.4em;
  font-size: 1.1rem;
  margin: 0.75rem 0;
}