#fallback-avatar[hidden], #character-canvas[hidden] { display: none !important; }
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=Nunito:wght@600;700;800;900&display=swap');

:root {
  --room-ink: #183c57;
  --room-muted: #587287;
  --room-paper: #fffdf2;
  --room-sky: #5bd4e8;
  --room-teal: #087e91;
  --room-coral: #ff705e;
  --room-sun: #ffd348;
  --room-green: #75cf72;
  --room-purple: #a875e8;
  --room-line: #d3e7e1;
  --room-shadow: 0 14px 34px rgba(24, 60, 87, .11);
}

* { box-sizing: border-box; }

body.character-page {
  min-height: 100dvh;
  margin: 0;
  color: var(--room-ink);
  font-family: "Nunito", sans-serif;
  background:
    radial-gradient(ellipse at 4% 3%, rgba(91, 212, 232, .46), transparent 34rem),
    radial-gradient(ellipse at 96% 8%, rgba(255, 211, 72, .42), transparent 30rem),
    radial-gradient(ellipse at 8% 88%, rgba(117, 207, 114, .24), transparent 35rem),
    linear-gradient(135deg, #e8fbf7 0%, #fff8df 52%, #f0e9ff 100%);
  background-attachment: fixed;
}

.room-shell { min-height: 100dvh; overflow: hidden; }
.room-topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1200px, calc(100% - 48px));
  min-height: 74px;
  margin: 0 auto;
  border-bottom: 1px solid rgba(24, 60, 87, .12);
}
.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--room-ink);
  text-decoration: none;
  font: 700 19px/1 "Fredoka", sans-serif;
  letter-spacing: -.35px;
}
.brand-spark { color: var(--room-teal); }
.brand-mark {
  display: grid;
  grid-template-columns: 8px 8px;
  gap: 2px;
  transform: rotate(-7deg);
}
.brand-mark i { width: 8px; height: 8px; border-radius: 3px; background: var(--room-coral); }
.brand-mark i:nth-child(2) { background: var(--room-sun); }
.brand-mark i:nth-child(3) { background: var(--room-sky); }
.brand-mark i:nth-child(4) { background: var(--room-green); }
.room-nav { display: flex; align-items: center; gap: 10px; }
.room-nav a, .profile-nav {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border: 0;
  border-radius: 13px;
  color: var(--room-muted);
  background: transparent;
  text-decoration: none;
  font: 900 14px/1 "Nunito", sans-serif;
  cursor: pointer;
  transition: background-color .16s ease, color .16s ease, transform .16s ease;
}
.room-nav a:hover, .profile-nav:hover { color: var(--room-ink); background: rgba(255,255,255,.64); transform: translateY(-1px); }
.room-nav a:focus-visible, .profile-nav:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid #a875e8;
  outline-offset: 3px;
}
.profile-nav { color: var(--room-paper); background: var(--room-teal); box-shadow: 0 4px 0 #056878; }
.profile-nav:hover { color: var(--room-paper); background: #096e7e; }

.room-main { width: min(1200px, calc(100% - 48px)); margin: 0 auto; }
.intro-row { display: flex; align-items: center; justify-content: space-between; padding: 38px 4px 28px; }
.intro-copy { max-width: 710px; }
.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 9px;
  color: var(--room-teal);
  font: 900 11px/1.2 "Nunito", sans-serif;
  letter-spacing: 1.45px;
}
.eyebrow-dot { width: 8px; height: 8px; border-radius: 3px; background: var(--room-coral); transform: rotate(45deg); }
.intro-copy h1 {
  margin: 0;
  font: 700 clamp(34px, 5vw, 57px)/1.05 "Fredoka", sans-serif;
  letter-spacing: -1.5px;
}
.intro-copy h1 span { position: relative; color: var(--room-teal); white-space: nowrap; }
.intro-copy h1 span::after {
  position: absolute;
  right: 0; bottom: -3px; left: 0;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 211, 72, .82);
  content: "";
  transform: rotate(-1deg);
  z-index: -1;
}
.intro-text { max-width: 570px; margin: 12px 0 0; color: var(--room-muted); font-size: 15px; font-weight: 800; line-height: 1.6; }
.intro-stamp {
  position: relative;
  display: flex;
  width: 110px;
  height: 110px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-right: 4%;
  border: 3px solid var(--room-ink);
  border-radius: 50%;
  background: var(--room-sun);
  box-shadow: 5px 6px 0 var(--room-ink);
  transform: rotate(9deg);
}
.stamp-sun { position: absolute; inset: -9px; border: 1.5px dashed var(--room-ink); border-radius: 50%; }
.stamp-word { z-index: 1; font: 700 18px/1 "Fredoka", sans-serif; }
.stamp-sub { z-index: 1; margin-top: 4px; font-size: 8px; font-weight: 900; letter-spacing: 1px; }

