:root {
  color-scheme: dark;
  font-family: "Trebuchet MS", system-ui, sans-serif;
  color: #fff5ff;
  background: #21122e;
  --pearl: #ffe3bd;
  --muted: #e3c9ec;
  --rim: #e5b5e052;
  --pink: #f78bc5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-height: 100svh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 40px);
  background:
    radial-gradient(ellipse at 24% 14%, #683c6a 0%, transparent 44%),
    radial-gradient(ellipse at 90% 90%, #452248 0%, transparent 45%),
    #21122e;
}

button {
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 3px solid var(--pearl);
  outline-offset: 3px;
}

h1:focus { outline: none; }

.studio {
  width: min(100%, 1200px);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  min-height: min(740px, 88svh);
  border: 1px solid #eab5db73;
  border-radius: 30px;
  overflow: hidden;
  background: #382047;
  box-shadow: 0 24px 85px #140a20bc, inset 0 0 0 1px #ffdcfa25;
}

.studio-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 6px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--rim);
  background: linear-gradient(110deg, #49285e, #392047 60%, #542a5d);
}

.wordmark {
  font: 700 clamp(17px, 2.5vw, 24px) Georgia, serif;
  color: #fff2fb;
}

.wordmark span { color: var(--pearl); margin-right: .2em; }
.wordmark em { color: #ffc3e4; font-weight: 400; }

.scene {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 330px;
  background: #6e4a80 url("./assets/processed/room.webp") center / cover no-repeat;
}

.scene::after {
  content: "";
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 75px #2a153970;
}

.stage {
  position: absolute;
  width: min(78%, 470px);
  height: clamp(48px, 13%, 108px);
  bottom: 6%;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

.actor {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 11%;
  height: 81%;
  max-width: 94%;
  aspect-ratio: 590 / 855;
  transform: translateX(-50%);
  transform-origin: 50% 94%;
  pointer-events: none;
}

.actor img { position: absolute; user-select: none; }

.panel {
  min-width: 0;
  display: grid;
  place-items: center;
  padding: clamp(17px, 3vw, 42px);
  background:
    radial-gradient(ellipse at 50% 6%, #9a4d7b7a, transparent 62%),
    linear-gradient(165deg, #583165, #352044 80%);
  border-left: 1px solid var(--rim);
}

.welcome-content {
  max-width: 100%;
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.ornament {
  width: 132px;
  display: flex;
  align-items: center;
  gap: .55rem;
  color: var(--pearl);
  font-size: 30px;
  text-shadow: 0 0 22px #ffccacaa;
}

.ornament span { flex: 1; height: 1px; background: var(--rim); }

h1, h2 { margin: 0; }

h1 {
  font: 700 clamp(36px, 6vw, 78px)/.99 Georgia, serif;
  letter-spacing: -.045em;
  text-wrap: balance;
}

h1 em { color: #ffc0e5; font-weight: 400; }
#welcome-title { font-size: clamp(32px, 5.1vw, 65px); }

.primary {
  min-height: 49px;
  min-width: min(168px, 100%);
  padding: .5em 1.25em;
  border: 1px solid #ffc5eb;
  border-radius: 999px;
  background: linear-gradient(#a33779, #792155);
  box-shadow: inset 0 1px 5px #ffb6df70, 0 5px 16px #23123180;
  font-size: 1.05rem;
}

.primary:hover { background: linear-gradient(#b34489, #853063); }
.primary:active { transform: translateY(1px); }
.primary span { color: var(--pearl); margin-left: .3em; }
.welcome-content .primary { margin-top: 12px; }

.quiet {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: .35em .85em;
  background: transparent;
  color: #ffddf2;
}

.quiet:hover { background: #ffb1e720; }
.reset { border: 1px solid var(--rim); white-space: nowrap; }

.wardrobe { width: 100%; max-width: 455px; display: grid; gap: 13px; }
.wardrobe h1 { font-size: clamp(32px, 4.5vw, 51px); }
.options { display: grid; gap: 8px; }

.shelf {
  min-width: 0;
  display: grid;
  grid-template-columns: 6.4em minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 7px 8px 7px 11px;
  border: 1px solid var(--rim);
  border-radius: 15px;
  background: #2b193f75;
}

.shelf h2 { font-size: .84rem; color: var(--muted); }
.items { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 86px), 1fr)); gap: 7px; }

.item {
  position: relative;
  display: grid;
  grid-template-rows: 36px auto;
  justify-items: center;
  align-content: center;
  gap: 3px;
  min-height: 55px;
  min-width: 0;
  padding: 4px 3px;
  border: 1px solid #bf95d56b;
  border-radius: 11px;
  background: #72477d;
  font-size: .72rem;
  line-height: 1.15;
}

.item img { width: 56px; height: 36px; object-fit: contain; pointer-events: none; }
.item:hover { background: #8b538a; }
.item[aria-pressed="true"] { border-color: var(--pearl); background: #903e79; box-shadow: inset 0 0 9px #ffacdc60; }
.item[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 3px; right: 5px; color: var(--pearl); }

.spotlight {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(ellipse at 50% 36%, #fff0cf60, transparent 49%);
  pointer-events: none;
}

.sparkles { position: absolute; z-index: 4; inset: 0; pointer-events: none; }
.sparkles i { position: absolute; opacity: 0; color: #fff2b9; text-shadow: 0 0 8px #fff, 0 0 17px #f39ade; font: 28px Georgia, serif; }
.sparkles i:nth-child(1) { top: 23%; left: 31%; }
.sparkles i:nth-child(2) { top: 43%; left: 73%; --delay: .5s; }
.sparkles i:nth-child(3) { top: 54%; left: 21%; --delay: .9s; }
.sparkles i:nth-child(4) { top: 30%; left: 64%; --delay: 1.25s; }
.sparkles i:nth-child(5) { top: 66%; left: 75%; --delay: 1.7s; }
.sparkles i:nth-child(6) { top: 71%; left: 29%; --delay: 2.25s; }
.showing .actor { animation: pose 4s ease-in-out; }
.showing .spotlight { animation: light 4s ease-in-out; }
.showing .sparkles i { animation: twinkle 1.6s var(--delay, .1s) ease-in-out; }

@keyframes pose {
  0%, 100% { transform: translateX(-50%); }
  25% { transform: translate(-52%, -1.5%) rotate(-2deg); }
  55% { transform: translate(-48%, -.8%) rotate(2deg); }
  80% { transform: translate(-51%, -1.1%) rotate(-1deg); }
}
@keyframes light { 0%, 100% { opacity: 0; } 20%, 75% { opacity: 1; } }
@keyframes twinkle {
  0%, 100% { opacity: 0; transform: scale(.65); }
  46% { opacity: 1; transform: scale(1.2); }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
}

@media (max-width: 650px) and (orientation: portrait) {
  body { display: block; padding: 0; }
  .studio { min-height: 100svh; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr; border: 0; border-radius: 0; }
  .studio-header { min-height: 54px; }
  .scene { min-height: 0; height: clamp(227px, 45svh, 440px); }
  .panel { border-left: 0; border-top: 1px solid var(--rim); }
  .stage { width: min(76%, 320px); }
}

@media (orientation: landscape) and (max-height: 530px) {
  body { padding: 6px max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left)); }
  .studio { min-height: calc(100svh - 12px); border-radius: 18px; }
  .studio-header { min-height: 44px; padding: 0 13px; }
  .reset { min-height: 44px; border-color: transparent; }
  .scene { min-height: 246px; }
  .stage { height: 17%; }
  .panel { padding: 8px 12px; }
  .welcome-content { gap: 6px; }
  h1 { font-size: clamp(35px, 6vw, 51px); }
  .wardrobe { gap: 5px; }
  .wardrobe h1 { font-size: 26px; }
  .options { gap: 3px; }
  .shelf { grid-template-columns: 6em minmax(0, 1fr); padding: 1px 4px 1px 7px; }
  .items { grid-template-columns: repeat(auto-fit, minmax(min(100%, 65px), 1fr)); }
  .item { min-height: 44px; grid-template-rows: 23px auto; gap: 2px; padding: 1px 3px; }
  .item img { height: 23px; }
  .primary { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .showing .actor, .showing .spotlight, .showing .sparkles i { animation: none; }
  .showing .spotlight { opacity: .7; }
  .showing .sparkles i { opacity: .8; }
}
