@font-face {
  font-family: "Fusion Pixel Public";
  src: url("/fonts/fusion-pixel-12px-proportional-zh_hans.otf.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 400 800;
}

:root {
  color-scheme: dark;
  --black: #050505;
  --panel: #0b0b0b;
  --line: #4b4b4b;
  --dim: #8b8b8b;
  --white: #f7f7f7;
  --door-dark: #241b17;
  --door-wood: #68462d;
  --door-light: #b07846;
  --brass: #e0c373;
  --font-pixel: "Fusion Pixel Public", "Cascadia Mono", "SFMono-Regular", Consolas, "Noto Sans Mono CJK SC", "Microsoft YaHei", monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

html { min-width: 320px; min-height: 100%; background: var(--black); }

html, body, * {
  scrollbar-width: thin;
  scrollbar-color: var(--white) var(--black);
}

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--black); border: 2px solid var(--line); }
::-webkit-scrollbar-track-piece { background: var(--black); }
::-webkit-scrollbar-thumb { min-height: 28px; border: 2px solid var(--black); background: var(--white); }
::-webkit-scrollbar-thumb:hover { background: var(--dim); }
::-webkit-scrollbar-corner { background: var(--black); }

::-webkit-scrollbar-button {
  display: block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--line);
  background-color: var(--black);
  background-repeat: no-repeat;
}

::-webkit-scrollbar-button:hover { border-color: var(--white); background-color: #171717; }
::-webkit-scrollbar-button:active { background-color: var(--line); }

::-webkit-scrollbar-button:single-button:vertical:decrement {
  background-image: linear-gradient(var(--white), var(--white)), linear-gradient(var(--white), var(--white)), linear-gradient(var(--white), var(--white));
  background-position: center 2px, center 4px, center 6px;
  background-size: 2px 2px, 6px 2px, 8px 2px;
}

::-webkit-scrollbar-button:single-button:vertical:increment {
  background-image: linear-gradient(var(--white), var(--white)), linear-gradient(var(--white), var(--white)), linear-gradient(var(--white), var(--white));
  background-position: center 6px, center 4px, center 2px;
  background-size: 2px 2px, 6px 2px, 8px 2px;
}

::-webkit-scrollbar-button:single-button:horizontal:decrement {
  background-image: linear-gradient(var(--white), var(--white)), linear-gradient(var(--white), var(--white)), linear-gradient(var(--white), var(--white));
  background-position: 2px center, 4px center, 6px center;
  background-size: 2px 2px, 2px 6px, 2px 8px;
}

::-webkit-scrollbar-button:single-button:horizontal:increment {
  background-image: linear-gradient(var(--white), var(--white)), linear-gradient(var(--white), var(--white)), linear-gradient(var(--white), var(--white));
  background-position: 6px center, 4px center, 2px center;
  background-size: 2px 2px, 2px 6px, 2px 8px;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  color: var(--white);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    var(--black);
  background-size: 16px 16px;
  font-family: var(--font-pixel);
  image-rendering: pixelated;
}

button, input, select, textarea { font: inherit; }
input, textarea, select {
  user-select: text;
  -webkit-user-select: text;
}
button:focus-visible, input:focus-visible { outline: 3px solid var(--white); outline-offset: 3px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--white); outline-offset: 3px; }
[hidden] { display: none !important; }

.login-shell { display: grid; min-height: 100vh; place-items: center; padding: 40px 24px; }

.environment-notice { position: fixed; z-index: 20; top: 14px; left: 50%; display: flex; width: min(620px, calc(100vw - 28px)); align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 3px solid var(--brass); color: rgb(255 241 212); background: rgb(33 22 14 / .95); box-shadow: 5px 5px rgb(0 0 0); transform: translateX(-50%); }
.environment-notice strong { display: block; color: rgb(255 224 160); font-size: 13px; }
.environment-notice p { margin: 5px 0 0; color: rgb(229 215 185); font-size: 11px; line-height: 1.5; }
.environment-notice button { flex: 0 0 auto; min-height: 34px; padding: 6px 9px; border: 2px solid rgb(45 27 13); color: rgb(35 20 8); background: rgb(239 209 139); box-shadow: inset 2px 2px rgb(255 240 197), 2px 2px rgb(0 0 0); cursor: pointer; font-size: 11px; }
.environment-notice button:hover, .environment-notice button:focus-visible { color: rgb(17 17 17); background: rgb(255 240 197); }
@media (max-width: 560px) { .environment-notice { top: 8px; align-items: start; }.environment-notice button { min-height: 40px; } }

