/* Profile: full-body avatar, points card, try-on bar. */
.pixel-avatar { image-rendering: pixelated; }
.toon-avatar, .shop-pic .toon-avatar, .shop-thumb .toon-avatar { image-rendering: auto !important; }
.profile-avatar { width: min(100%, 240px); aspect-ratio: 1; background: transparent; border-radius: 14px; }
.profile-avatar svg { width: 100%; height: 100%; }
@media (max-width: 550px) { .profile-avatar { width: 150px; } }

.try-bar {
  display: grid;
  gap: 4px;
  width: min(100%, 180px);
  padding: 8px;
  border: 2px dashed #7a4fc1;
  border-radius: 12px;
  background: #f1e9ff;
  color: #252046;
}
.try-bar[hidden] { display: none; }
.try-bar small { font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: #7a4fc1; }
.try-bar b { font-size: 14px; }
.try-bar button { min-height: 38px; padding: 4px 8px; font-size: 13px; }

#profileSkins button { display: flex; align-items: center; gap: 8px; text-align: left; }
#profileSkins .skin-preview { width: 30px; height: 45px; border-radius: 6px; }
#profileSkins button.skin-trying { outline: 3px solid #7a4fc1; outline-offset: 2px; background: #f1e9ff; }
#profileSkins button.skin-owned::after { content: '✓'; margin-left: auto; font-weight: 800; color: #1f7a4d; }

.points-card {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
  padding: 14px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: linear-gradient(135deg, #fff3cf, #f1e9ff);
  color: #252046;
  box-shadow: 4px 4px 0 var(--ink);
}
.points-card[hidden] { display: none; }
.points-level { display: flex; align-items: center; gap: 12px; }
.points-level > div { display: grid; flex: 1; min-width: 0; }
.points-level small { font-size: 11px; font-weight: 800; opacity: .75; }
.points-level b { font-size: 18px; }
.level-badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 52px;
  height: 52px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3a0, #f2b92b 70%);
  font: 800 22px/1 inherit;
  box-shadow: 2px 2px 0 var(--ink);
}
.level-bar { height: 12px; margin: 4px 0 2px; overflow: hidden; border: 2px solid var(--ink); border-radius: 999px; background: #fff; }
.level-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #7a4fc1, #ec3d70); }
.level-next { font-weight: 600 !important; }
.points-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.points-stats span { display: grid; gap: 2px; padding: 6px 4px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; font-size: 11px; text-align: center; }
.points-stats b { font-size: 16px; }
.daily-button { width: 100%; min-height: 46px; font-size: 15px; }
.daily-button.daily-ready { background: #b6f06b; }
.daily-button:disabled { opacity: .7; }
.points-log summary { cursor: pointer; font-weight: 800; }
.points-log ol { display: grid; gap: 4px; margin: 6px 0 0; padding: 0; list-style: none; }
.points-log li { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 4px 8px; border-radius: 8px; background: #ffffffa0; font-size: 12px; }
.points-log time { opacity: .65; }
.log-game { color: #7a4fc1; }
.log-bonus { color: #1f7a4d; }
.points-hint { margin: 0; font-size: 12px; }
@media (max-width: 550px) {
  .points-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: no-preference) {
  .level-bar i { transition: width 700ms cubic-bezier(.34, 1.4, .64, 1); }
  .points-pop { animation: points-pop 600ms cubic-bezier(.34, 1.56, .64, 1); }
  @keyframes points-pop { 40% { transform: scale(1.04) rotate(-1deg); } }
  .daily-ready { animation: daily-wiggle 2.4s ease-in-out infinite; }
  @keyframes daily-wiggle { 0%, 80%, 100% { transform: none; } 85% { transform: rotate(-2deg) scale(1.02); } 90% { transform: rotate(2deg) scale(1.02); } 95% { transform: rotate(-1deg); } }
}

/* Bigger full-body avatars in the lobby and on friend profiles. */
.lobby-players { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.lobby-avatar { width: 64px; height: 96px; border-radius: 12px; }
.friend-card-avatar.friend-card-body { width: 132px; height: 198px; }
.friend-level { margin: 2px 0 0 !important; font-weight: 800; color: #7a4fc1; }

/* Shop: full sets / separate pieces */
.shop-tabs { display: flex; gap: 8px; margin: 4px 0 10px; }
.shop-tabs button { flex: 1; min-height: 42px; }
.shop-tabs button[aria-pressed="true"] { background: #252046; color: #f8d633; }
.shop-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.shop-filters[hidden] { display: none; }
.shop-filters button { min-height: 34px; padding: 3px 12px; border-radius: 999px; font-size: 12px; box-shadow: none; }
.shop-filters button[aria-pressed="true"] { background: #f8d633; color: #252046; }

/* Shop previews show just the clothes. */
#profileSkins .skin-preview { width: 40px; height: 40px; border-radius: 8px; background: #ffffffb0; }
#profileSkins .skin-preview svg { width: 100%; height: 100%; }

/* Wide screens: the profile fits the window — avatar and profile left, shop right. Phones unchanged. */
@media (min-width: 900px) {
  dialog[aria-labelledby="accountTitle"]:has(.profile-form:not([hidden])) {
    width: min(1240px, calc(96vw / var(--site-zoom, 1)));
    max-width: none;
    height: min(880px, calc(94dvh / var(--site-zoom, 1)));
    max-height: calc(94dvh / var(--site-zoom, 1));
    padding: 16px 22px 12px;
    overflow: hidden;
  }
  dialog[aria-labelledby="accountTitle"][open]:has(.profile-form:not([hidden])) { display: flex; flex-direction: column; }
  dialog[aria-labelledby="accountTitle"] .dialog-head h2 { margin: 0; }
  dialog[aria-labelledby="accountTitle"] #accountMessage { margin: 0 0 4px; }
  dialog[aria-labelledby="accountTitle"] .profile-form:not([hidden]) { display: flex; flex: 1; flex-direction: column; min-height: 0; }
  dialog[aria-labelledby="accountTitle"] .profile-form fieldset {
    display: grid;
    flex: 1;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 20px;
    min-height: 0;
    margin: 8px 0 0;
  }
  dialog[aria-labelledby="accountTitle"] .profile-main { min-height: 0; overflow-y: auto; padding: 4px 8px 8px 4px; }
  dialog[aria-labelledby="accountTitle"] .profile-shop {
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin: 0;
    overflow: hidden;
    border-radius: 16px;
  }
  dialog[aria-labelledby="accountTitle"] .profile-shop > p { margin: 0 0 8px; font-size: 12px; }
  dialog[aria-labelledby="accountTitle"] #profileSkins {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    grid-auto-rows: max-content;
    align-content: start;
    padding: 4px 4px 8px;
  }
  /* Shop cards: the piece large on top, name below. */
  dialog[aria-labelledby="accountTitle"] #profileSkins button {
    flex-direction: column;
    justify-content: flex-start;
    gap: 6px;
    min-height: 140px;
    padding: 10px 8px;
    border-left-width: 2px;
    border-radius: 14px;
    text-align: center;
  }
  dialog[aria-labelledby="accountTitle"] #profileSkins .skin-preview { width: 84px; height: 84px; border-radius: 12px; }
  dialog[aria-labelledby="accountTitle"] #profileSkins button.skin-owned::after { position: absolute; top: 6px; right: 8px; margin: 0; }
  dialog[aria-labelledby="accountTitle"] #profileSkins button { position: relative; }
  dialog[aria-labelledby="accountTitle"] .profile-layout { margin-bottom: 10px; }
  dialog[aria-labelledby="accountTitle"] .points-card { margin-bottom: 12px; }
  dialog[aria-labelledby="accountTitle"] #profileStatus:empty { display: none; }
  dialog[aria-labelledby="accountTitle"] #profileStatus { margin: 6px 0 0; }
}

/* Profile: picture tiles for the clothes you own */
.wardrobe { margin-top: 10px; text-align: left; }
.wardrobe h4 { margin: 0 0 6px; font-size: 14px; }
.wardrobe-row { display: grid; grid-template-columns: 88px minmax(0, 1fr); align-items: center; gap: 8px; margin-bottom: 6px; }
.wardrobe-row > span { font-size: 12px; font-weight: 800; }
.wardrobe-tiles { display: flex; gap: 6px; overflow-x: auto; padding: 3px 2px 5px; scrollbar-width: thin; }
.wardrobe-tiles small { align-self: center; min-width: 0; opacity: .7; font-size: 11px; line-height: 1.2; }
.wardrobe-tile { flex: none; display: grid; place-items: center; width: 52px; height: 52px; min-height: 0; margin: 0; padding: 3px; border: 2px solid var(--ink, #252046); border-radius: 10px; background: var(--ui-inset, #fff7dc); box-shadow: 2px 2px 0 var(--ink, #252046); cursor: pointer; }
.wardrobe-tile :is(img, canvas, svg) { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.wardrobe-tile b { font-size: 18px; opacity: .55; }
.wardrobe-tile[aria-pressed="true"] { background: #f8d633; transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink, #252046); }
@media (max-width: 680px) { .wardrobe-row { grid-template-columns: 1fr; gap: 2px; } }
/* "My clothes" as a shop tab: bigger tiles that wrap */
.shop-tabs button { padding-inline: 8px; white-space: nowrap; }
#profileWardrobe { flex: 1; margin-top: 0; overflow-y: auto; min-height: 0; padding: 2px 4px 8px; }
#profileWardrobe .wardrobe-hint { margin: 0 0 8px; font-size: 12px; opacity: .75; }
#profileWardrobe .wardrobe-row { grid-template-columns: 1fr; gap: 4px; margin-bottom: 10px; }
#profileWardrobe .wardrobe-tiles { flex-wrap: wrap; overflow: visible; }
#profileWardrobe .wardrobe-tile { width: 64px; height: 64px; }
/* Profile: basic choices as picture tiles */
.profile-parts { display: grid; grid-template-columns: 1fr !important; gap: 8px !important; }
.basic-row { display: grid; gap: 4px; text-align: left; }
.basic-row > span { font-size: 12px; font-weight: 800; }
.basic-tiles { display: flex; flex-wrap: wrap; gap: 6px; }
.basic-tile { display: grid; place-items: center; width: 46px; height: 46px; min-height: 0; margin: 0; padding: 2px; overflow: hidden; border: 2px solid var(--ink, #252046); border-radius: 10px; background: var(--ui-inset, #fff7dc); box-shadow: 2px 2px 0 var(--ink, #252046); }
.basic-tile svg, .basic-tile img { display: block; width: 100%; height: 100%; object-fit: contain; }
.basic-tile b { font-size: 16px; opacity: .55; }
.basic-tile[aria-pressed="true"] { background: #f8d633; outline: 2px solid #8f52ff; outline-offset: 1px; }
.basic-tile:hover { transform: translateY(-1px); }

/* Profile: Save stays visible at the top while you scroll; sign out sits at the bottom. */
.profile-savebar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 0 12px; padding: 8px 8px 8px 14px;
  border: 1px solid var(--m-border, #0002); border-radius: 14px;
  background: var(--m-panel, #fff); box-shadow: var(--m-shadow, 0 8px 24px #0002);
}
.profile-savebar span { font-size: 12px; font-weight: 700; color: var(--m-muted, #666); }
.profile-savebar button { flex: none; min-width: 130px; margin: 0; }
dialog[aria-labelledby="accountTitle"] > #accountAuth { align-self: flex-end; margin: 10px 0 0; }
dialog[aria-labelledby="accountTitle"]:has(.profile-form:not([hidden])) > #accountAuth { display: inline-block; font-size: 13px; padding: 6px 14px; }
