:root {
  --ink: rgb(71,48,102); --rose: rgb(217,59,122); --rose-light: rgb(250,125,166);
  --font: "Nunito", "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { font-family: var(--font); color: var(--ink); background: rgb(209,237,250); touch-action: manipulation; -webkit-user-select: none; user-select: none;
  height: 100dvh; width: 100vw; position: fixed; inset: 0; }
button { font-family: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }

#storybook { position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, rgb(209,237,250), rgb(255,235,240), rgb(235,237,196)); }
#storybookCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#flowers { position: absolute; left: 0; right: 0; bottom: max(8px, env(safe-area-inset-bottom)); display: flex; justify-content: space-evenly; font-size: 27px; }
#flowers span:nth-child(3n+2) { transform: rotate(-12deg); } #flowers span:nth-child(3n) { transform: rotate(12deg); }

#screens { position: absolute; inset: 0; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
.hidden { display: none !important; }
.row { display: flex; align-items: center; justify-content: center; gap: 30px; }
.col { display: flex; flex-direction: column; align-items: center; }
.portrait { aspect-ratio: 340 / 440; width: min(400px, 36vw, 60vh); }

.kicker { font-size: 15px; font-weight: 800; letter-spacing: 3px; color: var(--rose); margin: 0 0 4px; }
.title-big { font-size: clamp(56px, 8vw, 91px); font-weight: 900; color: var(--rose); margin: 0; line-height: 1; }
.title-sub { font-size: clamp(26px, 3.5vw, 38px); font-weight: 800; margin: 8px 0 12px; }
.tagline { font-size: 20px; font-weight: 600; margin: 0 0 30px; }
.hint { font-size: 15px; opacity: .65; margin-top: 14px; }

.candy { display: inline-flex; align-items: center; gap: 14px; font-size: 26px; font-weight: 900; color: #fff; padding: 0 34px; min-height: 76px;
  border-radius: 999px; background: linear-gradient(to bottom, var(--rose-light), var(--rose)); box-shadow: inset 0 0 0 3px rgba(255,255,255,.9), 0 6px 0 rgba(217,59,122,.15);
  transition: transform .08s; }
.candy:active { transform: scale(.96); }
.candy.secondary { color: var(--ink); background: rgba(255,255,255,.93); }
.candy .ico { font-size: 24px; }