.auth-stage {
  width: min(100%, 680px);
}

.gate-panel {
  position: relative;
  display: grid;
  justify-items: center;
  width: 100%;
  padding: 20px 16px;
  border: 4px solid #292929;
  background: #090909;
  box-shadow: 10px 10px 0 #000, 14px 14px 0 #252525;
}

.gate-door {
  display: block;
  width: min(86vmin, 640px);
  max-width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
}

.gate-door-frame {
  position: relative;
  display: block;
  height: min(86vmin, 640px);
  padding: 14px;
  border: 8px solid #171717;
  outline: 4px solid #6f6f6f;
  background: #020202;
  box-shadow: inset 0 0 0 4px #000, 8px 8px 0 #000;
}

.gate-door-surface {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 4px solid #170e0a;
  color: #fff0d1;
  background:
    linear-gradient(90deg, transparent 15%, rgba(23, 14, 10, 0.55) 15% 17%, transparent 17% 48%, rgba(23, 14, 10, 0.58) 48% 50%, transparent 50% 82%, rgba(23, 14, 10, 0.55) 82% 84%, transparent 84%),
    repeating-linear-gradient(0deg, transparent 0 38px, rgba(30, 18, 11, 0.66) 38px 43px),
    linear-gradient(90deg, var(--door-dark), var(--door-wood) 48%, var(--door-light) 50%, var(--door-wood) 54%, var(--door-dark));
  box-shadow: inset 8px 0 0 rgba(16, 9, 6, 0.82), inset -8px 0 0 rgba(16, 9, 6, 0.7), inset 0 0 0 4px rgba(235, 195, 131, 0.12);
}

.gate-door-surface > i { position: absolute; display: block; width: 17px; height: 17px; background: rgba(255, 231, 184, 0.4); box-shadow: 3px 3px 0 rgba(30, 18, 11, 0.72); }
.gate-door-surface > i:nth-child(1) { top: 17%; left: 13%; }
.gate-door-surface > i:nth-child(2) { top: 17%; right: 13%; }
.gate-door-surface > i:nth-child(3) { bottom: 17%; left: 13%; }
.gate-door-surface > i:nth-child(4) { right: 13%; bottom: 17%; }

.gate-door-question {
  position: absolute;
  top: 27%;
  right: 20px;
  left: 20px;
  display: grid;
  min-height: 82px;
  padding: 14px 12px;
  border: 4px solid #1b100a;
  color: #fff1d4;
  background: rgba(35, 20, 12, 0.76);
  box-shadow: 4px 4px 0 rgba(15, 8, 4, 0.78), inset 0 0 0 2px rgba(255, 231, 184, 0.32);
  font-size: clamp(21px, 5vw, 28px);
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.35;
  place-items: center;
  text-shadow: 3px 3px 0 #21120b;
}

