:root {
  --ink: #16161a;
  --paper: #fffdf9;
  --amber: #e8a11c;
  --gold: #f6b71d;
  --gold-deep: #c9820a;
  --red: #e0413f;
  --green: #2fa84f;
  --shadow-lg: 0 40px 80px -30px rgba(74, 42, 8, .55), 0 12px 28px -14px rgba(74, 42, 8, .45);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --pop: cubic-bezier(.22, 1, .36, 1);
  --lx: 6px;
  --ly: 2px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Rubik", "Segoe UI", Arial, "David", sans-serif;
  color: var(--ink);
  background: #6d3a12;
  overflow-x: hidden;
}

.wall { position: fixed; inset: 0; z-index: -2; background: radial-gradient(ellipse at 70% 25%, #5b5b51, transparent 65%), linear-gradient(120deg, #232823, #3d4039 60%, #282e28); }
.wall__glow { position: absolute; inset: 0; background: radial-gradient(ellipse at 76% 18%, #d4b57b12, transparent 55%); }
.wall__grain { position: absolute; inset: 0; opacity: .1; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath fill='%23fff' filter='url(%23n)' opacity='.4' d='M0 0h180v180H0z'/%3E%3C/svg%3E"); }

.stage {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 40px 24px;
}

.scene {
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: minmax(380px, 460px) minmax(0, 1fr);
  align-items: center;
  gap: 32px;
  direction: ltr;
}

.doorwrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.door {
  position: relative;
  width: min(100%, 380px, calc((100svh - 140px) * .62));
  filter: drop-shadow(0 30px 40px rgba(52, 24, 2, .55));
  animation: doorIn 1s var(--ease) both;
}

@keyframes doorIn {
  from { opacity: 0; transform: translateX(50px) scale(.96); }
}

/* Architectural entrance: a solid leaf rotates on its actual left hinge. */
.entryway {
  position: relative;
  width: 76%;
  aspect-ratio: 0.51;
  margin: 5% auto 0;
  border: 11px solid #292b29;
  border-bottom: 0;
  clip-path: inset(-60px -80px 0);
  background: #24231f;
  box-shadow: 0 0 0 1px #787469, 0 0 0 5px #44453f, 16px 24px 42px #17171155;
  perspective: 2400px;
  perspective-origin: left center;
}
.entryway__interior { position: absolute; inset: 0; overflow: hidden; background: linear-gradient(90deg, #6b6356, #d4c7ad 65%, #a29277); }
.entryway__interior::after { content: ""; position: absolute; inset: 72% 0 0; background: linear-gradient(155deg, #c7b99b, #706654); border-top: 1px solid #e5d7bd; }
.entryway__portal { position: absolute; inset: 13% 18% 23%; background: linear-gradient(90deg, #282923, #555043); box-shadow: -2px 0 0 #f0dab1, -9px 0 22px #efca8750; }
.door__leaf {
  position: absolute; inset: 0;
  transform-origin: left center;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
  background: linear-gradient(90deg, #302721, #584437 38%, #3a2c24 78%, #29221d);
  box-shadow: inset 1px 0 #a68d6755, inset -3px 0 #181612;
  transition: transform 1.8s cubic-bezier(.32, .04, .18, 1) .22s;
}
.scene.is-open .door__leaf { transform: rotateY(-72deg); }
.door__leaf::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(105deg, #f3dbb312, transparent 45%, #0005); opacity: .3; transition: opacity 1.8s ease; }
.scene.is-open .door__leaf::after { opacity: .85; }
.door__veneer { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 3px, #b18c5d0c 3px 4px, transparent 4px 9px, #120b071a 9px 10px), repeating-linear-gradient(91deg, transparent 0 18px, #bf9d720b 19px, transparent 21px 34px); }
.door__inlay { position: absolute; inset: 0 22% 0 auto; width: 1px; background: #171411; box-shadow: 1px 0 #ba97613b; }
.door__number { position: absolute; top: 11%; right: 9%; color: #c2ad86; font: 300 clamp(11px, 2vw, 21px) Georgia, serif; letter-spacing: 3px; }
.door__reader { position: absolute; top: 39%; right: 9%; width: 9%; height: 8%; background: linear-gradient(110deg, #353633, #171916); border: 1px solid #68675a; border-radius: 2px; }
.door__indicator { position: absolute; top: 22%; left: 28%; right: 28%; height: 2px; background: #bba67e; transition: background .3s, box-shadow .3s; }
.scene.is-open .door__indicator { background: #a4c8a5; box-shadow: 0 0 5px #a4c8a555; }
.scene.is-locked .door__indicator { animation: accessPulse 1.8s ease-in-out infinite; }
@keyframes accessPulse { 50% { opacity: .35; } }
.door__pull { position: absolute; top: 49%; right: 10%; width: 5%; height: 25%; border-radius: 1px; background: linear-gradient(90deg, #65533a, #ccb991 32%, #e0cfac 45%, #a18a64 64%, #6f5e43); box-shadow: -5px 5px 8px #0008, 1px 0 0 #e0c79b; transform: translateZ(7px); }
.door__cylinder { position: absolute; top: 79%; right: 11%; width: 3%; aspect-ratio: 1; border: 2px solid #a08c68; border-radius: 50%; background: #1c1c18; }
.door__edge { position: absolute; top: 0; right: 0; bottom: 0; width: 7px; background: #201c17; transform-origin: right; transform: rotateY(-90deg); }
.beam { position: absolute; inset: 25% 0 10%; background: radial-gradient(ellipse, #ecd8ac24, transparent 65%); opacity: 0; transition: opacity 1.8s ease .3s; pointer-events: none; }
.scene.is-open .beam { opacity: 1; }

/* Brass-rimmed eyes retain the login character within the walnut door. */
.door__eyes { position: absolute; top: 22%; left: 14%; width: 53%; display: flex; justify-content: space-between; transform: translateZ(2px); }
.eye { position: relative; width: 39%; aspect-ratio: 1.2; border: 2px solid #aa9470; border-radius: 48%; background: #e9e3d6; box-shadow: 0 3px 7px #0007, inset 0 3px 6px #30251b44; overflow: hidden; transition: transform .35s var(--ease), background .3s ease, border-color .3s ease, box-shadow .3s ease; }
.eye__blink { position: absolute; inset: 0; display: grid; place-items: center; animation: eyeBlink 7s ease-in-out infinite; }
.eye__pupil { position: relative; width: 43%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 50% 50%, #111410 0 45%, #504b36 48%, #24271f 75%); transform: translate(var(--lx), var(--ly)); transition: transform .28s ease-out; }
.eye__pupil::after { content: ""; position: absolute; top: 18%; left: 21%; width: 22%; height: 22%; border-radius: 50%; background: #fffdf2; opacity: .85; }
.eye__lid { position: absolute; inset: -1px -1px auto; height: 13%; background: linear-gradient(90deg, #48382c, #63503d); border-bottom: 1px solid #b19a72; transition: height .35s ease, transform .35s ease; }
.scene[data-expression="wide"] .eye { transform: scale(1.08); }
.scene[data-expression="wide"] .eye__lid { height: 3%; }
.eye::after { content: ""; position: absolute; left: 3%; right: 3%; top: 16%; height: 46%; border-bottom: 3px solid #ceb78c; border-radius: 0 0 50% 50%; opacity: 0; transform: translateY(-8px); filter: drop-shadow(0 2px 1px #17120de6); transition: opacity .22s ease, transform .4s var(--ease); }
.scene[data-expression="focused"] .eye { background: transparent; border-color: transparent; box-shadow: none; transform: translateY(2px); }
.scene[data-expression="focused"] .eye__lid { height: 100%; opacity: 0; }
.scene[data-expression="focused"] .eye__blink { visibility: hidden; animation: none; }
.scene[data-expression="focused"] .eye::after { opacity: 1; transform: translateY(0); }
@media (max-width: 560px) { .eye::after { border-bottom-width: 2px; } }
.scene[data-expression="waiting"] .eye__lid { height: 22%; }
.scene[data-expression="error"] .eye:first-child .eye__lid { height: 37%; transform: rotate(12deg); }
.scene[data-expression="error"] .eye:last-child .eye__lid { height: 37%; transform: rotate(-12deg); }
.scene[data-expression="error"] .door__indicator { background: #cd8073; animation: none; }
.scene[data-expression="happy"] .eye { transform: scaleY(.84); }
.scene[data-expression="happy"] .eye__blink { animation: none; }
@keyframes eyeBlink { 0%, 93%, 97%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.08); } }

.card {
  position: relative;
  direction: rtl;
  background: var(--paper);
  border-radius: 16px;
  padding: 34px 32px 30px;
  box-shadow: var(--shadow-lg);
  min-height: 500px;
  display: grid;
  align-content: center;
  animation: cardIn .9s var(--ease) .1s both;
  overflow: hidden;
  isolation: isolate;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(30px) scale(.97); }
}

.card__glow {
  position: absolute;
  inset: -40% -10% auto;
  height: 70%;
  background: radial-gradient(60% 100% at 50% 0, rgba(204, 184, 147, .18), rgba(255, 214, 130, 0) 70%);
  z-index: -1;
}

.panel {
  grid-area: 1 / 1;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  opacity: 0;
  transform: translateY(18px) scale(.97);
  pointer-events: none;
  transition: opacity .4s var(--ease) .16s, transform .5s var(--ease) .16s;
}

.panel:not(.is-active) { transition: opacity .2s var(--ease), transform .2s var(--ease); }
.panel.is-active { opacity: 1; transform: none; pointer-events: auto; }
.panel.is-out-left { transform: translateX(-46px) scale(.94); }
.panel.is-out-right { transform: translateX(46px) scale(.94); }

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  font-size: 22px;
  margin-bottom: 6px;
}

.logo {
  max-width: 190px;
  max-height: 88px;
  width: auto;
  height: auto;
  display: block;
}

.brand--logo {
  gap: 0;
  padding: 10px 16px 12px;
  border-radius: 18px;
  background: #14141a;
  box-shadow: 0 18px 30px -20px rgba(20, 20, 26, .9);
}

.brand--logo .logo {
  width: auto;
  height: 72px;
  max-width: none;
  max-height: none;
}

.shield { width: 46px; height: 54px; }
.shield__body { fill: var(--gold); }
.shield__hole { fill: #fffdf9; }
.shield__stem { fill: #fffdf9; }

.title {
  margin: 0;
  font-size: 30px;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -.4px;
}

.title--bad { color: var(--red); }
.title--good { color: var(--green); }

.sub {
  margin: 0;
  font-size: 16px;
  color: #6b6b74;
  line-height: 1.5;
}

.mono { direction: ltr; display: inline-block; color: #45454f; font-weight: 500; word-break: break-all; }

.head { display: contents; }
.head--bad { display: none; flex-direction: column; align-items: center; gap: 12px; }
.panel.is-error .head--ok { display: none; }
.panel.is-error .head--bad { display: flex; animation: headIn .4s var(--ease) both; }

@keyframes headIn {
  from { opacity: 0; transform: translateY(10px); }
}

.field {
  position: relative;
  width: 100%;
  margin-top: 12px;
}

.field__input {
  width: 100%;
  font: inherit;
  font-size: 19px;
  color: #1d1d22;
  background: #fff;
  border: 1.5px solid #e4e0d8;
  border-radius: 12px;
  padding: 17px 46px 17px 18px;
  text-align: right;
  outline: none;
  transition: border-color .25s, box-shadow .25s;
}

.field__input::placeholder { color: #b9b9c1; direction: ltr; text-align: right; }
.field__input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(246, 183, 29, .22); }
.field.is-bad .field__input { border-color: #f3b6b4; background: #fff7f7; }
.field.is-bad .field__input:focus { box-shadow: 0 0 0 4px rgba(224, 65, 63, .16); }

.field__icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  color: #b3b3bb;
  pointer-events: none;
}

.err {
  margin: 0;
  min-height: 20px;
  font-size: 14px;
  color: var(--red);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .25s, transform .25s;
}

.err.is-on { opacity: 1; transform: none; }

.btn {
  position: relative;
  width: 100%;
  margin-top: 8px;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  font-size: 19px;
  color: #fff;
  background: linear-gradient(180deg, #2a2a30, #16161a);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  overflow: hidden;
  box-shadow: 0 16px 26px -18px rgba(0, 0, 0, .9);
  transition: transform .25s var(--pop), opacity .3s, box-shadow .25s;
}

.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(0) scale(.985); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn__arrow { font-size: 22px; line-height: 1; transition: transform .3s var(--pop); display: inline-block; }
.btn:hover:not(:disabled) .btn__arrow { transform: translateX(-6px); }

.link__arrow { font-size: 16px; line-height: 1; transition: transform .3s var(--pop); display: inline-block; }
.link:hover:not(:disabled) .link__arrow { transform: translateX(-4px); }

.btn::after {
  content: "";
  position: absolute;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(246, 183, 29, .5);
  transform: scale(0);
  opacity: .6;
  pointer-events: none;
}

.btn.is-pressed::after { animation: ripple .65s var(--ease); }

@keyframes ripple {
  from { transform: scale(0); opacity: .55; }
  to { transform: scale(2.4); opacity: 0; }
}

.link {
  border: 0;
  background: none;
  font: inherit;
  font-size: 14.5px;
  color: #55555f;
  cursor: pointer;
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background .25s, color .25s, opacity .25s;
}

.link:hover:not(:disabled) { background: #f4f1ea; color: var(--ink); }
.link:disabled { opacity: .45; cursor: not-allowed; }

.hint {
  margin: 18px 0 0;
  padding: 8px 16px;
  border: 1px dashed #ded8cc;
  border-radius: 10px;
  font-size: 13.5px;
  color: #8a8a93;
  background: #fbf8f2;
}

.hint b {
  direction: ltr;
  display: inline-block;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #3a3a42;
}

.loader { display: flex; flex-direction: column; align-items: center; gap: 18px; margin: 20px 0 24px; color: #9a8052; }
.loader__lock { width: 80px; height: 80px; }
.loader__shackle { animation: lockPrepare 2.4s ease-in-out infinite; }
.loader__bolt { animation: boltPrepare 2.4s ease-in-out infinite; }
.loader__track { width: 112px; height: 3px; border-radius: 3px; background: #e7e0d3; overflow: hidden; }
.loader__track span { display: block; width: 45%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #bfa779, #8b7146); animation: accessTravel 1.8s ease-in-out infinite; }
@keyframes lockPrepare { 0%, 100% { transform: translateY(0); } 35%, 65% { transform: translateY(-5px); } }
@keyframes boltPrepare { 0%, 100% { transform: translateX(0); opacity: 1; } 35%, 65% { transform: translateX(-8px); opacity: .5; } }
@keyframes accessTravel { from { transform: translateX(-110%); } to { transform: translateX(330%); } }
.panel:not(.is-active) .loader * { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) { .loader__track span { transform: translateX(60%); } }

.sendline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #8b8b94;
  margin: 0;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  animation: ping 1.4s ease-in-out infinite;
}

@keyframes ping {
  0%, 100% { transform: scale(.6); opacity: .5; }
  50% { transform: scale(1.15); opacity: 1; }
}

.codes { display: flex; gap: 10px; margin: 18px 0 0; }

.code {
  width: 52px;
  height: 62px;
  border-radius: 12px;
  border: 1.5px solid #e4e0d8;
  background: #fff;
  font: inherit;
  font-size: 27px;
  font-weight: 700;
  text-align: center;
  color: #1d1d22;
  outline: none;
  caret-color: transparent;
  padding: 0;
  transition: transform .3s var(--pop), border-color .25s, box-shadow .25s, color .25s, background .25s;
}

.code.is-filled { border-color: #cfcabb; box-shadow: 0 8px 16px -12px rgba(0, 0, 0, .6); }
.code.is-active {
  border-color: var(--gold);
  background: #fffdf5;
  box-shadow: 0 0 0 4px rgba(246, 183, 29, .22);
  transform: translateY(-2px);
}
.code.is-bad { border-color: #f3b6b4; background: #fff6f6; color: var(--red); }
.code.is-pop { animation: codePop .4s var(--pop); }

@keyframes codePop {
  0% { transform: translateY(-10px) scale(.8); }
  60% { transform: translateY(2px) scale(1.06); }
  100% { transform: none; }
}

.codes.is-bad { animation: shake .55s cubic-bezier(.36, .07, .19, .97); }

@keyframes shake {
  10%, 90% { transform: translateX(-3px); }
  20%, 80% { transform: translateX(6px); }
  30%, 50%, 70% { transform: translateX(-9px); }
  40%, 60% { transform: translateX(9px); }
}

.timer { margin: 4px 0 0; font-size: 15px; color: #55555f; }
.timer b { direction: ltr; display: inline-block; font-variant-numeric: tabular-nums; color: var(--ink); }
.timer.is-over { color: var(--red); }
.timer.is-over b { color: var(--red); }

.status {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  margin-bottom: 4px;
  animation: statusIn .6s var(--pop) both;
}

.status svg { width: 64px; height: 64px; }
.status--good { color: var(--green); }
.status--bad { color: var(--red); }

@keyframes statusIn {
  0% { transform: scale(.2); opacity: 0; }
  60% { transform: scale(.96); }
  100% { transform: scale(1); opacity: 1; }
}

@media (max-width: 980px) {
  .stage { min-height: 100svh; padding: 18px 14px; }
  .scene { grid-template-columns: 1fr; gap: 14px; }
  .doorwrap { order: 1; }
  .card { order: 2; min-height: 0; }
  .door { width: min(100%, 236px); }
  .beam { inset: 10% -10% 10% auto; width: 70%; }
}

@media (max-width: 560px) {
  .stage { padding: 12px 12px 18px; }
  .scene { gap: 10px; }
  .door { width: min(100%, 186px); }
  .card { padding: 20px 16px; border-radius: 22px; }
  .brand { font-size: 19px; margin-bottom: 2px; }
  .brand--logo { padding: 7px 13px 8px; border-radius: 15px; }
  .brand--logo .logo { height: 50px; }
  .title { font-size: 21px; }
  .sub { font-size: 14px; }
  .field__input { height: 50px; }
  .btn { height: 50px; font-size: 16px; }
  .codes { gap: 6px; }
  .code { width: 40px; height: 50px; font-size: 20px; }
  .hint { margin-top: 12px; padding: 7px 12px; font-size: 12.5px; }
  .hint b { font-size: 15px; letter-spacing: 2px; }
  .timer { font-size: 14px; }
  .link { font-size: 14px; }
  .status { width: 52px; height: 52px; margin-bottom: 0; }
  .status svg { width: 52px; height: 52px; }
  .panel { gap: 10px; }
}

@media (max-width: 380px) {
  .stage { padding: 10px 10px 12px; }
  .door { width: min(100%, 140px); }
  .codes { gap: 5px; }
  .code { width: 35px; height: 45px; font-size: 18px; }
  .title { font-size: 19px; }
}

@media (max-width: 560px) and (max-height: 700px) {
  .stage { padding: 8px 10px 10px; }
  .scene { gap: 8px; }
  .door { width: min(100%, 132px); }
  .card { padding: 16px 14px; }
  .panel { gap: 8px; }
  .brand--logo { padding: 6px 11px 7px; }
  .brand--logo .logo { height: 42px; }
  .title { font-size: 19px; }
  .sub { font-size: 13px; }
  .code { width: 36px; height: 44px; font-size: 18px; }
  .hint { margin-top: 8px; padding: 6px 10px; font-size: 12px; }
  .btn { height: 46px; }
}

@media (max-height: 640px) and (max-width: 900px) {
  .doorwrap { display: none; }
  .scene { gap: 0; }
  .card { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0ms !important; animation-delay: 0ms !important; }
}
