:root {
  --font: "Trebuchet MS", sans-serif;
  --rose: #5a2340;
  --pink: #ff8fb8;
  --cream: #fff6ec;
  --ol: 2px 0 0 var(--rose), -2px 0 0 var(--rose), 0 2px 0 var(--rose), 0 -2px 0 var(--rose), 2px 2px 0 var(--rose), -2px 2px 0 var(--rose), 2px -2px 0 var(--rose), -2px -2px 0 var(--rose), 0 4px 0 rgba(60, 10, 40, .55);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1a1030; font-family: var(--font); user-select: none; -webkit-user-select: none; touch-action: none; }
#stage { position: fixed; inset: 0; overflow: hidden; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
.hidden { display: none !important; }

/* generic 9-slice fallbacks (replaced by the art once loaded) */
.panel { background: var(--cream); border: 4px solid var(--pink); border-radius: 14px; box-shadow: 0 0 0 3px var(--rose); }
.btn9 { background: linear-gradient(#ffb3cf, #ff7fae); border: 3px solid var(--rose); border-radius: 12px; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
.hudpanel { position: absolute; background: rgba(90, 35, 64, .62); border: 2px solid rgba(255, 190, 215, .85); border-radius: 12px; color: #fff; text-shadow: var(--ol); font-weight: 900; }
#clockBox { left: calc(10px + env(safe-area-inset-left)); top: calc(10px + env(safe-area-inset-top)); padding: 5px 12px 6px; min-width: 132px; }
#hudDay { font-size: 14px; letter-spacing: .5px; opacity: .95; }
.clockrow { display: flex; align-items: center; gap: 8px; }
#hudWx { width: 28px; height: 28px; image-rendering: pixelated; }
#hudTime { font-size: 26px; letter-spacing: 1px; }
#goldBox { left: calc(152px + env(safe-area-inset-left)); top: calc(10px + env(safe-area-inset-top)); height: 40px; padding: 0 12px 0 6px; display: flex; align-items: center; gap: 6px; font-size: 18px; }
#goldBox img { width: 28px; height: 28px; image-rendering: pixelated; }
#minimap { position: absolute; left: calc(10px + env(safe-area-inset-left)); top: calc(82px + env(safe-area-inset-top)); width: 96px; height: 96px; border-radius: 50%; border: 3px solid rgba(255, 190, 215, .9); box-shadow: 0 0 0 2px var(--rose); background: rgba(40, 60, 40, .5); }

#prompt { position: absolute; left: 50%; top: 56%; transform: translate(-50%, 8px) scale(.9); opacity: 0; transition: .18s; padding: 8px 16px; border-radius: 22px; background: rgba(90, 35, 64, .78); border: 2px solid var(--pink); color: #fff; font-weight: 900; font-size: 16px; text-shadow: var(--ol); white-space: nowrap; pointer-events: none; }
#prompt.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

#labels { position: absolute; inset: 0; pointer-events: none; }
.nametag { position: absolute; transform: translate(-50%, -100%); padding: 2px 9px 3px; border-radius: 10px; background: rgba(90, 35, 64, .72); color: #fff; font-weight: 900; font-size: 13px; text-shadow: 0 1px 0 var(--rose); white-space: nowrap; border-bottom: 3px solid var(--hc); }
.nametag b { color: var(--hc); margin-left: 4px; letter-spacing: -1px; }

#toasts { position: absolute; left: 0; right: 0; top: calc(190px + env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { font-weight: 900; font-size: 18px; color: #fff; text-shadow: var(--ol); animation: toastIn .35s cubic-bezier(.3, 1.6, .5, 1); transition: .45s; }
.toast.out { opacity: 0; transform: translateY(-16px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.6); } to { opacity: 1; transform: none; } }

#banner { position: absolute; left: 0; right: 0; top: 30%; text-align: center; pointer-events: none; opacity: 0; }
#banner.show { animation: bannerAnim 3.2s ease forwards; }
@keyframes bannerAnim { 0% { opacity: 0; transform: scale(1.6); } 10% { opacity: 1; transform: scale(.95); } 16% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-20px); } }
.bn-title { font-size: 40px; font-weight: 900; color: #fff; text-shadow: var(--ol); letter-spacing: 2px; }
.bn-sub { font-size: 17px; font-weight: 900; color: #ffe1ec; text-shadow: var(--ol); margin-top: 4px; }
.bn-icons { display: flex; justify-content: center; gap: 14px; margin-top: 8px; }
.bn-icons span { display: flex; flex-direction: column; align-items: center; background: rgba(90, 35, 64, .6); border-radius: 10px; padding: 4px 8px; }
.bn-icons img { width: 32px; height: 32px; image-rendering: pixelated; }
.bn-icons small { color: #fff; font-weight: 900; font-size: 12px; text-shadow: 0 1px 0 var(--rose); }

/* ---------- dialogue ---------- */
#dialog { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 10px calc(14px + env(safe-area-inset-bottom)); pointer-events: none; }
#dlgPanel { position: relative; pointer-events: auto; padding: 26px 18px 16px; min-height: 150px; transform: translateY(40px); opacity: 0; transition: transform .25s cubic-bezier(.3, 1.5, .5, 1), opacity .2s; cursor: pointer; }
#dialog.show #dlgPanel { transform: none; opacity: 1; }
#dlgName { position: absolute; left: 18px; top: -18px; padding: 4px 14px 5px; border-radius: 12px; color: #fff; font-weight: 900; font-size: 17px; text-shadow: var(--ol); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--rose); }
#dlgHearts { position: absolute; right: 20px; top: 6px; color: #ff5f97; font-size: 16px; letter-spacing: 1px; text-shadow: 0 1px 0 #fff; }
#dlgText { color: #4a2338; font-weight: 800; font-size: 17px; line-height: 1.5; min-height: 52px; white-space: pre-wrap; }
#dlgNext { position: absolute; right: 22px; bottom: 10px; color: #e0507f; animation: bob .8s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(4px); } }
#dlgChoices { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.choice { position: relative; min-height: 48px; padding: 6px 16px; color: #fff; font-family: inherit; font-weight: 900; font-size: 16px; text-shadow: var(--ol); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: transform .12s, filter .12s; animation: popIn .25s cubic-bezier(.3, 1.6, .5, 1) both; }
.choice small { font-size: 12px; opacity: .9; margin-left: 4px; }
.choice .cicon { width: 30px; height: 30px; image-rendering: pixelated; }
.choice.focus { transform: scale(1.04); filter: brightness(1.12) drop-shadow(0 0 6px rgba(255, 255, 255, .9)); }
.choice.pressed { transform: scale(.94); }
.choice.disabled { filter: grayscale(.8) brightness(.9); opacity: .65; }
.choice.shake { animation: shake .3s; }
@keyframes popIn { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: none; } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- phone ---------- */
#phone { position: absolute; inset: 0; background: rgba(30, 10, 30, .45); display: flex; align-items: center; justify-content: center; padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)); }
.phone-panel { width: 100%; max-width: 420px; max-height: 100%; padding: 18px 16px 14px; display: flex; flex-direction: column; gap: 8px; transform: scale(.8); opacity: 0; transition: .25s cubic-bezier(.3, 1.5, .5, 1); color: #4a2338; }
#phone.show .phone-panel { transform: none; opacity: 1; }
.ph-head { display: flex; justify-content: space-between; align-items: baseline; }
.ph-title { font-size: 22px; font-weight: 900; color: #fff; text-shadow: var(--ol); }
.ph-date { font-weight: 900; font-size: 14px; color: #a0446a; }
.ph-fc { display: flex; gap: 8px; }
.fc-col { flex: 1; background: rgba(255, 143, 184, .16); border-radius: 10px; padding: 4px 6px; }
.fc-lbl { font-size: 12px; font-weight: 900; color: #a0446a; }
.fc-row { display: flex; justify-content: space-around; }
.fc-seg { display: flex; flex-direction: column; align-items: center; }
.fc-seg img { width: 26px; height: 26px; image-rendering: pixelated; }
.fc-seg small { font-size: 11px; font-weight: 800; }
.ph-card { display: flex; gap: 10px; align-items: center; background: #fff; border-radius: 12px; padding: 6px 8px; border-left: 6px solid var(--hc); box-shadow: 0 2px 0 rgba(90, 35, 64, .2); }
.ph-av { width: 54px; height: 64px; flex: none; border-radius: 8px; background: #ffe6ef center 8% / 180% no-repeat; image-rendering: pixelated; }
.ph-av.unknown { background: #e8d6de; }
.ph-av.unknown::after { content: "?"; display: block; text-align: center; font: 900 34px/64px sans-serif; color: #b08aa0; }
.ph-info { flex: 1; min-width: 0; }
.ph-name { font-weight: 900; font-size: 15px; display: flex; justify-content: space-between; gap: 6px; }
.ph-lv { font-size: 12px; color: var(--hc); white-space: nowrap; }
.ph-bar { position: relative; height: 14px; background: #f3e1e9; border-radius: 7px; margin: 3px 0; overflow: hidden; }
.ph-bar div { height: 100%; background: linear-gradient(90deg, #ffb3cf, var(--hc)); border-radius: 7px; }
.ph-bar span { position: absolute; right: 6px; top: -1px; font-size: 11px; font-weight: 900; color: #5a2340; }
.ph-meta { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 800; }
.ph-fav { width: 18px; height: 18px; image-rendering: pixelated; }
.tag { background: var(--hc); color: #fff; border-radius: 6px; padding: 0 5px; font-size: 11px; }
.ph-hint { font-size: 11px; color: #8a5a70; line-height: 1.3; margin-top: 2px; }
.ph-sub { font-weight: 900; font-size: 13px; color: #a0446a; }
.ph-irow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.ph-item { display: flex; align-items: center; gap: 2px; background: #fff; border-radius: 10px; padding: 2px 8px 2px 2px; font-weight: 900; font-size: 14px; }
.ph-item img { width: 30px; height: 30px; image-rendering: pixelated; }
.ph-none { font-size: 13px; color: #8a5a70; padding: 6px; }
.ph-btns { display: flex; gap: 10px; justify-content: center; margin-top: 4px; }
.pbtn { min-width: 110px; min-height: 48px; padding: 6px 18px; color: #fff; font-family: inherit; font-weight: 900; font-size: 17px; text-shadow: var(--ol); cursor: pointer; transition: transform .12s, filter .12s; }
.pbtn:hover { filter: brightness(1.1); transform: scale(1.04); }
.pbtn:active { transform: scale(.94); }

/* ---------- title ---------- */
#title { position: absolute; inset: 0; cursor: pointer; overflow: hidden; background: #2a1a3a; }
#titleBg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: kenburns 24s ease-in-out infinite alternate; }
@keyframes kenburns { to { transform: scale(1.06) translateY(-1%); } }
#titleLogo { position: absolute; left: 50%; top: 7%; width: 82%; max-height: 30%; object-fit: contain; transform: translateX(-50%); animation: logoIn .7s cubic-bezier(.3, 1.6, .5, 1) both, logoFloat 4s ease-in-out .7s infinite; filter: drop-shadow(0 4px 0 rgba(60, 10, 40, .4)); }
@keyframes logoIn { from { opacity: 0; transform: translate(-50%, -40px) scale(.6); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes logoFloat { 50% { transform: translate(-50%, -6px); } }
#titlePrompt { position: absolute; left: 0; right: 0; bottom: calc(9% + env(safe-area-inset-bottom)); text-align: center; color: #fff; font-weight: 900; font-size: 22px; line-height: 52px; min-height: 52px; text-shadow: var(--ol); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; transform: scale(.96); } }
#titlePetals { position: absolute; inset: 0; pointer-events: none; }
.petal { position: absolute; top: -20px; width: 8px; height: 6px; background: #ffc4dc; border-radius: 6px 0; animation: fall linear infinite; opacity: .85; }
@keyframes fall { to { transform: translate(-60px, 110vh) rotate(540deg); } }

/* ---------- cutscene ---------- */
#cut { position: absolute; inset: 0; background: #2a1a3a url(assets/cover-bg.webp) center / cover; }
#introVid { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#cutSub { position: absolute; left: 6%; right: 6%; bottom: calc(12% + env(safe-area-inset-bottom)); text-align: center; color: #fff; font-weight: 900; font-size: 18px; line-height: 1.5; text-shadow: var(--ol); }
#skipBtn { position: absolute; right: calc(12px + env(safe-area-inset-right)); top: calc(12px + env(safe-area-inset-top)); min-width: 88px; font-size: 15px; }

/* ---------- ending ---------- */
#ending { position: absolute; inset: 0; background: #1a1030; }
#endImg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: fadeIn 1.2s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: scale(1.05); } to { opacity: 1; transform: none; } }
#endCard { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; background: linear-gradient(transparent 45%, rgba(30, 10, 30, .55)); padding: 20px 20px calc(7% + env(safe-area-inset-bottom)); }
.end-inner { text-align: center; padding: 26px 24px 22px; min-width: 70%; animation: popIn .4s cubic-bezier(.3, 1.6, .5, 1) both; }
#endBig { font-size: 52px; font-weight: 900; color: #fff; text-shadow: var(--ol); letter-spacing: 6px; }
#endTitle { font-size: 22px; font-weight: 900; color: #e0507f; margin-top: 4px; }
#endSub { font-size: 14px; font-weight: 800; color: #6a3a52; margin: 6px 0 16px; line-height: 1.4; }

#fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .4s; }
#fade.on { opacity: 1; pointer-events: auto; }
