/* ============ The Glow Games — by Autumn Lee Beauty ============ */
:root {
  --ink: #2B1B25;          /* deep plum-ink */
  --ink-soft: #5A4350;
  --plum: #7A3B5E;
  --gold: #C9A227;
  --champagne: #E8D5B5;
  --blush: #F7E8EA;
  --bg-light: #FBF6F5;
  --white: #FFFDFD;
  --shadow: 0 12px 34px rgba(43, 27, 37, 0.18);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  height: 100%;
  background: var(--blush); /* canvas-level fallback, paints behind everything */
}
body {
  min-height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--ink);
  overflow-x: hidden;
}

/* ---------- Backgrounds ---------- */
.bg-layer { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: 1;
  transition: opacity 0.8s ease;
}
.bg-hidden { opacity: 0; }
body.victory #bg-main { opacity: 0; }
body.victory #bg-victory { opacity: 1; }
/* readability scrim over generated art */
.bg-layer::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(251,246,245,0.42) 0%, rgba(251,246,245,0.72) 100%);
}
body.victory .bg-layer::after {
  background: linear-gradient(180deg, rgba(20,14,20,0.45) 0%, rgba(20,14,20,0.62) 100%);
}

/* ---------- Debug overlay ---------- */
#debug-overlay {
  position: fixed; top: 64px; right: 8px; z-index: 999;
  font: 10px/1.4 'Inter', monospace; color: rgba(43,27,37,0.55);
  background: rgba(255,255,255,0.6); border-radius: 6px;
  padding: 3px 8px; pointer-events: none;
}

/* ---------- Screens ---------- */
#app { min-height: 100%; display: flex; flex-direction: column; }
.screen {
  display: none; flex: 1; flex-direction: column; align-items: center;
  padding: 24px 20px calc(28px + env(safe-area-inset-bottom));
  animation: screenIn 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}
