:root {
  --rose: #ff4d7d;
  --rose2: #ff8fab;
  --gold: #f5c97b;
  --wine: #2a0f1f;
  --text: #fff4f7;
  --muted: #f3c4d2;
  --glass: rgba(42, 12, 30, 0.55);
  --line: rgba(255, 200, 220, 0.25);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1c0a15; color: var(--text); font-family: 'Poppins', system-ui, sans-serif; overscroll-behavior: none; }
body { touch-action: none; user-select: none; -webkit-user-select: none; }
[hidden] { display: none !important; }
.script { font-family: 'Great Vibes', cursive; font-weight: 400; }
.muted { color: var(--muted); }
button { font: inherit; color: inherit; cursor: pointer; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }

.glass { background: var(--glass); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3); border: 1px solid var(--line); }

.btn { border: 1px solid var(--line); background: rgba(255, 255, 255, 0.08); border-radius: 999px; padding: 10px 18px; transition: .2s; }
.btn.primary { background: linear-gradient(135deg, var(--rose), #c2185b); border-color: transparent; box-shadow: 0 8px 26px rgba(255, 77, 125, .45); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn.big { width: 100%; padding: 14px 20px; font-size: 1.05rem; }

/* ---------- 2D screens ---------- */
.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; z-index: 20; }
#screen-loading, #screen-login { background: radial-gradient(circle at 30% 20%, #6b1640, #2a0f1f 60%, #14060e); }
#screen-loading { z-index: 40; text-align: center; transition: opacity .8s; }
#screen-loading.out { opacity: 0; pointer-events: none; }
#screen-loading p { color: var(--muted); letter-spacing: .03em; }
.pulse-heart { font-size: 4rem; animation: beat 1.3s infinite; display: inline-block; filter: drop-shadow(0 0 20px rgba(255, 77, 125, .7)); }
.pulse-heart.small { font-size: 3rem; }
@keyframes beat { 0%,100% { transform: scale(1) } 15% { transform: scale(1.2) } 30% { transform: scale(1) } 45% { transform: scale(1.12) } }

#bg-hearts { position: fixed; inset: 0; z-index: 21; pointer-events: none; overflow: hidden; }
#bg-hearts span { position: absolute; bottom: -40px; animation: floatUp linear infinite; opacity: .6; }
@keyframes floatUp { to { transform: translateY(-115vh) rotate(25deg); opacity: 0; } }

.login-card { width: 100%; max-width: 380px; padding: 30px 26px; border-radius: 24px; text-align: center; position: relative; z-index: 22; }
.login-card h1 { font-size: 3rem; margin: 4px 0 0; color: var(--rose2); font-weight: 400; }
.login-card p { margin: 0 0 18px; }
.login-card label { display: block; text-align: left; font-size: .85rem; color: var(--muted); margin-bottom: 12px; }
.login-card input { display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, .3); color: #fff; font: inherit; outline: none; user-select: text; -webkit-user-select: text; }
.login-card input:focus { border-color: var(--rose2); box-shadow: 0 0 0 3px rgba(255, 143, 171, .25); }
.err { min-height: 1.3em; color: #ffb3b3; font-size: .9rem; margin: 4px 0 10px; }

/* ---------- avatar selection ---------- */
.screen.select { display: flex; flex-direction: column; justify-content: space-between; align-items: center; pointer-events: none; padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); background: none; }
.select-head { text-align: center; text-shadow: 0 2px 14px rgba(0, 0, 0, .5); }
.couple-names { font-size: clamp(2.4rem, 7vw, 4rem); color: #fff; line-height: 1.1; text-shadow: 0 0 24px rgba(255, 77, 125, .8); }
.select-panel { pointer-events: auto; width: 100%; max-width: 760px; border-radius: 24px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.sel-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; }
.sel-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 6px; }
.sel-row .sel-label { margin: 0; }
.who { display: flex; gap: 8px; }
.who button { border: 1px solid var(--line); background: rgba(255, 255, 255, .06); border-radius: 999px; padding: 8px 16px; }
.who button.on { background: linear-gradient(135deg, var(--rose), #c2185b); border-color: transparent; }
.sel-col { display: flex; flex-direction: column; align-items: center; }
.link-btn { pointer-events: auto; background: none; border: none; color: var(--rose2); text-decoration: underline; font-size: .8rem; margin-top: 4px; padding: 4px; }
.partner-status { text-align: center; font-size: .9rem; color: var(--gold); }
.select-panel { max-width: 560px !important; }
.partner-pill { font-size: .72rem; color: var(--muted); margin-top: 2px; }
.partner-pill.on { color: #ffd6e2; text-shadow: 0 0 10px rgba(255, 77, 125, .8); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; justify-content: center; }
.chips button { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); border-radius: 999px; padding: 5px 11px 5px 6px; font-size: .82rem; }
.chips button i { width: 18px; height: 18px; border-radius: 50%; display: inline-block; border: 2px solid rgba(255, 255, 255, .7); }
.chips button.on { border-color: var(--gold); background: rgba(245, 201, 123, .18); color: #fff; }
.swatches { display: flex; gap: 8px; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); padding: 0; }
.swatches button.on { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245, 201, 123, .35); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud button, #hud .panel { pointer-events: auto; }
.hud-top { position: absolute; top: calc(10px + var(--safe-t)); left: 10px; right: 10px; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.hud-title { border-radius: 16px; padding: 6px 14px 8px; display: flex; flex-direction: column; min-width: 0; max-width: 55vw; }
.hud-title .script { font-size: 1.6rem; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.hud-title .where { font-size: .75rem; color: var(--gold); letter-spacing: .08em; text-transform: uppercase; }
.hud-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.ibtn { width: 44px; height: 44px; border-radius: 50%; font-size: 1.2rem; display: grid; place-items: center; padding: 0; transition: .2s; }
.ibtn.off { opacity: .45; }
.ibtn:active, .abtn:active { transform: scale(.92); }

#path-progress { position: absolute; top: calc(70px + var(--safe-t)); left: 50%; transform: translateX(-50%); width: min(340px, 70vw); border-radius: 99px; padding: 7px 12px; transition: opacity .5s; }
#path-progress.hide { opacity: 0; }
#path-progress .bar { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .15); overflow: hidden; }
#path-progress .fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--rose), var(--gold)); transition: width .4s; }
#path-progress .dots { position: absolute; inset: 0 12px; }
#path-progress .dots span { position: absolute; top: 50%; transform: translate(-50%, -50%); font-size: .8rem; filter: grayscale(1) opacity(.6); transition: .4s; }
#path-progress .dots span.on { filter: none; transform: translate(-50%, -50%) scale(1.3); }

.moment, .banner { position: absolute; left: 50%; top: 22%; transform: translate(-50%, -10px); text-align: center; opacity: 0; transition: opacity 1s, transform 1s; pointer-events: none; width: min(92vw, 720px); text-shadow: 0 2px 20px rgba(0, 0, 0, .65), 0 0 30px rgba(255, 77, 125, .5); }
.moment.show, .banner.show { opacity: 1; transform: translate(-50%, 0); }
.m-title, .b-small { font-size: .8rem; letter-spacing: .3em; text-transform: uppercase; color: var(--gold); }
.m-text { font-size: clamp(1.9rem, 5.5vw, 3.2rem); line-height: 1.15; color: #fff; margin-top: 4px; }
.b-name { font-size: clamp(2.6rem, 8vw, 4.6rem); color: #fff; line-height: 1.1; }
.b-sub { color: var(--muted); font-size: 1rem; }

#prompt { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(150px + var(--safe-b)); display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; width: 90vw; pointer-events: none; }
#prompt button { pointer-events: auto; border-radius: 999px; padding: 11px 20px; border: 1px solid rgba(255, 220, 230, .5); background: linear-gradient(135deg, rgba(255, 77, 125, .92), rgba(194, 24, 91, .92)); box-shadow: 0 8px 24px rgba(0, 0, 0, .35); font-weight: 500; animation: pop .35s; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }

.hud-bottom { position: absolute; left: 0; right: 0; bottom: calc(14px + var(--safe-b)); padding: 0 14px; display: flex; justify-content: space-between; align-items: flex-end; }
#joystick { width: 130px; height: 130px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .12), rgba(255, 255, 255, .04)); border: 2px solid rgba(255, 220, 230, .35); position: relative; pointer-events: auto; touch-action: none; display: none; backdrop-filter: blur(6px); }
#joystick .knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffb3c8, var(--rose)); box-shadow: 0 4px 18px rgba(255, 77, 125, .6); display: grid; place-items: center; }
#joystick .knob::after { content: '♥'; color: #fff; font-size: 1.3rem; }
body.touch #joystick { display: block; }
.actions { display: flex; gap: 8px; margin-left: auto; }
.abtn { border-radius: 18px; min-width: 62px; height: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 1.4rem; padding: 4px 10px; transition: .2s; }
.abtn span { font-size: .65rem; letter-spacing: .03em; color: var(--muted); }
.abtn.on { background: linear-gradient(135deg, var(--rose), #c2185b); }
.abtn.on span { color: #fff; }

.panel { position: absolute; right: 10px; top: calc(64px + var(--safe-t)); width: min(360px, calc(100vw - 20px)); max-height: calc(100vh - 100px - var(--safe-t) - var(--safe-b)); overflow: auto; border-radius: 20px; padding: 14px 16px; animation: pop .25s; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel h3 { margin: 0; font-family: 'Playfair Display', serif; }
.panel .x { background: none; border: none; font-size: 1.1rem; padding: 6px; }
.place { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.place:last-child { border-bottom: 0; }
.place .ic { font-size: 1.4rem; }
.place .nm { flex: 1; min-width: 0; font-size: .92rem; }
.place .nm small { display: block; color: var(--muted); font-size: .72rem; }
.place button { border: 1px solid var(--line); background: rgba(255, 255, 255, .08); border-radius: 999px; padding: 6px 10px; font-size: .78rem; }
.help { padding-left: 18px; margin: 10px 0 0; font-size: .9rem; line-height: 1.6; }
.help b { color: var(--gold); font-weight: 500; }

/* ---------- lightbox ---------- */
#lightbox { position: fixed; inset: 0; z-index: 30; background: rgba(15, 4, 10, .92); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; animation: fadeIn .3s; }
@keyframes fadeIn { from { opacity: 0 } }
.lb-media { max-width: 92vw; max-height: 78vh; display: grid; place-items: center; }
.lb-media img, .lb-media video { max-width: 92vw; max-height: 78vh; border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6), 0 0 0 6px rgba(224, 178, 90, .8); background: #000; }
.lb-close { position: absolute; top: calc(14px + var(--safe-t)); right: 14px; width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255, 255, 255, .1); font-size: 1.2rem; z-index: 2; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 64px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .08); font-size: 2rem; z-index: 2; }
.lb-nav.prev { left: 10px; } .lb-nav.next { right: 10px; }
.lb-info { position: absolute; bottom: calc(16px + var(--safe-b)); left: 0; right: 0; text-align: center; padding: 0 20px; }
.lb-cap { font-size: clamp(1.6rem, 5vw, 2.4rem); color: #fff; }
.lb-count { color: var(--muted); font-size: .8rem; }

/* ---------- intro / fade / toast ---------- */
.intro-card { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; z-index: 15; opacity: 0; pointer-events: none; transition: opacity 1.4s; width: min(92vw, 800px); text-shadow: 0 2px 24px rgba(0, 0, 0, .7), 0 0 40px rgba(255, 77, 125, .5); }
.intro-card.show { opacity: 1; }
.i-small { letter-spacing: .3em; text-transform: uppercase; font-size: .85rem; color: var(--gold); }
.i-names { font-size: clamp(3rem, 11vw, 6rem); line-height: 1.1; color: #fff; }
.i-msg { font-size: 1.05rem; color: #ffe3ea; margin-top: 6px; }
.i-skip { margin-top: 26px; font-size: .75rem; color: rgba(255, 255, 255, .6); }
#fade { position: fixed; inset: 0; background: #ffe3ec; z-index: 25; opacity: 0; pointer-events: none; transition: opacity .6s; }
#fade.on { opacity: 1; }
#toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%); z-index: 35; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
#toast div { background: rgba(42, 12, 30, .9); border: 1px solid var(--line); padding: 9px 18px; border-radius: 999px; animation: pop .3s; font-size: .9rem; text-align: center; max-width: 90vw; }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .select-panel { padding: 14px; gap: 10px; border-radius: 20px; }
  .chips button { font-size: .75rem; padding: 4px 9px 4px 5px; }
  .hud-title .script { font-size: 1.3rem; }
  .ibtn { width: 40px; height: 40px; font-size: 1.05rem; }
  .abtn { min-width: 56px; height: 56px; font-size: 1.2rem; }
  .abtn span { font-size: .58rem; }
  #path-progress { top: calc(64px + var(--safe-t)); }
  #prompt { bottom: calc(160px + var(--safe-b)); }
  .lb-nav { width: 40px; height: 54px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .screen.select { flex-direction: row; align-items: flex-end; }
  .select-head { align-self: flex-start; text-align: left; }
  .select-panel { max-width: 420px; max-height: calc(100vh - 24px); overflow: auto; }
  #joystick { width: 110px; height: 110px; }
  #prompt { bottom: calc(24px + var(--safe-b)); }
  #path-progress { display: none; }
}