.creator-layout { display: grid; grid-template-columns: minmax(340px, .94fr) minmax(440px, 1.06fr); align-items: start; gap: 22px; }
.preview-column { min-width: 0; }
.preview-card, .editor-card {
  border: 1px solid rgba(24, 60, 87, .11);
  border-radius: 25px;
  background: rgba(255, 253, 242, .93);
  box-shadow: var(--room-shadow), 0 5px 0 rgba(8, 126, 145, .08);
}
.preview-card { padding: 17px; }
.preview-topline, .preview-footer { display: flex; align-items: center; justify-content: space-between; }
.preview-topline { padding: 0 3px 12px; }
.preview-label { display: flex; align-items: center; gap: 8px; color: var(--room-ink); font-size: 10px; font-weight: 900; letter-spacing: 1.1px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #53c97e; box-shadow: 0 0 0 3px rgba(83,201,126,.16); }
.turn-hint { color: #71879a; font-size: 12px; font-weight: 800; }
.preview-stage {
  position: relative;
  isolation: isolate;
  display: flex;
  height: clamp(340px, 39vw, 468px);
  min-height: 330px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(8,126,145,.12);
  border-radius: 19px;
  background: linear-gradient(160deg, #d8f7f3 0%, #d6f5ee 54%, #eef9da 100%);
  touch-action: pan-y;
}
.stage-halo {
  position: absolute;
  z-index: -1;
  top: 13%; left: 50%;
  width: min(76%, 320px);
  aspect-ratio: 1;
  border: 1px solid rgba(8,126,145,.15);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,253,242,.92) 0 52%, rgba(255,253,242,.17) 53% 68%, transparent 69%);
  transform: translateX(-50%);
}
.stage-grid {
  position: absolute;
  z-index: -1;
  right: -12%; bottom: -26%;
  left: -12%; height: 42%;
  opacity: .45;
  background-image: linear-gradient(rgba(8,126,145,.13) 1px, transparent 1px), linear-gradient(90deg, rgba(8,126,145,.13) 1px, transparent 1px);
  background-size: 25px 25px;
  transform: perspective(220px) rotateX(48deg);
  transform-origin: top;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}
#character-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: pan-y; }
#character-canvas:active { cursor: grabbing; }
.fallback-avatar { position: absolute; inset: 18px 16px 40px; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.fallback-avatar svg { display: block; width: 68%; height: 100%; max-width: 290px; filter: drop-shadow(0 11px 0 rgba(24,60,87,.08)); }
.stage-caption { position: absolute; bottom: 15px; left: 50%; color: #58808a; font-size: 9px; font-weight: 900; letter-spacing: 1.6px; white-space: nowrap; transform: translateX(-50%); }
.stage-caption span { padding: 0 5px; color: var(--room-coral); }
.stage-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 9px; color: var(--room-teal); background: rgba(216,247,243,.78); font-size: 13px; font-weight: 900; transition: opacity .2s ease; }
.stage-loading.is-hidden { opacity: 0; pointer-events: none; }
.loading-block { width: 12px; height: 12px; border-radius: 3px; background: var(--room-coral); animation: block-hop .7s ease-in-out infinite alternate; }
@keyframes block-hop { to { transform: translateY(-5px) rotate(12deg); } }
.preview-footer { gap: 10px; padding: 12px 3px 1px; }
.look-status { min-width: 0; overflow: hidden; color: var(--room-muted); font-size: 12px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.reset-view { display: inline-flex; flex: none; align-items: center; gap: 6px; padding: 7px 9px; border: 1px solid #d9e8e3; border-radius: 11px; color: var(--room-teal); background: #fff; font: 900 11px "Nunito", sans-serif; cursor: pointer; }
.reset-view svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.reset-view:hover { background: #e8f8f4; }
.preview-note { display: flex; align-items: center; gap: 12px; margin: 15px 5px 0; padding: 13px 16px; border: 1px solid rgba(168,117,232,.22); border-radius: 17px; background: rgba(255,253,242,.7); }
.note-icon { display: grid; width: 31px; height: 31px; flex: none; place-items: center; border-radius: 10px; color: #7151a5; background: #eee3ff; font-size: 17px; }
.preview-note p { margin: 0; color: var(--room-muted); font-size: 12px; font-weight: 700; line-height: 1.5; }
.preview-note strong { color: var(--room-ink); font-weight: 900; }

.editor-card { padding: 23px 24px 19px; }
.editor-heading { display: flex; align-items: end; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.editor-heading .eyebrow { margin-bottom: 4px; font-size: 9px; }
.editor-heading h2 { margin: 0; font: 700 27px/1.1 "Fredoka", sans-serif; letter-spacing: -.3px; }
.choice-count { padding: 6px 10px; border-radius: 20px; color: #7354a5; background: #f0e8ff; font-size: 10px; font-weight: 900; white-space: nowrap; }
.option-groups { display: flex; flex-direction: column; gap: 8px; }
.choice-group { min-width: 0; margin: 0; padding: 10px 0 9px; border: 0; border-top: 1px solid #e4eee8; }
.choice-group legend { float: left; width: 100%; margin-bottom: 7px; padding: 0; color: var(--room-ink); font-size: 12px; font-weight: 900; }
.choice-group legend span { margin-left: 5px; color: #8ba0ad; font-size: 10px; font-weight: 800; }
.choice-options { display: flex; flex-wrap: wrap; gap: 7px; clear: both; }
.choice-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1.5px solid #dce9e4;
  border-radius: 11px;
  color: #49667b;
  background: #fffefa;
  font: 900 11px/1 "Nunito", sans-serif;
  cursor: pointer;
  transition: border-color .14s ease, background-color .14s ease, color .14s ease, transform .14s ease, box-shadow .14s ease;
}
.choice-button:hover { border-color: #8bcfd1; color: var(--room-ink); transform: translateY(-1px); }
.choice-button[aria-pressed="true"] { border-color: var(--room-teal); color: #075a68; background: #e2f8f2; box-shadow: inset 0 0 0 1px var(--room-teal); }
.choice-button.color-choice { min-width: 40px; padding: 5px; }
.color-swatch { width: 19px; height: 19px; border: 2px solid rgba(24,60,87,.13); border-radius: 7px; background: var(--swatch); box-shadow: inset 0 0 0 1px rgba(255,255,255,.28); }
.choice-button.color-choice[aria-pressed="true"] .color-swatch { outline: 2px solid var(--room-paper); box-shadow: 0 0 0 2px var(--room-teal); }
.choice-button .option-dot { width: 8px; height: 8px; border-radius: 3px; background: var(--room-coral); }
.choice-group[data-key="skin"] .option-dot { background: var(--choice-color); }
.choice-group[data-key="hairColor"] .option-dot,
.choice-group[data-key$="Color"] .option-dot { background: var(--choice-color); }

.editor-actions { margin-top: 5px; padding-top: 15px; border-top: 1px solid #e4eee8; }
.secondary-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.text-action { display: inline-flex; align-items: center; gap: 6px; padding: 7px 4px; border: 0; color: var(--room-muted); background: transparent; font: 900 11px "Nunito", sans-serif; cursor: pointer; }
.text-action:hover { color: var(--room-teal); }
.text-action svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.save-button {
  display: flex;
  width: 100%;
  min-height: 49px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 15px;
  color: #fffdf2;
  background: var(--room-coral);
  box-shadow: 0 5px 0 #d34f42, 0 9px 16px rgba(211,79,66,.15);
  font: 700 17px "Fredoka", sans-serif;
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease, background-color .14s ease;
}
.save-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.save-button:hover { background: #f66554; transform: translateY(-2px); box-shadow: 0 7px 0 #d34f42, 0 12px 18px rgba(211,79,66,.17); }
.save-button:active { transform: translateY(3px); box-shadow: 0 2px 0 #d34f42; }
.save-feedback { min-height: 17px; margin: 9px 0 0; color: #728897; text-align: center; font-size: 11px; font-weight: 800; }
.save-feedback.is-success { color: #177244; }
.save-feedback.is-error { color: #a53d30; }
.room-footer { display: flex; justify-content: space-between; gap: 12px; padding: 25px 4px 34px; color: #718797; font-size: 11px; font-weight: 800; }
.footer-star { padding-left: 3px; color: var(--room-coral); }

@media (max-width: 860px) {
  .creator-layout { grid-template-columns: minmax(280px, .85fr) minmax(360px, 1.15fr); gap: 14px; }
  .editor-card { padding: 20px 18px 16px; }
  .preview-stage { height: 390px; }
}
@media (max-width: 700px) {
  .room-topbar, .room-main { width: min(100% - 30px, 560px); }
  .room-topbar { min-height: 64px; }
  .brand-lockup { font-size: 17px; }
  .room-nav { gap: 1px; }
  .room-nav a, .profile-nav { min-height: 36px; padding: 0 10px; font-size: 12px; }
  .intro-row { padding: 28px 1px 21px; }
  .intro-copy h1 { max-width: 480px; font-size: clamp(36px, 9vw, 49px); }
  .intro-text { max-width: 460px; font-size: 14px; }
  .intro-stamp { display: none; }
  .creator-layout { grid-template-columns: 1fr; gap: 15px; }
  .preview-stage { height: min(108vw, 440px); min-height: 320px; }
  .editor-card { padding: 20px; }
  .option-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px; }
  .choice-group { align-self: start; }
  .room-footer { padding-top: 20px; padding-bottom: 25px; }
}
@media (max-width: 420px) {
  .room-topbar, .room-main { width: calc(100% - 24px); }
  .brand-lockup { gap: 7px; font-size: 15px; }
  .room-nav a { display: none; }
  .profile-nav { padding: 0 12px; }
  .intro-copy h1 { font-size: 36px; }
  .intro-text { font-size: 13px; }
  .preview-card { padding: 12px; }
  .preview-stage { min-height: 300px; }
  .editor-card { padding: 17px 14px 15px; }
  .option-groups { grid-template-columns: 1fr; gap: 0; }
  .choice-button { min-height: 32px; }
  .room-footer { flex-direction: column; gap: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