.screen.active { display: flex; }
@keyframes screenIn {
  from { opacity: 0; transform: translateY(18px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Shared type ---------- */
.small-caps {
  text-transform: uppercase; letter-spacing: 0.22em;
  font-size: 11px; font-weight: 700; color: var(--ink-soft);
}
.small-caps.gold { color: var(--gold); }
.serif-title { font-size: 26px; font-weight: 800; line-height: 1.15; }
.kicker { margin-bottom: 6px; }
.micro { font-size: 12.5px; color: var(--ink-soft); line-height: 1.55; }
.micro.center, .center { text-align: center; }
.script-title { font-family: 'Allura', cursive; font-size: 58px; font-weight: 400; line-height: 1.05; }
.gold { color: var(--gold); }

/* ---------- Buttons ---------- */
.btn {
  font-family: 'Inter', sans-serif; cursor: pointer; border: none;
  border-radius: 999px; padding: 14px 30px;
  font-size: 14px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; text-decoration: none; text-align: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.btn-primary {
  background: linear-gradient(135deg, #8A4A6B, #6B2F52);
  color: #fff; box-shadow: 0 8px 22px rgba(106,47,82,0.4);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(106,47,82,0.5); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
  background: rgba(255,253,253,0.8); color: var(--plum);
  border: 1px solid rgba(122,59,94,0.45);
}
.btn-ghost:hover { background: #fff; }
.btn-wide { width: 100%; }
.btn-small { padding: 10px 20px; font-size: 12px; }
.btn-stack { display: flex; flex-direction: column; gap: 12px; width: min(320px, 100%); }

/* ---------- Title screen ---------- */
.title-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; padding-top: 7vh; max-width: 480px; }
.crown { color: var(--gold); font-size: 26px; }
.byline { margin-top: -6px; }
.tagline { font-size: 15px; color: var(--ink-soft); font-style: italic; }
.title-wrap .btn-stack { margin-top: 10px; }
.glowlist-box {
  margin-top: 18px; width: min(340px, 100%);
  background: rgba(255,253,253,0.75); border: 1px solid rgba(201,162,39,0.4);
  border-radius: 18px; padding: 18px 18px 14px; text-align: center;
  backdrop-filter: blur(6px);
}
.glowlist-form { display: flex; gap: 8px; margin-top: 10px; }
.glowlist-form input {
  flex: 1; min-width: 0; border-radius: 999px; border: 1px solid rgba(43,27,37,0.2);
  padding: 10px 16px; font-size: 13px; font-family: 'Inter', sans-serif; background: #fff;
}
.glowlist-form input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.form-msg { margin-top: 8px; font-size: 12px; min-height: 16px; font-weight: 600; }
.form-msg.ok { color: #2E7D4F; }
.form-msg.err { color: #B3364B; }
.footnote { margin-top: 14px; font-size: 11px; color: var(--ink-soft); opacity: 0.75; }

/* ---------- Quiz ---------- */
.quiz-wrap { width: min(460px, 100%); padding-top: 4vh; }
.quiz-q { margin-top: 22px; text-align: center; }
.quiz-q .q-text { font-size: 17px; font-weight: 700; margin: 14px 0 16px; }
.quiz-opts { display: flex; flex-direction: column; gap: 10px; }
.quiz-opt {
  background: rgba(255,253,253,0.85); border: 1px solid rgba(122,59,94,0.3);
  border-radius: 16px; padding: 14px 18px; font-size: 14.5px; font-weight: 600;
  cursor: pointer; text-align: left; color: var(--ink); font-family: 'Inter', sans-serif;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.quiz-opt:hover { transform: translateY(-2px); border-color: var(--gold); background: #fff; }
.quiz-progress { display: flex; gap: 6px; justify-content: center; margin-top: 18px; }
.quiz-progress span { width: 26px; height: 4px; border-radius: 4px; background: rgba(122,59,94,0.2); }
.quiz-progress span.on { background: var(--gold); }

/* ---------- Challenge ---------- */
.challenge-wrap { width: min(430px, 100%); display: flex; flex-direction: column; }
.challenge-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.back-btn {
  border: 1px solid rgba(122,59,94,0.35); background: rgba(255,253,253,0.8);
  width: 38px; height: 38px; border-radius: 50%; font-size: 18px; color: var(--plum);
  cursor: pointer; flex-shrink: 0;
}
.challenge-head .serif-title { font-size: 21px; }
.stage { display: flex; gap: 14px; align-items: stretch; }
.portrait-frame {
  flex: 1; background: rgba(255,253,253,0.7); border: 1px solid rgba(201,162,39,0.45);
  border-radius: 22px; padding: 10px; text-align: center;
}
.portrait-frame svg { width: 100%; height: auto; display: block; }
.shade-label { margin-top: 6px; font-size: 12px; font-weight: 700; color: var(--plum); min-height: 16px; }
.glow-meter {
  width: 86px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center;
}
.meter-track {
  width: 10px; flex: 1; min-height: 120px; border-radius: 999px;
  background: rgba(43,27,37,0.12); overflow: hidden; display: flex; align-items: flex-end;
}
.meter-fill {
  width: 100%; height: 0%; border-radius: 999px;
  background: linear-gradient(180deg, #E8C15A, #C9A227);
  transition: height 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.meter-val { font-size: 22px; font-weight: 800; color: var(--plum); }

.tabs { display: flex; gap: 8px; margin: 16px 0 12px; }
.tab {
  flex: 1; border-radius: 999px; padding: 9px 4px; font-size: 11.5px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; cursor: pointer;
  border: 1px solid rgba(122,59,94,0.3); background: rgba(255,253,253,0.6); color: var(--ink-soft);
  font-family: 'Inter', sans-serif;
}
.tab.active { background: var(--ink); color: #F3E6C9; border-color: var(--ink); }

.options { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; min-height: 66px; }
.option {
  border-radius: 16px; border: 2px solid rgba(122,59,94,0.25); background: rgba(255,253,253,0.85);
  padding: 8px 12px; cursor: pointer; font-family: 'Inter', sans-serif;
  display: flex; align-items: center; gap: 9px; font-size: 12.5px; font-weight: 600; color: var(--ink);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.option:hover { transform: translateY(-2px); }
.option.selected { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,162,39,0.18); }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.9); box-shadow: 0 2px 6px rgba(43,27,37,0.25); flex-shrink: 0; }
.swatch-clear { position: relative; background-color: #fff; background-image: conic-gradient(#d1d1d1 25%, transparent 0 50%, #d1d1d1 0 75%, transparent 0); background-size: 8px 8px; border-color: #8b777f; }
.swatch-clear::after { content: ''; position: absolute; inset: 2px; border-radius: 50%; background: linear-gradient(130deg, transparent 28%, #ffffffcc 45%, transparent 62%); }
.shade-option-copy { min-width: 0; }
.shade-kind { display: block; margin-top: 2px; font-size: 10px; font-weight: 500; line-height: 1.3; color: var(--ink-soft); }
.brow-icon, .eye-icon { width: 34px; height: 18px; flex-shrink: 0; }
.skin-icon { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(43,27,37,0.25); }

/* ---------- Result ---------- */
body.victory #app { color: #F5EBDC; }
.result-wrap { width: min(400px, 100%); display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 3vh; }
body.victory .micro, body.victory .small-caps { color: #D9C6A8; }
body.victory .micro.gold, body.victory .small-caps.gold { color: #E8C15A; }
.stars { display: flex; gap: 8px; margin-top: 8px; min-height: 44px; }
.star { font-size: 38px; color: rgba(255,255,255,0.25); transform: scale(0.5); opacity: 0; }
.star.lit { color: #E8C15A; text-shadow: 0 0 18px rgba(232,193,90,0.65); }
.star.pop { animation: starPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
@keyframes starPop { to { transform: scale(1); opacity: 1; } }
.score-big { display: flex; align-items: baseline; gap: 10px; }
.score-big span:first-child { font-size: 52px; font-weight: 800; color: #F5EBDC; }
.score-word { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: #C9B58F; }
.judge-line { font-size: 15px; font-weight: 600; text-align: center; color: #F0E4D0; min-height: 22px; }
.points-line { text-align: center; }

.look-card {
  width: 100%; background: var(--bg-light); color: var(--ink);
  border-radius: 24px; overflow: hidden; box-shadow: var(--shadow);
  border: 1px solid rgba(201,162,39,0.5);
}
.look-card-head { text-align: center; padding: 16px 16px 10px; border-bottom: 1px solid rgba(201,162,39,0.3); }
.look-card-head .serif-title { font-size: 20px; }
.look-card-body { display: flex; gap: 14px; padding: 16px; align-items: center; }
.look-card-portrait { width: 118px; flex-shrink: 0; border-radius: 16px; overflow: hidden; border: 1px solid rgba(201,162,39,0.4); background: #fff; }
.look-card-portrait svg { width: 100%; height: auto; display: block; }
.look-card-details { flex: 1; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.look-card-details .row { display: flex; justify-content: space-between; gap: 8px; }
.look-card-details .row .k { color: var(--ink-soft); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; }
.look-card-details .row .v { font-weight: 700; text-align: right; }
.look-card-foot { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.look-card-foot .micro { color: #5A4350; font-size: 13px; font-weight: 500; }
.result-wrap .glowlist-box { margin-top: 8px; }
body.victory .glowlist-box { background: rgba(32,22,30,0.55); border-color: rgba(201,162,39,0.5); }
body.victory .glowlist-form input { background: #fff; }
.result-wrap .btn-stack { margin: 10px 0 20px; }

/* ---------- Duo ---------- */
.duo-wrap { width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; padding-top: 6vh; }
.duo-players { display: flex; align-items: center; gap: 14px; margin: 6px 0; }
.duo-player { background: rgba(255,253,253,0.8); border: 1px solid rgba(201,162,39,0.5); border-radius: 18px; padding: 16px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.duo-emoji { font-size: 34px; }
.duo-vs { color: var(--gold); }

/* ---------- Desktop polish ---------- */
@media (min-width: 720px) {
  .screen { justify-content: center; }
  .title-wrap { padding-top: 0; }
  .script-title { font-size: 76px; }
  .serif-title { font-size: 30px; }
}

/* ---------- Reduced motion / time advance ---------- */
body.time-advanced *, body.time-advanced *::before, body.time-advanced *::after {
  animation-duration: 0s !important; transition-duration: 0s !important; animation-delay: 0s !important;
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01s !important; transition-duration: 0.01s !important; }
}

/* ---------- Challenge brief ---------- */
.brief { margin-bottom: 12px; }

/* ---------- Desktop height fit: keep Submit above the fold ---------- */
@media (min-width: 720px) {
  .portrait-frame svg { max-height: 38vh; width: auto; margin: 0 auto; }
  .challenge-wrap { max-width: 480px; }
  .options { min-height: 56px; margin-bottom: 12px; }
  .challenge-head { margin-bottom: 6px; }
  .tabs { margin: 10px 0 10px; }
}

/* ---------- Mobile height fit: keep Submit above the fold ---------- */
@media (max-width: 719px) {
  .portrait-frame svg { max-height: 32vh; width: auto; margin: 0 auto; }
  .glow-meter { min-height: 100px; }
  .shade-label { margin-top: 4px; }
  .options { margin-bottom: 12px; }
}

/* ---------- Character edition ---------- */
button:focus-visible, a:focus-visible { outline: 3px solid var(--plum); outline-offset: 4px; }
.cast-preview { display: flex; justify-content: center; padding: 4px 0; }
.cast-preview img { width: 68px; height: 85px; object-fit: cover; object-position: center 30%; border: 3px solid var(--white); border-radius: 38px; box-shadow: 0 5px 16px #2b1b251c; }
.cast-preview img + img { margin-left: -9px; }
.cast-preview img:nth-child(2) { transform: translateY(-6px); }
.cast-caption { font-size: 12px; color: var(--ink-soft); text-align: center; }
.families-wrap { width: min(950px, 100%); padding-top: 16px; }
.characters-wrap { width: min(650px, 100%); padding-top: 8px; }
.chooser-head { display: flex; gap: 14px; align-items: center; padding-right: 28px; }
.chooser-head .serif-title { font-size: clamp(23px, 3vw, 32px); }
.chooser-intro { margin: 14px 0 22px; max-width: 650px; font-size: 14px; }
.family-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.family-card { padding: 0 0 13px; overflow: hidden; border: 1px solid #cab5bd; border-radius: 16px; background: #fffafa; text-align: left; font: inherit; cursor: pointer; box-shadow: 0 6px 18px #2b1b250a; transition: transform .18s, box-shadow .18s; }
.family-card:hover { transform: translateY(-4px); box-shadow: 0 9px 24px #2b1b2525; }
.family-card img { display: block; width: 100%; height: auto; aspect-ratio: 1.2; object-fit: contain; background: #e4cfbe; }
.family-name { display: block; font-size: 14px; font-weight: 700; color: var(--ink); margin: 12px 12px 6px; }
.family-card-note { display: flex; justify-content: space-between; font-size: 12px; color: var(--plum); margin: 0 12px; }
.family-story { display: block; color: var(--ink-soft); margin: 0 12px 12px; font-size: 12px; line-height: 1.5; min-height: 36px; }
.characters-wrap .chooser-intro { margin-bottom: 14px; }
.family-browser { display: flex; justify-content: space-between; align-items: center; margin: -6px 0 12px; padding: 3px 0; border-block: 1px solid #cbb4bd; }
.family-browse-btn { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 4px; border: 0; background: transparent; color: var(--plum); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.family-position { font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; letter-spacing: .12em; }
.role-firstname { display: block; margin: 12px 4px 0; font-size: 20px; font-weight: 700; }
.role-firstname + .role-name { font-size: 12px; font-weight: 500; margin: 3px 4px; }
.character-spotlight { display: grid; grid-template-columns: 170px 1fr; gap: 22px; align-items: center; padding: 18px; margin-top: 16px; border: 1px solid #cbb4bd; border-radius: 18px; background: #fffaf5; }
.spotlight-title .small-caps { color: var(--plum); font-size: 10px; letter-spacing: .12em; }
.spotlight-title h3 { font-size: 30px; line-height: 1.2; margin: 7px 0; letter-spacing: -.04em; }
.spotlight-traits { font-size: 12px; color: var(--plum); line-height: 1.6; }
.spotlight-story > p { font-size: 14px; color: var(--ink); line-height: 1.6; }
.spotlight-story .spotlight-note { font-size: 11px; color: var(--ink-soft); margin-top: 9px; }
.representation-note { margin-top: 20px; max-width: 720px; }
.role-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.role-card { border: 2px solid #cbb4bd; background: #fffafa; border-radius: 18px; overflow: hidden; cursor: pointer; padding: 0 0 14px; font: inherit; color: var(--ink); transition: border-color .18s, box-shadow .18s; }
.role-card img { width: 100%; height: auto; display: block; aspect-ratio: 4 / 5; object-fit: cover; object-position: center 25%; }
.role-name { display: block; font-size: 14px; font-weight: 700; margin: 12px 4px 4px; }
.role-age { display: block; font-size: 12px; color: var(--ink-soft); }
.role-selected { display: block; font-size: 12px; font-weight: 700; margin-top: 8px; color: var(--plum); }
.role-card.selected { border-color: var(--plum); box-shadow: 0 0 0 3px #7a3b5e22; background: #f6e9ef; }
.role-card:disabled { cursor: default; border-style: dashed; }
.selection-description { text-align: center; font-size: 14px; color: var(--ink-soft); margin: 14px 0 12px; min-height: 22px; }
.character-disclaimer { margin-top: 16px; }
@media (max-width: 600px) {
  .role-firstname { font-size: 16px; margin-top: 10px; }
  .character-spotlight { grid-template-columns: 1fr; gap: 8px; padding: 16px; margin-top: 16px; }
  .spotlight-title h3 { font-size: 26px; margin: 5px 0; }
  .spotlight-story > p { font-size: 13px; }
  .selection-description { margin-top: 12px; font-size: 12px; line-height: 1.6; }
  .family-story { margin-inline: 10px; min-height: 36px; }
  .legacy-name { font-size: 11px; }
}
.styling-identity { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 9px; font-size: 12px; font-weight: 600; }
.text-btn { background: none; border: none; color: var(--plum); text-decoration: underline; cursor: pointer; font: inherit; font-size: 14px; padding: 4px 0; }
.photo-portrait { position: relative; aspect-ratio: 480 / 780; overflow: hidden; isolation: isolate; background: #d6c3b3; }
.photo-portrait img { width: 100%; height: 100%; display: block; object-fit: cover; }
.photo-portrait .makeup-overlay { position: absolute; inset: 0; width: 100%; height: 100%; max-height: none; pointer-events: none; }
.lip-overlay, .brow-overlay, .eye-overlay { mix-blend-mode: multiply; }
.eye-overlay { filter: blur(1.2px); }
.dewy-highlight { filter: blur(7px); }
.finish-matte img { filter: contrast(.96) saturate(.96); }
#portrait-mount .photo-portrait { --portrait-height: clamp(180px, 29vh, 290px); height: var(--portrait-height); width: 100%; aspect-ratio: auto; margin: 0 auto; border-radius: 12px; }
.portrait-frame { padding: 8px; }
.portrait-frame .shade-label { font-size: 12px; margin-top: 7px; }
.glow-meter { width: 90px; gap: 7px; }
.glow-meter .small-caps { font-size: 12px; letter-spacing: .08em; }
.meter-track { min-height: 55px; }
.compare-btn { border: 1px solid #b58b9f; border-radius: 10px; background: #fffafa; padding: 7px 6px; color: var(--plum); font: 600 12px/1.3 'Inter', sans-serif; cursor: pointer; width: 100%; min-height: 42px; }
.compare-btn[aria-pressed="true"] { background: var(--ink); color: white; }
.preview-note { font-size: 12px; line-height: 1.45; text-align: center; color: var(--ink-soft); margin-top: 10px; }
.options { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; min-height: 0; }
.option { min-height: 52px; padding: 7px 6px; gap: 5px; font-size: 14px; line-height: 1.3; text-align: left; }
.option .swatch { width: 22px; height: 22px; }
.brow-icon, .eye-icon { width: 24px; }
.tab { min-height: 40px; font-size: 14px; letter-spacing: .06em; }
.tab:disabled { cursor: default; color: #67515d; border-style: dashed; background: #efe2e7; }
.look-card-portrait .photo-portrait { width: 100%; }
.look-card-portrait .makeup-overlay { max-height: none; }
.look-card-body { align-items: flex-start; }
.look-card-details { font-size: 12px; }
.look-card-details .row { flex-wrap: wrap; }
.look-card-details .row .k { font-size: 12px; }
.look-card-details .row .v { margin-left: auto; }
.look-card-portrait.legacy-portraits { width: 130px; display: flex; flex-direction: column; gap: 4px; background: #e8d5b5; }
.legacy-portraits .photo-portrait { aspect-ratio: 1; }
.legacy-portraits .photo-portrait img { object-fit: cover; }
.legacy-portraits .photo-portrait { aspect-ratio: 480 / 780; }
.duo-players { width: 100%; gap: 16px; }
.duo-player { flex: 1; min-width: 0; padding: 0 0 14px; overflow: hidden; font-size: 14px; font-weight: 700; }
.duo-player img { display: block; width: 100%; aspect-ratio: 480 / 660; object-fit: cover; object-position: top; }
.duo-player .small-caps { font-size: 12px; }
.small-caps.gold, .gold { color: #7a5b12; }
.footnote { font-size: 12px; opacity: 1; }
.title-wrap { gap: 11px; }
.title-wrap .glowlist-box { margin-top: 8px; }
body.victory .look-card .small-caps { color: #745317; }
body.victory .look-card-foot .micro { color: var(--ink-soft); }
body.victory .form-msg.ok { color: #A8E8C2; }
body.victory .form-msg.err { color: #FFB7C5; }
.legacy-card .look-card-body { flex-direction: column; }
.legacy-card .look-card-portrait.legacy-portraits { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; border: none; border-radius: 0; background: none; }
.legacy-character { border: 1px solid #cfb8c0; border-radius: 14px; overflow: hidden; }
.legacy-character .photo-portrait { aspect-ratio: 4 / 5; }
.legacy-name { display: block; background: #f3e5eb; color: var(--plum); text-align: center; font-size: 12px; font-weight: 700; padding: 7px; }
.legacy-card .look-card-details { width: 100%; }

@media (max-width: 719px) {
  .family-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
  .family-name { font-size: 14px; margin-left: 10px; margin-right: 10px; }
  .family-card-note { margin-left: 10px; margin-right: 10px; }
  .family-card img { aspect-ratio: 1.2; }
  .families-wrap { padding-top: 12px; }
  .characters-wrap { padding-top: 8px; }
  .role-grid { gap: 7px; }
  .role-card { border-radius: 12px; }
  .role-name { font-size: 14px; }
  .role-selected { font-size: 12px; }
  #screen-challenge { padding: 18px 16px 22px; }
  #portrait-mount .photo-portrait { --portrait-height: clamp(180px,25vh,230px); }
  .challenge-head { padding-right: 30px; }
  .brief { margin-bottom: 8px; font-size: 12px; }
  .challenge-head .serif-title { font-size: 20px; }
  .glow-meter { width: 78px; }
  .styling-identity { font-size: 11px; }
  .tabs { margin: 10px 0; }
  .options { margin-bottom: 10px; }
  .option { flex-direction: column; align-items: center; text-align: center; min-height: 60px; padding: 6px 3px; gap: 4px; font-size: 14px; }
  .look-card-portrait.legacy-portraits { width: 110px; }
  .title-wrap { padding-top: 3vh; }
}
@media (max-height: 700px) {
  .title-wrap { padding-top: 0; }
  #portrait-mount .photo-portrait { --portrait-height: 180px; }
  #screen-challenge { padding-top: 12px; }
  .challenge-head { margin-bottom: 4px; }
  .preview-note { font-size: 11px; margin-top: 7px; }
}

/* ---------- Guided play and Duo handoff ---------- */
.screen:focus { outline: none; }
.q-text:focus, .profile-reveal:focus { outline: none; }
.help-link { align-self: center; min-height: 36px; }
.styling-tools { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.styling-tools .text-btn { min-height: 30px; }
.styling-status { color: #922B43; font-size: 13px; font-weight: 600; line-height: 1.45; margin: 0 0 10px; }
.styling-status:empty { display: none; }
.score-panel { width: 100%; background: #FFFAFA; border: 1px solid #CBB4BD; border-radius: 14px; color: var(--ink); font-size: 14px; }
.stylist-notes { margin-top: 10px; }
.score-panel summary { cursor: pointer; padding: 12px 14px; font-weight: 700; color: var(--plum); min-height: 42px; }
.score-panel summary::marker { color: var(--plum); }
.score-panel summary span { float: right; color: var(--ink-soft); font-weight: 500; font-size: 12px; line-height: 20px; }
.score-panel-body { padding: 0 14px 14px; }
.stylist-tip { color: var(--ink-soft); line-height: 1.5; margin-bottom: 14px; }
.score-breakdown { margin: 0; width: 100%; font-variant-numeric: tabular-nums; }
.score-breakdown > div { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; }
.score-breakdown dt { color: var(--ink-soft); }
.score-breakdown dd { color: var(--ink); font-weight: 700; white-space: nowrap; }
.score-breakdown .breakdown-total { border-top: 1px solid #D7C1CB; margin-top: 5px; padding-top: 12px; }
.breakdown-total dt { font-weight: 700; color: var(--ink); }
.score-help { color: var(--ink-soft); font-size: 12px; line-height: 1.6; margin-top: 12px; }
.result-notes { margin-top: 16px; }
.restyle-btn { display: block; margin: 12px auto 0; border-radius: 999px; border: 1px solid #B58B9F; padding: 9px 17px; background: #F3E5EB; color: var(--plum); font: 600 14px 'Inter', sans-serif; cursor: pointer; min-height: 40px; }
.handoff-wrap { width: min(460px, 100%); display: flex; flex-direction: column; gap: 16px; padding-top: 30px; }
.handoff-wrap > .kicker { margin-bottom: -6px; }
.handoff-intro { color: var(--ink-soft); font-size: 14px; line-height: 1.55; }
.handoff-portraits { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.handoff-character { border-radius: 18px; overflow: hidden; background: #FFFAFA; border: 1px solid #CBB4BD; }
.handoff-character .photo-portrait { aspect-ratio: 1; }
.handoff-character > p { padding: 12px 8px; text-align: center; font-size: 14px; font-weight: 700; }
.handoff-character span { display: block; font-size: 12px; font-weight: 500; margin-top: 5px; color: var(--ink-soft); }
.handoff-rule { padding: 15px 18px; background: #F9F0E2; border: 1px solid #D6B66D; border-radius: 14px; }
.handoff-rule > p:nth-child(2) { font-size: 14px; line-height: 1.5; font-weight: 600; margin-top: 8px; }
.handoff-rule .score-help { margin-top: 8px; }
.guide-dialog { width: min(520px, calc(100% - 32px)); max-height: calc(100dvh - 36px); margin: auto; padding: 26px; border: 1px solid #B892A4; border-radius: 24px; background: #FFFAFA; color: var(--ink); box-shadow: 0 24px 80px #20161e55; overflow-y: auto; }
.guide-dialog::backdrop { background: #281821B8; backdrop-filter: blur(5px); }
.guide-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 12px; }
.guide-close { width: 38px; height: 38px; flex-shrink: 0; border: 1px solid #CBB4BD; border-radius: 50%; background: #F3E5EB; color: var(--plum); font-size: 24px; cursor: pointer; }
.guide-steps { list-style: decimal; padding-left: 22px; display: flex; flex-direction: column; gap: 15px; margin: 22px 0; font-size: 14px; line-height: 1.55; }
.guide-steps li::marker { color: var(--plum); font-weight: 700; }
.guide-steps strong { font-weight: 700; }
.guide-steps p { color: var(--ink-soft); margin-top: 4px; }
.guide-duo { border-top: 1px solid #D7C1CB; padding-top: 16px; }
.guide-duo h3 { font-size: 16px; margin-bottom: 6px; }
.guide-duo p { font-size: 14px; line-height: 1.55; color: var(--ink-soft); }
.guide-dialog > .btn { margin-top: 22px; }
@media (max-width: 719px) {
  .handoff-wrap { padding-top: 12px; gap: 13px; }
  .handoff-wrap .serif-title { font-size: 25px; }
  .guide-dialog { padding: 20px; }
  .guide-dialog .serif-title { font-size: 24px; }
  .guide-steps { gap: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Independent character roster. Original artwork source IDs are not UI groups. */
[hidden] { display: none !important; }
.roster-wrap { width: min(1080px, 100%); }
.roster-layout { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 28px; align-items: start; }
.roster-library { min-width: 0; }
.roster-search-label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 7px; }
.roster-search { display: flex; align-items: center; gap: 12px; }
.roster-search input { min-width: 0; width: 100%; min-height: 46px; border: 1px solid #b899a8; border-radius: 12px; background: #fffafa; padding: 12px 14px; font: inherit; font-size: 14px; color: var(--ink); }
.roster-search input:focus-visible { outline: 3px solid var(--plum); outline-offset: 2px; }
.duo-pick-steps { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.duo-pick-steps button { padding: 10px 14px; min-height: 44px; border: 1px solid #b899a8; border-radius: 24px; color: var(--plum); background: #fffafa; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.duo-pick-steps button[aria-pressed="true"] { background: var(--plum); color: #fffafa; border-color: var(--plum); }
.duo-pick-steps { margin: 0 0 20px; }
.cast-count { font-size: 12px; color: var(--ink-soft); margin: 0; }
.roster-label-row, .roster-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.roster-label-row { margin-bottom: 7px; }
.roster-label-row .roster-search-label { margin: 0; }
.roster-label-row .text-btn { min-height: 36px; font-size: 12px; }
.roster-toolbar { flex-wrap: wrap; margin: 12px 0 16px; }
.roster-sort-label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-soft); }
#cast-sort { border: 1px solid #b899a8; border-radius: 9px; min-height: 38px; padding: 6px 8px; font: inherit; color: var(--plum); background: #fffafa; cursor: pointer; }
.selection-outside-view { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; padding: 10px 12px; border: 1px solid #cbb4bd; border-radius: 12px; background: #fffafa; }
.selection-outside-view p { font-size: 12px; line-height: 1.5; color: var(--ink-soft); }
.selection-outside-view .text-btn { flex-shrink: 0; min-height: 38px; font-size: 12px; }
.cast-grid { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.cast-grid .role-firstname { font-size: 16px; margin: 10px 4px 5px; }
.cast-grid .role-card { position: relative; border-radius: 14px; scroll-margin-block: 100px; }
.cast-grid .role-card img { object-position: center 42%; }
.cast-grid .role-card:focus-visible, #cast-sort:focus-visible { outline: 3px solid var(--plum); outline-offset: 3px; }
.role-check { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%; color: #fffafa; background: var(--plum); padding: 3px; box-shadow: 0 1px 5px #24171c30; }
.cast-grid .role-selected { margin-top: 7px; }
.roster-selection { position: sticky; top: 24px; }
.roster-selection .character-spotlight { grid-template-columns: minmax(0,1fr); gap: 14px; margin: 0; padding: 16px; }
.spotlight-portrait { display: block; width: 100%; height: 190px; object-fit: cover; object-position: center 42%; border-radius: 12px; }
.roster-selection .spotlight-title h3 { font-size: 26px; overflow-wrap: anywhere; }
.roster-selection .spotlight-story { grid-column: 1 / -1; }
.roster-selection .spotlight-story summary { cursor: pointer; color: var(--plum); font-size: 12px; font-weight: 600; min-height: 32px; padding: 8px 0; }
.roster-selection .spotlight-traits { font-size: 11px; line-height: 1.7; }
.roster-selection .selection-description { font-size: 12px; line-height: 1.5; }
.roster-selection .character-disclaimer { font-size: 11px; }
.cast-empty { background: #fffafa; border: 1px solid #cbb4bd; border-radius: 16px; padding: 28px; }
.cast-empty h3 { font-size: 21px; margin-bottom: 8px; }
.cast-empty p { font-size: 14px; color: var(--ink-soft); line-height: 1.6; margin-bottom: 18px; }
.roster-mobile-action { display: none; }
.mobile-profile-btn { display: flex; gap: 9px; align-items: center; min-width: 0; padding: 0; border: none; border-radius: 9px; text-align: left; color: var(--ink); background: transparent; font: inherit; cursor: pointer; }
.mobile-profile-btn:focus-visible { outline: 3px solid var(--plum); outline-offset: 3px; }
.mobile-profile-btn img { flex-shrink: 0; width: 42px; height: 54px; object-fit: cover; object-position: center 25%; border: 1px solid #cbb4bd; border-radius: 9px; }
.mobile-profile-btn strong { display: block; font-size: 14px; line-height: 1.5; }
.mobile-profile-btn span span { display: block; font-size: 11px; line-height: 1.5; color: var(--plum); }
.character-profile-dialog { max-width: 420px; }
.profile-dialog-portrait { display: block; width: 100%; height: min(34vh,250px); object-fit: cover; object-position: center 25%; border-radius: 12px; margin: 18px 0; }
#profile-name { font-size: 27px; margin-bottom: 6px; }
#character-profile-content > p { font-size: 14px; line-height: 1.65; margin-top: 12px; }
#character-profile-content .profile-dialog-traits { font-size: 12px; color: var(--plum); margin-top: 0; }
#character-profile-content .score-help { font-size: 11px; }
@media (max-width: 900px) and (min-width: 720px) {
  .roster-layout { grid-template-columns: minmax(0,1fr) 260px; gap: 18px; }
  .cast-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 719px) {
  #screen-characters { padding-bottom: 110px; }
  .roster-layout { display: flex; flex-direction: column; gap: 22px; }
  .roster-library, .roster-selection { width: 100%; }
  .roster-selection { display: none; }
  .roster-selection .character-spotlight { gap: 12px; }
  .roster-selection .spotlight-story > p { font-size: 12px; }
  .roster-selection .spotlight-story .spotlight-note { font-size: 10px; }
  .roster-selection .selection-description, .roster-selection #btn-character-continue, .roster-selection .character-disclaimer { display: none; }
  .cast-grid { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
  .cast-grid .role-firstname { font-size: 14px; }
  .cast-grid .role-age, .cast-grid .role-selected { font-size: 11px; }
  .roster-mobile-action { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.15fr); align-items: center; gap: 12px; position: fixed; z-index: 20; bottom: 0; left: 0; right: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: #fffaf5; border-top: 1px solid #cbb4bd; }
  .roster-mobile-action .btn { font-size: 13px; padding-inline: 10px; white-space: normal; min-height: 46px; }
}