.gate-door:hover .gate-door-frame { outline-color: #b8b8b8; }
.gate-door:active .gate-door-frame { transform: translate(4px, 4px); box-shadow: 4px 4px 0 #000; }
.gate-door.is-knocking .gate-door-surface { animation: door-knock 360ms steps(1, end); }

.combination-lock {
  position: absolute;
  top: 61%;
  left: 50%;
  width: 76px;
  height: 96px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  transform: translate(-50%, -50%);
}

.combination-lock-shackle {
  position: absolute;
  top: 1px;
  left: 17px;
  width: 42px;
  height: 42px;
  border: 7px solid var(--brass);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  box-shadow: inset 5px 0 0 rgba(58, 37, 17, 0.4), 3px 0 0 #24170c;
}

.combination-lock-body {
  position: absolute;
  top: 34px;
  right: 4px;
  left: 4px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  height: 52px;
  padding: 8px 8px 11px;
  border: 5px solid #2a1b0d;
  background: var(--brass);
  box-shadow: 4px 4px 0 #100a05, inset 0 0 0 3px #f7dda0;
}

.combination-lock-body i { display: block; height: 21px; border: 3px solid #3a260f; background: #17110a; box-shadow: inset 0 7px 0 #725126; }
.combination-lock-body b { position: absolute; right: 0; bottom: 6px; left: 0; width: 7px; height: 7px; margin: auto; background: #26180a; }
.combination-lock:hover .combination-lock-body { background: #f7dda0; }
.combination-lock:active { margin-top: 3px; }
.combination-lock.is-turning { animation: lock-turn 260ms steps(2, end); }

.return-to-gate { display: block; margin: 7px auto 0; }

.login-panel {
  position: relative;
  width: 100%;
  padding: 42px 38px 38px;
  border: 4px solid var(--white);
  background: var(--panel);
  box-shadow: 10px 10px 0 #000, 14px 14px 0 var(--line);
}

.login-panel::before, .login-panel::after { position: absolute; content: ""; background: var(--white); }
.login-panel::before { top: -8px; left: 28px; width: 88px; height: 8px; }
.login-panel::after { right: -8px; bottom: 32px; width: 8px; height: 64px; }

.pixel-mark {
  display: grid;
  grid-template-columns: repeat(3, 10px);
  grid-template-rows: repeat(3, 10px);
  gap: 3px;
  width: max-content;
  margin-bottom: 28px;
}

.pixel-mark i { background: var(--line); }
.pixel-mark i:nth-child(odd) { background: var(--white); }

.login-heading { padding-bottom: 24px; border-bottom: 2px solid var(--line); }
.login-heading p { margin: 0 0 10px; color: var(--dim); font-size: 12px; font-weight: 700; letter-spacing: 0.2em; }
.login-heading h1 { margin: 0; font-size: clamp(24px, 8vw, 34px); line-height: 1; letter-spacing: 0.08em; }

.loading-panel {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 224px;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.loading-pixels { display: flex; gap: 4px; }
.loading-pixels i { width: 7px; height: 7px; background: var(--white); animation: loading-step 900ms steps(1, end) infinite; }
.loading-pixels i:nth-child(2) { animation-delay: 150ms; }
.loading-pixels i:nth-child(3) { animation-delay: 300ms; }

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 24px;
  padding: 4px;
  border: 2px solid var(--line);
  background: #080808;
}

.auth-tab {
  min-height: 40px;
  border: 0;
  border-radius: 0;
  color: var(--dim);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.auth-tab:hover { color: var(--white); }
.auth-tab.is-active { color: var(--black); background: var(--white); }

.login-form { display: grid; gap: 22px; padding-top: 22px; }
.login-form label { display: grid; gap: 9px; }
.login-form label > span { color: var(--dim); font-size: 11px; font-weight: 700; letter-spacing: 0.14em; }

.registration-form { gap: 13px; padding-top: 18px; }
.registration-form label { gap: 6px; }
.registration-form input { height: 42px; }
.registration-form .login-button { min-height: 48px; margin-top: 7px; }

.login-form input {
  width: 100%;
  height: 48px;
  padding: 0 13px;
  border: 2px solid var(--line);
  border-radius: 0;
  color: var(--white);
  background: #080808;
  caret-color: var(--white);
  font-size: 14px;
  outline: 0;
}

.login-form input::placeholder { color: #555; opacity: 1; }
.login-form input:hover, .login-form input:focus { border-color: var(--white); }
.login-form input:invalid:not(:placeholder-shown) { border-color: var(--dim); }
.login-form input:disabled, .login-form select:disabled, .login-form button:disabled { color: #555; background: #171717; border-color: #333; cursor: not-allowed; }
.login-form input:-webkit-autofill,
.login-form input:-webkit-autofill:hover,
.login-form input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--white);
  caret-color: var(--white);
  box-shadow: 0 0 0 1000px #080808 inset;
  border: 2px solid var(--white);
}

select {
  min-height: 42px;
  padding: 0 34px 0 12px;
  border: 2px solid var(--line);
  border-radius: 0;
  color: var(--white);
  background: #080808;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--white) 50%), linear-gradient(135deg, var(--white) 50%, transparent 50%);
  background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  border: 2px solid var(--line);
  border-radius: 0;
  accent-color: var(--white);
  appearance: none;
  vertical-align: middle;
}
input[type="checkbox"]:checked { background: var(--white); box-shadow: inset 0 0 0 4px var(--black); }
input[type="checkbox"]:disabled { opacity: 0.45; }

input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 0;
  border: 2px solid var(--line);
  border-radius: 50%;
  appearance: none;
  vertical-align: middle;
}
input[type="radio"]:checked { border: 5px solid var(--white); background: var(--black); }
input[type="radio"]:disabled { opacity: 0.45; }

.login-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 52px;
  margin-top: 4px;
  padding: 0 16px;
  border: 0;
  border-radius: 0;
  color: var(--black);
  background: var(--white);
  box-shadow: 5px 5px 0 var(--line);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.login-button:hover { color: var(--white); background: #222; }
.login-button:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--line); }
.login-button:disabled { color: var(--dim); background: #2b2b2b; box-shadow: none; cursor: wait; }
.login-button b { font-size: 18px; }

.form-secondary-button {
  width: max-content;
  min-height: 32px;
  margin: -5px auto 0;
  padding: 4px 6px;
  border: 0;
  border-bottom: 2px solid var(--line);
  border-radius: 0;
  color: var(--dim);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
}
.form-secondary-button:hover { border-color: var(--white); color: var(--white); }
.form-secondary-button:active { transform: translateY(2px); }
.form-secondary-button:disabled { color: #555; border-color: #333; cursor: wait; }

.form-status { min-height: 21px; margin: 15px 0 0; color: var(--dim); font-size: 11px; line-height: 1.5; }
.form-status[data-error="true"] { color: var(--white); }
.form-status[data-error="true"]::before { content: "! "; }

.completion-notice {
  display: grid;
  grid-template-columns: 12px 1fr;
  column-gap: 10px;
  align-items: center;
  margin-bottom: 3px;
  padding: 11px 12px;
  border: 2px solid var(--line);
  background: #080808;
}
.completion-notice .status-led { width: 8px; height: 8px; background: var(--white); box-shadow: 0 0 0 2px var(--line); }
.completion-notice p { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: 0.08em; }
.completion-notice small { grid-column: 2; margin-top: 5px; color: var(--dim); font-size: 10px; line-height: 1.5; }
.profile-completion-form { gap: 16px; }
.password-reset-form { gap: 17px; }

.noscript {
  position: fixed;
  inset: auto 16px 16px;
  z-index: 200;
  padding: 12px;
  border: 2px solid var(--white);
  color: var(--white);
  background: var(--black);
  font: 12px/1.5 var(--font-pixel);
  text-align: center;
}

@keyframes loading-step { 0%, 33% { opacity: 1; } 34%, 100% { opacity: 0.2; } }
@keyframes door-knock { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }
@keyframes lock-turn { 0%, 100% { transform: translate(-50%, -50%); } 50% { transform: translate(-50%, -50%) rotate(8deg); } }
@media (max-width: 520px) {
  .login-shell { padding: 28px 18px; }
  .auth-stage { width: min(100%, 680px); }
  .login-panel { padding: 34px 24px 28px; box-shadow: 7px 7px 0 #000, 10px 10px 0 var(--line); }
  .login-shell { place-items: start center; }
  .login-panel { margin-top: 8vh; }
  .gate-panel { padding: 20px 13px 18px; box-shadow: 7px 7px 0 #000, 10px 10px 0 #252525; }
}

@media (prefers-reduced-motion: reduce) {
  .loading-pixels i { animation: none; }
  .gate-door.is-knocking .gate-door-surface, .combination-lock.is-turning { animation: none; }
}
