/* The authentication page has one viewport and one compact, scroll-safe card. */
html:has(#authScreen), body:has(#authScreen) {
  width: 100%; height: 100%; margin: 0; overflow: hidden;
}
#authScreen.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
  width: 100%; max-width: none;
  height: 100vh; height: 100dvh; min-height: 0;
  margin: 0;
  padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  overflow: hidden;
  background-color: #599cd1;
  background-image: linear-gradient(180deg, rgba(3, 12, 25, .44), rgba(3, 12, 25, .62)), url('/assets/bgm.png');
  background-size: 100% 100%, cover;
  background-repeat: no-repeat;
  background-position: center, center bottom;
}
#authScreen .auth-panel {
  display: flex; flex-direction: column; align-items: stretch;
  justify-content: center; flex: none;
  width: min(100%, 400px); height: auto; min-height: 0; max-height: 100%;
  padding: 0; overflow: visible; background: transparent;
}
#authScreen .auth-card {
  width: 100%; min-height: 0; max-height: 100%;
  padding: 28px;
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: #86b8d880 transparent;
  color: #f5faff;
  border: 1px solid rgba(225, 242, 255, .3);
  border-radius: 24px;
  background: linear-gradient(140deg, rgba(69, 107, 138, .43), rgba(12, 35, 58, .57));
  -webkit-backdrop-filter: blur(22px) saturate(125%);
  backdrop-filter: blur(22px) saturate(125%);
  box-shadow: 0 24px 64px rgba(0, 9, 23, .3), inset 0 1px 0 rgba(255, 255, 255, .15);
  animation: auth-enter .35s ease-out both;
}
#authScreen .auth-heading { margin: 0 0 20px; text-align: center; }
#authScreen .auth-heading h1 { margin: 0 0 7px; color: #fff; font-size: 25px; font-weight: 800; line-height: 1.6; letter-spacing: -.6px; }
#authScreen .auth-heading p { margin: 0; color: #e0edf8; font-size: 13px; line-height: 1.9; }
#authScreen .auth-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  margin: 0 0 20px; padding: 5px;
  border: 1px solid rgba(219, 240, 255, .19); border-radius: 13px;
  background: rgba(3, 18, 35, .4);
  box-shadow: inset 0 1px 5px rgba(0, 0, 0, .13);
}
#authScreen .auth-tab { height: 38px; border: 1px solid transparent; border-radius: 9px; color: #e4f1fc; background: transparent; font-size: 14px; font-weight: 500; transition: background .18s, color .18s, box-shadow .18s; }
#authScreen .auth-tab:hover { background: rgba(255, 255, 255, .08); }
#authScreen .auth-tab.is-active { border-color: rgba(255, 255, 255, .8); color: #153c59; background: #e7f4ff; font-weight: 700; box-shadow: 0 3px 10px rgba(0, 12, 26, .2); }
#authScreen .auth-form { gap: 14px; }
#authScreen .auth-form label { gap: 6px; color: #f4f9ff; font-size: 14px; font-weight: 500; }
#authScreen .auth-form input {
  height: 46px; min-height: 46px; padding: 0 12px;
  border: 1px solid rgba(209, 230, 248, .28); border-radius: 11px;
  color: #fff; background: rgba(4, 20, 38, .34); caret-color: #fff;
  font-size: 16px !important; font-weight: 400;
  direction: ltr; text-align: left;
}
#authScreen .auth-form input::placeholder { color: #c3d4e4 !important; font-size: 13px; }
#authScreen .auth-form input:focus { border-color: #88d3ff; background: rgba(4, 20, 38, .46); box-shadow: 0 0 0 3px rgba(115, 204, 255, .14); }
#authScreen .auth-form input:-webkit-autofill { -webkit-text-fill-color: #fff; box-shadow: 0 0 0 1000px #24435e inset; caret-color: #fff; }
#authScreen .password-field input { padding-inline: 44px; }
#authScreen .password-toggle { display: grid; place-items: center; inset-inline-end: 5px; top: 1px; width: 44px; height: 44px; color: #dceefa; }
#authScreen .password-toggle:hover { background: rgba(255, 255, 255, .09); }
#authScreen .password-toggle svg { width: 20px; height: 20px; stroke-linecap: round; stroke-linejoin: round; }
#authScreen .eye-slash { display: none; }
#authScreen .password-toggle[aria-pressed="true"] .eye-slash { display: block; }
#authScreen .auth-form .button-primary {
  height: 46px; min-height: 46px; margin: 3px 0 0; padding-inline: 16px;
  border: 1px solid #a3defa; border-radius: 11px;
  color: #0b304a; background: linear-gradient(115deg, #a0dcff, #6cc7f5);
  font-size: 14px; box-shadow: 0 8px 22px rgba(0, 13, 29, .19);
}
#authScreen .auth-form .button-primary:hover { background: #b4e5ff; transform: translateY(-1px); }
#authScreen .form-message { min-height: 0; color: #e4f1fb; font-size: 13px; }
#authScreen .form-message:empty { display: none; }
#authScreen .form-message.error { color: #ffe1e6; }
#authScreen .form-message.success { color: #bcfadd; }
#authScreen .auth-privacy { display: block; margin: 20px 0 0; padding: 14px 0 0; border-top: 1px solid rgba(226, 241, 254, .2); color: #d5e6f5; text-align: center; font-size: 12px; line-height: 1.9; }
#authScreen .local-link { width: fit-content; max-width: 100%; margin: 10px auto 0; color: #e3f3ff; text-align: center; font-size: 12px; line-height: 1.9; }
#authScreen .local-link:hover { color: #fff; text-decoration: underline; text-underline-offset: 4px; }
#authScreen .auth-footer.privacy-link { display: block; width: fit-content; min-height: 32px; margin: 5px auto -5px; padding: 5px 12px; color: #d3e8f9; text-shadow: none; font-size: 12px; }
#authScreen .auth-footer.privacy-link:hover { color: #fff; }
#authScreen :is(button, a):focus-visible { outline: 2px solid #a0deff; outline-offset: 3px; }
@keyframes auth-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 480px) {
  #authScreen.auth-layout { padding-inline: max(16px, env(safe-area-inset-left)); }
  #authScreen .auth-card { padding: 24px 22px; border-radius: 21px; }
  #authScreen .auth-heading h1 { font-size: 23px; }
}
@media (max-height: 660px) {
  #authScreen.auth-layout { padding-block: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-bottom)); }
  #authScreen .auth-card { padding-block: 20px; }
  #authScreen .auth-heading, #authScreen .auth-tabs { margin-bottom: 14px; }
  #authScreen .auth-form { gap: 11px; }
  #authScreen .auth-privacy { margin-top: 14px; padding-top: 10px; }
}
@media (max-height: 540px) and (min-width: 620px) {
  #authScreen .auth-panel { width: min(100%, 540px); }
  #authScreen .auth-heading p { display: none; }
  #authScreen .auth-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  #authScreen .auth-form > :is(button, .form-message) { grid-column: 1 / -1; }
  #authScreen .auth-privacy { display: none; }
  #authScreen .auth-footer.privacy-link { margin-top: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  #authScreen .auth-card { animation: none; }
  #authScreen * { transition: none; }
}
