:root {
  --bg: #10161d;
  --surface: #18222c;
  --surface-strong: #22303b;
  --ink: #f4f7fb;
  --muted: #a8b5c2;
  --line: #344555;
  --accent: #12a185;
  --accent-strong: #18b99a;
  --sapphire: #5595dd;
  --danger: #ff6f61;
  --warning: #e2aa43;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.32);
  --panel-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
  --topbar-bg: rgba(16, 22, 29, 0.92);
  --input-bg: #111922;
  --ok-bg: #12392f;
  --ok-border: #286b5b;
  --warn-bg: #3a2d14;
  --warn-border: #7d632a;
  --error-bg: #3c1f20;
  --error-border: #7c3934;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-strong: #eef3f8;
  --ink: #182333;
  --muted: #687486;
  --line: #d9e1ea;
  --accent: #0f7f6e;
  --accent-strong: #0a6558;
  --sapphire: #2865ad;
  --danger: #c8453b;
  --warning: #ad7a1f;
  --shadow: 0 18px 45px rgba(28, 38, 54, 0.11);
  --panel-shadow: 0 8px 22px rgba(28, 38, 54, 0.05);
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --input-bg: #ffffff;
  --ok-bg: #e9f8f4;
  --ok-border: #b9e3d7;
  --warn-bg: #fff6df;
  --warn-border: #ead09a;
  --error-bg: #ffefed;
  --error-border: #efbbb5;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--sapphire) 16%, transparent), transparent 34%),
    linear-gradient(180deg, var(--bg), color-mix(in srgb, var(--bg) 82%, #000 18%));
  color: var(--ink);
  overflow-x: hidden;
  overscroll-behavior: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.login-view {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 28px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 22px;
  margin: 0 auto;
  max-width: 760px;
  padding: 28px;
  width: 100%;
}

.login-top {
  align-items: start;
  display: grid;
  gap: 14px;
  grid-template-columns: 42px minmax(0, 1fr);
}

.login-heading {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.login-connection {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  justify-self: start;
  min-height: 34px;
  padding: 6px 12px;
}

.login-connection.is-ready {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--accent-strong);
}

.login-connection.is-waiting {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warning);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.1;
}

h2 {
  font-size: 19px;
  line-height: 1.2;
}

h3 {
  font-size: 15px;
  line-height: 1.25;
}

.muted {
  color: var(--muted);
}

.login-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  padding: 18px;
}

.shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  align-items: center;
  backdrop-filter: blur(18px);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: flex-start;
  padding: 16px 22px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-main {
  display: grid;
  gap: 20px;
  margin: 0 auto;
  max-width: 1180px;
  padding: 22px;
  width: 100%;
}

.brand {
  display: grid;
  flex: 1 1 auto;
  gap: 3px;
  min-width: 0;
}

.brand-link {
  background: transparent;
  border: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
  padding: 0;
  text-align: left;
}

.top-actions {
  align-items: center;
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  justify-content: flex-end;
  margin-left: auto;
}

.app-toast {
  align-items: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(18px);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: min(420px, calc(100vw - 24px));
  padding: 8px 12px;
  position: fixed;
  left: 50%;
  top: calc(92px + env(safe-area-inset-top));
  transform: translateX(-50%);
  z-index: 30;
}

.status-pill {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  min-height: 34px;
  padding: 6px 12px;
}

.status-pill[data-kind="ok"] {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--accent-strong);
}

.status-pill[data-kind="warn"] {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warning);
}

.status-pill[data-kind="error"] {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--danger);
}

.status-message {
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
}

.status-message[data-kind="error"] {
  color: var(--danger);
}

.status-message[data-kind="warn"] {
  color: var(--warning);
}

.icon-only,
.icon-button {
  align-items: center;
  background: var(--surface-strong);
  border: 0;
  border-radius: 999px;
  display: inline-grid;
  flex: 0 0 40px;
  gap: 4px;
  height: 40px;
  justify-content: center;
  padding: 0;
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
  width: 40px;
}

.icon-only {
  display: inline-flex;
  padding: 0;
}

.icon-only:hover,
.icon-button:hover {
  background: color-mix(in srgb, var(--surface-strong) 72%, var(--sapphire));
  box-shadow: 0 10px 22px rgba(40, 101, 173, 0.16);
  transform: translateY(-1px);
}

.theme-toggle {
  flex-basis: 42px;
  height: 42px;
  width: 42px;
}

.icon-button span {
  background: var(--ink);
  border-radius: 999px;
  display: block;
  height: 2px;
  width: 18px;
}

.ui-icon {
  fill: none;
  height: 19px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 19px;
}

.home-hero {
  align-items: end;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--panel-shadow);
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 24px;
}

.home-hero h1,
.profile-title h1 {
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.home-metrics {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(92px, 1fr));
}

.home-metrics div,
.profile-stats div {
  background: var(--surface-strong);
  border-radius: 8px;
  display: grid;
  gap: 3px;
  padding: 12px;
}

.home-metrics strong,
.profile-stats strong {
  font-size: 22px;
}

.home-metrics span,
.profile-stats span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.home-grid {
  align-items: start;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.85fr);
}

.layout {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(290px, 360px) minmax(0, 1fr);
  padding: 22px;
}

.sidebar,
.detail {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--panel-shadow);
  padding: 16px;
}

