/* Arielle's dress-up game — sticker-book look: soft pastels, chunky white cards, big touch targets. RTL. */
:root {
  --pink: #ff5fa2;
  --pink-d: #e0457f;
  --pink-l: #ffe3f0;
  --purple: #8b6cf0;
  --purple-d: #6a4fd0;
  --mint: #2fc7a0;
  --mint-d: #1fa583;
  --sun: #ffd24d;
  --ink: #4b3564;
  --ink-soft: #8a7aa3;
  --card: #ffffff;
  --line: #ecdff5;
  --top-h: 60px;
  --hair-h: 116px;
  --gap: 10px;
  --stage-h: min(calc(var(--vh) - var(--top-h) - var(--hair-h) - 4 * var(--gap)), calc(46vw / 0.75));
  --r: 20px;
  --vh: 100vh; /* older iPads; newer ones get the dynamic height below */
}
@supports (height: 100dvh) { :root { --vh: 100dvh; } }
@font-face { font-family: 'Fredoka'; font-style: normal; font-weight: 300 700; font-stretch: 100%; font-display: swap; src: url(../fonts/Fredoka-hebrew.woff2) format('woff2'); unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: 'Fredoka'; font-style: normal; font-weight: 300 700; font-stretch: 100%; font-display: swap; src: url(../fonts/Fredoka-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: 'Fredoka', system-ui, -apple-system, "SF Hebrew", "Arial Hebrew", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12px 12px, rgba(255, 255, 255, .7) 2.5px, transparent 3px) 0 0 / 28px 28px,
    linear-gradient(160deg, #ffd9ec 0%, #f1dcff 55%, #d9e8ff 100%);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
#app { height: var(--vh); padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }
svg { display: block; width: 100%; height: 100%; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 10px 22px; border-radius: 999px;
  font-weight: 800; font-size: 20px; color: #fff; background: var(--pink);
  box-shadow: 0 5px 0 var(--pink-d), 0 10px 18px rgba(224, 69, 127, .25);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--pink-d); }
.btn.purple { background: var(--purple); box-shadow: 0 5px 0 var(--purple-d), 0 10px 18px rgba(106, 79, 208, .25); }
.btn.purple:active { box-shadow: 0 1px 0 var(--purple-d); }
.btn.mint { background: var(--mint); box-shadow: 0 5px 0 var(--mint-d), 0 10px 18px rgba(31, 165, 131, .25); }
.btn.mint:active { box-shadow: 0 1px 0 var(--mint-d); }
.btn.white { background: #fff; color: var(--ink); box-shadow: 0 5px 0 #dccbee, 0 10px 18px rgba(120, 90, 160, .15); }
.btn.white:active { box-shadow: 0 1px 0 #dccbee; }
.btn.big { min-height: 68px; font-size: 26px; padding: 12px 34px; }
.btn.small { min-height: 44px; font-size: 16px; padding: 6px 16px; }
.btn[disabled] { opacity: .55; }
.round-btn {
  width: 48px; height: 48px; border-radius: 50%; background: #fff; font-size: 24px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  box-shadow: 0 4px 0 #dccbee, 0 8px 14px rgba(120, 90, 160, .14);
}
.round-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #dccbee; }
.stars-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 48px; padding: 0 16px; border-radius: 999px; flex: none;
  background: #fff7d6; color: #a36b00; font-weight: 900; font-size: 22px; box-shadow: 0 4px 0 #f0d98a; direction: ltr;
}
.stars-pill.bump { animation: bump .5s; }
@keyframes bump { 30% { transform: scale(1.25) rotate(-4deg); } 60% { transform: scale(.95); } }

/* ---------- home ---------- */
.home { height: 100%; display: flex; align-items: center; justify-content: center; gap: 4vw; padding: 20px; }
.home-art { height: calc(var(--vh) * .86); aspect-ratio: 3 / 4; max-width: 44vw; border-radius: 32px; overflow: hidden; background: #fff; border: 8px solid #fff; box-shadow: 0 18px 40px rgba(120, 70, 160, .25); transform: rotate(-2.5deg); flex: none; }
.home-side { display: flex; flex-direction: column; align-items: center; gap: 18px; min-width: 300px; }
.title { font-size: clamp(34px, 5vw, 58px); font-weight: 900; line-height: 1.1; text-align: center; color: var(--pink-d); text-shadow: 0 3px 0 #fff, 0 6px 14px rgba(224, 69, 127, .25); margin: 0; }
.title-edit { font-size: 15px; color: var(--ink-soft); font-weight: 700; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .7); }
.home-buttons { display: flex; flex-direction: column; gap: 16px; align-items: stretch; width: 100%; max-width: 360px; }
.home-row { display: flex; gap: 12px; }
.home-row .btn { flex: 1; }
.home-top { position: fixed; top: calc(12px + env(safe-area-inset-top)); inset-inline: 14px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.home-top > * { pointer-events: auto; }

/* ---------- generic screen with header ---------- */
.screen { height: 100%; display: flex; flex-direction: column; padding: var(--gap); gap: var(--gap); }
.bar { display: flex; align-items: center; gap: 10px; height: var(--top-h); flex: none; }
.bar h2 { margin: 0; font-size: 26px; font-weight: 900; flex: 1; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r); }
.card-panel { background: rgba(255, 255, 255, .88); border-radius: var(--r); box-shadow: 0 8px 22px rgba(120, 90, 160, .14); }

/* ---------- pick a girl ---------- */
.girls { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; padding: 6px; align-content: center; min-height: 100%; margin: 0 auto;
  width: min(100%, calc((var(--vh) - var(--top-h) - 64px) / 2 * .75 * 6 + 60px)); }
.girl { background: #fff; border-radius: 26px; border: 5px solid #fff; overflow: hidden; aspect-ratio: 3 / 4; box-shadow: 0 8px 20px rgba(120, 90, 160, .2); transition: transform .12s; }
.girl:active { transform: scale(.96); }
.girl:nth-child(odd) { background: #fff0f7; }
.girl:nth-child(even) { background: #eef3ff; }
.girl:nth-child(3n) { background: #f3ecff; }

/* ---------- editor ---------- */
.editor {
  height: 100%; display: grid; gap: var(--gap); padding: var(--gap); max-width: 1500px; margin: 0 auto;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: var(--top-h) minmax(0, 1fr) var(--hair-h);
  grid-template-areas: "top top" "panel stage" "hair hair";
}
.topbar { grid-area: top; display: flex; align-items: center; gap: 10px; min-width: 0; }
.theme-chip {
  flex: 1; min-width: 0; height: 48px; display: flex; align-items: center; gap: 8px; padding: 0 16px; border-radius: 999px;
  background: #fff; box-shadow: 0 4px 0 #dccbee; font-weight: 800; font-size: 19px; white-space: nowrap; overflow: hidden;
}
.theme-chip .ico { font-size: 26px; }
.theme-chip small { color: var(--ink-soft); font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
.done-btn { min-height: 48px; font-size: 22px; padding: 6px 26px; flex: none; }

.stage-wrap { grid-area: stage; display: flex; align-items: center; justify-content: center; position: relative; }
.stage {
  position: relative; height: var(--stage-h); width: calc(var(--stage-h) * .75); border-radius: 26px; overflow: hidden; background: #fff;
  border: 6px solid #fff; box-shadow: 0 12px 28px rgba(120, 70, 160, .22);
}
.stage-art { position: absolute; inset: 0; transition: transform .4s cubic-bezier(.3, 1.3, .5, 1); transform-origin: 50% 27%; }
.stage.zoom .stage-art { transform: translateY(16%) scale(2.05); }
.stage-btn { position: absolute; z-index: 2; }
.name-pill {
  position: absolute; z-index: 2; bottom: 6px; left: 50%; transform: translateX(-50%); max-width: 84%;
  min-height: 36px; padding: 3px 16px; border-radius: 999px; background: rgba(255, 255, 255, .93); font-weight: 900; font-size: 18px;
  box-shadow: 0 3px 0 rgba(140, 100, 180, .25); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.name-pill.empty { color: var(--ink-soft); font-weight: 700; font-size: 14.5px; }
.zoom-btn { top: 10px; inset-inline-start: 10px; width: 44px; height: 44px; font-size: 20px; }
.pop { animation: pop .3s; }
@keyframes pop { 40% { transform: scale(1.035); } }

.panel { grid-area: panel; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.cats { display: flex; gap: 6px; padding: 8px 8px 0; flex: none; }
.cat {
  flex: 1; min-width: 0; min-height: 62px; border-radius: 18px 18px 0 0; background: #f3eafb; color: var(--ink-soft);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-weight: 800; font-size: 14px;
}
.cat .ico { font-size: 26px; line-height: 1.1; }
.cat.on { background: var(--pink); color: #fff; }
.subs { display: flex; gap: 8px; padding: 10px 10px 4px; overflow-x: auto; flex: none; scrollbar-width: none; }
.subs::-webkit-scrollbar { display: none; }
.sub { flex: none; min-height: 44px; padding: 4px 16px; border-radius: 999px; background: #f3eafb; font-weight: 800; font-size: 16px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.sub.on { background: var(--purple); color: #fff; }
.sub.only { background: #fff7d6; color: #a36b00; box-shadow: inset 0 0 0 2px #f0d98a; }
.sub.only.on { background: var(--sun); color: #6b4700; box-shadow: inset 0 0 0 2px #e0a800; }
.hint-box { text-align: center; padding: 26px 12px; font-weight: 800; font-size: 18px; color: var(--ink-soft); line-height: 1.5; }
.grid-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 10px 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.grid.small { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
.section-title { font-weight: 900; font-size: 17px; margin: 10px 4px 8px; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.section-title:first-child { margin-top: 2px; }

.tile {
  position: relative; aspect-ratio: 1; border-radius: 18px; background: #faf5ff; border: 3px solid var(--line); overflow: hidden;
  display: flex; align-items: center; justify-content: center; transition: transform .1s;
}
.tile:active { transform: scale(.94); }
.tile.on { border-color: var(--pink); background: #fff0f7; box-shadow: 0 0 0 3px rgba(255, 95, 162, .25); }
.tile.none { font-size: 34px; color: #c9b6dd; }
.tile.locked { background: #f4f1f8; }
.tile.locked svg { opacity: .8; }
.tile .lock {
  position: absolute; inset-inline: 4px; bottom: 4px; height: 26px; border-radius: 999px; background: rgba(75, 53, 100, .86); color: #fff;
  font-size: 14px; font-weight: 900; display: flex; align-items: center; justify-content: center; gap: 3px; direction: ltr;
}
.tile .badge { position: absolute; top: 3px; inset-inline-start: 4px; font-size: 17px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .18)); }
.tile .new { position: absolute; top: 4px; inset-inline-end: 5px; font-size: 14px; }
.tile.bg { aspect-ratio: 3 / 4; }
.tile .label { position: absolute; inset-inline: 0; bottom: 0; padding: 3px 4px; font-size: 12.5px; font-weight: 800; text-align: center; background: rgba(255, 255, 255, .86); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.colors { flex: none; display: flex; gap: 8px; padding: 8px 10px 10px; overflow-x: auto; border-top: 2px dashed var(--line); scrollbar-width: none; align-items: center; }
.colors::-webkit-scrollbar { display: none; }
.sw { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px #dccbee; position: relative; }
.sw.on { box-shadow: 0 0 0 3.5px var(--pink); transform: scale(1.08); }
.sw.locked::after { content: "🔒"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 18px; background: rgba(255, 255, 255, .45); border-radius: 50%; }
.sw.none { background: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; color: #c9b6dd; }
.sw.big { width: 54px; height: 54px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; padding: 4px 4px 8px; }

.stepper { display: flex; align-items: center; gap: 10px; padding: 4px; }
.stepper .dots { flex: 1; display: flex; gap: 8px; justify-content: center; }
.stepper .dot { width: 18px; height: 18px; border-radius: 50%; background: #eadcf7; }
.stepper .dot.on { background: var(--pink); transform: scale(1.25); }
.stepper .round-btn { width: 56px; height: 56px; font-size: 26px; }
.toggle { display: inline-flex; background: #f3eafb; border-radius: 999px; padding: 4px; gap: 4px; margin: 0 2px 8px; }
.toggle button { min-height: 44px; padding: 4px 16px; border-radius: 999px; font-weight: 800; font-size: 15px; }
.toggle button.on { background: #fff; box-shadow: 0 2px 6px rgba(120, 90, 160, .25); color: var(--pink-d); }

/* hair strip (bottom) */
.hairstrip { grid-area: hair; display: flex; gap: 10px; min-width: 0; padding: 8px 10px; align-items: stretch; }
.hair-label { flex: none; width: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 900; font-size: 14px; gap: 2px; }
.hair-label .ico { font-size: 30px; }
.hair-styles { flex: 1.5; min-width: 0; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.hair-styles::-webkit-scrollbar, .hair-colors::-webkit-scrollbar { display: none; }
.hair-styles .tile { flex: none; height: 100%; aspect-ratio: .82; }
.hair-colors { flex: 1; min-width: 0; display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, 1fr); grid-auto-columns: 46px; gap: 6px 8px; overflow-x: auto; scrollbar-width: none; align-items: center; padding: 2px 4px; border-inline-start: 2px dashed var(--line); padding-inline-start: 12px; }
.hair-colors .sw { width: 42px; height: 42px; }

/* ---------- gallery / shop ---------- */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; padding: 12px; }
.shelf.shop { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
.gcard { background: #fff; border-radius: 22px; overflow: hidden; border: 5px solid #fff; box-shadow: 0 8px 18px rgba(120, 90, 160, .18); display: flex; flex-direction: column; }
.gcard .pic { aspect-ratio: 3 / 4; }
.gcard .meta { padding: 6px 10px 8px; display: flex; justify-content: space-between; align-items: center; font-weight: 900; gap: 6px; }
.gcard .meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gcard .meta .sc { color: #a36b00; direction: ltr; flex: none; }
.empty-box { text-align: center; padding: 8vh 20px; font-size: 22px; font-weight: 800; color: var(--ink-soft); }
.empty-box .ico { font-size: 64px; display: block; margin-bottom: 10px; }
.shop-tile { background: #fff; border-radius: 20px; border: 4px solid #fff; overflow: hidden; box-shadow: 0 6px 14px rgba(120, 90, 160, .16); display: flex; flex-direction: column; }
.shop-tile .pic { aspect-ratio: 1; background: #faf5ff; position: relative; }
.shop-tile .nm { font-size: 14px; font-weight: 800; text-align: center; padding: 5px 4px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shop-tile .pr { font-size: 16px; font-weight: 900; text-align: center; padding: 0 4px 8px; color: #a36b00; direction: ltr; }
.shop-tile.owned .pr { color: var(--mint-d); direction: rtl; }
.shop-tile.owned .pic { opacity: .75; }

/* ---------- modals ---------- */
.modal-back { position: fixed; inset: 0; z-index: 40; background: rgba(75, 53, 100, .45); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: #fff; border-radius: 30px; padding: 24px; max-width: min(560px, 94vw); max-height: calc(var(--vh) * .94); overflow: auto; box-shadow: 0 24px 60px rgba(60, 30, 90, .35); text-align: center; animation: rise .28s cubic-bezier(.3, 1.4, .5, 1); position: relative; }
@keyframes rise { from { transform: translateY(30px) scale(.94); opacity: 0; } }
.modal h3 { margin: 0 0 10px; font-size: 28px; font-weight: 900; }
.modal p { margin: 6px 0 14px; font-size: 19px; font-weight: 600; line-height: 1.45; }
.modal .row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.modal .big-ico { font-size: 64px; line-height: 1.1; }
.modal .x { position: absolute; top: 12px; inset-inline-end: 12px; width: 44px; height: 44px; border-radius: 50%; background: #f3eafb; font-size: 20px; font-weight: 900; }
.modal.wide { max-width: min(880px, 96vw); width: 880px; text-align: start; }
.name-input { width: 100%; font: inherit; font-size: 28px; font-weight: 800; text-align: center; padding: 12px 16px; border-radius: 18px; border: 3px solid var(--line); color: var(--ink); background: #faf5ff; outline: none; -webkit-user-select: text; user-select: text; }
.name-input:focus { border-color: var(--pink); }
.preview-card { width: min(300px, 60vw); aspect-ratio: 3 / 4; border-radius: 22px; overflow: hidden; margin: 0 auto 10px; border: 5px solid #f3eafb; background: #fff; }
.preview-card img { width: 100%; height: 100%; display: block; -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; }

/* result */
.result { display: flex; gap: 22px; align-items: center; }
.result .pic { flex: none; width: min(300px, 38vw); aspect-ratio: 3 / 4; border-radius: 24px; overflow: hidden; border: 6px solid #fff3c4; box-shadow: 0 10px 24px rgba(200, 140, 0, .25); background: #fff; }
.result .side { flex: 1; min-width: 0; text-align: center; }
.result .praise { font-size: 40px; font-weight: 900; color: var(--pink-d); margin: 0 0 4px; }
.result .total { font-size: 62px; font-weight: 900; color: #e59a00; line-height: 1; direction: ltr; text-shadow: 0 3px 0 #fff3c4; margin: 4px 0 8px; }
.lines { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.line { display: flex; align-items: center; gap: 8px; background: #faf5ff; border-radius: 14px; padding: 7px 12px; font-weight: 800; font-size: 17px; text-align: start; opacity: 0; transform: translateX(-16px); transition: opacity .3s, transform .3s; }
.line.show { opacity: 1; transform: none; }
.line .ico { font-size: 22px; flex: none; }
.line .lb { flex: 1; min-width: 0; }
.line .pt { color: #a36b00; font-weight: 900; direction: ltr; flex: none; }
.line.surprise { background: #fff3c4; }
.note { font-size: 16px; font-weight: 800; color: var(--mint-d); margin: 6px 0; min-height: 22px; }
.note.soft { color: var(--ink-soft); }
.gain { display: inline-block; background: #fff7d6; color: #a36b00; font-weight: 900; font-size: 18px; border-radius: 999px; padding: 4px 14px; direction: ltr; }
.toast { position: fixed; z-index: 70; bottom: calc(26px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-weight: 800; font-size: 18px; padding: 12px 22px; border-radius: 999px; box-shadow: 0 10px 24px rgba(0, 0, 0, .25); animation: rise .25s; white-space: nowrap; }

/* ---------- narrower / portrait screens ---------- */
@media (max-width: 860px), (orientation: portrait) {
  :root { --stage-h: min(calc(var(--vh) - var(--top-h) - var(--hair-h) - 4 * var(--gap)), calc(44vw / 0.75)); }
  .cat { font-size: 12px; min-height: 58px; }
  .cat .ico { font-size: 23px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
  .theme-chip small { display: none; }
  .stage-wrap { align-items: flex-start; }
  .home { flex-direction: column; gap: 18px; }
  .home-art { height: calc(var(--vh) * .46); max-width: 80vw; }
  .result { flex-direction: column; }
  .girls { grid-template-columns: repeat(4, minmax(0, 1fr)); width: min(100%, calc((var(--vh) - var(--top-h) - 76px) / 3 * .75 * 4 + 40px)); }
  .result .pic { width: min(220px, 50vw); }
}
@media (max-height: 620px) {
  :root { --top-h: 52px; --hair-h: 96px; }
  .cat { min-height: 52px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* the stage in layers: background · living effects · the girl */
.art-bg, .art-fx, .art-char { position: absolute; inset: 0; }
.art-bg svg, .art-char svg { display: block; width: 100%; height: 100%; }
.art-fx { overflow: hidden; pointer-events: none; }
.sw.fabric-btn { display: inline-flex; align-items: center; justify-content: center; font-size: 20px; border-style: dashed; }
.sw.fabric-btn svg { width: 70%; height: 70%; }
