/* Account UI uses the same palette, typography, surfaces and radii as the site. */
#arcade-library[hidden],
#arcade-account [hidden],
.ap-panel[hidden] {
  display: none!important;
}
.arcade-heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .65rem 1rem;
  margin-bottom: .75rem;
}
.arcade-heading h1 {
  margin: 0;
}
.arcade-progress {
  padding: .35rem .65rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1.4;
}
.arcade-beta-notice {
  margin: 0 0 .65rem;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.5;
}
#arcade-account {
  margin: 1.75rem 0 2rem;
  min-width: 0;
  --ap-danger: #a92d39;
}
:root.theme-dark #arcade-account,
:root[data-page-theme] #arcade-account {
  --ap-danger: #ff9ca6;
}
.ap-card {
  min-width: 0;
  padding: clamp(1.25rem,3vw,2rem);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: linear-gradient(180deg,var(--card-surface),var(--card-surface-2));
  box-shadow: var(--shadow);
  margin: 1rem 0;
  overflow-wrap: anywhere;
}
.ap-card h2 {
  margin-top: 0;
  margin-bottom: 1.25rem;
  font-size: clamp(1.25rem,2.3vw,1.65rem);
}
.ap-card h3 {
  margin: 1.5rem 0 .75rem;
  font-size: 1.05rem;
}
.ap-card > p {
  max-width: 68ch;
  line-height: 1.65;
}
.ap-note,
.ap-field-hint {
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.65;
}
.ap-eyebrow {
  margin-bottom: .85rem;
  color: var(--link);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

/* A short introduction sits alongside a focused form on wider screens. */
.ap-auth {
  display: grid;
  grid-template-columns: minmax(0,.9fr) minmax(0,1.1fr);
  gap: clamp(1.5rem,4vw,4rem);
  padding: clamp(1.25rem,4vw,3rem);
}
.ap-auth-intro {
  padding-block: .5rem;
  min-width: 0;
}
.ap-auth-intro h2 {
  max-width: 15ch;
  font-size: clamp(1.5rem,2.5vw,2rem);
}
.ap-auth-intro > p:not(.ap-eyebrow) {
  max-width: 37ch;
  color: var(--muted);
  line-height: 1.7;
}
.ap-benefits {
  padding: 1.25rem 0 0;
  margin: 1.5rem 0 0;
  border-top: 1px solid var(--border);
  list-style: none;
  display: grid;
  gap: .85rem;
  font-size: .9rem;
  color: var(--muted);
}
.ap-benefits li {
  display: flex;
  align-items: baseline;
  gap: .65rem;
}
.ap-benefits li::before {
  content: '+';
  color: var(--accent);
  font-weight: 800;
}
.ap-auth-fields {
  min-width: 0;
  max-width: 36rem;
}
.ap-auth-fields h3 {
  margin: 1.4rem 0 .4rem;
}
.ap-auth-fields > .ap-note {
  margin-bottom: 1.25rem;
}
.ap-confirmation {
  max-width: 42rem;
  margin-inline: auto;
}
.ap-confirmation .btn {
  margin-top: .5rem;
}

/* Explicit control styles prevent browser defaults from breaking theme colors. */
#arcade-account .btn {
  min-height: 44px;
  max-width: 100%;
  font-family: var(--font);
  font-size: .78rem;
  line-height: 1.5;
  letter-spacing: .04em;
  white-space: normal;
  text-align: center;
  overflow-wrap: anywhere;
  border: 1px solid var(--border-strong);
  background: var(--hover-bg);
  color: var(--text);
  touch-action: manipulation;
}
#arcade-account .btn:hover {
  background: var(--hover-bg-strong);
  border-color: var(--accent);
}
#arcade-account .btn-primary {
  background: linear-gradient(90deg,var(--accent),var(--link));
  border-color: transparent;
  color: var(--on-accent);
  box-shadow: none;
}
#arcade-account .btn-primary:hover {
  filter: brightness(1.07);
}
#arcade-account button:disabled {
  cursor: wait;
  opacity: .65;
  transform: none;
}
#arcade-account :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
.ap-form {
  display: grid;
  gap: 1.1rem;
  max-width: 34rem;
  min-width: 0;
}
.ap-field {
  display: grid;
  gap: .45rem;
  min-width: 0;
}
.ap-field > label,
.ap-filters label {
  font-size: .9rem;
  font-weight: 650;
  color: var(--text);
}
.ap-form input:not([type=checkbox]),
.ap-form select,
.ap-filters select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: .75rem .9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  accent-color: var(--accent);
}
.ap-form input:hover,
.ap-filters select:hover {
  border-color: var(--accent);
}
.ap-form input:autofill {
  box-shadow: 0 0 0 1000px var(--bg) inset;
  -webkit-text-fill-color: var(--text);
}
.ap-form > .btn {
  width: 100%;
  margin-top: .15rem;
}
.ap-input-row {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  min-width: 0;
}
.ap-input-row:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.ap-input-row input:not([type=checkbox]) {
  border: 0;
  flex: 1;
  outline: none;
}
.ap-password-toggle {
  flex: none;
  min-width: 58px;
  padding: .5rem .65rem;
  border: 0;
  border-left: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--hover-bg);
  color: var(--link);
  font: 650 .78rem var(--font);
  cursor: pointer;
  touch-action: manipulation;
}
.ap-form .ap-check {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  line-height: 1.6;
  color: var(--muted);
  cursor: pointer;
}
.ap-check input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 3px 0 0;
  accent-color: var(--accent);
}
.ap-field-hint {
  font-weight: 400;
  font-size: .78rem;
}
.ap-captcha {
  order: 0;
  min-width: 0;
  max-width: 100%;
}
.ap-actions,
.ap-nav,
.ap-filters {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  align-items: center;
}
.ap-auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .35rem;
  padding: .35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
