/* Account access gateway
   Deliberately scoped to the account controls and overlays so multiplayer,
   local 2P, and the timer cockpit retain their existing visual contracts. */

#auth-login-btn {
  position: relative;
}

#auth-login-btn[aria-expanded="true"] {
  z-index: 321;
  background: rgba(247, 181, 31, 0.12);
  color: var(--cockpit-amber-bright, #ffbf28);
}

#auth-user-menu {
  position: relative;
  /* Keep the account menu below the site's blocking dialogs (z-index: 100). */
  z-index: 90;
  gap: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  cursor: default;
}

#auth-user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid var(--cockpit-line, #2d3033);
  border-radius: 4px;
  background: transparent;
  color: var(--cockpit-text, #e9eaec);
  cursor: pointer;
  font-family: 'Barlow Condensed', 'Avenir Next Condensed', sans-serif;
  font-size: 0.95rem;
}

#auth-user-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#auth-user-trigger:focus-visible,
#auth-user-trigger[aria-expanded="true"] {
  outline: 2px solid var(--cockpit-amber, #f7b51f);
  outline-offset: 2px;
}

#auth-user-trigger[aria-expanded="true"] .auth-caret {
  color: var(--cockpit-amber, #f7b51f);
}

#auth-dropdown {
  background: var(--cockpit-surface, #17191b);
  border: 1px solid var(--cockpit-line, #2d3033);
  border-radius: 4px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
  min-width: 176px;
  padding: 4px 0;
}

#auth-dropdown .auth-dropdown-item {
  color: var(--cockpit-muted, #8d9298);
  font-family: 'Barlow Condensed', 'Avenir Next Condensed', sans-serif;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  padding: 10px 14px;
}

#auth-dropdown .auth-dropdown-item:hover,
#auth-dropdown .auth-dropdown-item:focus-visible {
  background: rgba(247, 181, 31, 0.08);
  color: var(--cockpit-text, #e9eaec);
  outline: none;
}

/* The account gateway is an anchored panel rather than a page-blocking modal. */
#auth-modal.auth-overlay {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 300;
  background: transparent;
  pointer-events: none;
}

#auth-modal.auth-overlay.is-open {
  pointer-events: auto;
}

#auth-modal .auth-panel {
  position: fixed;
  top: var(--auth-panel-top, 94px);
  right: var(--auth-panel-right, 18px);
  width: min(368px, calc(100vw - 28px));
  min-width: 0;
  max-width: none;
  max-height: calc(100vh - var(--auth-panel-top, 94px) - 18px);
  overflow-y: auto;
  margin: 0;
  padding: 26px 24px 0;
  background: var(--cockpit-surface, #17191b);
  border: 1px solid #5b6065;
  border-radius: 4px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.46);
  color: var(--cockpit-text, #e9eaec);
  font-family: 'Barlow Condensed', 'Avenir Next Condensed', sans-serif;
  letter-spacing: 0.02em;
  text-align: left;
  pointer-events: auto;
}

