*{box-sizing:border-box} :root{--bg:#071820;--panel:#102832;--gold:#e5c58b;--cream:#f3e8d2;--muted:#a9b8b6;--line:rgba(229,197,139,.22)} body{margin:0;background:radial-gradient(ellipse at 50% 0%,#173541 0,#091e27 48%,#06151d 100%);color:var(--cream);font-family:'Kanit',sans-serif;font-weight:300;min-height:100vh;overflow-x:hidden}button,textarea{font:inherit}.ambient{position:fixed;border-radius:50%;filter:blur(90px);opacity:.13;pointer-events:none}.ambient-one{width:360px;height:360px;background:#c99b58;top:20%;left:-220px}.ambient-two{width:300px;height:300px;background:#2b8a83;right:-200px;bottom:0}.topbar{height:76px;padding:0 clamp(20px,6vw,90px);display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid rgba(255,255,255,.07);position:relative;z-index:2}.brand{color:var(--cream);text-decoration:none;font-size:13px;letter-spacing:2px}.brand b{color:var(--gold);font-weight:500}.brand-mark{color:var(--gold);font-size:23px;margin-right:10px}.edition,.microcopy,.preview-caption{font-size:10px;letter-spacing:2px;color:var(--muted)}main{max-width:1180px;margin:auto;padding:30px clamp(18px,5vw,64px) 70px;min-height:calc(100vh - 130px)}.screen{display:none;animation:fade .6s ease}.screen.active{display:block}@keyframes fade{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}.eyebrow{font-size:10px;letter-spacing:2.5px;color:var(--gold);font-weight:500}.hero-copy{text-align:center;padding:62px 0 20px;position:relative;z-index:1}.hero-copy h1{font-family:'Itim',cursive;font-size:clamp(64px,10vw,112px);line-height:.83;font-weight:400;margin:24px 0;color:#f6e8ce;text-shadow:0 5px 35px #d3a45b35}.hero-copy h1 em{color:var(--gold);font-style:normal}.lead{font-size:15px;line-height:2;color:#c1ceca;margin:28px 0 30px}.btn{border:1px solid var(--line);padding:13px 22px;border-radius:4px;cursor:pointer;transition:.25s;letter-spacing:.3px}.btn-primary{background:linear-gradient(120deg,#d5b47b,#a77e49);color:#17252a;border:0;font-weight:500;box-shadow:0 8px 30px #bd955333}.btn-primary:hover{transform:translateY(-2px);filter:brightness(1.08)}.btn span{margin-left:15px}.btn-ghost{background:transparent;color:var(--cream)}.full{width:100%;margin-top:24px}.hero-scene{height:240px;max-width:820px;margin:10px auto 0;position:relative;overflow:hidden}.moon{position:absolute;top:12px;left:50%;width:68px;height:68px;transform:translateX(-50%);border-radius:50%;background:#f2dfb7;box-shadow:0 0 45px 20px #dfc38c38}.moon-glow{position:absolute;top:0;left:50%;width:220px;height:150px;transform:translateX(-50%);background:radial-gradient(ellipse,#e9d09b22,transparent 70%)}.hero-water{position:absolute;bottom:0;left:0;right:0;height:115px;background:linear-gradient(180deg,#173f46,#0b2832);border-radius:50% 50% 0 0/22% 22% 0 0}.water-shimmer{position:absolute;left:25%;right:25%;top:12px;height:80px;background:repeating-linear-gradient(180deg,transparent 0 8px,#d6b77a22 9px 10px,transparent 11px 18px);filter:blur(2px)}.hero-krathong{position:absolute;bottom:55px;left:50%;transform:translateX(-50%);width:100px;height:35px;border-radius:50%;background:radial-gradient(ellipse,#d9b36c 0 28%,#527d63 30% 60%,#173d36 62%);box-shadow:0 0 25px #e8bd6b55}.flame,.mini-flame{position:absolute;left:50%;top:-17px;width:8px;height:15px;background:#ffe6a1;border-radius:100% 0 100% 0;transform:translateX(-50%) rotate(45deg);box-shadow:0 0 15px #ffd477}.petals{position:absolute;left:43px;top:-10px;color:#f1d7a4}.firefly{position:absolute;color:var(--gold);animation:twinkle 3s infinite alternate}.f1{top:75px;left:20%}.f2{top:125px;right:20%;animation-delay:1s}.f3{top:35px;right:30%;animation-delay:2s}@keyframes twinkle{to{opacity:.2;transform:scale(.7)}}.section-heading,.river-heading{text-align:center;margin:35px 0 38px}.section-heading h2,.river-heading h2{font-family:'Itim',cursive;font-size:clamp(34px,5vw,48px);font-weight:400;margin:10px 0}.section-heading>p:last-child,.river-heading>p:last-child{color:var(--muted);font-size:13px}.builder-layout{display:grid;grid-template-columns:1fr 1fr;gap:45px;align-items:center;max-width:920px;margin:auto}.preview-wrap{text-align:center}.preview-water{height:340px;border-radius:10px;background:radial-gradient(ellipse at center,#39717a,#17434b 50%,#0b2934 78%);display:grid;place-items:center;position:relative;overflow:hidden}.preview-water:after{content:"";position:absolute;inset:0;background:repeating-linear-gradient(170deg,transparent 0 25px,#d4c08a0c 26px 28px)}.krathong-preview{width:220px;height:120px;position:relative;filter:drop-shadow(0 15px 18px #06121799);z-index:1}.krathong-preview .base{position:absolute;inset:30px 8px 8px;border-radius:50%;background:radial-gradient(ellipse,#c6a15d 0 20%,#668b62 22% 55%,#285b48 58% 72%,#123b36 75%);border:5px solid #6d986d;box-shadow:inset 0 0 0 5px #d0b16e}.style-leaf .base{background:radial-gradient(ellipse,#b9a16b 0 20%,#547d4d 22% 70%,#244a36 72%);border-radius:45% 45% 50% 50%}.style-royal .base{border:8px double #dfbd79;box-shadow:inset 0 0 0 5px #527d5a}.flower{position:absolute;z-index:2;color:#f2d5aa;font-size:38px;text-shadow:0 2px 5px #16342c}.flower-a{left:88px;top:8px}.flower-b{left:48px;top:38px;font-size:29px}.flower-c{right:43px;top:40px;font-size:29px}.candle{position:absolute;z-index:3;left:105px;top:0;width:9px;height:42px;background:#f0dfb9;border-radius:4px}.candle i{position:absolute;top:-11px;left:1px;width:7px;height:12px;background:#ffe39a;border-radius:100% 0;transform:rotate(45deg);box-shadow:0 0 15px #ffd77a}.preview-caption{display:block;margin-top:14px}.builder-controls h3{font-size:15px;font-weight:400;margin:0 0 15px}.choice-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:9px}.choice,.flower-choice{background:#102832;border:1px solid var(--line);border-radius:5px;color:var(--cream);cursor:pointer}.choice{padding:14px 8px;text-align:center}.choice.selected,.flower-choice.selected{border-color:var(--gold);background:#b58e5420}.choice-icon{display:block;font-size:25px;margin-bottom:7px}.choice b{display:block;font-size:12px;font-weight:400}.choice small{display:block;color:var(--muted);font-size:9px;margin-top:4px}.mt{margin-top:26px!important}.flower-options{display:flex;flex-wrap:wrap;gap:8px}.flower-choice{padding:9px 11px;font-size:11px;text-align:left;min-width:calc(50% - 4px)}.flower-choice span{margin-right:4px}.flower-choice small{display:block;color:var(--muted);font-size:9px;margin:5px 0 0 23px;line-height:1.35}.notes-grid{display:grid;grid-template-columns:1fr 1fr;gap:22px;max-width:850px;margin:auto}.note{min-height:300px;padding:25px;background:#f1e4c8;color:#4e4639;display:flex;flex-direction:column;box-shadow:0 12px 35px #0003;transform:rotate(-1deg);position:relative}.note-release{background:#e9dfcf;transform:rotate(1deg)}.note-symbol{font-size:22px;color:#9b7947}.note-title{font-family:'Itim',cursive;font-size:24px;margin-top:10px}.note-hint{font-size:10px;letter-spacing:1px;color:#897c68}.note textarea{flex:1;resize:vertical;min-height:130px;border:0;outline:0;background:transparent;color:#4e4639;font-family:'Itim',cursive;font-size:17px;line-height:1.7;margin-top:14px}.note textarea::placeholder{color:#a79b88}.counter{text-align:right;font-size:10px;color:#958872}.privacy-note{text-align:center;color:var(--muted);font-size:11px;margin:25px}.button-row{display:flex;justify-content:center;gap:12px}.river-heading{margin-bottom:20px}.river-stage{height:390px;max-width:950px;margin:auto;position:relative;overflow:hidden;border-radius:8px;background:linear-gradient(180deg,#0b2734,#123d49 55%,#0a2732);box-shadow:inset 0 0 80px #020d15}.river-moon{position:absolute;top:25px;left:50%;width:58px;height:58px;border-radius:50%;background:#f4dfb4;box-shadow:0 0 45px 18px #e8c98744}.river-surface{position:absolute;inset:45% -20% -20%;background:repeating-linear-gradient(175deg,transparent 0 18px,#a5c4b51a 19px 21px,transparent 22px 37px);animation:watermove 8s linear infinite}@keyframes watermove{to{background-position:0 90px}}.river-bank{position:absolute;top:35%;height:70%;width:25%;background:linear-gradient(90deg,#081b20,#16352d);filter:blur(4px)}.bank-left{left:-8%;transform:rotate(8deg)}.bank-right{right:-8%;transform:rotate(-8deg)}.floating-krathong{position:absolute;left:50%;top:62%;width:85px;height:36px;transform:translate(-50%,-50%);border-radius:50%;background:radial-gradient(ellipse,#e4c17b 0 20%,#7a9b66 24% 58%,#275440 62%);border:3px solid #c2a36a;box-shadow:0 0 25px #e5c27a66;z-index:3}.mini-flame{top:-10px}.mini-flower{position:absolute;left:35px;top:-12px;color:#f5d5a1}.mini-note{position:absolute;right:9px;top:5px;color:#fff0c7;font-size:10px}.user-krathong.released{animation:floataway 9s ease-in forwards}@keyframes floataway{0%{left:50%;top:62%;transform:translate(-50%,-50%) scale(1)}35%{left:57%;top:55%;transform:translate(-50%,-50%) scale(.85) rotate(4deg)}70%{left:42%;top:38%;transform:translate(-50%,-50%) scale(.5) rotate(-5deg);opacity:.8}100%{left:60%;top:18%;transform:translate(-50%,-50%) scale(.12);opacity:0}}.community-lights span{position:absolute;width:22px;height:10px;border-radius:50%;background:#d7b776;box-shadow:0 0 16px #ffd88a;opacity:.7;animation:bob 4s ease-in-out infinite alternate}@keyframes bob{to{transform:translate(12px,-8px)}}.river-stars{position:absolute;top:15%;left:10%;right:10%;color:#e9d39e;opacity:.6;letter-spacing:15px}.river-actions{text-align:center;margin:24px}.river-actions .microcopy{letter-spacing:.5px}.tarot-result{display:grid;grid-template-columns:260px 1fr;gap:55px;align-items:center;max-width:790px;margin:35px auto}.tarot-card{height:390px;perspective:1000px;position:relative}.card-back,.card-front{position:absolute;inset:0;border:1px solid #d5b77d;border-radius:8px;display:flex;flex-direction:column;align-items:center;justify-content:center;backface-visibility:hidden;transition:transform 1s;background:linear-gradient(145deg,#173b42,#091b25);box-shadow:0 15px 40px #0005}.card-back{color:var(--gold);font-size:70px}.card-back small{font-size:9px;letter-spacing:3px}.card-front{transform:rotateY(180deg);background:linear-gradient(145deg,#f0dfbd,#d4bd91);color:#33423b;padding:20px}.tarot-card.flipped .card-back{transform:rotateY(180deg)}.tarot-card.flipped .card-front{transform:rotateY(0)}.card-art{font-size:105px;color:#a67e43}.card-name{font-family:'Itim',cursive;font-size:25px;margin-top:25px}.card-subtitle{font-size:8px;letter-spacing:2px}.tarot-copy h3{font-family:'Itim',cursive;font-size:32px;font-weight:400;margin:8px 0}.tarot-copy>p:not(.eyebrow){font-size:14px;line-height:2;color:#c5d0ca}.advice-box{border-left:2px solid var(--gold);padding:10px 16px;margin:22px 0;background:#ffffff08}.advice-box b{font-size:12px;color:var(--gold);font-weight:400}.advice-box p{font-size:13px;line-height:1.8;margin:6px 0}.text-button{display:block;background:none;border:0;color:var(--muted);text-decoration:underline;margin:17px auto;cursor:pointer}footer{border-top:1px solid #ffffff12;padding:20px clamp(20px,6vw,90px);display:flex;justify-content:space-between;color:#82938f;font-size:9px;letter-spacing:1.5px} @media(max-width:700px){.edition{font-size:8px}.hero-copy{padding-top:50px}.hero-scene{height:190px}.builder-layout{grid-template-columns:1fr;gap:25px}.preview-water{height:260px}.builder-controls{max-width:500px;width:100%;margin:auto}.notes-grid{grid-template-columns:1fr;gap:18px}.note{min-height:250px}.tarot-result{grid-template-columns:1fr;gap:25px;max-width:420px}.tarot-card{height:340px;width:225px;margin:auto}.tarot-copy{text-align:center}.advice-box{text-align:left}.river-stage{height:330px}.button-row{flex-wrap:wrap}.button-row .btn{flex:1}.section-heading{margin-top:25px}footer{font-size:8px}}
/* Phase 2: more dimensional krathong, water and iOS memory export */
.hero-scene{height:310px;max-width:1000px}
.hero-water{height:165px;background:
 radial-gradient(ellipse at 50% 8%,rgba(232,195,123,.22),transparent 45%),
 repeating-linear-gradient(177deg,transparent 0 13px,rgba(195,218,203,.09) 14px 16px,transparent 17px 29px),
 linear-gradient(180deg,#1c5960 0%,#103a46 35%,#081e2a 100%);border-radius:48% 48% 0 0/18% 18% 0 0}
.water-shimmer{background:repeating-linear-gradient(180deg,transparent 0 7px,rgba(246,215,158,.25) 8px 9px,transparent 10px 19px);filter:blur(2px)}
.hero-krathong{width:175px;height:100px;bottom:38px;background:none;border:0;box-shadow:none;border-radius:0}
.hero-krathong:before{display:none}
.hero-krathong .flame{z-index:2;top:5px}
.hero-krathong .petals{display:none}
.preview-water{background:
 radial-gradient(ellipse at 50% 46%,rgba(221,180,108,.2),transparent 43%),
 repeating-linear-gradient(175deg,transparent 0 19px,rgba(198,221,205,.1) 20px 22px,transparent 23px 39px),
 linear-gradient(155deg,#245e63,#143f4b 52%,#092630);box-shadow:inset 0 0 65px #06161c}
.krathong-preview{width:min(100%,420px);height:245px;filter:drop-shadow(0 24px 22px #020b0c99);animation:krathongFloat 4.8s ease-in-out infinite}
.krathong-photo{width:100%;height:100%;object-fit:contain;display:block}
.preview-flower{position:absolute;left:50%;top:42%;transform:translate(-50%,-50%);font-size:32px;filter:drop-shadow(0 2px 4px #1a1711)}
.krathong-photo[data-flower="marigold"]{filter:hue-rotate(24deg) saturate(1.12)}
.krathong-photo[data-flower="jasmine"]{filter:brightness(1.08) saturate(.78)}
.krathong-photo[data-flower="orchid"]{filter:hue-rotate(48deg) saturate(1.35)}
.krathong-photo[data-flower="rose"]{filter:hue-rotate(-24deg) saturate(1.25)}
@keyframes krathongFloat{0%,100%{transform:translateY(0) rotate(-1deg)}50%{transform:translateY(-9px) rotate(1deg)}}
.river-stage{background:
 radial-gradient(ellipse at 50% 18%,rgba(246,213,153,.17),transparent 23%),
 linear-gradient(180deg,rgba(5,18,26,.1),rgba(5,18,26,.5)),
 repeating-linear-gradient(177deg,transparent 0 17px,rgba(195,220,213,.1) 18px 20px,transparent 21px 38px),
 linear-gradient(180deg,#0b2935 0%,#1b5660 42%,#0c3441 70%,#071e2a 100%)}
.river-stage:before{content:"";position:absolute;left:0;right:0;top:25%;height:35%;background:
 radial-gradient(ellipse at 50% 75%,rgba(231,184,104,.28),transparent 36%),
 linear-gradient(180deg,transparent,#d3b77d14 55%,transparent);filter:blur(8px)}
.river-moon{box-shadow:0 0 50px 22px rgba(232,205,151,.27)}
.river-bank{z-index:1;background:linear-gradient(90deg,#06171c,#123a34 60%,#1d493b);opacity:.9}
.floating-krathong{width:160px;height:95px;background:none;border:0;border-radius:0;box-shadow:none;z-index:4;filter:drop-shadow(0 12px 14px #020b0c99)}
.river-krathong-art{width:100%;height:100%;object-fit:contain;display:block}
.user-krathong.released{animation:floataway 9s cubic-bezier(.3,.05,.7,.95) forwards}
.community-lights span{width:36px;height:22px;border-radius:50%;background:radial-gradient(ellipse,#ffe6ad 0 7%,#e4b85e 18%,#527b5c 55%,#183e37 78%);border:1px solid #d4b16c;box-shadow:0 0 17px #f3c87988;opacity:.8}
.export-hint{font-size:11px;line-height:1.7;color:#c4c8bd;text-align:center;margin:12px 0 0}
.image-preview-modal{position:fixed;inset:0;z-index:30;background:rgba(2,10,15,.92);display:none;align-items:center;justify-content:center;padding:18px;overflow:auto}
.image-preview-modal.visible{display:flex}
.image-preview-card{position:relative;width:min(100%,460px);max-height:94vh;overflow:auto;background:#102832;border:1px solid #b99661;border-radius:12px;padding:18px;text-align:center;box-shadow:0 20px 70px #0009}
.image-preview-card>p:first-of-type{color:var(--gold);font-size:14px}
.image-preview-card img{display:block;width:100%;height:auto;border-radius:5px;border:1px solid #d2b47b;touch-action:pan-y}
.ios-save-tip{font-size:12px;line-height:1.8;color:#d5d4ca}
.modal-close{position:absolute;right:10px;top:7px;border:0;background:transparent;color:#fff;font-size:28px;cursor:pointer}
@media(max-width:700px){.hero-scene{height:235px}.krathong-preview{height:210px}.floating-krathong{width:125px;height:76px}.image-preview-card{padding:13px}}

.krathong-photo,.river-krathong-art{mix-blend-mode:multiply}
.krathong-photo{object-fit:contain}
.river-krathong-art{object-fit:contain}

/* Phase 2 asset correction: use local transparent PNGs, never remote image fallbacks */
.hero-krathong{width:190px;height:145px;bottom:18px;background:none;border:0;box-shadow:none;}
.hero-krathong:before{display:none}
.hero-krathong-art{width:100%;height:100%;object-fit:contain;display:block;filter:drop-shadow(0 10px 12px #020b0c99);animation:krathongFloat 4.8s ease-in-out infinite}
.krathong-preview{width:min(100%,420px);height:260px;}
.krathong-photo,.river-krathong-art{mix-blend-mode:normal!important;object-fit:contain;}
.krathong-photo{width:100%;height:100%;display:block;filter:drop-shadow(0 12px 14px #07141999)}
.river-krathong-art{width:100%;height:100%;display:block;filter:drop-shadow(0 9px 12px #020b0c99)}
.floating-krathong{width:175px;height:145px;}
@media(max-width:700px){.hero-krathong{width:150px;height:120px}.krathong-preview{height:220px}.floating-krathong{width:135px;height:115px}}

/* Phase 3: composable krathong layers */
.layer-stage{position:relative;isolation:isolate;overflow:visible;background:none;border:0;border-radius:0;box-shadow:none}
.krathong-layer{position:absolute;height:auto;object-fit:contain;pointer-events:none;user-select:none;-webkit-user-drag:none}
.layer-base{left:2%;bottom:0;width:96%;z-index:1;filter:drop-shadow(0 10px 9px #020b0c66)}
.layer-flower{z-index:3;max-height:58%;object-fit:contain;filter:drop-shadow(0 3px 4px #07141988)}
.layer-decoration{z-index:4;max-height:25%;object-fit:contain;filter:drop-shadow(0 2px 3px #07141988)}
.layer-candle{z-index:6;height:60%;object-fit:contain;filter:drop-shadow(0 0 9px #ffd67b88)}
.layer-incense{z-index:5;height:55%;object-fit:contain}
.layer-glow{z-index:2;opacity:.65;mix-blend-mode:screen}
#krathongPreview{width:min(100%,440px);height:280px}
#heroKrathong{width:190px;height:145px;bottom:18px}
#floatingKrathong{width:175px;height:145px}
.control-hint{display:block;color:var(--muted);font-size:10px;font-weight:300;margin-top:3px}
.flower-choice{transition:border-color .2s,background .2s,transform .2s}
.flower-choice:active{transform:scale(.96)}
@media(max-width:700px){#krathongPreview{height:230px}#heroKrathong{width:150px;height:120px}#floatingKrathong{width:135px;height:115px}}


/* Phase 3 hotfix: make composited PNG layers reliably visible */
.layer-stage {
  display: block;
  position: relative;
  isolation: isolate;
  overflow: visible;
}
.layer-stage > .krathong-layer {
  display: block !important;
  position: absolute;
  visibility: visible;
  opacity: 1;
  max-width: none;
}
#heroKrathong.layer-stage {
  position: absolute;
}
#floatingKrathong.layer-stage {
  position: absolute;
}
#krathongPreview.layer-stage {
  position: relative;
}
.layer-base {
  left: 2%;
  bottom: 0;
  width: 96%;
  height: auto;
  z-index: 1;
}
.layer-flower {
  height: auto;
  max-height: none;
  z-index: 3;
}
.layer-decoration { height: auto; z-index: 4; }
.layer-candle { height: 60%; width: auto; z-index: 6; }
.layer-incense { height: 55%; width: auto; z-index: 5; }
.layer-glow { height: auto; z-index: 7; pointer-events: none; }
.krathong-layer.layer-load-error { display: none !important; }

/* Phase 4 — Advanced Krathong Studio */
#krathongPreview{touch-action:none;cursor:grab;filter:drop-shadow(0 22px 25px #020b0caa)}
#krathongPreview:active{cursor:grabbing}.krathong-layer{touch-action:none;cursor:grab;transition:filter .16s ease}.krathong-layer.layer-active{filter:drop-shadow(0 0 7px #ffe4a6) drop-shadow(0 0 2px #fff);outline:1px dashed #f4d49b;outline-offset:3px}.krathong-layer.layer-dragging{cursor:grabbing;z-index:30!important;transition:none}
.editor-tip{font-size:11px;color:#d8c49c;margin:12px 0 16px;line-height:1.7}.layer-manager{width:min(100%,420px);margin:12px auto 0;padding:13px 15px;border:1px solid #d7b77a44;border-radius:9px;background:linear-gradient(145deg,#142d34ee,#081b24ee);text-align:left}.layer-manager-title{font-size:13px;color:#f1d7a5;margin-bottom:8px}.layer-manager-title small{display:block;color:#9eaaa4;font-size:10px;margin-top:3px}.layer-row{display:flex;align-items:center;justify-content:space-between;border-top:1px solid #ffffff12;padding:5px 0;gap:8px}.layer-row.active{background:#d7b77a12}.layer-row button,.layer-tune button{border:0;background:transparent;color:#e9dfcb;font:inherit;cursor:pointer}.layer-select{font-size:11px;text-transform:capitalize;text-align:left;flex:1}.layer-eye{font-size:10px;color:#d8b779!important}.layer-tune{border-top:1px solid #ffffff20;margin-top:8px;padding-top:10px;display:grid;grid-template-columns:1fr 1fr;gap:10px}.layer-tune label{font-size:10px;color:#c5c4b7;display:flex;flex-direction:column;gap:5px}.layer-tune input{width:100%;accent-color:#d7b77a}.layer-tune button{grid-column:1/-1;text-align:center;border:1px solid #d7b77a55;border-radius:5px;padding:7px;font-size:10px}.editor-actions{display:flex;justify-content:center;gap:8px;margin-top:10px}.editor-btn{background:#122b33;border:1px solid #d7b77a66;border-radius:5px;padding:8px 14px;color:#e8d4ae;font:inherit;font-size:11px;cursor:pointer}.preview-water{background:radial-gradient(ellipse at 50% 65%,#4b8582 0,#1c555b 44%,#092a36 82%);box-shadow:inset 0 0 65px #04151d}.preview-water:before{content:"";position:absolute;inset:60% -10% -10%;background:repeating-radial-gradient(ellipse at 50% 0,transparent 0 18px,#e6d19a16 19px 21px,transparent 22px 36px);animation:studioRipple 9s linear infinite}@keyframes studioRipple{to{transform:translateY(14px)}}
.krathong-layer[hidden]{display:none!important}
#floatingKrathong:not(.released){animation:gentleFloat 5.2s ease-in-out infinite}
#heroKrathong{animation:gentleFloat 6s ease-in-out infinite}
@keyframes gentleFloat{0%,100%{translate:0 0;rotate:-1deg}50%{translate:0 -7px;rotate:1deg}}

/* Phase 4.1 interaction hotfix */
#krathongPreview>.krathong-layer:not(.layer-base):not(.layer-glow){pointer-events:auto!important;touch-action:none;cursor:grab;user-select:none;-webkit-user-drag:none}
#krathongPreview>.krathong-layer.layer-dragging{cursor:grabbing;z-index:50!important}
#layerManager .layer-row button{min-height:30px}
#layerManager .layer-row.active{outline:1px solid #d7b77a55}

/* Phase 4.2: candle glow is physically anchored to the candle layer */
.krathong-preview .layer-candle { overflow:visible; }
.krathong-preview .candle-aura {
  position:absolute; left:50%; top:1%; width:230%; aspect-ratio:1;
  transform:translate(-50%,-25%); border-radius:50%; pointer-events:none;
  background:radial-gradient(circle,rgba(255,219,133,.72) 0%,rgba(255,177,68,.28) 28%,rgba(255,151,48,.10) 48%,transparent 72%);
  filter:blur(5px); mix-blend-mode:screen; z-index:-1;
  animation:candlePulse 2.4s ease-in-out infinite alternate;
}
@keyframes candlePulse { from{opacity:.65;transform:translate(-50%,-25%) scale(.92)} to{opacity:1;transform:translate(-50%,-25%) scale(1.08)} }
.krathong-preview .layer-candle img { filter: drop-shadow(0 0 5px #ffd77a99) drop-shadow(0 0 11px #ffb84a55); }
.krathong-preview .layer-flower { filter: saturate(1.22) contrast(1.12) brightness(1.03) drop-shadow(0 4px 5px #06141999); }
.krathong-preview .layer-decoration { filter: saturate(1.15) contrast(1.10) drop-shadow(0 3px 4px #061419aa); }
.krathong-preview .layer-base { filter: saturate(1.24) contrast(1.16) brightness(.96) drop-shadow(0 12px 11px #020b0c88); }
.krathong-preview .layer-candle { filter: none; }

/* Photographic finish for existing transparent PNG cut-outs */
.krathong-preview .layer-stage { perspective:900px; }
.krathong-preview .layer-flower,
.krathong-preview .layer-decoration { image-rendering:auto; }
.krathong-preview .layer-flower { filter:saturate(1.28) contrast(1.15) brightness(1.04) drop-shadow(0 5px 6px #020b0ccc); }
.krathong-preview .layer-decoration { filter:saturate(1.2) contrast(1.14) drop-shadow(0 4px 5px #020b0cbb); }
.krathong-preview .layer-base { filter:saturate(1.3) contrast(1.18) brightness(.94) drop-shadow(0 14px 12px #020b0caa); }
.krathong-preview .candle-aura { will-change:transform,opacity; }
.krathong-preview .layer-candle.layer-dragging .candle-aura { animation-play-state:paused; }

/* Phase 4.3 — photographic river atmosphere */
.preview-water {
  background-image: radial-gradient(ellipse at 50% 65%, rgba(79,137,132,.55), rgba(10,39,50,.96));
  background-size: cover;
  background-position: center 56%;
  border: 1px solid rgba(229,197,139,.2);
  box-shadow: inset 0 0 55px rgba(2,10,15,.42), 0 18px 38px rgba(0,0,0,.22);
}
.river-stage {
  background-image: radial-gradient(ellipse at 50% 45%, #1c5260, #071b29 78%);
  background-size: cover;
  background-position: center 58%;
}
.preview-water:after {
  background: linear-gradient(180deg, rgba(6,18,24,.02), rgba(6,18,24,.12)),
    repeating-linear-gradient(170deg, transparent 0 25px, rgba(212,192,138,.07) 26px 28px);
}

/* Phase 4.4 — realistic transparent asset library */
.krathong-preview .layer-flower,
.krathong-preview .layer-decoration {
  image-rendering: auto;
  filter: saturate(1.08) contrast(1.08) drop-shadow(0 5px 6px rgba(0,0,0,.38));
}
.krathong-preview .layer-base {
  image-rendering: auto;
  filter: saturate(1.12) contrast(1.12) drop-shadow(0 14px 12px rgba(0,0,0,.46));
}
.krathong-preview .layer-candle img {
  image-rendering: auto;
}

/* Phase 4.5 — three-depth krathong composition */
.krathong-preview .layer-base-back {
  z-index: 1 !important;
  pointer-events: none !important;
}
.krathong-preview .layer-flower {
  z-index: 10;
}
.krathong-preview .layer-decoration {
  z-index: 16;
}
.krathong-preview .layer-candle {
  z-index: 18 !important;
}
.krathong-preview .layer-incense {
  z-index: 19 !important;
}
.krathong-preview .layer-base-front {
  z-index: 24 !important;
  pointer-events: none !important;
  clip-path: inset(54% 0 0 0);
  filter: saturate(1.3) contrast(1.18) drop-shadow(0 -3px 5px rgba(0,0,0,.28));
}
.krathong-preview .layer-base-front.layer-dragging {
  cursor: default;
}

/* Phase 5.0 — real-time Three.js studio */
.preview-water-3d {
  position: relative;
  overflow: hidden;
  min-height: 430px;
  background:
    radial-gradient(ellipse at 50% 32%, rgba(40,91,102,.55), transparent 54%),
    linear-gradient(180deg, #071923 0%, #0c303b 58%, #061820 100%);
  border: 1px solid rgba(220,190,130,.25);
  box-shadow: inset 0 0 70px rgba(0,0,0,.38), 0 18px 42px rgba(0,0,0,.28);
}
.krathong-3d-stage { position:relative; width:100%; height:430px; min-height:430px; }
.krathong-3d-stage canvas { display:block; width:100%; height:100%; touch-action:none; outline:none; }
.three-hud {
  position:absolute; left:14px; right:14px; bottom:12px;
  display:flex; justify-content:space-between; gap:8px; pointer-events:none;
  color:rgba(245,226,190,.78); font-size:10px; letter-spacing:.12em;
  text-shadow:0 1px 5px #000;
}
.three-hud span:first-child { color:#e5c68e; font-weight:700; }
.three-loading {
  position:absolute; inset:0; display:grid; place-items:center;
  color:#e8d3ad; font-size:13px; z-index:2;
}
.three-controls { display:flex; gap:8px; flex-wrap:wrap; margin-top:12px; }
.three-status { margin-top:8px; color:#b9a98b; font-size:12px; min-height:18px; }
.preview-wrap-3d .editor-tip { color:#c9bda8; }
@media(max-width:640px) {
  .preview-water-3d,.krathong-3d-stage { min-height:340px; height:340px; }
  .three-hud { font-size:9px; }
}

/* Phase 5.2: live Three.js river scene and 3D placement canvas */
.krathong-3d-stage canvas{display:block;width:100%;height:100%;touch-action:none;cursor:crosshair}
.krathong-3d-stage{position:relative;isolation:isolate}
.river-stage{background:#071b2a!important}
.river-3d-stage{position:absolute;inset:0;z-index:1;width:100%;height:100%;overflow:hidden}
.river-3d-stage canvas{display:block;width:100%;height:100%}
#floatingKrathong{display:none!important}
.river-moon,.river-bank,.river-surface,.community-lights,.river-stars{pointer-events:none;z-index:2}
.river-3d-stage canvas{position:relative;z-index:1}
.river-3d-stage.released{animation:riverCanvasFade 10s ease-in forwards}
@keyframes riverCanvasFade{0%{opacity:1}85%{opacity:.9}100%{opacity:.72}}

/* Phase 5.3 editor controls */
.three-controls .editor-btn:disabled{opacity:.38;cursor:not-allowed;filter:saturate(.4)}
.three-controls .editor-btn:not(:disabled):hover{border-color:rgba(255,220,150,.65);color:#ffe4a8}


/* Phase 5.3.1: ensure decorative water overlays never intercept 3D pointer input */
.preview-water-3d::before,
.preview-water-3d::after { pointer-events: none !important; }
.preview-water-3d .krathong-3d-stage,
.preview-water-3d .krathong-3d-stage canvas { position: relative; z-index: 1; pointer-events: auto; }
.preview-water-3d .three-loading,
.preview-water-3d .three-hud { pointer-events: none !important; }

/* Phase 5.6 — mobile-first 3D editor controls */
.object-scale-control{width:min(100%,460px);margin:12px auto;padding:12px 14px;border:1px solid rgba(215,183,122,.28);border-radius:12px;background:rgba(8,27,36,.82);text-align:left}
.object-scale-control label{display:flex;justify-content:space-between;align-items:center;color:#ead8b5;font-size:12px;margin-bottom:8px;gap:12px}
.object-scale-control strong{font-variant-numeric:tabular-nums;color:#f6d58f}
.object-scale-control input{width:100%;accent-color:#d7b77a;min-height:32px;touch-action:pan-x}
.object-scale-control input:disabled{opacity:.38}
.krathong-3d-stage canvas,.river-3d-stage canvas{display:block;width:100%;height:100%;touch-action:pan-y}
@media(max-width:700px){
 .builder-layout{display:flex;flex-direction:column;gap:18px}
 .preview-wrap-3d{width:100%;min-width:0}
 .preview-water-3d{height:min(62svh,480px);min-height:340px;border-radius:16px;overflow:hidden}
 .krathong-3d-stage{height:100%;min-height:340px}
 .three-hud{font-size:9px;padding:7px 9px;gap:8px}
 .three-controls{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
 .three-controls .editor-btn{min-height:44px;padding:9px 7px;font-size:12px;touch-action:manipulation}
 .object-scale-control{margin:10px 0;width:100%}
 .builder-controls{width:100%;padding:0 2px}
 .choice-grid,.flower-options{gap:8px}
 .flower-choice,.choice{min-height:44px;touch-action:manipulation}
 .editor-tip{font-size:12px;line-height:1.65}
 .river-stage{height:68svh;min-height:440px}
}

/* Procedural hero krathong illustration — no raster artwork required */
#heroKrathong{background:radial-gradient(ellipse at 50% 72%,rgba(247,210,140,.18),transparent 65%)}
#heroKrathong:after{content:"🪷";position:absolute;left:50%;top:30%;transform:translate(-50%,-50%);font-size:68px;filter:drop-shadow(0 5px 12px rgba(0,0,0,.45));opacity:.92}



/* Phase 5.7.1: floating contextual delete action, shown only for a selected object */
.three-floating-delete[hidden] { display: none !important; }
.three-floating-delete {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 12px) scale(.96);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 999px;
  color: #fff;
  background: rgba(153, 42, 54, .94);
  box-shadow: 0 8px 24px rgba(0,0,0,.32);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease, background .18s ease;
}
.three-floating-delete.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0) scale(1);
}
.three-floating-delete span { font-size: 18px; }
@media (max-width:640px) {
  .three-floating-delete { bottom: 14px; min-height: 48px; padding: 0 22px; }
}

/* Phase 5.22: remove legacy CSS river overlays; keep hidden hooks for app.js compatibility */
#riverStage .legacy-river-hooks{display:none!important}
#riverStage>.river-moon,
#riverStage>.river-bank,
#riverStage>.river-surface,
#riverStage>.river-stars{display:none!important}

/* Phase 5.24: river camera view controls */
.river-view-controls{display:flex;justify-content:center;gap:10px;flex-wrap:wrap;margin:12px auto 4px}
.river-view-controls .btn{font-size:13px;padding:10px 16px}



/* Version 5.3.30 — Mobile studio: persistent preview + scrollable decoration tray */
@media (max-width: 700px) {
  body:has(#screen-builder.active) {
    overflow: hidden;
  }
  main:has(#screen-builder.active) {
    height: calc(100dvh - 76px);
    min-height: 0;
    padding: 0 12px env(safe-area-inset-bottom);
    overflow: hidden;
  }
  #screen-builder.active {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: none;
  }
  #screen-builder > .section-heading {
    flex: 0 0 auto;
    margin: 7px 0 8px;
  }
  #screen-builder > .section-heading .eyebrow {
    margin: 0 0 2px;
    font-size: 8px;
  }
  #screen-builder > .section-heading h2 {
    font-size: 25px;
    line-height: 1.05;
    margin: 0;
  }
  #screen-builder > .section-heading > p:last-child {
    display: none;
  }
  #screen-builder .builder-layout {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0;
    max-width: none;
    margin: 0;
    overflow: hidden;
  }
  #screen-builder .preview-wrap-3d {
    grid-row: 1;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow: hidden;
    padding-bottom: 5px;
    background: linear-gradient(180deg, rgba(7,24,32,.98), rgba(7,24,32,.88));
    z-index: 3;
  }
  #screen-builder .preview-water-3d {
    flex: 0 0 auto;
    width: min(100%, 46dvh, 100vw);
    aspect-ratio: 1 / 1;
    height: auto;
    min-height: 0;
    max-height: none;
    margin-inline: auto;
    border-radius: 13px;
    position: relative;
  }
  #screen-builder .krathong-3d-stage {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
  }
  #screen-builder .preview-caption,
  #screen-builder .editor-tip {
    display: none;
  }
  #screen-builder .three-hud {
    left: 8px;
    right: 8px;
    bottom: 7px;
    font-size: 8px;
  }
  #screen-builder .three-floating-delete {
    bottom: 8px;
    min-height: 38px;
    font-size: 11px;
    padding: 0 14px;
  }
  #screen-builder .three-controls {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin: 7px 0 0;
  }
  #screen-builder .three-controls .editor-btn {
    min-width: 0;
    min-height: 36px;
    padding: 6px 4px;
    font-size: 10px;
    line-height: 1.25;
    white-space: normal;
  }
  #screen-builder .object-scale-control {
    flex: 0 0 auto;
    margin: 6px 0 0;
    padding: 7px 10px;
    width: 100%;
  }
  #screen-builder .object-scale-control label {
    font-size: 10px;
    margin-bottom: 3px;
  }
  #screen-builder .object-scale-control input {
    min-height: 22px;
  }
  #screen-builder .three-status {
    flex: 0 0 auto;
    min-height: 14px;
    margin-top: 3px;
    font-size: 10px;
  }
  #screen-builder .builder-controls {
    grid-row: 2;
    min-height: 0;
    height: 100%;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 12px 2px calc(14px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    border-top: 1px solid rgba(229,197,139,.22);
  }
  #screen-builder .builder-controls h3 {
    font-size: 13px;
    margin: 0 0 9px;
  }
  #screen-builder .builder-controls h3.mt {
    margin-top: 15px !important;
  }
  #screen-builder .choice-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  #screen-builder .choice {
    min-width: 0;
    min-height: 68px;
    padding: 7px 4px;
  }
  #screen-builder .choice-icon {
    font-size: 20px;
    margin-bottom: 3px;
  }
  #screen-builder .choice b {
    font-size: 10px;
  }
  #screen-builder .choice small {
    display: none;
  }
  #screen-builder .flower-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  #screen-builder .flower-choice {
    min-width: 0;
    min-height: 42px;
    padding: 7px 9px;
    font-size: 11px;
    line-height: 1.25;
  }
  #screen-builder .flower-choice small {
    display: none;
  }
  #screen-builder .control-hint {
    font-size: 10px;
    line-height: 1.45;
    margin-top: 7px;
  }
  #screen-builder .builder-controls > .btn[data-go="wishes"] {
    position: sticky;
    bottom: -1px;
    z-index: 5;
    margin: 12px 0 0;
    min-height: 44px;
    box-shadow: 0 -8px 18px rgba(7,24,32,.75);
  }
}

@media (max-width: 380px) {
  #screen-builder .builder-layout {
    grid-template-rows: minmax(175px, 40dvh) minmax(0, 1fr);
  }
  #screen-builder .three-controls .editor-btn {
    font-size: 9px;
  }
}


/* Version 5.3.35 — larger wish slips and square 3D builder preview */
.preview-wrap-3d .preview-water-3d {
  width: min(100%, 500px);
  aspect-ratio: 1 / 1;
  height: auto;
  min-height: 0;
  margin-inline: auto;
}
.preview-wrap-3d .krathong-3d-stage {
  width: 100%;
  height: 100%;
  min-height: 0;
}
@media (max-width: 900px) {
  .preview-wrap-3d .preview-water-3d,
  .preview-wrap-3d .krathong-3d-stage {
    min-height: 0;
    height: auto;
  }
  .preview-wrap-3d .preview-water-3d {
    width: min(100%, 43dvh, 100vw);
    aspect-ratio: 1 / 1;
    flex: 0 0 auto;
  }
  .preview-wrap-3d .krathong-3d-stage {
    position: absolute;
    inset: 0;
    height: 100%;
  }
}
@media (max-width: 700px) {
  .preview-wrap-3d .preview-water-3d {
    width: min(100%, 42dvh, 100vw);
  }
}

/* Back-navigation controls */
.river-actions [data-go="wishes"] {
  margin: 0 auto 10px;
  display: inline-flex;
}
#editNotesBtn {
  display: block;
  margin: 14px auto 6px;
}

/* v5.3.37: keep the explicit PNG download link visually consistent with buttons */
#downloadMemoryImage { display:block; text-align:center; text-decoration:none; box-sizing:border-box; margin-top:12px; }


/* v5.3.42: landing hero uses the same moonlit river atmosphere as the 3D river scene */
#screen-intro .hero-scene{
  height:clamp(250px,34vw,340px);
  max-width:100%;
  margin:12px auto 0;
  border-radius:10px 10px 0 0;
  isolation:isolate;
  background:
    radial-gradient(ellipse at 50% 25%,rgba(246,213,153,.20),transparent 25%),
    linear-gradient(180deg,rgba(3,8,20,.05),rgba(3,10,20,.38)),
    linear-gradient(180deg,#071322 0%,#102d3a 42%,#17434a 62%,#092631 100%);
}
#screen-intro .hero-scene:before{
  content:"";
  position:absolute;
  z-index:1;
  left:0;right:0;top:34%;height:32%;
  opacity:.72;
  background:
    linear-gradient(180deg,transparent 0 54%,#071b25 55% 100%),
    linear-gradient(90deg,transparent 0 8%,#102a2c 8% 12%,transparent 12% 18%,#102a2c 18% 23%,transparent 23% 76%,#102a2c 76% 81%,transparent 81% 88%,#102a2c 88% 92%,transparent 92%);
  clip-path:polygon(0 58%,8% 58%,10% 32%,12% 58%,18% 58%,21% 18%,24% 58%,34% 58%,38% 43%,42% 58%,58% 58%,62% 40%,66% 58%,76% 58%,79% 22%,82% 58%,90% 58%,93% 35%,96% 58%,100% 58%,100% 100%,0 100%);
  pointer-events:none;
}
#screen-intro .hero-water{
  z-index:2;
  height:48%;
  border-radius:0;
  background:
    radial-gradient(ellipse at 50% 5%,rgba(231,184,104,.24),transparent 44%),
    repeating-linear-gradient(177deg,transparent 0 15px,rgba(195,220,213,.11) 16px 18px,transparent 19px 35px),
    linear-gradient(180deg,#1b5660 0%,#0c3441 55%,#071e2a 100%);
  box-shadow:inset 0 18px 36px rgba(4,13,24,.24);
}
#screen-intro .water-shimmer{
  left:8%;right:8%;top:10px;height:85%;
  background:repeating-linear-gradient(180deg,transparent 0 9px,rgba(246,215,158,.18) 10px 11px,transparent 12px 23px);
}
#screen-intro .moon{z-index:0;top:8%;width:74px;height:74px;background:#f2dfb7;box-shadow:0 0 48px 22px rgba(223,195,140,.24)}
#screen-intro .moon-glow{z-index:0;top:0}
#screen-intro .distant-lights{
  position:absolute;z-index:3;left:0;right:0;top:62%;height:18%;
  pointer-events:none;
}
#screen-intro .distant-lights:before,
#screen-intro .distant-lights:after{
  content:"";position:absolute;left:50%;top:50%;
  width:22px;height:11px;border-radius:50%;
  background:radial-gradient(ellipse,#fff0b8 0 10%,#e4b85e 23%,#527b5c 58%,#183e37 82%);
  border:1px solid rgba(212,177,108,.75);
  box-shadow:0 0 16px rgba(243,200,121,.55),-210px 12px 0 -2px #b88c4d,-210px 12px 9px 0 rgba(243,200,121,.35),-125px -10px 0 -3px #d3a85c,-125px -10px 8px 0 rgba(243,200,121,.3),115px 8px 0 -2px #b88c4d,115px 8px 9px 0 rgba(243,200,121,.35),205px -8px 0 -3px #d3a85c,205px -8px 8px 0 rgba(243,200,121,.3);
}
#screen-intro .distant-lights:after{transform:translate(-50%,18px) scale(.68);opacity:.65;filter:blur(.3px)}
#screen-intro .hero-krathong{z-index:4;bottom:24px}
#screen-intro .firefly{z-index:5}
@media(max-width:700px){
  #screen-intro .hero-scene{height:245px}
  #screen-intro .distant-lights:before{box-shadow:0 0 14px rgba(243,200,121,.5),-105px 10px 0 -2px #b88c4d,-105px 10px 8px 0 rgba(243,200,121,.3),-62px -8px 0 -3px #d3a85c,62px 8px 0 -2px #b88c4d,105px -8px 0 -3px #d3a85c}
}


/* v5.3.44: real-time landing-page view of the exact river scene used at release */
#screen-intro .hero-scene.hero-scene-3d{
  position:relative;
  width:100%;
  max-width:1180px;
  height:clamp(300px,43vw,560px);
  margin:18px auto 0;
  overflow:hidden;
  border:1px solid rgba(211,181,124,.22);
  border-radius:8px;
  isolation:isolate;
  background:#030612;
  box-shadow:0 24px 70px rgba(0,0,0,.38),0 0 38px rgba(202,164,99,.08);
}
#screen-intro .intro-river-3d-stage{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  overflow:hidden;
}
#screen-intro .intro-river-3d-stage canvas{
  display:block;
  width:100%;
  height:100%;
}
#screen-intro .hero-scene-vignette{
  position:absolute;
  z-index:2;
  inset:0;
  pointer-events:none;
  background:linear-gradient(180deg,rgba(2,6,18,.08),transparent 24%,transparent 70%,rgba(2,6,18,.25)),
             linear-gradient(90deg,rgba(2,6,18,.14),transparent 18%,transparent 82%,rgba(2,6,18,.14));
}
@media(max-width:700px){
  #screen-intro .hero-scene.hero-scene-3d{
    height:clamp(260px,72vw,390px);
    margin-top:14px;
    border-radius:6px;
  }
}


/* v5.3.50: remove the legacy CSS river silhouette overlay from the 3D intro scene */
#screen-intro .hero-scene.hero-scene-3d::before{
  content:none !important;
  display:none !important;
}

/* v5.3.45: tarot card faces can load replaceable WebP artwork from assets */
.tarot-card .card-back,
.tarot-card .card-front{overflow:hidden;isolation:isolate}
.tarot-card .tarot-face-image{
  position:absolute;
  z-index:3;
  inset:0;
  display:block;
  width:100%;
  height:100%;
  object-fit:cover;
  border-radius:7px;
}
.tarot-card .card-back.has-tarot-image>span,
.tarot-card .card-back.has-tarot-image>small,
.tarot-card .card-front.has-tarot-image>.card-art,
.tarot-card .card-front.has-tarot-image>.card-name,
.tarot-card .card-front.has-tarot-image>.card-subtitle{visibility:hidden}
#screen-intro .hero-scene.hero-scene-3d{
  height:clamp(340px,46vw,590px);
  background:#071b2b;
}
#screen-intro .intro-river-3d-stage canvas{filter:brightness(1.12) saturate(1.12) contrast(1.04)}

/* v5.3.53 — explicit pick mode and compact contextual delete control */
.editor-mode-btn.is-active {
  border-color: rgba(255,220,150,.9) !important;
  color: #ffe4a8 !important;
  background: rgba(229,197,139,.16) !important;
  box-shadow: inset 0 0 0 1px rgba(229,197,139,.22);
}
.three-floating-delete {
  min-height: 32px;
  padding: 0 12px;
  gap: 6px;
  font-size: 11px;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.three-floating-delete span { font-size: 14px; }
@media (max-width:640px) {
  .three-floating-delete {
    min-height: 30px;
    padding: 0 11px;
    font-size: 10px;
  }
  .three-floating-delete span { font-size: 13px; }
  #screen-builder .three-controls { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

/* v5.3.55 — mobile 3D preview uses landscape 4:3 */
@media (max-width: 700px) {
  .preview-wrap-3d .preview-water-3d {
    width: min(100%, 46dvh, 100vw);
    aspect-ratio: 1 / 1;
    height: auto;
    min-height: 0;
    flex: 0 0 auto;
  }
  .preview-wrap-3d .krathong-3d-stage {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
  }
}

/* v5.3.56: square mobile preview and four compact studio actions */
@media (max-width: 700px) {
  #screen-builder .three-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


/* v5.3.57: FORCE the mobile 3D preview to a true full-width 4:3 frame.
   These !important declarations intentionally override all earlier responsive rules. */
@media screen and (max-width: 700px) {
  #screen-builder.active .builder-layout {
    grid-template-rows: auto minmax(0, 1fr) !important;
  }
  #screen-builder.active .preview-wrap-3d {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    flex: 0 0 auto !important;
  }
  #screen-builder.active .preview-wrap-3d .preview-water-3d {
    display: block !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    aspect-ratio: 4 / 3 !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    flex: 0 0 auto !important;
    margin: 0 auto !important;
    position: relative !important;
    overflow: hidden !important;
  }
  #screen-builder.active .preview-wrap-3d .krathong-3d-stage {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
  }
}


/* v5.3.58: consolidate preview overlay actions and move view/reset tools to builder options */
.preview-wrap-3d .preview-water-3d { position: relative; }
.preview-wrap-3d .three-hud {
  top: 10px;
  bottom: auto;
  z-index: 5;
}
.preview-overlay-panel {
  position: absolute;
  z-index: 10;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 7px;
  padding: 8px;
  border: 1px solid rgba(229,197,139,.28);
  border-radius: 13px;
  background: rgba(5,18,27,.76);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.preview-overlay-panel .three-floating-delete {
  position: static;
  left: auto;
  bottom: auto;
  transform: none;
  align-self: center;
  min-height: 34px;
  padding: 0 14px;
  opacity: 1;
}
.preview-overlay-panel .three-floating-delete[hidden] { display: none !important; }
.preview-overlay-panel .object-scale-control {
  width: 100%;
  margin: 0;
  padding: 5px 9px;
  border: 0;
  border-radius: 8px;
  background: rgba(255,255,255,.055);
}
.preview-overlay-panel .object-scale-control label {
  margin-bottom: 3px;
  font-size: 10px;
}
.preview-overlay-panel .object-scale-control input {
  display: block;
  width: 100%;
  min-height: 24px;
}
.preview-overlay-panel .three-controls {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 7px;
  margin: 0;
}
.preview-overlay-panel .three-controls .editor-btn {
  min-width: 0;
  min-height: 36px;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.25;
}
#screen-builder .three-status { margin-top: 5px; }
.builder-layout-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px;
}
.builder-layout-actions .editor-btn {
  min-height: 38px;
  padding: 7px 12px;
  font-size: 11px;
}
@media (max-width: 700px) {
  .preview-wrap-3d .preview-water-3d { position: relative !important; }
  .preview-overlay-panel {
    left: 7px;
    right: 7px;
    bottom: 7px;
    gap: 5px;
    padding: 6px;
  }
  .preview-overlay-panel .three-controls { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
  .preview-overlay-panel .three-controls .editor-btn {
    min-height: 34px;
    padding: 5px 4px;
    font-size: 10px;
  }
  .preview-overlay-panel .object-scale-control { padding: 4px 7px; }
  .preview-overlay-panel .object-scale-control label { font-size: 9px; }
  .preview-overlay-panel .object-scale-control input { min-height: 20px; }
  .builder-layout-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }
  .builder-layout-actions .editor-btn { min-width: 0; font-size: 10px; padding: 6px 5px; }
}


/* v5.3.59 — separate fixed preview actions from selection-only tools */
.preview-overlay-panel[hidden] { display: none !important; }
.preview-wrap-3d .preview-overlay-panel {
  left: auto;
  right: 10px;
  top: 48px;
  bottom: auto;
  width: max-content;
  max-width: min(190px, calc(100% - 20px));
  gap: 5px;
  padding: 6px;
  border-radius: 10px;
}
.preview-overlay-panel .three-floating-delete {
  align-self: stretch;
  min-height: 28px;
  padding: 3px 8px;
  font-size: 10px;
  line-height: 1.2;
}
.preview-overlay-panel .three-floating-delete span { font-size: 12px; }
.preview-overlay-panel .object-scale-control {
  width: 100%;
  padding: 4px 6px;
  background: transparent;
}
.preview-overlay-panel .object-scale-control label {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin: 0 0 2px;
  font-size: 9px;
  white-space: nowrap;
}
.preview-overlay-panel .object-scale-control input {
  min-height: 17px;
  height: 17px;
  margin: 0;
}
.three-controls-below-preview {
  position: sticky;
  bottom: 10px;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 500px);
  margin: 10px auto 0;
  padding: 7px;
  border: 1px solid rgba(229,197,139,.25);
  border-radius: 12px;
  background: rgba(5,18,27,.92);
  box-shadow: 0 5px 18px rgba(0,0,0,.22);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.three-controls-below-preview .editor-btn {
  min-width: 0;
  min-height: 36px;
  padding: 6px 8px;
  font-size: 11px;
}
.builder-controls > .builder-layout-actions {
  margin: 0 0 12px;
}
@media (max-width: 700px) {
  .preview-wrap-3d .preview-overlay-panel {
    top: 42px;
    right: 7px;
    max-width: 160px;
    padding: 5px;
  }
  .three-controls-below-preview {
    bottom: 6px;
    gap: 6px;
    margin-top: 7px;
    padding: 6px;
  }
  .three-controls-below-preview .editor-btn {
    min-height: 34px;
    padding: 5px 4px;
    font-size: 10px;
  }
}


/* v5.3.60 — compact selection tools in one bottom row */
.preview-wrap-3d .preview-overlay-panel {
  top: auto !important;
  bottom: 10px !important;
  left: 10px !important;
  right: 10px !important;
  width: auto !important;
  max-width: none !important;
  display: grid !important;
  grid-template-columns: auto minmax(90px, 1fr) !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 5px 7px !important;
  border-radius: 9px !important;
  background: rgba(5,18,27,.68) !important;
  box-shadow: 0 2px 9px rgba(0,0,0,.18);
}
.preview-overlay-panel .three-floating-delete {
  justify-self: start !important;
  align-self: center !important;
  min-height: 27px !important;
  padding: 3px 7px !important;
  white-space: nowrap;
  font-size: 9px !important;
  line-height: 1.1 !important;
}
.preview-overlay-panel .three-floating-delete span {
  font-size: 11px !important;
}
.preview-overlay-panel .object-scale-control {
  min-width: 0 !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 3px !important;
  background: transparent !important;
}
.preview-overlay-panel .object-scale-control label {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 5px !important;
  margin: 0 0 1px !important;
  font-size: 8px !important;
  line-height: 1.1 !important;
}
.preview-overlay-panel .object-scale-control input {
  display: block !important;
  width: 100% !important;
  min-width: 0 !important;
  height: 14px !important;
  min-height: 14px !important;
  margin: 0 !important;
  padding: 0 !important;
}
@media (max-width: 700px) {
  .preview-wrap-3d .preview-overlay-panel {
    left: 7px !important;
    right: 7px !important;
    bottom: 7px !important;
    grid-template-columns: auto minmax(75px, 1fr) !important;
    gap: 6px !important;
    padding: 4px 6px !important;
  }
  .preview-overlay-panel .three-floating-delete {
    min-height: 25px !important;
    padding: 2px 6px !important;
    font-size: 8px !important;
  }
  .preview-overlay-panel .object-scale-control label {
    font-size: 7px !important;
  }
  .preview-overlay-panel .object-scale-control input {
    height: 12px !important;
    min-height: 12px !important;
  }
}


/* v5.3.61 — enforce hidden state for selection-only controls.
   This selector intentionally matches the specificity of the visible grid rule. */
.preview-wrap-3d .preview-overlay-panel[hidden] {
  display: none !important;
}


/* v5.3.62 — make reset and clear actions more compact */
.builder-controls > .builder-layout-actions {
  gap: 6px !important;
  margin: 0 0 10px !important;
}
.builder-controls > .builder-layout-actions .editor-btn {
  min-height: 29px !important;
  padding: 4px 8px !important;
  font-size: 9px !important;
  line-height: 1.15 !important;
  border-radius: 4px;
}
@media (max-width: 700px) {
  .builder-controls > .builder-layout-actions {
    gap: 5px !important;
    margin-bottom: 8px !important;
  }
  .builder-controls > .builder-layout-actions .editor-btn {
    min-height: 26px !important;
    padding: 3px 6px !important;
    font-size: 8px !important;
  }
}


/* v5.3.65 — authoritative tarot ratio, actual brand artwork and page background */
html, body { min-height: 100%; }
body {
  background-color: #071820 !important;
  background-image:
    linear-gradient(rgba(4, 16, 24, .42), rgba(4, 16, 24, .58)),
    url("../images/loy-bg.jpg") !important;
  background-repeat: repeat, repeat !important;
  background-position: 0 0, 0 0 !important;
  background-size: auto, 500px 500px !important;
  background-attachment: fixed, fixed !important;
}

/* Keep the source artwork's exact 937 × 1679 proportion on every device. */
#screen-tarot .tarot-result {
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr) !important;
  align-items: start !important;
}
#screen-tarot #tarotCard,
#screen-tarot .tarot-card {
  display: block !important;
  position: relative !important;
  box-sizing: border-box !important;
  width: min(220px, 100%) !important;
  min-width: 0 !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: 937 / 1679 !important;
  margin: 0 auto !important;
  flex: none !important;
}
#screen-tarot .tarot-card .card-back,
#screen-tarot .tarot-card .card-front {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  box-sizing: border-box !important;
  padding: 0 !important;
  overflow: hidden !important;
  border-radius: 8px !important;
}
#screen-tarot .tarot-card .tarot-face-image {
  position: absolute !important;
  inset: 0 !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: fill !important;
  object-position: center !important;
  border-radius: inherit !important;
}
#screen-tarot .tarot-card .card-front > :not(.tarot-face-image) {
  max-width: 100%;
}
@media (max-width: 700px) {
  #screen-tarot .tarot-result {
    grid-template-columns: minmax(0, 1fr) !important;
    width: min(100%, 420px) !important;
    gap: 24px !important;
  }
  #screen-tarot #tarotCard,
  #screen-tarot .tarot-card {
    width: min(205px, 70vw) !important;
    aspect-ratio: 937 / 1679 !important;
    margin-inline: auto !important;
  }
}

/* Use the supplied logo asset consistently, without oversized header branding. */
.topbar .brand { line-height: 0 !important; }
.topbar .brand-logo {
  display: block !important;
  width: 132px !important;
  height: auto !important;
  max-width: min(132px, 38vw) !important;
  max-height: 42px !important;
  object-fit: contain !important;
}
.card-back .card-back-logo {
  display: block;
  width: 42%;
  max-width: 118px;
  height: auto;
  max-height: 42px;
  object-fit: contain;
  filter: brightness(1.25) contrast(1.05);
}
.preview-caption {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
}
.preview-caption .preview-brand-logo {
  display: inline-block;
  width: 72px;
  height: auto;
  max-height: 23px;
  object-fit: contain;
  vertical-align: middle;
}
.preview-caption > span { display: inline-block; }
footer .footer-brand-logo {
  display: block;
  width: 92px;
  height: auto;
  max-height: 30px;
  object-fit: contain;
}
@media (max-width: 700px) {
  .topbar .brand-logo {
    width: 112px !important;
    max-width: min(112px, 34vw) !important;
    max-height: 36px !important;
  }
  footer .footer-brand-logo { width: 76px; }
  .preview-caption .preview-brand-logo { width: 62px; }
}