.section-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.player-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.player-card {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  display: grid;
  gap: 12px;
  grid-template-columns: 48px minmax(0, 1fr);
  min-height: 118px;
  padding: 14px;
  text-align: left;
  width: 100%;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.player-card:hover,
.player-card.is-selected {
  border-color: var(--sapphire);
  box-shadow: 0 10px 24px rgba(40, 101, 173, 0.12);
  transform: translateY(-1px);
}

.player-card.is-eliminated {
  background: color-mix(in srgb, var(--surface) 55%, var(--surface-strong));
  border-color: color-mix(in srgb, var(--line) 72%, var(--muted));
  color: var(--muted);
  filter: grayscale(0.9);
  opacity: 0.68;
}

.player-card.is-eliminated:hover,
.player-card.is-eliminated.is-selected {
  opacity: 0.82;
}

.player-card.is-self {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.player-name-row {
  align-items: center;
  display: flex;
  gap: 8px;
  min-width: 0;
}

.self-badge {
  background: var(--ok-bg);
  border-radius: 4px;
  color: var(--accent-strong);
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 6px;
}

.avatar {
  align-items: center;
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  font-weight: 800;
  height: 46px;
  justify-content: center;
  letter-spacing: 0;
  overflow: hidden;
  width: 46px;
}

.avatar img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.avatar.large {
  height: 58px;
  width: 58px;
}

.avatar.huge {
  box-shadow: 0 18px 35px rgba(0, 0, 0, 0.24);
  font-size: 30px;
  height: 96px;
  width: 96px;
}

.player-main {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.player-name {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.stats-row {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 8px;
}

.player-lives {
  display: block;
  min-width: 0;
  overflow: hidden;
  width: 100%;
}

.life-meter {
  background: var(--surface-strong);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.life-meter span {
  background: linear-gradient(90deg, var(--accent), var(--sapphire));
  display: block;
  height: 100%;
}

.life-count {
  align-items: center;
  display: inline-flex;
  font-size: 15px;
  font-weight: 700;
  gap: 6px;
  white-space: nowrap;
}

.life-count-value {
  font-variant-numeric: tabular-nums;
}

.heart-row {
  display: grid;
  gap: 8px;
  max-width: 100%;
}

.heart-line {
  align-items: center;
  display: flex;
  gap: var(--heart-gap, 4px);
  justify-content: center;
  min-width: 0;
}

.heart {
  color: color-mix(in srgb, var(--muted) 45%, transparent);
  font-size: 22px;
  line-height: 1;
  text-shadow: 1px 1px 6px rgb(0 0 0);
}

.heart.is-full {
  color: #e03b45;
}

.heart-row.profile {
  --heart-gap: min(4px, calc(15cqw / var(--heart-columns)));
  width: 100%;
}

.heart-row.profile .heart {
  font-size: min(36px, calc((100cqw - (var(--heart-columns) - 1) * var(--heart-gap)) / var(--heart-columns)));
}

.mini-team {
  align-items: center;
  display: grid;
  gap: 4px;
  grid-column: 1 / -1;
  grid-template-columns: repeat(6, minmax(0, 48px));
  min-width: 0;
  width: 100%;
}

.mini-team.empty {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.player-card .mini-team {
  display: flex;
  justify-content: center;
}

.player-card .mini-team .pokemon-icon.mini {
  flex: 0 1 48px;
}

.home-loading {
  display: grid;
  gap: 16px;
}

.profile-shell .profile-hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-color: color-mix(in srgb, var(--region-color) 55%, var(--line));
  background: linear-gradient(135deg, color-mix(in srgb, var(--region-color) 18%, var(--surface)), var(--surface));
}
.profile-style-pixel .profile-hero { border-radius: 0; box-shadow: 6px 6px 0 color-mix(in srgb, var(--region-color) 30%, transparent); }
.profile-style-pixel .profile-title h1 { font-family: ui-monospace, monospace; }
.profile-style-league .profile-hero { box-shadow: inset 0 0 0 6px var(--surface), inset 0 0 0 7px var(--region-color); }
.profile-style-league .profile-title h1 { font-family: Georgia, serif; }
.profile-frame-double .profile-hero { border: 4px double var(--region-color); }
.profile-frame-bold .profile-hero { border: 3px solid var(--region-color); }
.profile-hero::before { content: ""; position: absolute; inset: 0; z-index: -1; opacity: .18; pointer-events: none; }
.profile-pattern-dots .profile-hero::before { background: radial-gradient(var(--region-color) 1.5px, transparent 2px) 0 0 / 16px 16px; }
.profile-pattern-grid .profile-hero::before { background: linear-gradient(var(--region-color) 1px, transparent 1px), linear-gradient(90deg, var(--region-color) 1px, transparent 1px); background-size: 24px 24px; }
.profile-pattern-stripes .profile-hero::before { background: repeating-linear-gradient(135deg, transparent 0 16px, var(--region-color) 16px 18px); }

.pokemon-with-types { display: grid; justify-items: center; gap: 5px; }
.pokemon-types { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; }
.pokemon-types:empty { display: none; }
.pokemon-type { color: var(--ink); background: color-mix(in srgb, var(--type-color) 18%, var(--surface)); border: 1px solid color-mix(in srgb, var(--type-color) 40%, var(--line)); border-radius: 4px; font-size: 9px; padding: 2px 4px; line-height: 1.2; }
.team-icon-button { flex-direction: column; gap: 5px; }
.team-reorder { display: flex; gap: 3px; grid-column: 1 / -1; }
.team-reorder button { color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 5px; min-width: 30px; min-height: 28px; }
.drag-handle { cursor: grab; font-size: 20px; }
.team-slot.is-dragging { opacity: .45; outline: 2px dashed var(--muted); }

.loading-message {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 14px;
  gap: 8px;
}

.loading-spinner {
  animation: loading-spin 800ms linear infinite;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  height: 16px;
  width: 16px;
}

.player-skeleton {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 48px minmax(0, 1fr);
  padding: 14px;
}

.skeleton {
  animation: loading-pulse 1.2s ease-in-out infinite alternate;
  background: var(--surface-strong);
  border-radius: 4px;
  display: block;
}

.skeleton-avatar {
  border-radius: 50%;
  height: 46px;
  width: 46px;
}

.skeleton-lines,
.history-skeleton {
  display: grid;
  gap: 12px;
}

.skeleton-name {
  height: 16px;
  width: 60%;
}

.skeleton-lives {
  height: 20px;
  width: 90%;
}

.skeleton-team {
  grid-column: 1 / -1;
  height: 48px;
}

.skeleton-history {
  height: 40px;
}

.home-load-error {
  align-items: start;
  display: grid;
  gap: 16px;
  justify-items: start;
}

@keyframes loading-spin {
  to { transform: rotate(360deg); }
}

@keyframes loading-pulse {
  to { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
  .loading-spinner,
  .skeleton {
    animation: none;
  }
}

.detail-head {
  align-items: center;
  display: flex;
  gap: 14px;
  min-width: 0;
}

.detail-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select,
textarea {
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 10px;
  width: 100%;
}

input[type="color"] {
  padding: 3px;
}

input[readonly] {
  color: var(--muted);
}

textarea {
  min-height: 72px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--sapphire);
  box-shadow: 0 0 0 3px rgba(40, 101, 173, 0.15);
  outline: none;
}

.actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.actions.left {
  justify-content: flex-start;
  margin-top: 12px;
}

.button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  display: inline-flex;
  font-weight: 800;
  gap: 8px;
  justify-content: center;
  min-height: 40px;
  padding: 9px 13px;
  text-decoration: none;
  white-space: nowrap;
}

.button.primary {
  background: var(--accent);
  color: #fff;
}

.button.primary:hover {
  background: var(--accent-strong);
}

.button.secondary {
  background: var(--surface-strong);
  border-color: var(--line);
  color: var(--ink);
}

.button.danger {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--danger);
}

.button.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  flex: 0 0 auto;
  font-weight: 800;
  min-height: 38px;
  padding: 8px 12px;
}

.tab.is-active {
  background: var(--sapphire);
  border-color: var(--sapphire);
  color: #fff;
}

.gym-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 620px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td:first-child,
th:first-child {
  padding-left: 0;
}

td:last-child,
th:last-child {
  padding-right: 0;
}

.row-actions {
  width: 52px;
}

.empty-state {
  background: var(--surface-strong);
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.readonly-list {
  display: grid;
  gap: 10px;
}

.readonly-item {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 3px;
  padding-bottom: 10px;
}

.readonly-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.admin-tools {
  display: grid;
  gap: 14px;
}

.user-admin-list {
  display: grid;
  gap: 12px;
}

.user-admin-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 12px;
}

.user-admin-title {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 46px minmax(0, 1fr);
}

.user-admin-title div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.user-admin-title strong,
.user-admin-title span {
  overflow-wrap: anywhere;
}

.divider {
  background: var(--line);
  height: 1px;
}

.divider.spaced {
  margin: 16px 0;
}

.pin-form {
  display: grid;
  gap: 12px;
}

.small {
  font-size: 12px;
  margin-top: 8px;
}

.avatar-form {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.update-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.update-item {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
}

.update-item strong {
  font-size: 13px;
}

.update-item span {
  color: var(--muted);
  font-size: 12px;
}

.event-list {
  display: grid;
  gap: 10px;
}

.event-item {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 3px;
  padding-bottom: 10px;
}

.event-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.event-item strong {
  font-size: 13px;
  line-height: 1.25;
}

.event-item span {
  color: var(--muted);
  font-size: 12px;
}

.profile-shell {
  display: grid;
  gap: 16px;
}

.profile-nav {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.profile-hero {
  align-items: center;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--sapphire) 22%, transparent), transparent 44%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 20px;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  justify-items: center;
  padding: 24px;
  text-align: center;
}

.profile-core {
  display: grid;
  gap: 20px;
  justify-items: center;
  min-width: 0;
  width: 100%;
}

.profile-badge-column {
  display: grid;
  gap: 10px;
  justify-items: center;
  width: 64px;
}

.profile-badge-column .earned-medal {
  height: 56px;
  width: 56px;
}

.medal-image {
  display: block;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.earned-badge-row {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(8, minmax(0, 38px));
  min-width: 0;
  width: 100%;
}

.earned-badge-row .earned-medal {
  aspect-ratio: 1;
  min-width: 0;
}

.home-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  grid-column: 1 / -1;
  justify-content: center;
}

.home-badges .earned-medal {
  width: 30px;
}

.profile-badges-mobile {
  display: none;
}

.profile-avatar-wrap {
  align-items: center;
  display: grid;
  gap: 8px;
  justify-items: center;
}

.avatar-edit-button {
  align-items: center;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  gap: 6px;
  min-height: 30px;
  padding: 5px 10px;
}

.profile-title {
  display: grid;
  gap: 10px;
  justify-items: center;
  min-width: 0;
  width: 100%;
}

.profile-title h1 {
  overflow-wrap: anywhere;
}

.profile-summary {
  align-items: center;
  container-type: inline-size;
  display: grid;
  gap: 8px;
  justify-items: center;
  width: 100%;
}

.profile-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
}

.team-strip-panel {
  display: grid;
  gap: 12px;
}

.team-strip-head {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: space-between;
}

.team-strip {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(6, minmax(0, 120px));
  justify-content: center;
}

.team-meta {
  font-size: 13px;
  margin: 0;
}

.fallen-section .section-head {
  flex-wrap: wrap;
}

.fallen-list {
  display: grid;
  gap: 4px 24px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

.fallen-entry {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  min-width: 0;
  padding: 12px 0;
}

.pokemon-icon.fallen {
  height: 64px;
  width: 64px;
}

.fallen-info {
  display: grid;
  gap: 4px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.fallen-info strong {
  font-size: 15px;
}

.fallen-name {
  align-items: center;
  display: flex;
  gap: 7px;
}

.fallen-skull {
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
}

.fallen-info .muted {
  font-size: 12px;
}

.fallen-actions {
  display: flex;
  gap: 4px;
}

.fallen-actions .icon-only {
  border-radius: 6px;
  flex-basis: 32px;
  height: 32px;
  width: 32px;
}

.fallen-actions .icon-only[data-action="delete-fallen"] {
  color: var(--danger);
}

.fallen-empty {
  font-size: 14px;
  padding: 8px 0;
}

.fallen-form {
  display: grid;
  gap: 16px;
}

.fallen-picker {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: 64px minmax(0, 1fr);
}

.fallen-error {
  color: var(--danger);
  font-size: 14px;
}

.pokemon-detail-line {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  margin: 0;
  padding: 8px 10px;
}

.team-icon-button {
  align-items: center;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  justify-content: center;
  min-height: 0;
  min-width: 0;
  padding: 8px 4px;
  transition: transform 140ms ease, border-color 140ms ease;
  width: 100%;
}

.team-icon-button .pokemon-icon {
  background: transparent;
  border: 0;
  border-radius: 0;
  flex: none;
  height: 72px;
  min-height: 0;
  width: 100%;
}

.team-pokemon-name {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  min-height: 2.4em;
  overflow-wrap: anywhere;
  text-align: center;
  width: 100%;
}

.team-icon-button .pokemon-types { flex-wrap: wrap; min-height: 20px; gap: 3px; }
.team-icon-button .pokemon-type { font-size: 10px; padding: 2px 3px; }

.team-icon-button:hover {
  border-color: var(--sapphire);
  transform: translateY(-1px);
}

.team-editor {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.team-slot,
.readonly-item {
  align-items: center;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  padding: 12px;
  position: relative;
}

.team-slot-fields {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.pokemon-icon {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  height: 54px;
  justify-content: center;
  overflow: hidden;
  width: 54px;
}

.pokemon-icon.mini {
  aspect-ratio: 1;
  border-radius: 6px;
  height: auto;
  min-width: 0;
  width: 100%;
}

.pokemon-icon.mini img {
  height: 100%;
  padding: 2px;
  width: 100%;
}

.pokemon-icon img {
  height: 100%;
  image-rendering: auto;
  object-fit: contain;
  width: 100%;
}

.pokemon-icon span {
  color: var(--muted);
  font-weight: 900;
}

.trash-button {
  align-items: center;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  height: 30px;
  justify-content: center;
  padding: 0;
  position: absolute;
  right: 8px;
  top: 8px;
  width: 30px;
}

.trash-button .ui-icon {
  height: 15px;
  width: 15px;
}

.trash-button:hover {
  color: var(--danger);
}

.is-hidden {
  display: none !important;
}

.quick-edit-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.lives-edit-row {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(88px, 140px) auto;
  justify-content: start;
}

.lives-edit-row .button {
  min-width: 96px;
}

.progress-edit-row {
  align-items: center;
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(190px, 236px) minmax(0, 1fr);
}

.medal-picker {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(8, minmax(0, 72px));
  min-width: 0;
}

.medal-toggle {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  display: grid;
  gap: 5px;
  justify-items: center;
  min-height: 83px;
  min-width: 0;
  padding: 7px 2px;
  width: 100%;
}

.medal-toggle .medal-image {
  filter: grayscale(1);
  height: 48px;
  max-width: 100%;
  opacity: 0.42;
  width: 48px;
}

.medal-toggle span {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.medal-toggle:hover:not(:disabled),
.medal-toggle:focus-visible {
  border-color: var(--line);
  color: var(--ink);
}

.medal-toggle.is-earned {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--ink);
}

.medal-toggle.is-earned .medal-image {
  filter: none;
  opacity: 1;
}

.location-field {
  margin-top: 14px;
}

.team-bottom-actions {
  margin-top: 14px;
}

.event-team-details { margin: 4px 0; font-size: 13px; overflow-wrap: anywhere; }
.history-more { margin-top: 12px; }

@media (max-width: 700px) {
  .team-bottom-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
  }
  .team-bottom-actions .button { width: 100%; }
}

.location-chip {
  background: var(--surface-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 7px 10px;
}

.team-view {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.team-view .readonly-item {
  grid-template-columns: 54px minmax(0, 1fr);
}

.team-view .readonly-item span:not(.pokemon-icon) {
  grid-column: 2;
}

.drawer-layer {
  inset: 0;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  transition: opacity 160ms ease;
  z-index: 40;
}

.drawer-layer.is-open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-backdrop {
  background: rgba(0, 0, 0, 0.48);
  border: 0;
  inset: 0;
  position: absolute;
}

.admin-drawer {
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  height: 100%;
  margin-left: auto;
  max-width: 460px;
  overflow-y: auto;
  padding: 18px;
  position: relative;
  transform: translateX(24px);
  transition: transform 160ms ease;
  width: min(92vw, 460px);
}

.drawer-layer.is-open .admin-drawer {
  transform: translateX(0);
}

.drawer-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.modal-layer {
  align-items: center;
  display: grid;
  inset: 0;
  justify-items: center;
  padding: 18px;
  position: fixed;
  z-index: 60;
}

.modal-backdrop {
  background: rgba(0, 0, 0, 0.54);
  border: 0;
  inset: 0;
  position: absolute;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  max-width: 420px;
  padding: 18px;
  position: relative;
  width: min(100%, 420px);
}

@media (max-width: 980px) {
  .layout,
  .gym-grid,
  .login-grid,
  .home-grid,
  .home-hero,
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .form-grid.compact,
  .team-editor,
  .update-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .progress-edit-row {
    gap: 16px;
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: center;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 10px;
    padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 10px calc(12px + env(safe-area-inset-left));
  }

  .brand {
    min-width: 0;
  }

  .top-actions {
    gap: 8px;
    justify-content: flex-end;
    margin-left: 0;
    min-width: max-content;
  }

  .app-toast {
    left: 50%;
    max-width: calc(100vw - 24px);
    top: calc(86px + env(safe-area-inset-top));
    transform: translateX(-50%);
    width: max-content;
  }

  .icon-only,
  .icon-button {
    flex-basis: 38px;
    height: 38px;
    width: 38px;
  }

  .theme-toggle {
    flex-basis: 40px;
    height: 40px;
    width: 40px;
  }

  .layout,
  .app-main {
    padding: 14px;
  }

  .login-view {
    padding: 14px;
  }

  .login-card,
  .panel {
    padding: 14px;
  }

  .form-grid,
  .form-grid.compact,
  .update-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 26px;
  }

  .player-list {
    grid-template-columns: 1fr;
  }

  .player-card {
    grid-template-columns: 44px minmax(0, 1fr);
    min-height: 112px;
    padding: 13px;
  }

  .player-main {
    gap: 6px;
  }

  .player-lives {
    display: block;
    width: 100%;
  }

  .home-hero,
  .profile-hero {
    padding: 18px;
  }

  .profile-hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .profile-badge-column {
    display: none;
  }

  .profile-badges-mobile:not(:empty) {
    display: grid;
    justify-content: center;
  }

  .medal-picker {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .home-metrics,
  .profile-stats,
  .team-editor,
  .quick-edit-grid {
    grid-template-columns: 1fr;
  }

  .lives-edit-row {
    grid-template-columns: minmax(78px, 1fr) auto;
  }

  .team-strip {
    gap: 4px;
  }

  .team-slot {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .team-slot .button {
    grid-column: 1 / -1;
    width: 100%;
  }
}

/* Illustrated profile decoration */
.profile-art-host { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.profile-wallpaper { position: absolute; inset: 0; overflow: hidden; }
.wallpaper-scene { background-size: cover; background-position: center; }
.profile-hero .wallpaper-scene::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(8,18,31,.72), rgba(8,18,31,.22) 75%), linear-gradient(0deg, rgba(8,18,31,.6), transparent 50%); }
.profile-hero .profile-title h1 { color: var(--ink); }
.profile-hero:has(.profile-art-host .profile-wallpaper) .profile-title h1 { color: #fff; text-shadow: 0 2px 12px #10161d; }
.profile-shell:has(.wallpaper-scene) .profile-hero { min-height: 370px; border-radius: 18px; }
.profile-shell .profile-hero .profile-badge-column { z-index: 1; filter: drop-shadow(0 3px 4px rgba(0,0,0,.55)); }
.wallpaper-starters { background: radial-gradient(ellipse at 20% 100%, color-mix(in srgb, var(--region-color) 65%, #0b1627), #0b1627 70%); }
.wallpaper-pokemon { position: absolute; width: min(230px,28%); height: auto; aspect-ratio: 1; max-height: calc(100% - 48px); object-fit: contain; filter: drop-shadow(0 12px 16px rgba(0,0,0,.4)); opacity: .85; }
.wallpaper-pokemon.art-0 { left: 7%; bottom: 24px; transform: rotate(-10deg); }
.wallpaper-pokemon.art-1 { right: 6%; bottom: 24px; transform: rotate(10deg); }
.wallpaper-pokemon.art-2 { right: 17%; top: 16px; opacity: .4; width: min(180px,26%); max-height: calc(100% - 32px); }
.wallpaper-legends { background: radial-gradient(ellipse at 80% 60%, #4d387c, #0b1428 70%); }
.wallpaper-legends::before { content: ''; position: absolute; inset: 0; background: radial-gradient(#fff 1px,transparent 2px) 0 0/47px 53px; opacity: .28; }
.wallpaper-legend { position: absolute; right: 6%; bottom: -30px; height: 360px; width: 360px; object-fit: contain; filter: drop-shadow(0 0 22px #a397e6); opacity: .85; }
.legend-orbit { position: absolute; width: 280px; height: 280px; border: 1px solid #b9a7eb; border-radius: 50%; right: 12%; top: 40px; transform: rotate(-25deg); box-shadow: 0 0 0 25px #a694d814, 0 0 0 50px #a694d80a; }
.avatar-decoration { position: relative; width: 110px; height: 110px; display: grid; place-items: center; isolation: isolate; }
.profile-avatar-art-host { padding: 12px 26px 12px 12px; }
.avatar-frame-art { position: absolute; inset: -10px; border-radius: 50%; pointer-events: none; z-index: -1; }
.avatar-frame-pokeball .avatar-frame-art { background: linear-gradient(#e44f58 0 44%,#172432 44% 56%,#edf2f5 56%); box-shadow: 0 0 0 3px #16202d, 0 5px 18px #0006; }
.avatar-frame-pokeball .avatar-frame-art::after { content: ''; position: absolute; width: 16px; height: 16px; border: 4px solid #18202b; border-radius: 50%; background: #fff; top: calc(50% - 12px); right: -7px; }
.avatar-frame-aura .avatar-frame-art { border: 3px solid var(--region-color); box-shadow: 0 0 0 5px color-mix(in srgb,var(--region-color) 30%,transparent),0 0 28px var(--region-color),inset 0 0 20px var(--region-color); }
.avatar-frame-stars .avatar-frame-art { border: 2px solid #efcc75; box-shadow: 0 0 20px #efd28166; }
.avatar-frame-stars .avatar-frame-art::before { content: '✦'; position: absolute; color: #ffe2a2; left: -10px; top: 4px; font-size: 30px; text-shadow: 110px 80px #ffe2a2,15px 110px #ffe2a2; }
.avatar-frame-pixel .avatar-frame-art { border: 5px solid var(--region-color); border-radius: 8px; transform: rotate(-7deg); box-shadow: 5px 5px 0 #0005; }
.profile-companion { position: absolute; width: 108px; height: 108px; object-fit: contain; right: -70px; bottom: -25px; z-index: 2; filter: drop-shadow(0 5px 4px #0008); }
.profile-hero .avatar-decoration .avatar { width: 110px; height: 110px; }
.decoration-top-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; max-width: 560px; }
.decoration-group { border: 0; padding: 0; margin: 24px 0 0; min-width: 0; }
.decoration-group legend { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.background-options { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.background-option { color: var(--ink); background: var(--surface-strong); border: 2px solid transparent; border-radius: 12px; padding: 5px 5px 12px; text-align: left; overflow: hidden; }
.background-thumb { height: 92px; display: block; border-radius: 8px; overflow: hidden; position: relative; --region-color: #58b79d; background: linear-gradient(135deg,var(--surface-strong),var(--surface)); }
.background-thumb .wallpaper-pokemon { width: min(80px,30%); height: auto; max-height: calc(100% - 16px); }
.background-thumb .wallpaper-pokemon.art-0 { bottom: 8px; left: 8px; }
.background-thumb .wallpaper-pokemon.art-1 { bottom: 8px; right: 8px; }
.background-thumb .wallpaper-pokemon.art-2 { top: 8px; right: 33%; opacity: 1; }
.background-thumb .wallpaper-legend { height: 100px; width: 100px; right: calc(50% - 50px); bottom: -10px; }
.background-option strong,.background-option > .muted { display: block; padding: 8px 6px 0; font-size: 12px; }
.background-option > .muted { font-size: 10px; padding-top: 4px; }
.background-option.is-picked,.companion-option.is-picked,.avatar-frame-option.is-picked { border-color: var(--sapphire); background: color-mix(in srgb,var(--sapphire) 12%,var(--surface)); }
.background-option:hover,.companion-option:hover,.avatar-frame-option:hover { border-color: var(--region-color); }
.companion-options,.avatar-frame-options { display: flex; flex-wrap: wrap; gap: 10px; }
.companion-option { width: 74px; height: 74px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface-strong); color: var(--muted); padding: 5px; font-size: 11px; }
.companion-option img { width: 100%; height: 100%; object-fit: contain; }
.companion-search { margin-top: 14px; max-width: 420px; }
.avatar-frame-option { width: 115px; padding: 15px 8px 10px; border: 2px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--surface-strong); display: grid; gap: 14px; justify-items: center; font-size: 11px; }
.mini-frame { width: 44px; height: 44px; position: relative; isolation: isolate; display: grid; place-items: center; }
.mini-frame .avatar-frame-art { inset: -5px; }
.mini-avatar { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--surface); font-weight: 800; }
.mini-frame.avatar-frame-stars .avatar-frame-art::before { font-size: 15px; text-shadow: 42px 34px #ffe2a2; }
.decoration-save-note { color: var(--muted); font-size: 12px; margin: 18px 0 0; }
.decoration-credit { font-size: 10px; margin-top: 18px; }
@media (max-width: 700px) {
  .background-options { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .profile-shell:has(.wallpaper-scene) .profile-hero { min-height: 360px; }
  .wallpaper-pokemon { opacity: .5; }
  .wallpaper-legend { width: 260px; height: 260px; right: -70px; opacity: .45; }
  .profile-companion { width: 90px; height: 90px; right: -55px; }
  .avatar-frame-option { width: 90px; }
  .decoration-form .section-head { align-items: flex-start; flex-wrap: wrap; }
}

/* Customization sidebar and responsive profile layout */
html, body, #app, .shell, .app-main, .profile-shell, .home-grid, .panel { min-width: 0; }
.profile-shell { min-width: 338px; }
.app-main:has(.profile-shell) { overflow-x: auto; }
#app,.shell,.app-main { max-width: 100%; }
.app-main { max-width: 1180px; }
.profile-nav { display: grid; grid-template-columns: 42px max-content max-content minmax(0,1fr); gap: 8px; }
.profile-nav .button { white-space: normal; min-width: 0; }
.profile-nav-home { grid-column: 1; padding: 9px; }
.profile-nav-export { grid-column: 2; }
.profile-nav-customize { grid-column: 3; }
.profile-nav-edit { grid-column: 4; justify-self: end; }
.profile-shell.profile-style-none .profile-hero { background: var(--surface); }
.profile-shell.profile-style-none .team-strip-panel { border-color: var(--line); }
.profile-title h1 { font-size: clamp(24px,4vw,42px); }
.profile-core, .profile-summary { min-width: 0; max-width: 100%; }
.profile-art-host { border-radius: inherit; overflow: hidden; }
.profile-shell .profile-hero,.player-card { --border-color: var(--profile-border-color,var(--region-color,var(--line))); }
.profile-shell .profile-hero { border: 1px solid var(--border-color); }
.profile-shell.profile-frame-double .profile-hero,.player-card.profile-frame-double { border: 4px double var(--border-color); }
.profile-shell.profile-frame-bold .profile-hero,.player-card.profile-frame-bold { border: 4px solid var(--border-color); }
.profile-shell.profile-frame-neon .profile-hero,.player-card.profile-frame-neon { border: 2px solid var(--border-color); box-shadow: 0 0 12px color-mix(in srgb,var(--border-color) 60%,transparent),inset 0 0 12px color-mix(in srgb,var(--border-color) 25%,transparent); }
.profile-shell.profile-frame-dashed .profile-hero,.player-card.profile-frame-dashed { border: 2px dashed var(--border-color); }
.profile-shell.profile-frame-stitched .profile-hero,.player-card.profile-frame-stitched { border: 3px dotted var(--border-color); }
.profile-shell.profile-frame-pixel .profile-hero,.player-card.profile-frame-pixel { border: 3px solid var(--border-color); border-radius: 0; box-shadow: 4px 4px 0 color-mix(in srgb,var(--border-color) 40%,transparent); }
.profile-shell.profile-frame-none .profile-hero,.player-card.profile-frame-none { border: 0; box-shadow: none; }
.profile-shell.profile-style-pixel .profile-hero { border-radius: 0; }
.home-profile-art { position: absolute; inset: 0; pointer-events: none; z-index: -1; overflow: hidden; border-radius: inherit; }
.home-profile-art:empty { display: none; }
.player-card { position: relative; isolation: isolate; overflow: hidden; border-color: var(--border-color); }
.player-card > :not(.home-profile-art) { position: relative; z-index: 1; }
.home-profile-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg,rgba(8,18,31,.82),rgba(8,18,31,.4)); }
.player-card:has(.home-profile-art .profile-wallpaper) { color: #fff; }
.player-card .player-name { color: var(--ink); }
.player-card:has(.home-profile-art .profile-wallpaper) .player-name { color: #fff; }
.player-card:has(.home-profile-art .profile-wallpaper) .player-lives { color: #eaf0f5; }
.player-card .wallpaper-pokemon { width: min(110px,28%); height: auto; max-height: calc(100% - 32px); }
.player-card .wallpaper-pokemon.art-0 { left: 5%; bottom: 16px; }
.player-card .wallpaper-pokemon.art-1 { right: 4%; bottom: 16px; }
.player-card .wallpaper-pokemon.art-2 { right: 35%; top: 8px; }
.player-card .wallpaper-legend { width: 180px; height: 180px; right: 0; bottom: -15px; }
.player-card .legend-orbit { width: 120px; height: 120px; top: 10px; right: 20px; }
.customization-layer .drawer-backdrop { background: transparent; backdrop-filter: none; }
.customization-drawer { display: flex; flex-direction: column; width: min(440px,100%); height: 100%; height: 100dvh; margin-left: auto; background: var(--surface); border-left: 1px solid var(--line); box-shadow: -8px 0 26px #0003; position: relative; min-width: 0; padding: 0; }
.customization-drawer .drawer-head { flex: 0 0 auto; padding: max(12px,env(safe-area-inset-top)) 16px 10px; }
.customization-preview-host { flex: 0 0 auto; padding: 0 16px 12px; }
.customization-preview { position: relative; width: 100%; isolation: isolate; overflow: hidden; }
.profile-preview-copy { position: absolute; top: 0; transform-origin: top left; pointer-events: none; }
.preview-live-label { z-index: 1; color: #fff; pointer-events: none; }
.preview-live-label { position: absolute; top: 6px; left: 8px; font-size: 9px; background: #0a162ab8; padding: 3px 7px; border-radius: 99px; }
.customization-controls { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 0; }
.customization-drawer .background-options { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.customization-drawer .background-thumb { height: 65px; }
.customization-drawer .background-option { padding-bottom: 8px; }
.customization-drawer .background-option strong { font-size: 11px; padding-top: 5px; }
.customization-drawer .avatar-frame-options { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; }
.customization-drawer .avatar-frame-option { width: auto; min-width: 0; font-size: 10px; padding: 14px 3px 8px; }
.customization-drawer .companion-search { margin-top: 22px; }
.customization-drawer .decoration-group { margin-top: 20px; }
.customization-save { position: sticky; bottom: 0; display: grid; gap: 7px; background: var(--surface); padding: 12px 0 max(12px,env(safe-area-inset-bottom)); border-top: 1px solid var(--line); z-index: 3; margin-top: 12px; }
.customization-save .decoration-save-note { margin: 0; font-size: 11px; }
.customization-drawer input[type="color"] { width: 100%; height: 42px; padding: 4px; }
.avatar-frame-greatball .avatar-frame-art { background: conic-gradient(#386dc9 0deg 25deg,#e34f59 25deg 45deg,#386dc9 45deg 135deg,#e34f59 135deg 155deg,#f0f4fa 155deg 335deg,#386dc9 335deg); box-shadow: 0 0 0 3px #172432; }
.avatar-frame-ultraball .avatar-frame-art { background: conic-gradient(#ead247 0deg 35deg,#24262d 35deg 65deg,#ead247 65deg 110deg,#24262d 110deg 180deg,#f0f4fa 180deg 360deg); box-shadow: 0 0 0 3px #172432; }
.avatar-frame-premierball .avatar-frame-art { background: linear-gradient(#f8faff 0 44%,#e56464 44% 56%,#f8faff 56%); box-shadow: 0 0 0 2px #c9d2dd; }
.avatar-frame-luxuryball .avatar-frame-art { background: linear-gradient(#272c35 0 40%,#d8b75a 40% 44%,#ca4b56 44% 56%,#d8b75a 56% 60%,#272c35 60%); box-shadow: 0 0 0 2px #d8b75a; }
.avatar-frame-flowers .avatar-frame-art { border: 3px solid #78b981; box-shadow: 0 0 0 5px #32704433; }
.avatar-frame-flowers .avatar-frame-art::before { content: '✿'; color: #f2a2d2; font-size: 26px; position: absolute; top: -8px; left: 6px; text-shadow: 82px 62px #ffc8ab,12px 90px #f2c667; }
.avatar-frame-hexagon .avatar-frame-art { border-radius: 0; background: linear-gradient(135deg,#8be7ed,#7183d4,#d3a5fa); clip-path: polygon(25% 0,75% 0,100% 50%,75% 100%,25% 100%,0 50%); inset: -13px; }
.avatar-frame-champion .avatar-frame-art { border: 4px double #efc96c; box-shadow: 0 0 18px #e1b85655; }
.avatar-frame-champion .avatar-frame-art::before { content: '♛'; position: absolute; top: -32px; left: calc(50% - 17px); color: #efc96c; font-size: 34px; }
.avatar-frame-rainbow .avatar-frame-art { background: conic-gradient(#e7749b,#f2cb69,#7cce9c,#72c4ea,#a197eb,#e7749b); box-shadow: 0 0 14px #ba9aea55; }
.mini-frame.avatar-frame-flowers .avatar-frame-art::before { font-size: 16px; text-shadow: 33px 25px #ffc8ab,4px 39px #f2c667; }
.mini-frame.avatar-frame-champion .avatar-frame-art::before { font-size: 20px; top: -17px; left: calc(50% - 10px); }
@media (min-width: 1050px) {
  .shell:has(.customization-drawer) .app-main { max-width: calc(1180px + 440px); padding-right: 462px; }
}
@media (max-width: 700px) {
  .team-strip { grid-template-columns: repeat(3, minmax(0, 120px)); gap: 8px; }
  .profile-nav { grid-template-columns: 38px repeat(3,minmax(0,1fr)); gap: 6px; width: 100%; }
  .profile-nav .button { width: 100%; min-height: 42px; font-size: 12px; padding: 9px 4px; justify-content: center; }
  .topbar { width: 100%; min-width: 0; }
  .brand-link { font-size: 15px; overflow-wrap: anywhere; }
  .brand .muted { font-size: 12px; overflow-wrap: anywhere; }
  .top-actions { min-width: 0; flex-shrink: 0; gap: 5px; }
  .theme-toggle { flex-shrink: 0; }
  .app-main { padding: 12px; }
  .profile-hero,.profile-shell:has(.wallpaper-scene) .profile-hero { min-height: 0; padding: 22px 12px 16px; gap: 14px; }
  .profile-core { gap: 14px; }
  .profile-title h1 { font-size: clamp(22px,6vw,28px); }
  .profile-avatar-art-host { padding-left: 12px; padding-right: 12px; }
  .profile-summary .hearts { max-width: 100%; }
  .profile-badges-mobile { justify-content: center; }
  .profile-hero .profile-badges-mobile .earned-medal { width: 30px; }
  .customization-drawer { width: min(440px,100%); }
  .customization-drawer .drawer-head h2 { font-size: 17px; }
  .customization-drawer .field input,.customization-drawer .field select { font-size: 16px; }
  .customization-drawer .field span { font-size: 10px; }
  .mini-team { max-width: 100%; }
}
@media (max-width: 360px) {
  .app-main { padding: 10px; }
  .topbar { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .top-actions .icon-only { width: 32px; height: 32px; flex-basis: 32px; }
  .profile-hero .profile-badges-mobile .earned-medal { width: 26px; }
  .customization-controls { padding-left: 12px; padding-right: 12px; }
  .customization-drawer .avatar-frame-options { grid-template-columns: repeat(3,minmax(0,1fr)); }
}

/* Profile compositions share the same structure in the page and its preview. */
.layout-field { margin-top: 16px; }
.wallpaper-position { margin-bottom: 8px; }
.wallpaper-controls { background: var(--surface-strong); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.profile-height-controls { background: var(--surface-strong); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 18px; }
.profile-height-controls .field { margin-bottom: 12px; }
.profile-height-controls button { width: 100%; min-height: 36px; }
.wallpaper-controls-hint { font-size: 12px; line-height: 1.4; margin-bottom: 12px; }
.wallpaper-controls .wallpaper-position { margin-bottom: 12px; }
.wallpaper-controls output { background: var(--surface); padding: 2px 6px; border-radius: 4px; min-width: 36px; text-align: right; }
.wallpaper-controls .wallpaper-center { margin-bottom: 0; width: 100%; min-height: 36px; }
.customization-preview-host:has(.profile-wallpaper) { touch-action: none; }
.customization-preview:has(.profile-wallpaper) { cursor: grab; user-select: none; }
.is-adjusting-wallpaper .customization-preview { cursor: grabbing; }
.wallpaper-position > span:first-child { display: flex; justify-content: space-between; gap: 8px; }
.wallpaper-position output { color: var(--accent-strong); font-variant-numeric: tabular-nums; }
.wallpaper-position input[type="range"] { width: 100%; height: 30px; padding: 0; border: 0; box-shadow: none; background: transparent; accent-color: var(--accent); cursor: pointer; }
.wallpaper-position input:disabled { opacity: .4; cursor: default; }
.wallpaper-position .wallpaper-position-labels { display: flex; justify-content: space-between; gap: 8px; font-size: 10px; color: var(--muted); text-transform: none; }
.wallpaper-center { font-size: 11px; padding: 5px 8px; margin-bottom: 12px; }
.layout-description { font-size: 11px; line-height: 1.5; margin-top: 6px; }
.profile-hero:not([data-profile-layout="normal"]) .profile-badge-column { display: none; }
.profile-hero:not([data-profile-layout="normal"]) .profile-badges-mobile:not(:empty) { display: grid; justify-content: center; }
.profile-shell .profile-hero:is([data-profile-layout="left"],[data-profile-layout="right"]) { min-height: 400px; grid-template-rows: auto auto; align-content: center; gap: 16px; }
.profile-hero[data-profile-layout="left"] { grid-template-columns: minmax(0,340px) minmax(0,1fr); }
.profile-hero[data-profile-layout="right"] { grid-template-columns: minmax(0,1fr) minmax(0,340px); }
.profile-hero:is([data-profile-layout="left"],[data-profile-layout="right"]) .profile-core { grid-row: 1; gap: 14px; }
.profile-hero:is([data-profile-layout="left"],[data-profile-layout="right"]) .profile-badges-mobile { grid-row: 2; }
.profile-hero:is([data-profile-layout="left"],[data-profile-layout="right"]) .profile-badges-mobile { grid-template-columns: repeat(var(--earned-badge-count,1),minmax(0,var(--lateral-medal-size,38px))); }
.profile-hero:is([data-profile-layout="left"],[data-profile-layout="right"]) .profile-badges-mobile .earned-medal { width: 100%; max-width: var(--lateral-medal-size,38px); }
.profile-hero[data-profile-layout="left"] :is(.profile-core,.profile-badges-mobile) { grid-column: 1; }
.profile-hero[data-profile-layout="right"] :is(.profile-core,.profile-badges-mobile) { grid-column: 2; }
.profile-hero:is([data-profile-layout="left"],[data-profile-layout="right"]) .profile-title h1 { font-size: clamp(22px,3vw,30px); }
.profile-hero:is([data-profile-layout="left"],[data-profile-layout="right"]) .heart-row.profile .heart { font-size: min(28px,calc((100cqw - (var(--heart-columns) - 1) * var(--heart-gap)) / var(--heart-columns))); }
.profile-shell .profile-hero[data-profile-layout="horizontal"] { min-height: 300px; grid-template-columns: minmax(0,1fr); align-content: center; }
.profile-hero:is([data-profile-layout="horizontal"],[data-profile-layout="bottom"]) .profile-core { grid-template-columns: auto minmax(0,1fr); align-items: center; max-width: 760px; gap: 24px; }
.profile-hero:is([data-profile-layout="horizontal"],[data-profile-layout="bottom"]) .profile-avatar-art-host { padding-right: 60px; }
.profile-hero:is([data-profile-layout="horizontal"],[data-profile-layout="bottom"]) .profile-title { justify-items: start; text-align: left; }
.profile-hero:is([data-profile-layout="horizontal"],[data-profile-layout="bottom"]) .heart-line { justify-content: flex-start; }
.profile-hero:is([data-profile-layout="horizontal"],[data-profile-layout="bottom"]) .profile-badges-mobile { max-width: 760px; }
.profile-shell .profile-hero[data-profile-layout="bottom"] { min-height: 460px; grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(160px,1fr) auto auto; gap: 16px; }
.profile-hero[data-profile-layout="bottom"] .profile-core { grid-row: 2; }
.profile-hero[data-profile-layout="bottom"] .profile-badges-mobile { grid-row: 3; }


@media (max-width: 700px) {
  .profile-shell .profile-hero:is([data-profile-layout="left"],[data-profile-layout="right"]) { min-height: 380px; padding: 22px 12px; gap: 12px; }
  .profile-shell .profile-hero[data-profile-layout="left"] { grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
  .profile-shell .profile-hero[data-profile-layout="right"] { grid-template-columns: minmax(0,1fr) minmax(0,2fr); }
  .profile-shell .profile-hero:is([data-profile-layout="left"],[data-profile-layout="right"]) .profile-badges-mobile { --lateral-medal-size: 34px; }
  .profile-shell .profile-hero:not([data-profile-layout="normal"]) .avatar-decoration,.profile-shell .profile-hero:not([data-profile-layout="normal"]) .avatar-decoration .avatar { width: 72px; height: 72px; font-size: 26px; }
  .profile-shell .profile-hero:not([data-profile-layout="normal"]) .profile-companion { width: 66px; height: 66px; right: -42px; bottom: -16px; }
  .profile-shell .profile-hero[data-profile-layout="horizontal"] { min-height: 250px; gap: 16px; }
  .profile-shell .profile-hero:is([data-profile-layout="horizontal"],[data-profile-layout="bottom"]) .profile-core { gap: 8px; }
  .profile-shell .profile-hero:is([data-profile-layout="horizontal"],[data-profile-layout="bottom"]) .profile-avatar-art-host { padding-left: 8px; padding-right: 42px; }
  .profile-shell .profile-hero:is([data-profile-layout="horizontal"],[data-profile-layout="bottom"]) .profile-title h1 { font-size: clamp(18px,5vw,25px); }
  .profile-shell .profile-hero[data-profile-layout="bottom"] { min-height: 400px; grid-template-rows: minmax(140px,1fr) auto auto; }
}

/* Optional personalization experiments: removable without changing player data. */
.saved-designs p,.device-customization p { font-size: 11px; line-height: 1.5; }
.saved-design-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
.saved-design-slot { position: relative; min-width: 0; }
.saved-design-pick { width: 100%; display: grid; gap: 5px; text-align: center; padding: 8px; border: 1px solid var(--line); background: var(--surface-strong); color: var(--ink); border-radius: 10px; cursor: pointer; }
.saved-design-pick strong { font-size: 11px; }.saved-design-pick small { font-size: 10px; color: var(--muted); }
.saved-design-thumb { display: block; position: relative; height: 54px; isolation: isolate; overflow: hidden; border-radius: 6px; }
.saved-design-empty { height: 54px; display: grid; place-items: center; font-size: 28px; color: var(--accent); }
.saved-design-delete { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; min-width: 26px; background: var(--surface); }.saved-design-delete svg { width: 15px; }
.device-customization { display: grid; gap: 10px; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.export-options { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; order: 5; grid-column: 1 / -1; }
.profile-shell[data-profile-device="mobile"] .profile-nav { grid-template-columns: 38px repeat(3,minmax(0,1fr)); gap: 6px; }
.profile-shell[data-profile-device="mobile"] .profile-nav .button { width: 100%; min-height: 42px; font-size: 12px; padding: 9px 4px; justify-content: center; }
.profile-shell[data-profile-device="mobile"] .export-options .button { width: auto; flex: 1; }
.profile-shell[data-editing-device="mobile"]:not(.profile-preview-copy) { width: min(390px,100%); margin-inline: auto; }
.profile-shell[data-profile-device="mobile"] .profile-hero { grid-template-columns: minmax(0,1fr); min-height: 0; padding: 22px 12px 16px; gap: 14px; }
.profile-shell[data-profile-device="mobile"] .profile-core { gap: 14px; }
.profile-shell[data-profile-device="mobile"] .profile-title h1 { font-size: 28px; }
.profile-shell[data-profile-device="mobile"] .profile-avatar-art-host { padding-left: 12px; padding-right: 12px; }
.profile-shell[data-profile-device="mobile"] .profile-badge-column { display: none; }
.profile-shell[data-profile-device="mobile"] .profile-badges-mobile:not(:empty) { display: grid; justify-content: center; }
.profile-shell[data-profile-device="mobile"] .profile-badges-mobile .earned-medal { width: 30px; }
.profile-shell[data-profile-device="mobile"] .profile-hero:is([data-profile-layout="left"],[data-profile-layout="right"]) { min-height: 380px; padding: 22px 12px; gap: 12px; }
.profile-shell[data-profile-device="mobile"] .profile-hero[data-profile-layout="left"] { grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
.profile-shell[data-profile-device="mobile"] .profile-hero[data-profile-layout="right"] { grid-template-columns: minmax(0,1fr) minmax(0,2fr); }
.profile-shell[data-profile-device="mobile"] .profile-hero:is([data-profile-layout="left"],[data-profile-layout="right"]) .profile-badges-mobile { --lateral-medal-size: 34px; }
.profile-shell[data-profile-device="mobile"] .profile-hero:not([data-profile-layout="normal"]) .avatar-decoration,.profile-shell[data-profile-device="mobile"] .profile-hero:not([data-profile-layout="normal"]) .avatar-decoration .avatar { width: 72px; height: 72px; font-size: 26px; }
.profile-shell[data-profile-device="mobile"] .profile-hero:not([data-profile-layout="normal"]) .profile-companion { width: 66px; height: 66px; right: -42px; bottom: -16px; }
.profile-shell[data-profile-device="mobile"] .profile-hero[data-profile-layout="horizontal"] { min-height: 250px; gap: 16px; }
.profile-shell[data-profile-device="mobile"] .profile-hero:is([data-profile-layout="horizontal"],[data-profile-layout="bottom"]) .profile-core { gap: 8px; }
.profile-shell[data-profile-device="mobile"] .profile-hero:is([data-profile-layout="horizontal"],[data-profile-layout="bottom"]) .profile-avatar-art-host { padding-left: 8px; padding-right: 42px; }
.profile-shell[data-profile-device="mobile"] .profile-hero:is([data-profile-layout="horizontal"],[data-profile-layout="bottom"]) .profile-title h1 { font-size: 25px; }
.profile-shell[data-profile-device="mobile"] .profile-hero[data-profile-layout="bottom"] { min-height: 400px; grid-template-rows: minmax(140px,1fr) auto auto; }
.profile-shell[data-profile-device="desktop"] .profile-hero { padding: 24px; gap: 20px; }
.profile-shell[data-profile-device="desktop"] .profile-hero[data-profile-layout="normal"] { grid-template-columns: 64px minmax(0,1fr) 64px; }
.profile-shell[data-profile-device="desktop"] .profile-hero[data-profile-layout="normal"] .profile-badge-column { display: grid; }
.profile-shell[data-profile-device="desktop"] .profile-hero[data-profile-layout="normal"] .profile-badges-mobile { display: none; }
.profile-shell[data-profile-device="desktop"] .profile-core { gap: 20px; }
.profile-shell[data-profile-device="desktop"] .profile-title h1 { font-size: 32px; }
.profile-shell[data-profile-device="desktop"]:has(.wallpaper-scene) .profile-hero { min-height: 370px; }
.profile-shell[data-profile-device="desktop"] .profile-hero:is([data-profile-layout="left"],[data-profile-layout="right"]) { min-height: 400px; grid-template-rows: auto auto; gap: 16px; }
.profile-shell[data-profile-device="desktop"] .profile-hero[data-profile-layout="left"] { grid-template-columns: minmax(0,340px) minmax(0,1fr); }
.profile-shell[data-profile-device="desktop"] .profile-hero[data-profile-layout="right"] { grid-template-columns: minmax(0,1fr) minmax(0,340px); }
.profile-shell[data-profile-device="desktop"] .profile-hero:is([data-profile-layout="left"],[data-profile-layout="right"]) .profile-core { gap: 14px; }
.profile-shell[data-profile-device="desktop"] .profile-hero:is([data-profile-layout="left"],[data-profile-layout="right"]) .profile-title h1 { font-size: 30px; }
.profile-shell[data-profile-device="desktop"] .profile-hero[data-profile-layout="horizontal"] { min-height: 300px; }
.profile-shell[data-profile-device="desktop"] .profile-hero[data-profile-layout="bottom"] { min-height: 460px; grid-template-rows: minmax(160px,1fr) auto auto; }
.profile-shell[data-profile-device="desktop"] .avatar-decoration,.profile-shell[data-profile-device="desktop"] .avatar-decoration .avatar { width: 110px; height: 110px; }
.profile-shell[data-profile-device="desktop"] .profile-companion { width: 108px; height: 108px; right: -70px; bottom: -25px; }
.profile-shell[data-profile-device="desktop"] .profile-avatar-art-host { padding: 12px 26px 12px 12px; }
.profile-shell[data-profile-device="desktop"] .profile-hero:is([data-profile-layout="horizontal"],[data-profile-layout="bottom"]) .profile-core { gap: 24px; }
.profile-shell[data-profile-device="desktop"] .profile-hero:is([data-profile-layout="horizontal"],[data-profile-layout="bottom"]) .profile-avatar-art-host { padding-right: 60px; }
.profile-shell[data-profile-device="desktop"] .profile-hero:is([data-profile-layout="left"],[data-profile-layout="right"]) .profile-badges-mobile { --lateral-medal-size: 38px; }
.profile-shell[data-profile-device="desktop"] .profile-badges-mobile .earned-medal { width: 100%; }
.avatar-decoration:is(.avatar-frame-pikachu,.avatar-frame-gengar,.avatar-frame-umbreon,.avatar-frame-sylveon) .avatar-frame-art,.mini-frame:is(.avatar-frame-pikachu,.avatar-frame-gengar,.avatar-frame-umbreon,.avatar-frame-sylveon) .avatar-frame-art { inset: -16%; background: transparent; }
.avatar-frame-pikachu .avatar-frame-art { background: url("/assets/avatar-frames/pikachu.svg") center / contain no-repeat !important; }
.avatar-frame-gengar .avatar-frame-art { background: url("/assets/avatar-frames/gengar.svg") center / contain no-repeat !important; }
.avatar-frame-umbreon .avatar-frame-art { background: url("/assets/avatar-frames/umbreon.svg") center / contain no-repeat !important; }
.avatar-frame-sylveon .avatar-frame-art { background: url("/assets/avatar-frames/sylveon.svg") center / contain no-repeat !important; }

.card-editor-entry { width: 100%; margin-top: 20px; }
.card-export-preview { flex: 0 0 auto; display: grid; place-items: center; padding: 0 16px 12px; min-height: 130px; }
.card-export-preview img { display: block; width: auto; max-width: 100%; max-height: min(310px,36dvh); border-radius: 8px; }
.card-export-preview img:not([src]) { display: none; }
.card-export-preview [role="status"] { font-size: 12px; color: var(--muted); text-align: center; }
.card-format-field { margin-top: 20px; }
.card-export-hint { font-size: 12px; line-height: 1.5; margin: 12px 0; }
.card-export-drawer .wallpaper-controls button { width: 100%; }