#auth-modal.auth-overlay::before {
  position: fixed;
  top: calc(var(--auth-panel-top, 94px) - 8px);
  right: calc(var(--auth-panel-right, 18px) + var(--auth-arrow-right, 48px));
  width: 14px;
  height: 14px;
  background: var(--cockpit-surface, #17191b);
  border-top: 1px solid var(--cockpit-amber, #f7b51f);
  border-left: 1px solid var(--cockpit-amber, #f7b51f);
  content: '';
  transform: rotate(45deg);
}

#auth-modal.auth-overlay::after {
  position: fixed;
  top: calc(var(--auth-panel-top, 94px) - 22px);
  right: calc(var(--auth-panel-right, 18px) + var(--auth-arrow-right, 48px) + 6px);
  width: 2px;
  height: 16px;
  background: var(--cockpit-amber, #f7b51f);
  content: '';
}

#auth-modal .auth-panel-header,
#change-pw-modal .auth-panel > .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
  margin: 0 0 18px;
  color: var(--cockpit-muted, #8d9298);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase;
}

#auth-modal .auth-panel-title {
  color: var(--cockpit-muted, #8d9298);
}

#auth-modal .auth-panel-header .modal-close,
#change-pw-modal .auth-panel > .modal-header .modal-close {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  color: var(--cockpit-muted, #8d9298);
  font-size: 1.25rem;
  line-height: 1;
}

#auth-modal .auth-panel-header .modal-close:hover,
#auth-modal .auth-panel-header .modal-close:focus-visible,
#change-pw-modal .auth-panel > .modal-header .modal-close:hover,
#change-pw-modal .auth-panel > .modal-header .modal-close:focus-visible {
  background: transparent;
  color: var(--cockpit-text, #e9eaec);
  outline: 2px solid var(--cockpit-amber, #f7b51f);
  outline-offset: 1px;
}

#auth-modal .auth-panel-tabs {
  margin: 0;
  border-bottom: 1px solid var(--cockpit-line, #2d3033);
}

#auth-modal .auth-tabs {
  display: flex;
  gap: 0;
  width: min(100%, 230px);
}

#auth-modal .auth-tab {
  position: relative;
  flex: 1 1 50%;
  min-height: 42px;
  padding: 8px 12px 11px;
  border: 0;
  border-bottom: 3px solid transparent;
  margin: 0;
  background: transparent;
  color: var(--cockpit-muted, #8d9298);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

#auth-modal .auth-tab:hover,
#auth-modal .auth-tab:focus-visible {
  color: var(--cockpit-text, #e9eaec);
  outline: none;
}

#auth-modal .auth-tab.active {
  color: var(--cockpit-amber, #f7b51f);
  border-bottom-color: var(--cockpit-amber, #f7b51f);
}

#auth-modal .auth-form,
#change-pw-modal .auth-form {
  margin: 0;
  padding-top: 24px;
}

#auth-modal .auth-field,
#change-pw-modal .auth-field {
  margin-bottom: 24px;
}

#auth-modal #auth-login-form .auth-field:first-child {
  margin-bottom: 32px;
}

#auth-modal .auth-label,
#change-pw-modal .auth-label {
  display: block;
  margin: 0 0 8px;
  color: var(--cockpit-muted, #8d9298);
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
}

#auth-modal .mp-input,
#change-pw-modal .mp-input {
  width: 100%;
  min-height: 56px;
  padding: 13px 14px;
  background: #151718;
  border: 1px solid #52575b;
  border-radius: 4px;
  color: var(--cockpit-text, #e9eaec);
  font-family: 'Share Tech Mono', monospace;
  font-size: 1rem;
  letter-spacing: 0.02em;
  outline: none;
}

#auth-modal .mp-input::placeholder,
#change-pw-modal .mp-input::placeholder {
  color: #72777b;
  opacity: 1;
}

#auth-modal .mp-input:focus,
#change-pw-modal .mp-input:focus {
  border-color: var(--cockpit-amber, #f7b51f);
  box-shadow: 0 0 0 1px var(--cockpit-amber, #f7b51f);
}

#auth-modal .auth-password-control {
  position: relative;
}

#auth-modal .auth-password-control .mp-input {
  padding-right: 50px;
}

#auth-modal .auth-password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--cockpit-muted, #8d9298);
  cursor: pointer;
  font-size: 1.15rem;
  transform: translateY(-50%);
}

#auth-modal .auth-password-toggle:hover,
#auth-modal .auth-password-toggle:focus-visible {
  color: var(--cockpit-text, #e9eaec);
  outline: 2px solid var(--cockpit-amber, #f7b51f);
  outline-offset: 0;
}

#auth-modal .auth-submit,
#change-pw-modal .auth-submit {
  width: 100%;
  min-height: 56px;
  padding: 12px 18px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

#auth-modal .auth-submit {
  min-height: 52px;
  border-color: var(--cockpit-amber, #f7b51f);
  background: linear-gradient(180deg, #ffca2b 0%, #f7b51f 100%);
  color: #16100a;
}

#auth-modal .auth-submit:disabled,
#change-pw-modal .auth-submit:disabled,
#auth-modal #auth-forgot-btn:disabled,
#auth-modal #auth-resend-btn:disabled {
  cursor: wait;
  opacity: 0.58;
}

#auth-modal .auth-forgot {
  margin: 25px 0 0;
  text-align: center;
}