.dress-title { font-size: 40px; font-weight: 900; color: var(--rose); margin: 0 0 8px; }
.dress-portrait { width: min(355px, 30vw, 52vh); }
.beautiful { font-size: 25px; font-weight: 800; color: var(--rose); margin: 6px 0 0; }
.dress-controls { gap: 22px; }
.categories { display: flex; gap: 12px; }
.categories button { width: 67px; height: 67px; font-size: 33px; border-radius: 21px; background: rgba(255,255,255,.4); box-shadow: inset 0 0 0 3px transparent; }
.categories button.on { background: #fff; box-shadow: inset 0 0 0 3px var(--rose); }
.category-name { font-size: 27px; font-weight: 800; margin: 0; }
.items { display: grid; grid-template-columns: repeat(3, 119px); gap: 16px; }
.items button { position: relative; width: 119px; height: 101px; font-size: 49px; border-radius: 25px; background: rgba(255,255,255,.85); box-shadow: inset 0 0 0 2px #fff; }
.items button.on { box-shadow: inset 0 0 0 4px var(--rose); }
.items button.on::after { content: "✓"; position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%; background: var(--rose); color: #fff; font-size: 14px; font-weight: 900; line-height: 22px; }

.choose-title { font-size: 42px; font-weight: 900; margin: 0 0 6px; }
.choose-sub { font-size: 21px; opacity: .7; margin: 0 0 26px; }
.cards { display: flex; gap: 24px; margin-bottom: 32px; }
.cards button { width: 215px; height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; border-radius: 35px;
  background: rgba(255,255,255,.9); box-shadow: inset 0 0 0 4px #fff, 0 7px 12px rgba(217,59,122,.12); transition: transform .08s; }
.cards button:active { transform: scale(.96); }
.cards .icon { font-size: 75px; line-height: 1; } .cards .name { font-size: 31px; font-weight: 900; } .cards .blurb { font-size: 17px; }
.cards .dots { display: flex; gap: 7px; } .cards .dots i { width: 12px; height: 12px; border-radius: 50%; background: rgba(217,59,122,.65); }

#maze { padding: 0; }
#mazeCanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.hud { position: absolute; top: max(18px, env(safe-area-inset-top)); left: 50%; transform: translateX(calc(-50% - 32px)); display: flex; align-items: center; gap: 22px;
  padding: 13px; border-radius: 999px; background: rgba(255,255,255,.65); pointer-events: none; }
.crowns { display: flex; gap: 8px; font-size: 28px; } .crowns span.off { opacity: .35; }
.foods { display: flex; gap: 10px; }
.foods span { position: relative; width: 51px; height: 54px; display: flex; align-items: center; justify-content: center; font-size: 31px; border-radius: 16px; background: rgba(255,255,255,.9); }
.foods span.got { opacity: 1; } .foods span.got em { opacity: .3; }
.foods span.got::after { content: "✓"; position: absolute; right: -2px; bottom: -2px; width: 19px; height: 19px; border-radius: 50%; background: var(--rose); color: #fff; font-size: 12px; font-weight: 900; line-height: 19px; text-align: center; box-shadow: 0 0 0 2px #fff; }

#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.victory-col { gap: 8px; position: relative; }
.crown-big { font-size: 49px; line-height: 1; }
.victory-title { font-size: clamp(30px, 4.2vw, 49px); font-weight: 900; color: var(--rose); margin: 0; white-space: nowrap; }
.victory-sub { font-size: 23px; font-weight: 700; margin: 0; }
.victory-portrait { width: min(263px, 24vw, 40vh); }
.buttons { gap: 25px; margin-top: 10px; }

#gear { position: absolute; top: max(18px, env(safe-area-inset-top)); right: max(18px, env(safe-area-inset-right)); width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,.45); font-size: 26px; color: rgba(71,48,102,.55); touch-action: none; }
#gear .ring { position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--rose); opacity: 0; transform: scale(.6); pointer-events: none; }
#gear.holding .ring { opacity: 1; transform: scale(1); transition: transform 2s linear, opacity .2s; }

.modal { position: absolute; inset: 0; background: rgba(60,40,80,.35); display: flex; align-items: center; justify-content: center; z-index: 20; }
.sheet { width: 460px; max-width: 92vw; max-height: 90dvh; overflow: auto; background: #fff; border-radius: 28px; padding: 32px; display: flex; flex-direction: column; gap: 18px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; } .sheet h3 { font-size: 28px; font-weight: 800; margin: 0; }
.toggle { display: flex; justify-content: space-between; align-items: center; font-size: 19px; }
.toggle input { width: 30px; height: 30px; accent-color: var(--rose); } .toggle select { font-size: 17px; padding: 6px 10px; border-radius: 10px; border: 1px solid #ccc; font-family: inherit; }
.fine { font-size: 14px; color: #777; margin: 0; }
.sheet-actions, .confirm { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.confirm { background: #fff2f6; border-radius: 16px; padding: 14px; } .confirm p { margin: 0; font-weight: 700; width: 100%; }
.mini { font-size: 17px; font-weight: 700; padding: 10px 18px; border-radius: 12px; background: #f1edf5; min-height: 44px; }
.mini.primary { background: var(--rose); color: #fff; } .mini.danger { color: #c0392b; }

.rotate { position: absolute; inset: 0; z-index: 30; background: rgb(255,235,240); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; font-size: 28px; font-weight: 800; text-align: center; padding: 30px; }
.rotate div { font-size: 96px; animation: turn 1.6s ease-in-out infinite alternate; }
@keyframes turn { from { transform: rotate(0deg); } to { transform: rotate(-90deg); } }
.error { position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; text-align: center; padding: 40px; font-size: 20px; background: rgb(255,235,240); white-space: pre-wrap; }

@media (max-height: 640px) {
  .candy { min-height: 62px; font-size: 22px; } .cards button { width: 180px; height: 210px; } .cards .icon { font-size: 56px; } .cards .name { font-size: 26px; }
  .items { grid-template-columns: repeat(3, 100px); gap: 10px; } .items button { width: 100px; height: 82px; font-size: 40px; }
  .dress-title { font-size: 30px; } .choose-title { font-size: 32px; } .choose-sub { margin-bottom: 14px; } .cards { margin-bottom: 16px; }
  .victory-sub { font-size: 18px; } .crown-big { font-size: 36px; } .tagline { margin-bottom: 14px; } #flowers { font-size: 20px; }
}

.gate { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(to bottom, rgb(209,237,250), rgb(255,235,240)); }
.gate-card { background: rgba(255,255,255,.92); border-radius: 32px; padding: 22px 30px; display: flex; flex-direction: column; align-items: center; gap: 12px; box-shadow: 0 10px 30px rgba(217,59,122,.15); }
.gate-crown { font-size: 40px; line-height: 1; } .gate-card h2 { margin: 0; font-size: 28px; font-weight: 900; color: var(--rose); }
.gate-dots { display: flex; gap: 12px; height: 24px; } .gate-dots i { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--rose); }
.gate-dots i.on { background: var(--rose); }
.gate-dots.wrong { animation: shake .4s; } @keyframes shake { 20%,60% { transform: translateX(-10px); } 40%,80% { transform: translateX(10px); } }
.gate-pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 10px; }
.gate-pad button { height: 64px; font-size: 28px; font-weight: 800; border-radius: 20px; background: #fff; box-shadow: inset 0 0 0 2px rgba(217,59,122,.25); }
.gate-pad button:active { background: #ffe4ee; }
.gate-fine { margin: 0; font-size: 14px; opacity: .65; }
@media (max-height: 640px) { .gate-pad { grid-template-columns: repeat(3, 66px); gap: 8px; } .gate-pad button { height: 50px; font-size: 22px; } .gate-card { padding: 14px 22px; gap: 8px; } .gate-crown { font-size: 28px; } }
