:root {
  --gold: #e5c16c;
  --gold-soft: #f2d990;
  --ink: #130d0a;
  --paper: #f0dfba;
  --wine: #4a1823;
  --green: #183f32;
  --blue: #152a44;
  --shadow: rgba(8, 5, 3, 0.72);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--paper);
  font-family: Georgia, "Times New Roman", serif;
  background: var(--ink);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -3;
  background-image: url("assets/ancient-library.png");
  background-position: center;
  background-size: cover;
  content: "";
}

body::after {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 50% 42%, rgba(230, 187, 96, 0.24), transparent 28rem),
    linear-gradient(90deg, rgba(7, 6, 4, 0.86), rgba(21, 42, 68, 0.42), rgba(7, 6, 4, 0.86)),
    linear-gradient(180deg, rgba(7, 6, 4, 0.4), rgba(7, 6, 4, 0.92));
  content: "";
}

.library-shell {
  display: grid;
  min-height: 100svh;
  padding: clamp(1.25rem, 4vw, 4rem);
  place-items: center;
}

.gate {
  position: relative;
  width: min(100%, 51rem);
  padding: clamp(2.6rem, 7vw, 5.5rem) clamp(1.65rem, 6vw, 4.9rem);
  overflow: hidden;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(20, 13, 8, 0.88), rgba(24, 63, 50, 0.74)),
    rgba(19, 13, 10, 0.74);
  border: 1px solid rgba(229, 193, 108, 0.34);
  border-radius: 8px;
  box-shadow:
    0 2.5rem 5rem rgba(0, 0, 0, 0.5),
    inset 0 0 0 1px rgba(242, 217, 144, 0.12),
    inset 0 0 4rem rgba(229, 193, 108, 0.08);
  backdrop-filter: blur(5px);
}

.gate::before,
.gate::after {
  position: absolute;
  inset: 0.8rem;
  pointer-events: none;
  content: "";
}

.gate::before {
  border: 1px solid rgba(229, 193, 108, 0.28);
}

.gate::after {
  background:
    linear-gradient(90deg, transparent 0 14%, rgba(229, 193, 108, 0.18) 14.3%, transparent 14.6% 85.4%, rgba(229, 193, 108, 0.18) 85.7%, transparent 86%),
    linear-gradient(0deg, transparent 0 13%, rgba(229, 193, 108, 0.14) 13.3%, transparent 13.7% 86.3%, rgba(229, 193, 108, 0.14) 86.7%, transparent 87%);
  opacity: 0.8;
}

h1 {
  margin: 0;
  color: #fff5cf;
  font-size: 2.85rem;
  font-weight: 400;
  line-height: 0.95;
  text-shadow:
    0 0 1.3rem rgba(229, 193, 108, 0.25),
    0 0.25rem 1rem rgba(0, 0, 0, 0.6);
}

.password-form {
  margin-top: clamp(2rem, 5vw, 3rem);
}

.password-grid {
  display: grid;
  grid-template-columns: repeat(var(--cell-count), minmax(0, 1fr));
  gap: clamp(0.55rem, 2vw, 1rem);
  max-width: 31.2rem;
  margin: 0 auto;
}

.password-cell {
  width: 100%;
  min-width: 0;
  aspect-ratio: 1;
  color: #fff8d9;
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 3.15rem;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  background:
    linear-gradient(180deg, rgba(255, 248, 217, 0.12), rgba(229, 193, 108, 0.03)),
    rgba(15, 10, 6, 0.66);
  border: 1px solid rgba(229, 193, 108, 0.62);
  border-radius: 8px;
  box-shadow:
    inset 0 0 1.2rem rgba(0, 0, 0, 0.4),
    0 0.8rem 1.6rem rgba(0, 0, 0, 0.24);
  outline: none;
  caret-color: var(--gold);
}

.password-cell:focus {
  border-color: #fff1b5;
  box-shadow:
    inset 0 0 1.2rem rgba(0, 0, 0, 0.36),
    0 0 0 3px rgba(229, 193, 108, 0.24),
    0 0 1.8rem rgba(229, 193, 108, 0.28);
}

.password-cell.is-wrong {
  border-color: #e47b7b;
  animation: tremble 220ms ease-in-out 2;
}

.status {
  min-height: 1.3rem;
  margin: 1rem 0 0;
  color: #ffc7b8;
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.95rem;
}

.answer {
  display: grid;
  gap: 1rem;
  margin-top: clamp(1.6rem, 5vw, 2.3rem);
  color: #fff8d9;
  place-items: center;
  animation: reveal 700ms ease-out both;
}

.answer h2 {
  margin: 0;
  color: #fff0b5;
  font-size: 3.85rem;
  font-weight: 400;
  line-height: 1.1;
}

.answer p {
  max-width: 29rem;
  margin: 0;
  font-size: 1.22rem;
  line-height: 1.55;
}

.answer img {
  display: block;
  width: min(100%, 30rem);
  max-height: 55vh;
  object-fit: contain;
  border: 1px solid rgba(229, 193, 108, 0.46);
  border-radius: 8px;
  box-shadow: 0 1.4rem 3rem var(--shadow);
}

.is-unlocked .password-form {
  display: none;
}

@keyframes tremble {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-0.25rem);
  }

  75% {
    transform: translateX(0.25rem);
  }
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(0.7rem);
  }

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

@media (max-width: 620px) {
  h1 {
    font-size: 2.15rem;
  }

  .password-cell {
    font-size: 2.35rem;
  }

  .answer h2 {
    font-size: 2.7rem;
  }

  .answer p {
    font-size: 1.08rem;
  }
}

@media (max-width: 430px) {
  .library-shell {
    padding: 1rem;
  }

  .gate {
    padding-inline: 1rem;
  }

  .password-grid {
    grid-template-columns: repeat(var(--cell-count), minmax(0, 1fr));
  }

  h1 {
    font-size: 1.9rem;
  }

  .password-cell {
    font-size: 1.95rem;
  }

  .answer h2 {
    font-size: 2.2rem;
  }
}
