:root {
  --bg: #fbeef3;
  --panel: #ffffff;
  --ink: #3a2a30;
  --muted: #8a7178;
  --line: #f1d9e2;
  --pink: #e8799f;
  --pink-dark: #c2537b;
  --pink-soft: #fde6ee;
  --stage: #fff7fa;
  --radius: 18px;
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { padding: 16px; min-height: 100vh; }
button { font: inherit; color: inherit; cursor: pointer; }

.top { text-align: center; margin-bottom: 14px; }
.top h1 { margin: 0; font-size: 30px; letter-spacing: .5px; color: var(--pink-dark); }
.tag { margin: 2px 0 0; color: var(--muted); }

.layout { display: grid; grid-template-columns: minmax(280px, 440px) minmax(0, 1fr); gap: 16px; max-width: 1100px; margin: 0 auto; align-items: start; }
@media (max-width: 760px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.layout > * { min-width: 0; }

/* ---------- doll ---------- */
.stage-wrap { position: sticky; top: 12px; }
/* Phones: keep the doll pinned at the top so items can be dragged onto her
   while the wardrobe scrolls underneath. */
@media (max-width: 760px) {
  body { padding: 10px; }
  .top { margin-bottom: 6px; }
  .top h1 { font-size: 24px; }
  .tag { display: none; }
  .stage-wrap { top: 0; z-index: 5; background: var(--bg); padding: 6px 0 8px; }
  .stage { height: 44vh; width: auto; margin: 0 auto; }
  .actions button { padding: 7px 4px; font-size: 13px; }
}
.views { display: flex; gap: 6px; justify-content: center; margin-bottom: 8px; }
.views button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 16px; }
.views button[aria-pressed="true"] { background: var(--pink); border-color: var(--pink); color: #fff; }

.stage { position: relative; aspect-ratio: 848 / 1264; background: var(--stage); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.stage img { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; }
.layers { position: absolute; inset: 0; }
.stage.target { outline: 3px dashed var(--pink); outline-offset: -6px; background: var(--pink-soft); }
.drop-hint { position: absolute; left: 0; right: 0; bottom: 14px; margin: 0; text-align: center; color: var(--pink-dark); font-weight: 700; opacity: 0; transition: opacity .15s; pointer-events: none; }
.stage.target .drop-hint { opacity: 1; }
.layer.pop { animation: pop .25s ease-out; }
@keyframes pop { from { transform: scale(.97); opacity: .4; } to { transform: none; opacity: 1; } }

.actions { display: flex; gap: 8px; margin-top: 10px; }
.actions button { flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 9px 6px; font-size: 14px; }
.actions button:hover, .views button:hover { border-color: var(--pink); }

/* ---------- wardrobe ---------- */
.side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.tab { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font-size: 14px; }
.tab[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.tab .n { opacity: .6; margin-left: 4px; font-size: 12px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; margin-top: 10px; min-height: 140px; }
.card { position: relative; border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 8px; text-align: left; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.card:hover { border-color: var(--pink); }
.card.worn { border-color: var(--pink-dark); box-shadow: 0 0 0 2px var(--pink-soft); }
.card.worn::after { content: "On"; position: absolute; top: 6px; right: 6px; background: var(--pink-dark); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.card .pic { aspect-ratio: 1; background: var(--stage); border-radius: 10px; display: grid; place-items: center; overflow: hidden; }
.card .pic img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; -webkit-user-drag: none; }
.card .nm { font-size: 13px; font-weight: 600; margin-top: 6px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .pr { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card.dragging { opacity: .35; }
.price-note { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.empty { grid-column: 1 / -1; color: var(--muted); text-align: center; align-self: center; margin: 0; }
.hint { font-size: 12px; color: var(--muted); margin: 10px 0 0; }

/* ---------- outfit ---------- */
.outfit h2 { margin: 0 0 8px; font-size: 17px; }
.wearing { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.wearing li { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; }
.wearing img { width: 44px; height: 44px; object-fit: contain; background: var(--stage); border-radius: 8px; }
.wearing .nm { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wearing .meta { font-size: 12px; color: var(--muted); }
.wearing a { font-size: 13px; color: #fff; background: var(--pink-dark); padding: 5px 10px; border-radius: 999px; text-decoration: none; white-space: nowrap; }
.tuckbar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
.tuckbar[hidden] { display: none; }
.tuck { border: none; background: var(--pink-dark); color: #fff; border-radius: 999px; padding: 8px 16px; font-size: 14px; font-weight: 700; animation: pop .25s ease-out; }
.tuck:hover { background: #a9416a; }
.tuck[aria-pressed="true"] { background: #fff; color: var(--pink-dark); box-shadow: inset 0 0 0 2px var(--pink-dark); }
.wearing .off { border: none; background: none; color: var(--muted); font-size: 18px; padding: 4px 6px; }
.wearing li.none { display: block; color: var(--muted); font-size: 14px; }
.total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.total strong { font-size: 18px; color: var(--pink-dark); }

/* ---------- drag ghost + toast ---------- */
.ghost { position: fixed; left: 0; top: 0; width: 110px; height: 110px; pointer-events: none; z-index: 50; transform: translate(-50%, -50%); filter: drop-shadow(0 8px 14px rgba(120, 40, 70, .25)); }
.ghost[hidden] { display: none; }
.ghost img { width: 100%; height: 100%; object-fit: contain; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 14px; margin: 0; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; }
.toast.show { opacity: 1; }

/* ---------- desktop: fit the doll to the window ---------- */
@media (min-width: 761px) {
  .layout { grid-template-columns: auto minmax(0, 1fr); max-width: 1400px; }
  /* Doll as tall as the window allows (minus header, buttons and room for the tuck bar). */
  .stage { height: min(calc(100dvh - 250px), 820px); min-height: 420px; width: auto; }
  .stage-wrap { display: flex; flex-direction: column; align-items: center; }
  .actions { width: 100%; }
}
/* Wide screens: the Wearing list gets its own column beside the wardrobe. */
@media (min-width: 1200px) {
  .side { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
  .outfit { position: sticky; top: 12px; }
}

/* ---------- phones: buttons beside the doll ---------- */
@media (max-width: 760px) {
  .top h1 { font-size: 20px; }
  .stage-wrap {
    display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px;
    grid-template-areas: "stage views" "stage actions" "tuck tuck";
    align-items: start;
  }
  .stage { grid-area: stage; height: min(50dvh, 420px); }
  .views { grid-area: views; flex-direction: column; margin: 0; }
  .views button { padding: 8px 6px; font-size: 14px; }
  .actions { grid-area: actions; flex-direction: column; margin: 0; gap: 6px; align-self: end; }
  .actions button { padding: 8px 4px; font-size: 13px; }
  .tuckbar { grid-area: tuck; margin-top: 0; }
  .tuckbar:empty { display: none; }
  .panel { padding: 10px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .card { padding: 6px; border-radius: 12px; }
  .card .nm { font-size: 12px; }
  .card .pr { font-size: 11px; }
}

/* adjusting a hat or accessory */
.tuckbar.adjusting { align-items: center; gap: 6px; }
.tuckbar .adj-name { flex-basis: 100%; text-align: center; font-size: 13px; color: var(--muted); }
.tuckbar .adj { border: none; background: #fff; color: var(--pink-dark); box-shadow: inset 0 0 0 2px var(--pink-dark); border-radius: 999px; min-width: 40px; height: 40px; padding: 0 12px; font-size: 16px; font-weight: 700; }
.tuckbar .adj:hover { background: #fdeef4; }
.tuckbar .adj.done { background: var(--pink-dark); color: #fff; }
.layers img[hidden] { display: none; }

/* =====================================================================
   Glitter girly theme - early-00s dress-up game look.
   Glossy gel buttons, polka dots and glitter, chunky outlined panels with
   title ribbons, a bubbly font, a star cursor and a sparkle trail.
   (Layout comes from the rules above; this only restyles.)
   ===================================================================== */
:root {
  --bg: #ffd6ea;
  --panel: #fff8fc;
  --ink: #5b2350;
  --muted: #a0618f;
  --line: #ff9fcf;
  --pink: #ff5fae;
  --pink-dark: #e0218a;
  --pink-soft: #ffe3f2;
  --lilac: #c99bff;
  --lilac-dark: #8f4fe0;
  --stage: #fff0f8;
  --radius: 22px;
  font-family: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 26 26'%3E%3Cpath d='M13 1l3.2 7.6 8.2.7-6.2 5.4 1.9 8L13 18.4 5.9 22.7l1.9-8L1.6 9.3l8.2-.7z' fill='%23ff5fae' stroke='%23fff' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E") 13 13, auto;
}
html, body {
  background-color: var(--bg);
  /* polka dots over soft diagonal stripes */
  background-image:
    radial-gradient(#fff 2.5px, transparent 3px),
    radial-gradient(#ffc2e0 2.5px, transparent 3px),
    repeating-linear-gradient(45deg, rgba(255,255,255,.35) 0 14px, transparent 14px 28px);
  background-size: 34px 34px, 34px 34px, auto;
  background-position: 0 0, 17px 17px, 0 0;
  background-attachment: fixed;
}
button, a, .card, .tab { cursor: inherit; }

/* ---------- title ---------- */
.top h1 {
  font-family: "Chewy", "Fredoka", cursive;
  font-weight: 400;
  font-size: 54px;
  line-height: 1;
  letter-spacing: 2px;
  color: #fff;
  background: linear-gradient(180deg, #ff9ad1 0%, #ff4fa7 55%, #d81b7f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 2px #fff;
  filter: drop-shadow(0 3px 0 #c2187a) drop-shadow(0 6px 10px rgba(194, 24, 122, .35));
  display: inline-flex; align-items: center; gap: 12px;
}
.top .spark {
  -webkit-text-fill-color: #fff6a8;
  -webkit-text-stroke: 1px #ff7cc0;
  font-size: 30px;
  animation: twinkle 1.6s ease-in-out infinite;
}
.top .spark:last-child { animation-delay: .8s; }
@keyframes twinkle { 0%, 100% { transform: scale(.7) rotate(0); opacity: .6; } 50% { transform: scale(1.15) rotate(20deg); opacity: 1; } }
.tag {
  display: inline-block; margin-top: 8px; padding: 4px 16px;
  background: #fff; color: var(--pink-dark); font-weight: 600;
  border: 2px dashed var(--line); border-radius: 999px;
}

/* ---------- gel buttons ---------- */
.views button, .actions button, .tab, .tuck, .tuckbar .adj, .wearing a {
  position: relative;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(150, 10, 90, .45);
  background: linear-gradient(180deg, #ffa3d2 0%, #ff5fae 50%, #f03c98 51%, #ff74b9 100%);
  box-shadow: 0 0 0 2px var(--pink-dark), 0 4px 0 #b3166d, 0 6px 10px rgba(179, 22, 109, .3);
  transition: transform .08s, filter .15s;
}
/* the glossy highlight across the top */
.views button::before, .actions button::before, .tab::before, .tuck::before, .tuckbar .adj::before, .wearing a::before {
  content: ""; position: absolute; left: 10%; right: 10%; top: 2px; height: 42%;
  border-radius: 999px; background: linear-gradient(rgba(255,255,255,.85), rgba(255,255,255,.1));
  pointer-events: none;
}
.views button:hover, .actions button:hover, .tab:hover, .tuck:hover, .tuckbar .adj:hover, .wearing a:hover { filter: brightness(1.08) saturate(1.1); border-color: #fff; background: linear-gradient(180deg, #ffa3d2 0%, #ff5fae 50%, #f03c98 51%, #ff74b9 100%); }
.views button:active, .actions button:active, .tab:active, .tuck:active, .tuckbar .adj:active, .wearing a:active { transform: translateY(3px); box-shadow: 0 0 0 2px var(--pink-dark), 0 1px 0 #b3166d; }
/* lilac for the selected / pressed state */
.views button[aria-pressed="true"], .tab[aria-selected="true"], .tuck[aria-pressed="true"], .tuckbar .adj.done {
  background: linear-gradient(180deg, #e3c8ff 0%, #b27cff 50%, #9a5cf0 51%, #c091ff 100%);
  box-shadow: 0 0 0 2px var(--lilac-dark), 0 4px 0 #6a2fb8, 0 6px 10px rgba(106, 47, 184, .3);
  color: #fff; border-color: #fff;
}
.tab .n { opacity: .9; }
.actions { gap: 10px; }
.actions button { padding: 10px 6px; font-size: 15px; }
.tabs { padding: 4px 4px 10px; gap: 8px; }
.tab { padding: 6px 14px; }

/* ---------- the doll's stage ---------- */
.stage {
  border: 4px solid #fff;
  border-radius: 28px;
  box-shadow: 0 0 0 4px var(--pink), 0 0 0 8px #fff, 0 10px 24px rgba(194, 24, 122, .25);
  background:
    radial-gradient(circle at 50% 38%, rgba(255,255,255,.95) 0 34%, rgba(255,255,255,0) 62%),
    radial-gradient(#ffd0ea 2px, transparent 2.5px) 0 0 / 22px 22px,
    linear-gradient(180deg, #fff3fa, #ffe0f0);
}
/* sparkles in the corners */
.stage::before, .stage::after {
  position: absolute; pointer-events: none; z-index: 2;
  font-size: 20px; color: #ff9fd0; text-shadow: 0 0 6px #fff;
  animation: glow 2.4s ease-in-out infinite;
}
.stage::before { content: "✦ ✧"; top: 10px; left: 14px; }
.stage::after { content: "✧ ✦"; bottom: 10px; right: 14px; animation-delay: 1.2s; }
@keyframes glow { 50% { color: #ffd23f; } }
.stage.target { outline: 4px dashed var(--lilac); background-color: #f4e8ff; }
.drop-hint { font-family: "Chewy", cursive; font-size: 24px; font-weight: 400; color: var(--lilac-dark); }

/* ---------- panels ---------- */
.panel {
  position: relative;
  background: var(--panel);
  border: 3px solid var(--pink);
  border-radius: var(--radius);
  box-shadow: 0 0 0 4px #fff, 0 0 0 6px var(--line), 0 10px 22px rgba(194, 24, 122, .18);
  padding: 30px 14px 14px;
  margin-top: 14px;
}
/* title ribbons */
.wardrobe::before, .outfit h2 {
  position: absolute; top: -16px; left: 18px; margin: 0;
  font-family: "Chewy", cursive; font-weight: 400; font-size: 20px; letter-spacing: 1px;
  color: #fff; padding: 3px 18px;
  background: linear-gradient(180deg, #ff8cc6, #ff4fa7);
  border: 2px solid #fff; border-radius: 999px;
  box-shadow: 0 0 0 2px var(--pink-dark), 0 3px 0 #b3166d;
  text-shadow: 0 1px 0 #b3166d;
}
.wardrobe::before { content: "♥ Wardrobe ♥"; }
.outfit h2::before { content: "★ "; }
.outfit h2::after { content: " ★"; }

/* ---------- item cards ---------- */
.card {
  border: 2px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
  transition: transform .12s;
}
.card .pic {
  border-radius: 14px;
  background: radial-gradient(#ffe0f0 1.5px, transparent 2px) 0 0 / 14px 14px, #fff7fb;
  border: 2px dotted #ffc0df;
}
.card:hover { border-color: var(--pink); transform: translateY(-2px) rotate(-1deg); box-shadow: 0 5px 0 var(--pink); }
.card:nth-child(even):hover { transform: translateY(-2px) rotate(1deg); }
.card .nm { color: var(--ink); font-weight: 600; }
.card .pr { color: var(--pink-dark); font-weight: 600; }
.card.worn { border-color: var(--lilac-dark); box-shadow: 0 0 0 3px #eadbff, 0 3px 0 var(--lilac-dark); }
.card.worn::after {
  content: "♥ On"; top: 4px; right: 4px;
  background: linear-gradient(180deg, #c091ff, #8f4fe0); border: 2px solid #fff;
  box-shadow: 0 2px 0 #6a2fb8;
}

/* ---------- wearing list ---------- */
.wearing li { background: #fff; border: 2px dashed #ffc0df; border-radius: 14px; padding: 6px 8px; }
.wearing li.none { border: none; background: none; }
.wearing img { background: #fff0f8; border-radius: 10px; }
.wearing a { padding: 5px 12px; font-size: 13px; }
.wearing .off { color: var(--pink-dark); font-weight: 700; }
.total { border-top: 2px dashed var(--line); }
.total strong { font-family: "Chewy", cursive; font-weight: 400; font-size: 24px; color: var(--pink-dark); }
.hint, .price-note { color: var(--muted); }

/* ---------- toast ---------- */
.toast {
  background: linear-gradient(180deg, #c091ff, #8f4fe0); border: 2px solid #fff;
  box-shadow: 0 0 0 2px #6a2fb8, 0 6px 14px rgba(106, 47, 184, .35); font-weight: 600;
}

/* ---------- sparkle trail ---------- */
.trail {
  position: fixed; z-index: 100; pointer-events: none; font-size: 14px;
  color: #ff5fae; text-shadow: 0 0 6px #fff, 0 0 2px #fff;
  transform: translate(-50%, -50%);
  animation: trail .8s ease-out forwards;
}
.trail:nth-of-type(3n) { color: #b27cff; }
.trail:nth-of-type(3n+1) { color: #ffd23f; }
@keyframes trail { to { transform: translate(calc(-50% + var(--dx)), 20px) scale(.3) rotate(90deg); opacity: 0; } }

/* phones: a smaller title, no corner sparkles crowding the doll */
@media (max-width: 760px) {
  .top h1 { font-size: 34px; }
  .top .spark { font-size: 20px; }
  .stage { border-width: 3px; box-shadow: 0 0 0 3px var(--pink), 0 0 0 6px #fff; }
  .stage::before, .stage::after { display: none; }
  .panel { padding: 26px 10px 10px; }
  /* the pinned doll needs a solid backdrop so the wardrobe scrolls under it */
  .stage-wrap { background: var(--bg); box-shadow: 0 6px 10px -6px rgba(194, 24, 122, .3); margin: 0 -10px; padding: 10px 10px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .top .spark, .stage::before, .stage::after { animation: none; }
}