#arcade-account .ap-auth-tabs .btn {
  padding: .6rem .45rem;
  letter-spacing: 0;
  border-radius: var(--radius-sm);
  border-color: transparent;
  background: none;
  text-transform: none;
  font-size: .85rem;
}
#arcade-account .ap-auth-tabs button[aria-pressed=true] {
  background: var(--hover-bg-strong);
  border-color: var(--accent);
  color: var(--link);
}
#arcade-account .ap-text-button {
  padding: .65rem 0;
  margin-top: .5rem;
  min-height: 44px;
  background: none;
  border-color: transparent;
  box-shadow: none;
  color: var(--link);
  text-transform: none;
  letter-spacing: 0;
  font-size: .88rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.ap-status {
  padding: .85rem 1rem;
  margin: .75rem 0;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--hover-bg);
  color: var(--text);
  font-size: .9rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.ap-status:empty {
  display: none;
}
.ap-form .ap-status {
  margin: 0;
}
.ap-status[data-error=true] {
  border-left-color: var(--ap-danger);
}

/* Signed-in navigation remains visible and wraps instead of scrolling sideways. */
.ap-topline {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  padding: .75rem 0 1rem;
  border-bottom: 1px solid var(--border);
}
.ap-topline p {
  margin: 0;
  font-weight: 650;
  overflow-wrap: anywhere;
  min-width: 0;
}
.ap-nav {
  margin: 1rem 0;
  gap: .45rem;
}
#arcade-account .ap-nav .btn {
  padding: .6rem .9rem;
  border-radius: var(--radius-sm);
  font-size: .75rem;
}
#arcade-account .ap-nav button[aria-pressed=true] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}
.ap-settings-grid {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  gap: 2rem;
}
.ap-settings-section {
  min-width: 0;
}
.ap-settings-section > h3:first-child {
  margin-top: 0;
}
.ap-settings-section > .btn {
  margin-top: 1rem;
}
.ap-danger {
  margin-top: 2rem;
  padding: 1.25rem;
  box-shadow: none;
  border-color: var(--ap-danger);
  background: var(--card-surface-2);
}
.ap-danger h2 {
  font-size: 1.1rem;
}
.ap-danger h2::after {
  background: var(--ap-danger);
}
#arcade-account .ap-danger .btn-primary {
  background: var(--hover-bg);
  color: var(--ap-danger);
  border-color: var(--ap-danger);
  filter: none;
}
.ap-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(145px,1fr));
  gap: .8rem;
  margin: 1rem 0 1.25rem;
}
.ap-metric {
  min-width: 0;
  padding: 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--hover-bg);
}
.ap-metric strong {
  display: block;
  font-size: clamp(1.4rem,2vw,1.85rem);
  font-weight: 800;
  line-height: 1.3;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.ap-metric span {
  display: block;
  margin-top: .35rem;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.5;
}
.ap-filters {
  align-items: end;
  margin: 1.25rem 0;
  gap: .85rem;
}
.ap-filters label {
  display: grid;
  gap: .4rem;
  flex: 1 1 150px;
  min-width: 0;
  max-width: 24rem;
}
.ap-table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: .75rem 0 1rem;
  overscroll-behavior-x: contain;
}
.ap-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  font-variant-numeric: tabular-nums;
}
.ap-table th,
.ap-table td {
  text-align: left;
  vertical-align: top;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  line-height: 1.6;
}
.ap-table th {
  color: var(--text);
  font-size: .75rem;
  font-weight: 800;
  background: var(--hover-bg);
}
.ap-table td {
  color: var(--muted);
}
.ap-table tbody tr:last-child td {
  border-bottom: 0;
}
.ap-table button {
  font: inherit;
  color: var(--link);
  background: none;
  border: 0;
  min-height: 44px;
  text-align: left;
  text-decoration: underline;
  cursor: pointer;
}
.ap-empty,
.ap-loading {
  padding: 1rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.6;
}
.ap-profile {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.ap-achievements {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(min(100%,240px),1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.ap-achievement {
  min-width: 0;
  padding: 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--hover-bg);
}
.ap-achievement h3 {
  margin: 0 0 .6rem;
  font-size: 1rem;
}
.ap-achievement-state {
  font-size: .8rem;
  font-weight: 700;
  color: var(--link);
}
.ap-achievement progress {
  width: 100%;
  height: .5rem;
  accent-color: var(--accent);
}

/* Retro and Rain retain their sharp edges and distinct surface treatments. */
:root[data-page-theme] #arcade-account .btn-primary {
  background: var(--bg);
  color: var(--text);
  border-color: var(--accent);
  box-shadow: none;
}
:root[data-page-theme] #arcade-account .btn-primary:hover {
  background: var(--hover-bg-strong);
  color: var(--text);
  filter: none;
}
:root[data-page-theme=retro] .ap-card {
  border: 3px solid var(--accent);
  box-shadow: var(--shadow);
}
:root[data-page-theme=retro] .ap-card.ap-danger {
  border-color: var(--ap-danger);
  box-shadow: none;
}
:root[data-page-theme=retro] #arcade-account .btn-primary {
  border-width: 2px;
  border-right-color: var(--accent-2);
  border-bottom-color: var(--accent-2);
}
:root[data-page-theme=rain] .ap-card {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}
:root[data-page-theme] .ap-card.ap-danger {
  border-color: var(--ap-danger);
}
:root[data-page-theme] #arcade-account .ap-card.ap-danger .btn-primary {
  border-color: var(--ap-danger);
  color: var(--ap-danger);
}

