/* ═══════════════════════════════════════════════════════════════
   ДВЕРЬ С ТРЕМЯ ЗАМКАМИ
   ═══════════════════════════════════════════════════════════════ */

.door {
  align-items: center;
  padding: 34px 20px 90px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 59, 87, .1), transparent 60%),
    var(--bg);
}

.door__head { text-align: center }

.door__title {
  font-family: var(--font-display);
  font-size: clamp(26px, 6vw, 44px);
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--danger);
  text-shadow: 0 0 40px rgba(255, 59, 87, .45);
}

.door__title--open {
  color: var(--accent);
  text-shadow: 0 0 44px rgba(0, 229, 122, .55);
  animation: dropIn .5s cubic-bezier(.22, 1, .36, 1) both;
}

.door__sub { margin-top: 8px; color: var(--text-dim); font-size: 15px }

/* ── сама дверь ───────────────────────────────────────────── */
.door__art { margin: 26px 0 32px; perspective: 1100px }

/* коробка */
.door__frame {
  position: relative;
  width: min(230px, 52vw);
  aspect-ratio: 5 / 9;
  margin: 0 auto;
  padding: 10px;
  border-radius: 6px;
  background: linear-gradient(160deg, #3a3126, #221c15);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.06),
    0 30px 70px rgba(0,0,0,.65);
  transform-style: preserve-3d;
}

/* то, что за дверью — видно, когда откроется */
.door__void {
  position: absolute;
  inset: 10px;
  border-radius: 3px;
  background: radial-gradient(ellipse at 50% 60%, #2b1116, #050609 70%);
  box-shadow: inset 0 0 60px rgba(0,0,0,.9);
}

/* полотно */
.door__leaf {
  position: absolute;
  inset: 10px;
  border-radius: 3px;
  background:
    repeating-linear-gradient(92deg, rgba(0,0,0,.12) 0 1px, transparent 1px 9px),
    linear-gradient(165deg, #6b4d2f, #4a3520 45%, #35251594);
  background-color: #4a3520;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.09),
    inset 0 -30px 60px rgba(0,0,0,.45),
    0 10px 30px rgba(0,0,0,.5);
  transform-origin: left center;
  transition: transform 1.2s cubic-bezier(.35, 0, .2, 1);
  will-change: transform;
}

.door__art--open .door__leaf { transform: rotateY(-72deg) }

/* филёнки */
.door__panel {
  position: absolute;
  left: 13%;
  right: 13%;
  border-radius: 3px;
  background: linear-gradient(160deg, rgba(0,0,0,.22), rgba(255,255,255,.05));
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,.35),
    inset 0 0 0 2px rgba(255,255,255,.05);
}

.door__panel--top { top: 7%; height: 26% }
.door__panel--bottom { bottom: 7%; height: 26% }

/* петли */
.door__hinge {
  position: absolute;
  left: -3px;
  width: 9px;
  height: 26px;
  border-radius: 2px;
  background: linear-gradient(90deg, #8a8f9b, #4a4f5a);
  box-shadow: 0 1px 3px rgba(0,0,0,.6);
}

.door__hinge--top { top: 14% }
.door__hinge--bottom { bottom: 14% }

/* ручка */
.door__handle {
  position: absolute;
  right: 9%;
  top: 50%;
  width: 26px;
  height: 9px;
  margin-top: -4px;
  border-radius: 5px;
  background: linear-gradient(180deg, #d9c07a, #8a7230);
  box-shadow: 0 2px 6px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.4);
}

.door__handle::before {
  content: '';
  position: absolute;
  right: -5px;
  top: -6px;
  width: 15px;
  height: 21px;
  border-radius: 4px;
  background: linear-gradient(180deg, #c8ad68, #7a642a);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
}

/* замочные скважины */
.door__slots {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 2;
}

.door__slot {
  width: 26px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: linear-gradient(180deg, #2a2f3a, #14171f);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.12),
    0 2px 5px rgba(0,0,0,.6);
  transition: box-shadow .4s;
}

/* сама прорезь: круг с ножкой */
.door__keyhole {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #05060a;
  transition: background .4s, box-shadow .4s;
}

.door__keyhole::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 6px;
  width: 4px;
  height: 9px;
  margin-left: -2px;
  background: #05060a;
  transition: background .4s;
}

.door__slot.is-open {
  box-shadow:
    inset 0 0 0 1px var(--accent),
    0 0 20px rgba(0, 229, 122, .55);
}

.door__slot.is-open .door__keyhole,
.door__slot.is-open .door__keyhole::after {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

/* ── скважина как кнопка ──────────────────────────────────── */
.door__slot { cursor: pointer }
.door__slot:hover:not(:disabled) { box-shadow: inset 0 0 0 1px var(--gold), 0 0 16px rgba(255,194,61,.4) }
.door__slot:disabled { cursor: default }





/* ── окно с задачей ───────────────────────────────────────── */
.lock-modal {
  position: relative;
  width: min(420px, 94vw);
  text-align: left;
  transition: box-shadow .4s;
}

.lock-modal--open { box-shadow: 0 0 0 1px var(--accent), 0 0 60px rgba(0,229,122,.3) }

.lock-modal__close {
  position: absolute;
  right: 14px;
  top: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 14px;
  color: var(--text-faint);
  background: var(--bg-2);
  transition: color .15s, background .15s;
}

.lock-modal__close:hover { color: var(--text); background: var(--bg-3) }

.lock__name {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .2em;
  color: var(--text-faint);
}

.lock__hint {
  margin-top: 10px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text-dim);
}

.lock__body { margin-top: 18px }
.lock__row { display: flex; gap: 8px; margin-top: 12px }

.lock__input {
  flex: 1;
  min-width: 0;
  padding: 13px 14px;
  font-family: var(--mono);
  font-size: 16px;
  text-align: center;
  letter-spacing: .16em;
  text-transform: uppercase;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  outline: none;
}

.lock__input:focus { border-color: var(--accent-dim) }
.lock__wide { width: 100%; margin-top: 10px }

.lock__err {
  margin-top: 12px;
  min-height: 16px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--danger);
  text-align: center;
}

.lock__done {
  padding: 26px 14px;
  text-align: center;
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: .2em;
  color: var(--accent);
}

.lock__done::before { content: '✓ ' }

/* ═══════════════════════════════════════════════════════════════
   ЗАМОК 1 — ПОРЯДОК СИМВОЛОВ
   ═══════════════════════════════════════════════════════════════ */

.ord__slots {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 14px;
}

.ord__slot {
  width: 42px;
  height: 50px;
  display: grid;
  place-items: center;
  font-size: 21px;
  color: var(--text-faint);
  background: var(--bg-2);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: color .2s, box-shadow .2s;
}

.ord__slot.is-set {
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-dim), 0 0 16px rgba(0, 229, 122, .2);
}

.ord__bank { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap }

.ord__chip {
  width: 46px;
  height: 46px;
  font-size: 22px;
  color: var(--text);
  background: var(--bg-3);
  border-radius: 10px;
  transition: transform .12s, opacity .2s, background .15s;
}

.ord__chip:hover:not(:disabled) { background: var(--line); transform: translateY(-2px) }
.ord__chip.is-used { opacity: .18; pointer-events: none }

/* ═══════════════════════════════════════════════════════════════
   ЗАМОК 1 — ХАНОЙСКАЯ БАШНЯ
   ═══════════════════════════════════════════════════════════════ */

.hanoi__count {
  margin-bottom: 10px;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--text-faint);
}

.hanoi {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  align-items: end;
}

.hanoi__peg {
  position: relative;
  height: 116px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
}

.hanoi__peg:hover { background: rgba(255,255,255,.03) }
.hanoi__peg.is-held { background: rgba(0, 229, 122, .1) }

.hanoi__rod {
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 5px;
  height: 96px;
  margin-left: -2.5px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, #3c4354, #232833);
}

.hanoi__base {
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 0;
  height: 8px;
  border-radius: 3px;
  background: linear-gradient(180deg, #454c5e, #262b36);
}

.hanoi__disks {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 3px;
}

/* цвет диска зависит от его номера — так порядок читается сразу */
.hanoi__disk {
  height: 17px;
  border-radius: 9px;
  background: hsl(calc(var(--d) * 48 + 150) 70% 52%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.35),
    0 2px 6px rgba(0,0,0,.5);
  transition: width .15s;
}

.hanoi__peg.is-held .hanoi__disks > :last-child {
  transform: translateY(-8px);
  box-shadow: 0 0 18px rgba(0, 229, 122, .6), inset 0 1px 0 rgba(255,255,255,.35);
}

/* ═══════════════════════════════════════════════════════════════
   ЗАМОК 2 — ЛАТИНСКИЙ КВАДРАТ
   ═══════════════════════════════════════════════════════════════ */

.sud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  max-width: 230px;
  margin: 0 auto;
  padding: 4px;
  background: var(--line);
  border-radius: 10px;
}

.sud__cell {
  aspect-ratio: 1;
  font-family: var(--mono);
  font-size: 21px;
  font-weight: 700;
  color: var(--accent);
  background: var(--bg-2);
  border-radius: 4px;
  transition: background .12s, color .12s;
}

.sud__cell:hover:not(:disabled) { background: var(--bg-3) }
.sud__cell.is-fixed { color: var(--text-dim); background: #0b0d13; cursor: default }

/* толстые границы между блоками 2×2 */
.sud__cell:nth-child(2n) { margin-right: 3px }
.sud__cell:nth-child(4n) { margin-right: 0 }
.sud__cell:nth-child(n+9):nth-child(-n+16) { margin-top: 0 }
.sud > :nth-child(5), .sud > :nth-child(6), .sud > :nth-child(7), .sud > :nth-child(8) { margin-bottom: 3px }

/* ═══════════════════════════════════════════════════════════════
   ЗАМОК 3 — ШИФР
   ═══════════════════════════════════════════════════════════════ */

.cipher__cap {
  margin: 4px 0 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .22em;
  color: var(--text-faint);
}

.cipher__legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
  gap: 6px;
  margin-bottom: 16px;
}

.cipher__pair {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 4px;
  border-radius: 8px;
  background: var(--bg-2);
}

.cipher__glyph { font-size: 19px; color: var(--gold) }
.cipher__eq { font-size: 11px; color: var(--text-faint) }
.cipher__letter { font-family: var(--mono); font-size: 15px; font-weight: 700; color: var(--text) }

.cipher__code {
  display: flex;
  gap: 7px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 16px 10px;
  border-radius: 10px;
  background: #0b0d13;
  box-shadow: inset 0 0 0 1px var(--line);
}

.cipher__code span {
  font-size: 26px;
  color: var(--accent);
  text-shadow: 0 0 16px rgba(0, 229, 122, .5);
}


/* ═══════════════════════════════════════════════════════════════
   ЗАМОК 2 — ПОРЯДОК СИМВОЛОВ
   ═══════════════════════════════════════════════════════════════ */

.ord__slots { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px }

.ord__slot {
  position: relative;
  width: 48px;
  height: 56px;
  display: grid;
  place-items: center;
  background: var(--bg-2);
  border-radius: 9px;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow .2s;
}

.ord__num {
  position: absolute;
  top: 3px;
  left: 5px;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-faint);
}

