.auth {
  display: grid;
  place-content: center;
  text-align: center;
}

.auth form {
  width: min(420px, 80vw);
  display: grid;
  gap: 16px;
  margin: 18px auto 0;
  text-align: left;
}

.auth label {
  display: grid;
  gap: 7px;
  color: #4a5574;
  font-weight: 800;
}

.auth input,
.register-dialog > form > label input {
  width: 100%;
  min-width: 0;
  border: 2px solid #dfe3f5;
  border-radius: 14px;
  padding: 13px 15px;
  color: #243257;
  background: #fff;
  font: inherit;
  font-weight: 800;
  line-height: normal;
  box-shadow: none;
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.auth input:focus,
.register-dialog > form > label input:focus {
  border-color: #7168df;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(113, 104, 223, .15);
}

.auth input:not(:placeholder-shown),
.register-dialog > form > label input:not(:placeholder-shown) {
  color: #243257;
  background-color: #fff;
}

.auth input:-webkit-autofill,
.auth input:-webkit-autofill:hover,
.auth input:-webkit-autofill:focus,
.register-dialog > form > label input:-webkit-autofill,
.register-dialog > form > label input:-webkit-autofill:hover,
.register-dialog > form > label input:-webkit-autofill:focus {
  -webkit-text-fill-color: #243257;
  caret-color: #243257;
  box-shadow: 0 0 0 1000px #fff inset, 0 0 0 3px rgba(113, 104, 223, .15);
  transition: background-color 9999s ease-out 0s;
}

.auth-actions,
.start-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.form-error {
  min-height: 1.4em;
  margin: 0;
  color: #b33b3b;
  text-align: center;
}

/* The activity form has more controls than authentication forms. Keep its
   action visible within the fixed-height app shell without changing fields. */
.battle-create {
  place-content: center;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.battle-create > .eyebrow,
.battle-create > h1 {
  margin-top: 0;
  margin-bottom: 8px;
}

.auth .battle-create-form,
.battle-create form {
  width: min(620px, 86vw);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  margin-top: 6px;
}

.battle-create label {
  gap: 4px;
}

.battle-create input[type="number"] {
  padding: 9px 12px;
}

.battle-create fieldset {
  grid-column: 1 / -1;
  gap: 6px;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid #dfe3f5;
  border-radius: 14px;
  background: #fafaff;
}

.battle-create fieldset label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .92rem;
}

.battle-create fieldset input {
  width: auto;
  flex: 0 0 auto;
}

.battle-create legend {
  padding: 0 5px;
  color: #4a5574;
  font-weight: 900;
}

.battle-create small {
  color: #69728b;
  font-weight: 600;
}

.battle-create .form-error,
.battle-create .auth-actions {
  grid-column: 1 / -1;
}

@media (max-width: 600px) {
  .battle-create {
    place-content: start center;
    padding: 16px 14px;
  }

  .battle-create form {
    width: min(100%, 420px);
    grid-template-columns: minmax(0, 1fr);
  }

  .battle-create fieldset,
  .battle-create .form-error,
  .battle-create .auth-actions {
    grid-column: 1;
  }
}

.account-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  color: #596481;
  font-weight: 800;
}

.text-button {
  border: 0;
  padding: 5px;
  color: #625bc6;
  background: transparent;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.recent-accounts {
  width: min(460px, 84vw);
  display: grid;
  gap: 10px;
  margin: 20px auto;
}

.account-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  border: 1px solid rgba(80, 88, 145, .16);
  border-radius: 18px;
  padding: 12px 16px;
  color: #243257;
  background: rgba(255, 255, 255, .86);
  text-align: left;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(57, 64, 112, .08);
}

.account-card:hover { border-color: #8a82e8; transform: translateY(-1px); }
.account-avatar { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: #f0efff; font-size: 30px; }
.account-card strong, .account-card small { display: block; }
.account-card small { margin-top: 3px; color: #7a839c; }
.auth-switch { display: flex; justify-content: center; align-items: center; gap: 14px; }
.register-link { justify-self: center; }

.register-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  border: 1px solid rgba(113, 104, 223, .12);
  border-radius: 28px;
  padding: 0;
  color: #243257;
  background: linear-gradient(145deg, #fff 0%, #fbfaff 100%);
  box-shadow: 0 28px 90px rgba(34, 38, 76, .32);
  overflow: hidden;
}
.register-dialog::backdrop { background: rgba(28, 31, 55, .52); backdrop-filter: blur(6px); }
.register-dialog form {
  display: grid;
  width: auto;
  max-height: calc(100vh - 32px);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 18px;
  margin: 0;
  padding: 32px 36px 34px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.dialog-heading {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding-bottom: 4px;
}
.dialog-heading h2 { margin: 4px 0 0; font-size: clamp(1.55rem, 3vw, 2rem); }
.dialog-heading .eyebrow { margin-bottom: 2px; }
.dialog-close {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  color: #69728c;
  background: #f1f0fb;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.dialog-close:hover { color: #4f48b2; background: #e8e6fb; }
.register-dialog fieldset {
  grid-column: 1 / -1;
  border: 1px solid rgba(113, 104, 223, .14);
  border-radius: 18px;
  padding: 16px 18px 18px;
  margin: 0 0 2px;
  background: rgba(245, 244, 255, .72);
}
.register-dialog legend { padding: 0 8px; color: #4a5574; font-weight: 800; }
.register-dialog > form > label { align-content: start; }
.avatar-picker { display: flex; flex-wrap: wrap; gap: 11px; }
.avatar-picker label { display: block; }
.avatar-picker input { position: absolute; opacity: 0; pointer-events: none; }
.avatar-picker span {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 2px solid transparent;
  border-radius: 50%;
  background: #fff;
  font-size: 29px;
  cursor: pointer;
  box-shadow: 0 5px 14px rgba(57, 64, 112, .08);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.avatar-picker label:hover span { transform: translateY(-2px); }
.avatar-picker input:focus-visible + span { outline: 3px solid rgba(113, 104, 223, .2); outline-offset: 2px; }
.avatar-picker input:checked + span { border-color: #7168df; box-shadow: 0 0 0 4px rgba(113, 104, 223, .13), 0 7px 16px rgba(57, 64, 112, .1); }
.register-dialog .form-error,
.register-dialog .primary { grid-column: 1 / -1; }
.register-dialog .form-error { margin-top: -4px; }
.register-dialog .primary { min-height: 50px; margin-top: -4px; }

@media (max-width: 760px) {
  .register-dialog { width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 24px); border-radius: 22px; }
  .register-dialog form {
    max-height: calc(100vh - 24px);
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    padding: 24px 22px 26px;
  }
  .dialog-heading,
  .register-dialog fieldset,
  .register-dialog .form-error,
  .register-dialog .primary { grid-column: 1; }
  .avatar-picker { gap: 9px; }
  .avatar-picker span { width: 48px; height: 48px; font-size: 27px; }
}

@media (max-width: 600px) {
  .auth-actions,
  .start-actions { flex-direction: column; }
  .account-bar { justify-content: center; }
}

@media (max-width: 420px) {
  .register-dialog form {
    gap: 12px;
    padding: 18px 16px;
  }
  .dialog-heading { gap: 14px; }
  .register-dialog fieldset { padding: 14px; }
}