@media (max-width:760px) {
  .ap-auth {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  .ap-auth-intro {
    padding: 0;
  }
  .ap-auth-intro h2 {
    max-width: none;
    font-size: 1.5rem;
    margin-bottom: .85rem;
  }
  .ap-auth-intro > p:not(.ap-eyebrow) {
    max-width: none;
    margin-bottom: 0;
  }
  .ap-benefits {
    display: none;
  }
  .ap-auth-fields {
    max-width: none;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
  }
  .ap-settings-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .ap-settings-section + section {
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
  }
}
@media (max-width:480px) {
  #arcade-account {
    margin-top: 1.25rem;
  }
  .ap-card {
    padding: 1rem;
  }
  .ap-auth-tabs {
    grid-template-columns: 1fr 1fr;
  }
  .ap-auth-tabs > .btn:last-child {
    grid-column: 1/-1;
  }
  .ap-auth-fields h3 {
    margin-top: 1rem;
  }
  .ap-nav {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
  #arcade-account .ap-nav .btn {
    padding: .65rem .5rem;
  }
  .ap-nav > .btn:first-child {
    grid-column: 1/-1;
  }
  .ap-metrics {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
  .ap-metric {
    padding: .85rem;
  }
  .ap-table th,
  .ap-table td {
    padding: .65rem .75rem;
  }
  .ap-filters label {
    max-width: none;
    flex-basis: 100%;
  }
  .arcade-progress {
    font-size: .65rem;
  }
}
@media (prefers-reduced-motion:reduce) {
  #arcade-account button {
    transition: none;
    transform: none!important;
  }
}
