.account-page {
  --account-bg: #f7f6fb;
  --surface: #fff;
  --soft: #f2eff8;
  --ink: #211a30;
  --muted: #655a75;
  --line: #ddd5ea;
  --brand: #6345bd;
  font-family: "DM Sans", system-ui, sans-serif;
}
:root[data-theme="dark"] .account-page {
  --account-bg: #18181d;
  --surface: #24232d;
  --soft: #302b3d;
  --ink: #f5f2fb;
  --muted: #c5bcd0;
  --line: #453c53;
  --brand: #b79aff;
}
.account-page, .account-page *, .account-link { box-sizing: border-box; }
.account-page [hidden] { display: none !important; }

.account-link {
  position: absolute;
  z-index: 3;
  top: 12px;
  left: 12px;
  display: grid;
  place-items: center;
  min-height: 42px;
  max-width: min(32vw, 180px);
  padding: 0 12px;
  border: 1px solid #ddd;
  border-radius: 999px;
  background: #f8f8f8;
  color: #292929;
  font: 650 .8rem system-ui, sans-serif;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html[data-theme="dark"] .account-link { background: #292832; color: #f5f3fa; border-color: #494653; }
.account-link:hover { border-color: #9171e5; }
body:has(.game-page) .account-link { left: auto; right: 62px; }
@media (max-width: 620px) {
  body:has(.game-page) .game-header { grid-template-columns: 1fr; }
  body:has(.game-page) .game-header h1 { text-align: center; }
}

.account-page { margin: 0; background: var(--account-bg); color: var(--ink); }
.account-shell { width: min(100% - 32px, 1000px); margin-inline: auto; padding-bottom: 40px; }
.account-header { min-height: 70px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding: 12px 54px 12px 0; }
.account-header > a { font: 700 1.15rem "Segoe Print", cursive; color: inherit; text-decoration: none; }
.account-header nav { display: flex; gap: 16px; }
.account-page a { color: var(--brand); text-underline-offset: 3px; }
.account-panel { margin-block: 14px; padding: clamp(16px, 3vw, 24px); border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.account-panel h1, .account-panel h2 { margin: 0 0 12px; letter-spacing: -.035em; }
.account-panel h2 { font-size: 1.15rem; }
.auth-panel { max-width: 520px; margin: 40px auto; }
.account-page form { display: grid; gap: 13px; }
.account-page label { display: grid; gap: 5px; font-size: .85rem; font-weight: 650; min-width: 0; }
.account-page input, .account-page select, .account-page textarea, .account-page button:not(.theme-toggle), .account-button {
  font: inherit; color: inherit; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.account-page input, .account-page select, .account-page textarea { width: 100%; }
.account-page input[type="color"] { min-height: 34px; padding: 3px; }
.account-page input[type="checkbox"] { width: auto; accent-color: var(--brand); }
.account-page textarea { resize: vertical; }
.account-page button:not(.theme-toggle), .account-page .account-button { cursor: pointer; font-size: .85rem; font-weight: 650; text-decoration: none; }
.account-page button:disabled { cursor: wait; opacity: .65; }
.account-page .primary { background: #6245b7; border-color: #6245b7; color: white; }
.account-page button:hover, .account-button:hover { border-color: var(--brand); }
.account-page :focus-visible, .account-link:focus-visible { outline: 2px solid #9271e7; outline-offset: 3px; }
.form-note, .profile-handle { color: var(--muted); font-size: .85rem; margin: 0; }
.account-page label.check { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.panel-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 7px; margin-bottom: 8px; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 14px; }
.profile-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.profile-cover {
  display: flex; align-items: end; flex-wrap: wrap; gap: 16px;
  padding: clamp(16px, 4vw, 30px); border-radius: 18px;
  position: relative;
  isolation: isolate;
  min-height: clamp(160px, 26vw, 290px);
  border: 1px solid var(--line);
  background: linear-gradient(120deg, #232947, #36304d 55%, #23273f);
}
.profile-avatar { display: grid; place-items: center; width: 82px; height: 82px; flex-shrink: 0; overflow: hidden; border: 4px solid var(--profile-ring, #f5c66b); border-radius: 50%; color: white; background: #211b34; font-size: 2rem; font-weight: 750; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-identity { max-width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; border-radius: 11px; border: 1px solid transparent; padding: 8px 12px; color: #fff; text-shadow: 0 1px 4px #21192ad0; background: #211b346c; }
.profile-identity[data-plate="solid"] { background: #211b34; }
.profile-identity[data-plate="outline"] { border-color: #fff9; background: #211b3438; }
.profile-identity[data-plate="plain"] { background: transparent; }
.profile-identity h1 { margin: 0; font-size: clamp(1.4rem, 5vw, 2.4rem); line-height: 1.04; overflow-wrap: anywhere; }
.profile-identity .profile-handle { flex-basis: 100%; color: #fff; }
.profile-details p { white-space: pre-wrap; overflow-wrap: anywhere; }
.profile-details h2 { margin-block: 14px 8px; }
.badges { display: inline-flex; align-items: center; gap: 4px; flex-wrap: nowrap; vertical-align: middle; }
.badges:empty { display: none; }
#profile-badges:has(.badges:empty) { display: none; }
.badge {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: var(--badge-size, 17px);
  height: var(--badge-size, 17px);
  flex: 0 0 auto;
  isolation: isolate;
  text-shadow: none;
  color: #191d30;
}
.badge::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: var(--badge-color);
  border-radius: 50%;
}
.badge-mark {
  font: 900 calc(var(--badge-size, 17px) * .68) / 1 system-ui, sans-serif;
}
.profile-identity .badge { --badge-size: 22px; }
.badge.verified { --badge-color: #30a9ff; color: #073a63; }
.badge.verified::before {
  clip-path: polygon(50% 0, 63% 12%, 80% 9%, 88% 24%, 100% 33%, 94% 50%, 100% 67%,
    88% 76%, 80% 91%, 63% 88%, 50% 100%, 37% 88%, 20% 91%, 12% 76%, 0 67%,
    6% 50%, 0 33%, 12% 24%, 20% 9%, 37% 12%);
}
.badge.developer { --badge-color: #bd9aff; color: #312052; }
.badge.developer::before { border-radius: 5px; }
/* Draw the code brackets symmetrically around the center slash. */
.badge.developer .badge-mark {
  position: relative;
  width: 68%;
  height: 64%;
  background: linear-gradient(105deg, transparent 43%, currentColor 44% 55%, transparent 56%);
}
.badge.developer .badge-mark::before,
.badge.developer .badge-mark::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 27%;
  aspect-ratio: 1;
  border: solid currentColor;
  border-width: 0 0 1px 1px;
}
.badge.developer .badge-mark::before { left: 3%; transform: translateY(-50%) rotate(45deg); }
.badge.developer .badge-mark::after { right: 3%; transform: translateY(-50%) rotate(225deg); }
.badge.admin { --badge-color: #ff9b72; color: #602817; }
.badge.admin::before {
  border-radius: 0;
  clip-path: polygon(50% 0, 94% 16%, 87% 62%, 72% 83%, 50% 100%, 28% 83%, 13% 62%, 6% 16%);
}
.badge.admin .badge-mark { font-size: calc(var(--badge-size, 17px) * .45); }
.badge.owner { --badge-color: #ffd36b; }
.badge.owner::before {
  inset: 2px 0;
  border-radius: 0;
  clip-path: polygon(0 20%, 31% 44%, 50% 0, 69% 44%, 100% 20%, 83% 91%, 17% 91%);
}
.badge:hover { z-index: 2; }
.badge-tooltip {
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  width: max-content;
  max-width: 150px;
  transform: translate(-50%, 3px);
  padding: 5px 8px;
  border: 1px solid #ffffff26;
  border-radius: 6px;
  background: #242036;
  color: #fff;
  font: 600 .72rem / 1.25 system-ui, sans-serif;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 130ms ease, transform 130ms ease, visibility 130ms;
}
.badge:hover .badge-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}
@media (prefers-reduced-motion: reduce) {
  .badge-tooltip { transition: none; }
}
.player-list { display: grid; gap: 7px; margin-top: 12px; }
.player-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-block: 8px; }
.player-row .friend-state { color: var(--muted); font-size: .8rem; }
#account-message { background: var(--soft); border: 1px solid var(--line); padding: 9px 12px; border-radius: 8px; }
#account-message[data-error="true"] { border-color: #da697d; }
#admin-fields { margin: 0; border: 1px solid var(--line); border-radius: 9px; padding: 12px; display: grid; gap: 10px; }
#people-form { display: flex; align-items: end; }
@media (max-width: 660px) { .dash-grid { grid-template-columns: 1fr; gap: 0; } }
.profile-content { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 14px; }
.profile-content > .account-panel { margin-top: 0; }
.profile-summary { display: grid; gap: 12px; }
.profile-summary p { margin: 0; }
.favorite-games { display: grid; gap: 10px; }
.favorite-cover {
  display: block;
  width: min(100%, 340px);
  aspect-ratio: 2.5;
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: 0 3px 0 #1b17233b;
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.favorite-cover:hover { transform: translateY(-2px); box-shadow: 0 5px 0 #1b17233b; }
.favorite-cover:active { transform: translateY(2px); }

.people-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(105deg,
    color-mix(in srgb, var(--row-from) 20%, var(--surface)),
    color-mix(in srgb, var(--row-to) 10%, var(--surface)));
  transition: border-color 150ms ease, transform 150ms ease;
}
.people-row:hover { border-color: var(--brand); }
.account-page .people-main {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 3px 0;
  color: var(--ink);
  text-decoration: none;
}
.people-row .profile-avatar { width: 38px; height: 38px; border-width: 2px; font-size: .9rem; }
.people-identity { display: flex; align-items: center; flex-wrap: wrap; min-width: 0; gap: 4px 8px; }
.people-name { font-weight: 750; overflow-wrap: anywhere; }
.people-handle { flex-basis: 100%; color: var(--muted); font-size: .7rem; overflow-wrap: anywhere; }
.people-arrow { margin-inline-start: auto; color: var(--muted); }
.people-row .action-row { flex: 0 0 auto; }
.people-row .action-row button { padding: 6px 8px; font-size: .75rem; }
.people-row .friend-state { color: var(--muted); font-size: .75rem; }
@media (max-width: 550px) { .profile-content { grid-template-columns: 1fr; gap: 0; } }
@media (prefers-reduced-motion: reduce) {
  .favorite-cover, .people-row { transition: none; }
  .favorite-cover:hover, .favorite-cover:active { transform: none; }
}

.people-row .has-row-avatar { position: relative; }
.people-row .has-row-avatar img { position: absolute; inset: 0; }
@media (max-width: 420px) {
  .people-row { flex-wrap: wrap; }
  .account-page .people-main { flex-basis: 100%; }
  .people-row .action-row { margin-inline-start: 48px; }
}

.upload-status[data-error="true"] { color: #9a2444; }
:root[data-theme="dark"] .upload-status[data-error="true"] { color: #ffa2b9; }


.account-page.profile-background {
  min-height: 100vh;
  background: linear-gradient(var(--profile-angle, 135deg), var(--gradient-from, #5f45b9), var(--gradient-to, #e46088)) fixed;
}

.profile-background .account-header a {
  padding: 5px 9px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}

.profile-background .account-header a:hover { text-decoration: underline; }

.profile-banner {
  position: absolute;
  z-index: -1;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.profile-cover:has(.profile-banner:not([hidden]))::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(transparent 35%, #1511238c);
  pointer-events: none;
}

.custom-player-name[data-name-style="pixel"] {
  font-family: "Press Start 2P", "Courier New", monospace;
  font-weight: 900;
  letter-spacing: -.065em;
}
.custom-player-name[data-name-style="arcade"] {
  font-family: Impact, "Archivo Black", "Arial Black", sans-serif;
  font-weight: 800;
  letter-spacing: .015em;
  text-transform: uppercase;
}
.custom-player-name[data-name-style="script"] { font-family: "Segoe Print", "Comic Sans MS", cursive; }
.custom-player-name[data-name-style="serif"] { font-family: "DM Serif Text", Georgia, serif; }
.custom-player-name[data-name-style="mono"] { font-family: "IBM Plex Mono", Consolas, monospace; }

.profile-identity .custom-player-name { color: var(--name-color, #fff); }
.profile-identity [data-name-style="pixel"] {
  -webkit-text-stroke: 1.4px #1a1427;
  paint-order: stroke fill;
  text-shadow: 1px 2px var(--name-accent, #ffca64), 2px 3px #1a1427;
}
.profile-identity [data-name-style="arcade"] {
  text-shadow: 2px 2px var(--name-accent, #ffca64), 3px 4px #1a1427;
}

@media (prefers-reduced-motion: no-preference) {
  .profile-identity [data-name-motion="shimmer"] {
    background: linear-gradient(110deg, var(--name-color) 32%, var(--name-accent) 48%, var(--name-color) 62%);
    background-size: 240% 100%;
    background-clip: text;
    color: transparent;
    -webkit-text-stroke: 0;
    text-shadow: none;
    animation: profile-shimmer 3.8s ease-in-out infinite;
  }
  .profile-identity [data-name-motion="glow"] { animation: profile-glow 2.4s ease-in-out infinite alternate; }
  .profile-identity [data-name-motion="float"] { animation: profile-float 2.6s ease-in-out infinite; }
  @keyframes profile-shimmer {
    0%, 15% { background-position: 100% 0; }
    78%, 100% { background-position: 0 0; }
  }
  @keyframes profile-glow {
    from { text-shadow: 0 1px 4px #23192b; }
    to { text-shadow: 0 0 9px var(--name-accent), 0 1px 3px #23192b; }
  }
  @keyframes profile-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
  }
}