.ord__sym { font-size: 24px; color: var(--accent) }

.ord__slot.is-set { box-shadow: inset 0 0 0 1px var(--accent-dim), 0 0 16px rgba(0,229,122,.2) }

.ord__cap {
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .2em;
  color: var(--text-faint);
}

.ord__bank { display: flex; flex-direction: column; gap: 6px }

.ord__chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-radius: 9px;
  text-align: left;
  background: var(--bg-3);
  transition: background .15s, opacity .2s, transform .1s;
}

.ord__chip:hover:not(:disabled) { background: var(--line); transform: translateX(3px) }
.ord__chip.is-used { opacity: .2; pointer-events: none }

.ord__chip-sym { font-size: 21px; color: var(--gold); width: 26px; text-align: center }
.ord__chip-src { font-size: 13.5px; color: var(--text-dim) }

/* ── поле шифра ────────────────────────────────────────────── */
/* Отдельные правила с приоритетом: общий .modal input сжимал
   поле и делал набранное почти неразличимым. */
.lock-modal .cipher__input {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 16px 14px;
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  caret-color: var(--accent);
}

.lock-modal .cipher__input::placeholder {
  color: var(--text-faint);
  letter-spacing: .2em;
  font-weight: 400;
}

.lock-modal .cipher__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 22px rgba(0, 229, 122, .2);
}

/* зазор между словами в шифровке */
.cipher__gap { width: 18px; display: inline-block }

.cipher__code { row-gap: 10px }
