﻿/* Princess Dress-Up — kid-friendly, touch-first styles */
:root {
  --card: #ffffff;
  --ink: #4a2a5a;
  --soft: #8a6a9a;
  --line: #f3d9ec;
  --pink: #ff5c9a;
  --pink2: #ff9cc6;
  --lav: #9d6bff;
  --gold: #ffc83d;
  --shadow: 0 5px 0 rgba(150, 70, 140, .12), 0 10px 22px rgba(150, 70, 140, .14);
  font-family: Fredoka, 'Comic Sans MS', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { color: var(--ink);
  background:
    radial-gradient(circle at 20px 20px, rgba(255, 92, 154, .08) 5px, transparent 6px) 0 0 / 70px 70px,
    radial-gradient(circle at 55px 55px, rgba(157, 107, 255, .08) 5px, transparent 6px) 0 0 / 70px 70px,
    linear-gradient(#fff2f8, #f1e8ff) fixed; }
h1, h2 { margin: 0; font-weight: 700; }
button, input { font: inherit; color: inherit; touch-action: manipulation; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: #d63f86; }

.shell { height: 100vh; height: 100dvh; display: flex; flex-direction: column; max-width: 1320px; margin: 0 auto; user-select: none; -webkit-user-select: none; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px 4px; padding-top: max(8px, env(safe-area-inset-top)); }
.title { font-size: clamp(18px, 4.6vw, 28px); color: var(--pink); text-shadow: 0 2px 0 #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { text-decoration: none; font-weight: 600; color: var(--soft); background: var(--card); border-radius: 999px; padding: 8px 14px; box-shadow: var(--shadow); min-height: 44px; display: inline-flex; align-items: center; white-space: nowrap; }
.top-right { display: flex; gap: 8px; align-items: center; }
.icon-btn { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow); font-size: 21px; flex: none; }
.stars-pill { display: flex; align-items: center; gap: 5px; background: linear-gradient(#fffbe6, #fff0b8); border: 3px solid #ffe08a; border-radius: 999px; padding: 4px 14px 4px 10px; font-size: 22px; box-shadow: var(--shadow); min-height: 46px; }
.stars-pill b { font-size: 22px; color: #c98a00; min-width: 1.1em; }

/* ---------- royal invitation ---------- */
.req { display: flex; align-items: center; gap: 8px; margin: 2px 10px 8px; padding: 6px 6px 6px 12px; background: #fff; border: 3px dashed #ffc3dd; border-radius: 22px; box-shadow: var(--shadow); min-height: 56px; }
.req-icon { font-size: 20px; }
.req-who { font-size: 30px; line-height: 1; }
.req-text { flex: 1; font-weight: 600; font-size: 16px; line-height: 1.2; }
.req-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: #efe6ff; font-size: 18px; flex: none; }
.req-go { border: 0; border-radius: 999px; background: #e9dff0; color: var(--soft); font-weight: 700; font-size: 18px; padding: 0 18px; min-height: 44px; flex: none; }
.req.ready { border-style: solid; border-color: #ffd84d; background: linear-gradient(#fffdf0, #fff6cf); }
.req.ready .req-go { background: var(--pink); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

/* ---------- main layout: stage + panel ---------- */
.app { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 470px); gap: 10px; padding: 0 10px 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.stage { position: relative; min-height: 0; border-radius: 26px; overflow: hidden; box-shadow: var(--shadow); background: #ffe0f0; touch-action: manipulation; }
.stage svg { display: block; width: 100%; height: 100%; }
.stage [data-act] { cursor: pointer; outline: none; }
.stage [data-act]:focus-visible { filter: drop-shadow(0 0 6px #ff5c9a); }
.actions { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 8px; }
.actions button { width: 50px; height: 50px; border-radius: 50%; border: 3px solid #fff; background: rgba(255, 255, 255, .88); box-shadow: var(--shadow); font-size: 24px; font-weight: 700; color: var(--pink); }
.actions button:active { transform: scale(.92); }
.actions button:disabled { opacity: .4; cursor: default; }

#pr-twirl.twirl { animation: twirl 1.2s ease-in-out; transform-box: view-box; transform-origin: 0 0; }
@keyframes twirl { 25% { transform: scaleX(0.05); } 50% { transform: scaleX(-1); } 75% { transform: scaleX(0.05); } }
.petbob { animation: petbob 1.6s ease-in-out infinite; }
@keyframes petbob { 50% { transform: translateY(-8px); } }
.twinkle { animation: twinkle 2.6s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .25; } }
.flake { animation: flake 7s linear infinite; }
@keyframes flake { from { transform: translate(0, -40px); opacity: 0; } 15% { opacity: 1; } to { transform: translate(30px, 140px); opacity: 0; } }

.bubble { position: absolute; z-index: 5; max-width: min(280px, 72%); background: #fff; color: var(--ink); border-radius: 20px; padding: 10px 14px; font-size: 17px; font-weight: 600; line-height: 1.25; text-align: center; box-shadow: var(--shadow); transform: translate(-50%, -100%); pointer-events: none; animation: bubble .3s cubic-bezier(.2, 1.5, .4, 1); }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -10px; margin-left: -10px; border: 10px solid transparent; border-bottom: 0; border-top-color: #fff; }
@keyframes bubble { from { opacity: 0; transform: translate(-50%, -80%) scale(.7); } }

.panel { min-height: 0; display: flex; flex-direction: column; background: #fff; border-radius: 26px; box-shadow: var(--shadow); overflow: hidden; }
.tabs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 8px 8px 6px; background: #fff5fa; border-bottom: 2px solid var(--line); }
.tabs button { position: relative; border: 0; background: transparent; border-radius: 14px; padding: 4px 0 3px; display: flex; flex-direction: column; align-items: center; gap: 0; min-height: 54px; justify-content: center; }
.tabs button b { font-size: 25px; line-height: 1.15; font-weight: 400; }
.tabs button span { font-size: 11.5px; font-weight: 600; color: var(--soft); white-space: nowrap; }
.tabs button[aria-selected="true"] { background: #fff; box-shadow: 0 0 0 3px var(--pink2), 0 3px 8px rgba(150, 70, 140, .15); }
.tabs button[aria-selected="true"] span { color: var(--pink); }
.tabs button.nudge { animation: nudge .5s ease-in-out 4; background: #fff3c4; }
@keyframes nudge { 50% { transform: translateY(-5px) scale(1.1); } }

.opts { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 12px 16px; overscroll-behavior: contain; }
.sec { font-size: 16px; font-weight: 700; color: var(--soft); margin: 12px 2px 8px; }
.note { color: var(--soft); font-size: 14px; margin: 8px 2px; }
.grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.grid.swatchs { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); }
.grid.emojis, .grid.shoes { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
.grid.places { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.grid.looks, .grid.presets { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.opt { position: relative; border: 3px solid var(--line); background: linear-gradient(#fff, #fff6fb); border-radius: 18px; padding: 4px 4px 5px; display: flex; flex-direction: column; align-items: center; gap: 2px; overflow: hidden; }
.opt svg { width: 100%; aspect-ratio: 1; height: auto; display: block; }
.opt.place svg { border-radius: 12px; }
.looks .opt svg, .presets .opt svg { aspect-ratio: 4 / 5; border-radius: 12px; }
.opt.shoe svg { aspect-ratio: 68 / 40; padding: 6px 4px; }
.opt .ol { font-size: 12.5px; font-weight: 600; line-height: 1.1; text-align: center; min-height: 2.2em; display: flex; align-items: center; }
.opt .sw { width: 100%; aspect-ratio: 1; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px #e8d6e4 inset, 0 2px 4px rgba(0, 0, 0, .1); }
.opt.swatch { border-radius: 50px 50px 18px 18px; }
.opt .oe { font-size: 42px; line-height: 1.25; }
.opt .oe.big { font-size: 64px; flex: 1; display: flex; align-items: center; }
.opt.on { border-color: var(--pink); background: #fff0f7; box-shadow: 0 0 0 3px #ffd1e6; }
.opt.on::after { content: '✓'; position: absolute; top: 3px; right: 5px; width: 20px; height: 20px; border-radius: 50%; background: var(--pink); color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center; }
.opt:active { transform: scale(.95); }
.look { position: relative; }
.look .opt { width: 100%; }
.look .del { position: absolute; top: 4px; right: 4px; width: 34px; height: 34px; border-radius: 50%; border: 2px solid #fff; background: rgba(255, 255, 255, .9); color: var(--soft); font-weight: 700; box-shadow: var(--shadow); }
.look .del.sure { background: #ffe0ea; color: #d6336c; }
.save-look { width: 100%; margin-top: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; border: 0; border-radius: 999px; padding: 12px 20px; font-weight: 700; font-size: 17px; background: var(--pink); color: #fff; box-shadow: var(--shadow); min-height: 48px; }
.btn.alt { background: #efe6ff; color: var(--ink); }
.btn.ghost { background: #fff; color: var(--soft); border: 2px solid var(--line); box-shadow: none; }
.btn.hold { position: relative; overflow: hidden; }
.btn.hold i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(255, 92, 154, .25); }
.btn.hold.holding i { width: 100%; transition: width 2s linear; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(74, 42, 90, .45); display: grid; place-items: center; padding: 16px; }
.modal-box { background: #fff; border-radius: 30px; padding: 22px 22px 20px; width: min(460px, 100%); max-height: 92dvh; overflow-y: auto; text-align: center; box-shadow: var(--shadow); animation: drop .4s cubic-bezier(.2, 1.5, .4, 1); border: 4px solid #ffe0ef; }
@keyframes drop { from { transform: translateY(30px) scale(.8); opacity: 0; } }
.m-emoji { font-size: 80px; line-height: 1.1; animation: bounce 1.2s ease-in-out infinite; display: inline-block; }
@keyframes bounce { 50% { transform: translateY(-8px) rotate(-4deg); } }
.modal-box h2 { font-size: 27px; color: var(--pink); margin: 6px 0 6px; }
.modal-box p { color: var(--soft); margin: 0 0 8px; font-size: 18px; }
.m-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.photo-img { width: 100%; max-height: 56dvh; object-fit: contain; border-radius: 16px; box-shadow: var(--shadow); margin: 6px 0; display: block; }
.stickers { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 10px 0; }
.stk { aspect-ratio: 1; display: grid; place-items: center; font-size: 34px; background: #fff5d6; border-radius: 16px; border: 2px solid #ffe08a; }
.stk.empty { background: #f6f2f8; border: 2px dashed #e3d6ea; color: #cbbbd6; font-size: 22px; font-weight: 700; }
.field { display: block; font-weight: 600; margin: 10px 2px 12px; text-align: left; }
.row { display: flex; gap: 8px; margin-top: 6px; }
.row input { flex: 1; min-width: 0; font-size: 18px; padding: 10px 14px; border-radius: 14px; border: 3px solid var(--line); outline: none; user-select: text; -webkit-user-select: text; }
.row input:focus { border-color: var(--pink2); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 2px; border-bottom: 2px solid #f7edf4; font-weight: 600; text-align: left; }
.small { font-size: 14px !important; color: var(--soft); line-height: 1.45; text-align: left; margin: 10px 2px !important; }

/* ---------- first visit ---------- */
.start { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; overflow-y: auto;
  background: radial-gradient(circle at 50% 0, #fff 0, #ffe3f1 40%, #e4d7ff 100%); }
.start-box { text-align: center; width: min(900px, 100%); }
.start-title { font-size: clamp(26px, 6vw, 44px); color: var(--pink); text-shadow: 0 3px 0 #fff; }
.start-sub { font-size: 22px; font-weight: 600; margin: 6px 0 16px; }
.princess-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.pcard { border: 4px solid #fff; background: linear-gradient(#fff, #fff5fb); border-radius: 26px; padding: 8px 4px 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pcard svg { width: 100%; max-width: 190px; aspect-ratio: 1; height: auto; }
.pcard .pdice { flex: 1; display: flex; align-items: center; font-size: 72px; }
.pcard .pn { font-size: clamp(16px, 3.4vw, 22px); font-weight: 700; color: var(--pink); }
.pcard:hover svg, .pcard:focus-visible svg { animation: bounce 1s ease-in-out infinite; }
.pcard:active { transform: scale(.96); }

/* ---------- effects ---------- */
.fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 70; }
.flash { position: fixed; inset: 0; background: #fff; z-index: 65; pointer-events: none; animation: flash .5s ease-out forwards; }
@keyframes flash { from { opacity: .95; } to { opacity: 0; } }

.site-footer { text-align: center; color: var(--soft); font-size: 13px; padding: 14px 16px 18px; }

/* ---------- portrait: stage on top, choices below ---------- */
@media (orientation: portrait), (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1.05fr) minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .title span { display: none; }
  .title::after { content: ' Dress-Up'; }
  .top .back { padding: 8px 12px; }
  .icon-btn { width: 42px; height: 42px; font-size: 19px; }
  .stars-pill { min-height: 42px; padding: 2px 10px 2px 8px; font-size: 19px; }
  .req { margin: 0 8px 6px; gap: 6px; padding-left: 8px; }
  .req-icon { display: none; }
  .req-who { font-size: 26px; }
  .req-text { font-size: 14px; }
  .req-btn { width: 36px; height: 36px; font-size: 16px; }
  .req-go { padding: 0 12px; font-size: 16px; }
  .app { padding: 0 8px 8px; gap: 8px; }
  .actions { right: 6px; top: 6px; gap: 6px; }
  .actions button { width: 44px; height: 44px; font-size: 21px; }
  .tabs { gap: 2px; padding: 6px 4px 4px; }
  .tabs button { min-height: 48px; }
  .tabs button b { font-size: 22px; }
  .tabs button span { font-size: 10px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
  .grid.swatchs { grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); }
  .grid.places, .grid.looks, .grid.presets { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .princess-cards { grid-template-columns: repeat(2, 1fr); }
  .pcard svg { max-width: 150px; }
  .start-sub { font-size: 19px; }
}
/* phones held sideways */
@media (orientation: landscape) and (max-height: 540px) {
  .top { padding: 4px 10px 2px; }
  .back, .icon-btn, .stars-pill { min-height: 38px; height: 38px; }
  .icon-btn { width: 38px; }
  .req { min-height: 44px; margin-bottom: 4px; padding-top: 2px; padding-bottom: 2px; }
  .req-who { font-size: 22px; }
  .req-btn, .req-go { min-height: 34px; height: 34px; }
  .req-btn { width: 34px; }
  .app { grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); }
  .actions button { width: 40px; height: 40px; font-size: 19px; }
  .actions { gap: 5px; }
  .tabs button { min-height: 40px; }
  .tabs button span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
