﻿/* Princess Castle Builder — kid-friendly, touch-first styles */
:root {
  --card: #ffffff;
  --ink: #4a2a5a;
  --soft: #8a6a9a;
  --line: #f3d9ec;
  --pink: #ff5c9a;
  --pink2: #ff9cc6;
  --lav: #9d6bff;
  --gold: #ffc83d;
  --mint: #2fbf8f;
  --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; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.shell { height: 100vh; height: 100dvh; display: flex; flex-direction: column; max-width: 1280px; 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: 24px; color: #c98a00; min-width: 1.2em; text-align: center; }
.stars-pill.pop { animation: pop .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { 40% { transform: scale(1.25); } }

.goal { display: flex; align-items: center; gap: 10px; padding: 2px 16px 6px; font-size: 15px; font-weight: 600; color: var(--soft); }
.goal-bar { flex: 1; height: 12px; background: #fff; border-radius: 99px; box-shadow: inset 0 1px 3px rgba(0, 0, 0, .12); overflow: hidden; max-width: 380px; }
.goal-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffd84d, #ff9cc6, #b79cff); border-radius: 99px; transition: width .6s; }

/* ---------- scene ---------- */
.app { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 10px 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); gap: 8px; }
.scene { position: relative; flex: 1; min-height: 0; border-radius: 26px; overflow: hidden; box-shadow: var(--shadow); background: #cfeaff; touch-action: manipulation; }
.scene svg { display: block; width: 100%; height: 100%; }
.scene [data-act] { cursor: pointer; outline: none; }
.scene [data-act]:focus-visible { filter: drop-shadow(0 0 6px #ff5c9a) drop-shadow(0 0 2px #fff); }
.scene [data-act="room"]:hover, .scene [data-act="roof"]:hover, .scene [data-act="garden"]:hover { filter: brightness(1.06); }

.plus { animation: pulse 1.5s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.flag { animation: flag 1.1s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: left center; }
@keyframes flag { to { transform: skewY(-7deg) scaleX(.92); } }
.cloud { animation: drift 50s ease-in-out infinite alternate; }
.cloud.rev { animation-direction: alternate-reverse; }
@keyframes drift { from { transform: translateX(-50px); } to { transform: translateX(60px); } }
.twinkle { animation: twinkle 2.6s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .25; } }
.sway { animation: sway 3s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes sway { from { transform: rotate(-3deg); } to { transform: rotate(3deg); } }
.firefly { animation: firefly 4s ease-in-out infinite; }
@keyframes firefly { 0%, 100% { transform: translate(0, 0); opacity: .2; } 50% { transform: translate(14px, -18px); opacity: 1; } }
.pop-in { animation: popin .5s cubic-bezier(.2, 1.6, .4, 1); transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes popin { from { transform: scale(.2); opacity: 0; } }

.daynight { position: absolute; left: 12px; bottom: 12px; width: 54px; height: 54px; border-radius: 50%; border: 3px solid #fff; background: rgba(255, 255, 255, .85); font-size: 26px; box-shadow: var(--shadow); }
.bubble { position: absolute; z-index: 5; max-width: min(280px, 70%); 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); } }
.hint { position: absolute; z-index: 4; font-size: 46px; pointer-events: none; animation: hint 1s ease-in-out infinite; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .25)); }
@keyframes hint { 50% { transform: translate(-6px, -10px); } }

/* ---------- toolbar ---------- */
.toolbar { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.toolbar button { position: relative; border: 0; background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 6px 2px 5px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 64px; }
.toolbar button b { font-size: 28px; line-height: 1.15; font-weight: 400; }
.toolbar button span { font-size: 13px; font-weight: 600; color: var(--soft); white-space: nowrap; }
.toolbar button:active { transform: translateY(2px); }
.dot { position: absolute; top: 6px; right: calc(50% - 22px); width: 14px; height: 14px; border-radius: 50%; background: var(--pink); border: 2px solid #fff; }

/* ---------- sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(74, 42, 90, .32); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: min(760px, 100%); max-height: 74dvh; display: flex; flex-direction: column; background: #fff; border-radius: 28px 28px 0 0; box-shadow: 0 -8px 30px rgba(74, 42, 90, .25); animation: up .3s cubic-bezier(.2, 1.2, .4, 1); padding-bottom: env(safe-area-inset-bottom); }
@keyframes up { from { transform: translateY(100%); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px 20px; }
.sheet-head h2 { font-size: 24px; color: var(--pink); }
.close { width: 46px; height: 46px; border-radius: 50%; border: 0; background: #ffeaf4; color: var(--pink); font-size: 22px; font-weight: 700; flex: none; }
.sheet-body { overflow-y: auto; padding: 4px 16px 20px; overscroll-behavior: contain; }
.sec { font-size: 16px; font-weight: 700; color: var(--soft); margin: 14px 4px 8px; }
.sec:first-child { margin-top: 2px; }
.note { color: var(--soft); font-size: 15px; margin: 4px 4px 10px; }

.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 10px; }
.choice { position: relative; border: 3px solid var(--line); background: #fff; border-radius: 20px; padding: 8px 4px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 104px; justify-content: center; }
.choice .ce { font-size: 44px; line-height: 1.1; }
.choice svg { width: 70px; height: 70px; }
.choice .cn { font-size: 14px; font-weight: 600; line-height: 1.15; text-align: center; }
.choice.on { border-color: var(--pink); background: #fff2f8; box-shadow: 0 0 0 3px #ffd1e6; }
.choice:not(.locked):active { transform: scale(.95); }
.choice.locked { background: #f6f2f8; border-style: dashed; cursor: default; }
.choice.locked .ce, .choice.locked svg { filter: grayscale(1) brightness(1.15); opacity: .35; }
.choice .lock { font-size: 14px; font-weight: 700; color: #b08300; }
.choice .new { position: absolute; top: -8px; right: -6px; background: var(--gold); color: #6b4a00; font-size: 12px; font-weight: 700; border-radius: 99px; padding: 2px 7px; border: 2px solid #fff; }
.choice.wide { grid-column: span 2; flex-direction: row; gap: 10px; min-height: 70px; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; width: 60px; height: 60px; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 0 0 2px var(--line), var(--shadow); }
.swatch.on { box-shadow: 0 0 0 4px var(--pink), var(--shadow); }
.swatch.locked { opacity: .4; cursor: default; }
.swatch .lock { position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%); background: #fff; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 1px 5px; color: #b08300; white-space: nowrap; }

.wish { display: flex; align-items: center; gap: 12px; border: 3px solid var(--line); border-radius: 20px; padding: 10px 12px; margin-bottom: 10px; background: #fffafd; }
.wish .who { font-size: 42px; line-height: 1; }
.wish .wt { flex: 1; font-size: 18px; font-weight: 600; }
.wish .wt small { display: block; font-size: 14px; color: #c98a00; }
.say-btn { width: 48px; height: 48px; border-radius: 50%; border: 0; background: #efe6ff; font-size: 22px; flex: none; }
.done-list { display: flex; flex-wrap: wrap; gap: 6px; font-size: 28px; }

.field { display: block; font-weight: 600; margin: 6px 4px 14px; }
.row { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.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); }
.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; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 4px; border-bottom: 2px solid #f7edf4; font-weight: 600; }
.small { font-size: 14px; color: var(--soft); line-height: 1.45; }

/* ---------- 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(440px, 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: 76px; 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-stars { font-size: 26px; font-weight: 700; color: #c98a00; margin: 4px 0 6px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 10px 0; }
.chip { background: #fff5d6; border-radius: 16px; padding: 6px 10px; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.chip b { font-size: 24px; font-weight: 400; }
.m-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.photo-img { width: 100%; border-radius: 16px; box-shadow: var(--shadow); margin: 6px 0; display: block; }

/* ---------- choose a princess ---------- */
.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 { position: relative; text-align: center; width: min(820px, 100%); }
.start-box > .close { position: absolute; right: 0; top: 0; }
.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; color: var(--ink); }
.princess-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.pcard { border: 4px solid #fff; background: linear-gradient(#fff, #fff5fb); border-radius: 28px; padding: 10px 6px 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pcard svg { width: 100%; max-width: 170px; aspect-ratio: 150 / 225; height: auto; }
.pcard .pn { font-size: clamp(17px, 3.6vw, 24px); font-weight: 700; color: var(--pink); }
.pcard .pp { font-size: 14px; color: var(--soft); }
.pcard.on { border-color: var(--pink2); }
.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; }

/* ---------- small screens ---------- */
@media (max-width: 520px) {
  .title span { display: none; }
  .title::after { content: ' Castle'; }
  .goal { font-size: 13px; padding: 0 12px 5px; }
  .toolbar { gap: 4px; }
  .toolbar button { min-height: 58px; border-radius: 14px; }
  .toolbar button b { font-size: 25px; }
  .toolbar button span { font-size: 11px; }
  .princess-cards { gap: 8px; }
  .start-sub { font-size: 19px; }
  .pcard .pp { display: none; }
  .daynight { width: 46px; height: 46px; font-size: 22px; left: 8px; bottom: 8px; }
  .choices { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
  .choice .ce { font-size: 38px; }
}
/* phones held sideways: tools move to the side */
@media (orientation: landscape) and (max-height: 540px) {
  .top { padding: 4px 10px 2px; }
  .back, .icon-btn, .stars-pill { min-height: 40px; height: 40px; }
  .icon-btn { width: 40px; }
  .goal { display: none; }
  .app { flex-direction: row; }
  .toolbar { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 1fr; width: 150px; flex: none; }
  .toolbar button { min-height: 0; padding: 2px; }
  .toolbar button b { font-size: 22px; }
  .sheet { max-height: 92dvh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
