/* ---------- The tower gate (shown until every floor is solved) ---------- */
:root {
  --gate-gold: #e8c872;
  --gate-dim: rgba(255, 255, 255, 0.45);
}

body.locked {
  overflow: hidden;                 /* nothing to scroll to until the door opens */
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 48px;
  padding: 24px;
  background-color: #000;          /* fallback if the gradient isn't drawn */
  background-image: radial-gradient(ellipse at 50% 35%, #161616 0%, #000 70%);
  color: #fff;
  font-family: 'SpecialElite', 'Courier New', monospace;
  overflow-y: auto;
}

/* Floors, drawn top (the door) to bottom (floor 1) */
.gate-floors {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gate-floors li {
  width: 46px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.3);
  font-size: 14px;
  transition: all 0.6s ease;
}

.gate-floors li.solved {
  background: rgba(232, 200, 114, 0.18);
  border-color: rgba(232, 200, 114, 0.5);
  color: var(--gate-gold);
}

.gate-floors li.current {
  border-color: var(--gate-gold);
  color: #fff;
  box-shadow: 0 0 14px rgba(232, 200, 114, 0.35);
}

.gate-floors li.door {
  border: none;
  font-size: 22px;
  color: rgba(232, 200, 114, 0.35);
}

/* The riddle panel */
.gate-panel {
  width: 100%;
  max-width: 520px;
}

.gate-tower {
  margin: 0 0 4px;
  color: var(--gate-dim);
  font-size: 13px;
  letter-spacing: 4px;
  text-transform: uppercase;
}

.gate-level {
  margin: 0 0 22px;
  font-size: 34px;
  font-weight: 400;
  color: var(--gate-gold);
}

.gate-clue {
  min-height: 4.5em;
  margin-bottom: 26px;
  font-size: 18px;
  line-height: 1.6;
}

.gate-form {
  display: flex;
  gap: 10px;
}

.gate-form input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  color: #fff;
  font: inherit;
  font-size: 18px;
}

.gate-form input:focus {
  outline: none;
  border-color: var(--gate-gold);
  box-shadow: 0 0 0 3px rgba(232, 200, 114, 0.2);
}

.gate-form button,
.gate-lookup {
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--gate-gold);
  border-radius: 4px;
  color: var(--gate-gold);
  font: inherit;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.gate-form button:hover,
.gate-lookup:hover {
  background: var(--gate-gold);
  color: #000;
}

/* Separate rule on purpose: browsers that don't know :focus-visible (iOS 15.0-15.3) drop the whole rule it's in */
.gate-form button:focus-visible,
.gate-lookup:focus-visible {
  background: var(--gate-gold);
  color: #000;
  outline: none;
}

.gate-form button:disabled {
  opacity: 0.5;
  cursor: wait;
}

.gate-feedback {
  min-height: 1.5em;
  margin: 14px 0 0;
  color: var(--gate-dim);
}

.gate-extra {
  margin: 4px 0 0;
  color: var(--gate-gold);
  font-size: 15px;
}

.gate-rules {
  margin: 30px 0 0;
  color: rgba(255, 255, 255, 0.3);
  font-size: 13px;
  line-height: 1.6;
}

/* Phones can't see the tab title, so they get a "look up" button instead */
.gate-lookup {
  display: none;
  margin-top: 14px;
  padding: 6px 14px;
  font-size: 14px;
}

.gate-lookup-text {
  margin: 10px 0 0;
  padding: 8px 12px;
  border-left: 2px solid var(--gate-gold);
  color: #fff;
  font-size: 15px;
}

@media (hover: none), (pointer: coarse) {
  .gate-lookup {
    display: inline-block;
    min-height: 44px;              /* comfortable touch target (Apple/Google guidelines) */
    padding: 10px 18px;
  }
}

/* ---------- Motion ---------- */
.gate.climb .gate-panel {
  animation: gate-climb 0.7s ease;
}

@keyframes gate-climb {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

.gate-form.shake {
  animation: gate-shake 0.4s ease;
}

@keyframes gate-shake {
  0%, 100% { transform: none; }
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}

.gate.opening {
  animation: gate-open 1.4s ease forwards;
}

.gate.opening .gate-floors li.door {
  color: var(--gate-gold);
  text-shadow: 0 0 18px var(--gate-gold);
  transform: scale(1.5);
}

@keyframes gate-open {
  0%, 45% { opacity: 1; }
  100%    { opacity: 0; }
}

/* ---------- Phones: floors become a row above the riddle ---------- */
@media (max-width: 640px) {
  .gate {
    flex-direction: column;
    justify-content: flex-start;
    gap: 28px;
    padding-top: 48px;
  }

  .gate-floors {
    flex-direction: row-reverse;   /* floor 1 on the left, the door on the right */
  }

  .gate-floors li {
    width: 38px;
    height: 30px;
  }

  .gate-level {
    font-size: 28px;
  }

  .gate-clue {
    min-height: 0;
    margin-bottom: 20px;
    font-size: 16px;
  }
}

/* Small or short screens (e.g. iPhone SE, phones in landscape): pull the input up so the keyboard doesn't cover it */
@media (max-width: 380px), (max-height: 600px) {
  .gate {
    padding-top: 20px;
    gap: 16px;
  }

  .gate-level {
    margin-bottom: 12px;
    font-size: 24px;
  }

  .gate-clue {
    margin-bottom: 16px;
  }

  .gate-rules {
    margin-top: 18px;
  }
}

/* ---------- Image clues ---------- */
.gate-clue img {
  display: block;
  max-width: 100%;
  max-height: 42vh;                 /* leave room for the input, even on phones */
  width: auto;
  height: auto;
  margin: 0 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

@media (max-width: 640px), (max-height: 600px) {
  .gate-clue img {
    max-height: 32vh;
  }
}

/* "Back to the tower" link on the 404 page (reuses the button look, visible on every device) */
.gate-home {
  display: inline-block;
  text-decoration: none;
}
