:root {
  color-scheme: dark;
  --page: #201218;
  --card: #2e1d25;
  --soft: #39252e;
  --line: #684653;
  --text: #fff3e5;
  --muted: #dfc3c4;
  --gold: #f5d693;
  --accent: #a94455;
  --display: Georgia, "Times New Roman", serif;
  font-family: system-ui, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--page);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at 58% -15%, #52303c 0, transparent 64%), var(--page); }
button, input { font: inherit; }
button { min-height: 44px; cursor: pointer; }
button:disabled { opacity: .56; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h2, h3 { font-family: var(--display); font-weight: 600; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.15rem; }
.muted { color: var(--muted); line-height: 1.55; }

.topbar, .shell { max-width: 1180px; width: calc(100% - 64px); margin-inline: auto; }
.topbar { min-height: 80px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: .65rem; color: var(--text); text-decoration: none; font: 600 1.22rem var(--display); }
.seal { display: grid; width: 38px; aspect-ratio: 1; place-items: center; color: var(--gold); background: #792f43;
  border: 1px solid #b46a6c; border-radius: 11px; font: 600 1.28rem var(--display); }
.shell { display: grid; grid-template-columns: minmax(300px, .78fr) minmax(0, 1.22fr); gap: 24px; padding-bottom: 48px; align-items: start; }

.stage {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  isolation: isolate; text-align: center; min-height: 602px; overflow: hidden; border: 1px solid var(--line); border-radius: 22px;
  background: #43242f url('./art/palace.webp') center 48% / cover;
}
.stage::before {
  position: absolute; z-index: -1; content: ''; inset: 0;
  background: linear-gradient(180deg, #1d0f19ee 0%, #25111a80 36%, #24131a26 63%, #200f19ee 100%);
}
.stage-heading { padding: 34px 18px 0; }
.stage-heading p { font-size: .86rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 650; color: var(--gold); }
.stage h1 { margin-top: 12px; font: 500 clamp(2.55rem, 5vw, 4.7rem)/.98 var(--display); letter-spacing: -.045em; }
.hero-avatar { display: block; width: min(58%, 250px); height: 293px; object-fit: contain; object-position: center bottom; filter: drop-shadow(8px 14px 12px #140b13bd); }
.stage-caption { display: grid; gap: 4px; margin: 0 10px 24px; padding: 10px 24px; border-radius: 12px; background: #261720e6; border: 1px solid #af796e; }
.stage-caption strong { color: var(--gold); }
.stage-caption span { color: var(--muted); font-size: .875rem; }

.desk { display: grid; gap: 16px; }
.card { display: grid; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 24px; }
.identity { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.identity h2 { overflow-wrap: anywhere; }
.identity p:empty { display: none; }
.sync-time { text-align: right; font-size: .875rem; }
form { display: grid; gap: 6px; }
label { color: var(--muted); font-size: .9rem; font-weight: 550; }
.form-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
input { min-width: 0; min-height: 48px; padding: .6rem .75rem; background: #22151d; color: var(--text); border: 1px solid #926170; border-radius: 10px; }
input::placeholder { color: #b995a2; }
.primary, .quiet { font-weight: 650; border-radius: 10px; padding: .55rem .95rem; }
.primary { color: #fffaf2; background: var(--accent); border: 1px solid #d78086; }
.primary:not(:disabled):hover { background: #bd5364; }
.quiet { color: var(--text); background: #382630; border: 1px solid #88606c; }
.quiet:hover { background: #55333e; }
.challenge { display: grid; gap: 10px; padding: 14px; background: #23141d; border: 1px solid #926170; border-radius: 12px; }
.challenge p { line-height: 1.5; }
.code-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
code { font-size: 1rem; color: var(--gold); }
.sections { display: flex; gap: 8px; }
.sections button { flex: 1; color: var(--muted); border: 1px solid var(--line); background: var(--card); border-radius: 10px; font-weight: 650; }
.sections button[aria-pressed="true"] { background: #49303b; color: var(--gold); border-color: #bf9567; }

#profile-record { display: grid; gap: 10px; }
.rank { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rank div { min-width: 0; }
.rank p { color: var(--muted); font-size: .9rem; }
.rank strong { display: block; color: var(--gold); font: 600 1.3rem var(--display); }
progress { width: 100%; height: 9px; accent-color: #e6b773; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin: 4px 0 0; }
.stats div { background: #23161d; padding: 10px; border-radius: 8px; }
.stats dt { color: var(--muted); font-size: .875rem; }
.stats dd { margin: 2px 0 0; font-weight: 650; overflow-wrap: anywhere; }
.rewards ul { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 7px 0 0; }
.rewards li { color: var(--gold); background: #432a2c; padding: 5px 9px; border-radius: 8px; font-size: .875rem; }

.character-choice { min-width: 0; padding: 0; margin: 0; border: 0; }
.character-choice legend { margin-bottom: 6px; color: var(--muted); font-size: .9rem; font-weight: 550; }
.outfits { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.outfits[data-gender="male"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.outfit { display: grid; justify-items: center; gap: 4px; text-align: center; min-width: 0; padding: 7px 4px;
  background: #251820; color: var(--text); border: 1px solid #6f4b58; border-radius: 11px; }
.outfit:hover { background: #462c38; }
.outfit[aria-pressed="true"] { border-color: var(--gold); background: #60343e; box-shadow: inset 0 0 0 1px #d6ae70; }
.outfit img { display: block; width: 100%; max-width: 82px; height: 101px; object-fit: contain; object-position: bottom; }
.outfit span { min-height: 2.7em; font-size: .875rem; font-weight: 550; }
.wardrobe-action { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.wardrobe-action button { flex-shrink: 0; }
.notice { padding: 0 4px; color: var(--gold); }
@media (max-width: 850px) {
  .topbar, .shell { width: calc(100% - 32px); }
  .shell { grid-template-columns: 1fr; gap: 14px; max-width: 620px; }
  .stage { min-height: 255px; text-align: left; align-items: start; background-position: center 42%; }
  .stage-heading { padding: 25px 0 0 20px; }
  .stage h1 { font-size: clamp(2.15rem, 9vw, 3.85rem); }
  .hero-avatar { position: absolute; bottom: 12px; right: 4px; width: min(42%, 185px); height: 205px; }
  .stage-caption { margin: 10px 0 18px 20px; padding: 7px 10px; }
  .topbar { max-width: 620px; min-height: 62px; }
}
@media (max-width: 440px) {
  .card { padding: 16px; border-radius: 16px; }
  .outfit span { min-height: 1.4em; }
  .wardrobe-action { align-items: stretch; flex-direction: column; gap: 8px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .identity { grid-template-columns: 1fr; gap: 4px; }
  .sync-time { text-align: left; }
}