#auth-modal .auth-resend {
  margin: 18px 0 22px;
  text-align: center;
}

#auth-modal .btn-link {
  padding: 3px 6px;
  color: var(--cockpit-amber, #f7b51f);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

#auth-modal .btn-link:hover,
#auth-modal .btn-link:focus-visible {
  color: var(--cockpit-amber-bright, #ffbf28);
  outline: 2px solid var(--cockpit-amber, #f7b51f);
  outline-offset: 2px;
}

#auth-modal .auth-verify-title {
  margin: 0 0 8px;
  color: var(--cockpit-text, #e9eaec);
  font-size: 1.2rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
}

#auth-modal .auth-verify-hint {
  margin: 0 0 22px;
  color: var(--cockpit-muted, #8d9298);
  font-size: 0.95rem;
  line-height: 1.35;
}

#auth-modal #auth-verify-code {
  font-size: 1.2rem;
  letter-spacing: 0.3em;
  text-align: center;
}

#auth-modal .auth-feedback,
#change-pw-modal .auth-feedback {
  min-height: 20px;
  margin: 0;
  color: var(--cockpit-red, #f04b4b);
  font-family: 'Barlow Condensed', 'Avenir Next Condensed', sans-serif;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  line-height: 1.25;
  text-align: left;
}

#auth-modal .auth-feedback.is-success,
#change-pw-modal .auth-feedback.is-success {
  color: var(--cockpit-green, #8bcf35);
}

#auth-modal .auth-panel-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 84px;
  margin: 0;
  border-top: 1px solid var(--cockpit-line, #2d3033);
  color: var(--cockpit-muted, #8d9298);
  font-size: 1rem;
  line-height: 1.2;
}

#auth-modal .auth-panel-footer .ph {
  color: #7d8388;
  font-size: 1.65rem;
}

/* Change password remains a centered account overlay, using the same tokens. */
#change-pw-modal.auth-overlay {
  z-index: 340;
  background: rgba(7, 8, 9, 0.78);
}

#change-pw-modal .auth-panel {
  width: min(430px, calc(100vw - 28px));
  min-width: 0;
  max-width: none;
  padding: 24px;
  background: var(--cockpit-surface, #17191b);
  border: 1px solid #5b6065;
  border-radius: 4px;
  color: var(--cockpit-text, #e9eaec);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.5);
}

#change-pw-modal .auth-panel > .modal-header {
  margin-bottom: 0;
}

#change-pw-modal .auth-form {
  padding-top: 8px;
}

@media (max-width: 700px) {
  #auth-user-trigger {
    max-width: clamp(86px, 30vw, 132px);
  }

  #auth-modal .auth-panel {
    top: var(--auth-panel-top, 72px);
    right: 10px;
    left: 10px;
    width: calc(100vw - 20px);
    max-height: calc(100dvh - var(--auth-panel-top, 72px));
    border-right: 1px solid #5b6065;
    border-left: 1px solid #5b6065;
    border-radius: 0 0 4px 4px;
    padding: 22px 18px 0;
  }

  #auth-modal.auth-overlay::before,
  #auth-modal.auth-overlay::after {
    display: none;
  }

  #auth-modal .auth-panel-header {
    margin-bottom: 16px;
  }

  #auth-modal .auth-panel-footer {
    min-height: 62px;
  }

  #change-pw-modal .auth-panel {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  #auth-modal .auth-panel,
  #auth-modal .auth-tab,
  #auth-modal .mp-input {
    transition: none;
  }
}
