#ui { --plum:#4a2347; --straw:#ff6fa3; --mint:#6fe3c0; --lemon:#ffd45c; --grape:#a98bff; --cream:#fff4e6; font-family: "Arial Rounded MT Bold","Trebuchet MS",sans-serif; }
#ui .layer { position:absolute; inset:0; pointer-events:none; display:none; }
#ui .layer.on { display:block; }
#ui #title.layer, #ui #select.layer, #ui #share.layer { pointer-events:auto; }
#ui .txt { color:#fff; font-weight:900; -webkit-text-stroke:5px var(--plum); paint-order:stroke fill; text-shadow:0 3px 0 var(--plum); letter-spacing:.5px; }
#ui .txt.sm { -webkit-text-stroke:3.5px var(--plum); text-shadow:0 2px 0 var(--plum); }
@keyframes pop { 0%{transform:scale(.85);opacity:0} 70%{transform:scale(1.04);opacity:1} 100%{transform:scale(1)} }
#ui .layer.on > .popin { animation:pop .2s ease-out; }

/* panel + buttons */
#ui .panel { border:22px solid transparent; border-image:url(../assets/ui-panel.webp) 60 fill / 22px stretch; box-sizing:border-box; color:var(--plum); }
#ui .btn { pointer-events:auto; cursor:pointer; border:14px solid transparent; border-image:url(../assets/ui-button.webp) 40 fill / 14px stretch; box-sizing:border-box; min-width:44px; min-height:44px; display:flex; align-items:center; justify-content:center; gap:6px; padding:0 8px; font-size:clamp(14px,2.8vh,24px); transition:transform .1s, filter .1s; background:none; -webkit-tap-highlight-color:transparent; }
#ui .btn.primary { font-size:clamp(18px,4.2vh,34px); min-height:clamp(52px,12vh,84px); padding:0 14px; filter:saturate(1.3) brightness(1.08); border-image-source:url(../assets/ui-button.webp); }
#ui .btn:hover, #ui .btn.focus { transform:scale(1.06); filter:brightness(1.12); }
#ui .btn:active { transform:scale(.94); }
#ui .btn.dis { filter:grayscale(.7) brightness(.9); pointer-events:none; }
#ui .focus { outline:3px solid var(--lemon); outline-offset:2px; border-radius:14px; }

/* title */
#title { background:#2a1f3d center/cover no-repeat; pointer-events:auto; cursor:pointer; }
#title .logo { position:absolute; left:4%; top:5%; width:46%; max-height:34%; }
#title .logo .lw { position:relative; width:100%; height:100%; animation:float 3s ease-in-out infinite; }
#title .logo img { width:100%; max-height:34vh; object-fit:contain; display:block; }
#title .logo .shine { position:absolute; inset:0; -webkit-mask-position:left top; mask-position:left top; -webkit-mask-size:100% 100%; mask-size:100% 100%; -webkit-mask-repeat:no-repeat; mask-repeat:no-repeat; background:linear-gradient(110deg,transparent 40%,rgba(255,255,255,.95) 50%,transparent 60%) -150% 0/60% 100% no-repeat; animation:shine 3.2s linear infinite; }
#title.on .logo { animation:drop .6s cubic-bezier(.3,1.4,.5,1); }
@keyframes drop { 0%{transform:translateY(-120%)} 100%{transform:none} }
@keyframes float { 50%{transform:translateY(-6px) rotate(.6deg)} }
@keyframes shine { 0%{background-position:-150% 0} 60%,100%{background-position:250% 0} }
#title .prompt { position:absolute; left:20%; right:20%; bottom:7%; box-sizing:border-box; text-align:center; font-size:clamp(15px,3vh,24px); animation:pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50%{transform:scale(1.08);opacity:.75} }
#title .trophy { position:absolute; top:max(12px,env(safe-area-inset-top)); right:max(12px,env(safe-area-inset-right)); width:48px; height:48px; pointer-events:auto; opacity:.8; cursor:pointer; background:none; border:0; padding:0; }
#title .trophy img { width:100%; height:100%; }
#title .trophy:hover, #title .trophy.focus { opacity:1; transform:scale(1.1); }

/* select */
#select { background:rgba(74,35,71,.35); backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px); pointer-events:auto; }
#select .bgimg { position:absolute; inset:0; background:center/cover; filter:blur(8px) brightness(.8); }
#select .wrap { position:absolute; inset:0; padding:max(8px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left)); display:flex; flex-direction:column; gap:1.4vh; }
#select .head { display:flex; align-items:center; justify-content:center; position:relative; height:9vh; min-height:40px; }
#select .head h1 { margin:0; font-size:clamp(20px,5.4vh,44px); }
#select .gold { position:absolute; right:60px; top:50%; transform:translateY(-50%); display:flex; align-items:center; gap:6px; font-size:clamp(16px,3vh,24px); }
#select .gold img { width:28px; height:28px; }
#select .gold .btn { font-size:14px; }
#select .cards { display:flex; gap:1.2vw; justify-content:center; align-items:center; flex:1 1 auto; min-height:0; }
#select .cards .card { padding-top:2.5vh; padding-bottom:3vh; min-height:min(44vh, 100%); box-sizing:border-box; }
#select .card { pointer-events:auto; cursor:pointer; flex:0 1 18%; max-width:210px; padding:6px 4px; display:flex; flex-direction:column; align-items:center; text-align:center; gap:2px; transition:transform .12s; overflow:hidden; border-width:16px; border-image-width:16px; }
#select .card.sel { animation:bounce .7s ease-in-out infinite; filter:drop-shadow(0 0 6px var(--lemon)) drop-shadow(0 0 3px var(--lemon)); outline:3px solid var(--lemon); outline-offset:-10px; border-radius:20px; }
@keyframes bounce { 50%{transform:translateY(-5px) scale(1.03)} }
#select .card img, #select .card .q { width:auto; height:17vh; max-width:100%; aspect-ratio:1; object-fit:contain; flex:0 0 auto; }
#select .card .q { font-size:11vh; line-height:17vh; text-align:center; color:var(--straw); font-weight:900; -webkit-text-stroke:4px var(--plum); paint-order:stroke fill; }
#select .card .nm { font-size:clamp(15px,3.2vh,24px); color:var(--plum); font-weight:900; }
#select .card .ds { font-size:clamp(12px,2.2vh,14px); line-height:1.15; color:var(--plum); }
#select .tops { display:flex; align-items:center; justify-content:center; gap:1.4vw; height:clamp(66px,13vh,100px); flex:0 0 auto; }
#select .tops .lbl { font-size:clamp(14px,2.6vh,20px); margin-right:6px; }
#select .slot { pointer-events:auto; cursor:pointer; position:relative; width:clamp(52px,10vh,70px); height:clamp(52px,10vh,70px); border-radius:50%; background:rgba(255,244,230,.92); border:3px solid var(--plum); display:flex; align-items:center; justify-content:center; transition:transform .12s; }
#select .slot img { width:78%; height:78%; object-fit:contain; }
#select .slot.sel { border-color:var(--lemon); box-shadow:0 0 0 4px var(--lemon),0 0 14px var(--lemon); transform:scale(1.1); }
#select .slot:hover, #select .slot.focus { transform:scale(1.1); }
#select .slot .none { width:60%; height:60%; border:4px solid #c44; border-radius:50%; position:relative; }
#select .slot .none::after { content:""; position:absolute; left:50%; top:-4px; bottom:-4px; width:4px; margin-left:-2px; background:#c44; transform:rotate(45deg); }
#select .slot .tag { position:absolute; bottom:-22px; left:50%; transform:translateX(-50%); background:var(--plum); color:#fff; border-radius:10px; font-size:13px; padding:1px 6px; white-space:nowrap; display:flex; align-items:center; gap:2px; font-weight:900; }
#select .slot .tag img { width:14px; height:14px; }
#select .foot { display:flex; justify-content:space-between; align-items:flex-end; flex:0 0 auto; }
#select .foot .btn { min-width:clamp(90px,16vw,150px); }
#select .foot .btn.primary { min-width:clamp(150px,26vw,280px); }

/* HUD */
#hud .pcard { position:absolute; top:8px; left:max(72px,env(safe-area-inset-left)); display:flex; align-items:center; gap:8px; padding:4px 10px 4px 4px; background:rgba(74,35,71,.65); border-radius:16px; border:2px solid rgba(255,244,230,.6); }
#hud .pcard img { width:40px; height:40px; border-radius:50%; background:var(--cream); object-fit:contain; }
#hud .hpbar { position:relative; width:clamp(110px,16vw,180px); height:18px; border-radius:9px; background:rgba(0,0,0,.45); overflow:hidden; border:2px solid var(--plum); }
#hud .hpfill { position:absolute; left:0; top:0; bottom:0; width:100%; background:var(--mint); transition:width .15s, background .2s; }
#hud .hpnum { position:absolute; inset:0; text-align:center; font-size:13px; line-height:18px; -webkit-text-stroke:3px var(--plum); }
#hud .score { font-size:18px; display:flex; align-items:center; gap:4px; margin-top:2px; }
#hud .star { width:18px; height:18px; background:var(--lemon); clip-path:polygon(50% 0,62% 36%,100% 38%,70% 60%,80% 100%,50% 76%,20% 100%,30% 60%,0 38%,38% 36%); }
#hud .timer { position:absolute; top:6px; left:50%; transform:translateX(-50%); font-size:clamp(26px,5.6vh,32px); }
#hud .timer.low { color:var(--straw); animation:pulse .5s ease-in-out infinite; }
#hud .feed { position:absolute; top:70px; left:max(72px,env(safe-area-inset-left)); display:flex; flex-direction:column; gap:3px; }
#hud .feed div { font-size:14px; animation:fin .2s ease-out; transition:opacity .4s; padding:1px 8px; background:rgba(74,35,71,.5); border-radius:8px; }
@keyframes fin { from{transform:translateX(-20px);opacity:0} }
#hud .board { position:absolute; top:62px; right:max(10px,env(safe-area-inset-right)); width:clamp(120px,19vw,170px); display:flex; flex-direction:column; gap:2px; }
#hud .board .r { display:flex; align-items:center; gap:5px; font-size:14px; padding:1px 6px; background:rgba(74,35,71,.55); border-radius:8px; color:#fff; font-weight:900; }
#hud .board .r.me { background:rgba(111,227,192,.8); color:var(--plum); }
#hud .board .r .d { width:10px; height:10px; border-radius:50%; flex:0 0 auto; border:1px solid #fff; }
#hud .board .r .n { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#hud .board .r .k { width:14px; text-align:center; }

/* banner, subtitle, toast, feed */
#banner { position:absolute; left:0; right:0; top:34%; text-align:center; pointer-events:none; }
#banner span { display:inline-block; font-size:clamp(40px,14vh,110px); -webkit-text-stroke:10px var(--plum); text-shadow:0 6px 0 var(--plum); }
#banner.mid span { font-size:clamp(26px,8vh,64px); -webkit-text-stroke:7px var(--plum); }
#banner.show span { animation:slam .35s cubic-bezier(.3,1.5,.5,1); }
@keyframes slam { 0%{transform:scale(2);opacity:0} 100%{transform:scale(1);opacity:1} }
#banner.fade { opacity:0; transition:opacity .3s; }
#sub { position:absolute; left:10%; right:10%; bottom:18%; text-align:center; font-size:clamp(15px,3vh,22px); pointer-events:none; display:none; }
#toast { position:absolute; left:50%; top:45%; transform:translate(-50%,0); padding:8px 18px; background:rgba(74,35,71,.9); border-radius:18px; font-size:16px; display:none; border:2px solid var(--cream); }

/* replay */
#replay .bar { position:absolute; left:0; right:0; height:9%; background:var(--plum); }
#replay .bar.t { top:0; } #replay .bar.b { bottom:0; }
#replay .rec { position:absolute; top:calc(9% + 8px); left:max(72px,env(safe-area-inset-left)); display:flex; align-items:center; gap:8px; font-size:clamp(16px,3.4vh,26px); }
#replay .rec i { width:14px; height:14px; border-radius:50%; background:#f33; animation:blink 1s steps(2) infinite; }
@keyframes blink { 50%{opacity:.1} }
#replay .line { position:absolute; top:calc(9% + 8px); left:50%; transform:translateX(-50%); font-size:clamp(15px,3.2vh,24px); text-align:center; white-space:nowrap; }
#replay .stand { position:absolute; left:max(12px,env(safe-area-inset-left)); top:calc(9% + 54px); width:clamp(190px,26vw,280px); padding:20px 14px 12px; background:rgba(74,35,71,.7); border-radius:16px; border:2px solid rgba(255,244,230,.5); }
#replay .stand h3 { margin:0 0 4px; font-size:15px; }
#replay .stand .r { display:flex; align-items:center; gap:6px; font-size:14px; line-height:20px; color:#fff; font-weight:900; padding:0 4px; border-radius:6px; }
#replay .stand .r.me { background:rgba(111,227,192,.85); color:var(--plum); }
#replay .stand .r .d { width:10px; height:10px; border-radius:50%; border:1px solid #fff; flex:0 0 auto; }
#replay .stand .r .n { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#replay .stand .r .a { width:18px; } #replay .stand .r .s { width:44px; text-align:right; } #replay .stand .r .k { width:28px; text-align:right; }
#replay .btns { position:absolute; left:0; right:0; bottom:calc(9% + 10px); display:flex; justify-content:center; gap:12px; }
#replay .btns .btn { min-width:clamp(100px,16vw,170px); }
#replay .adres { position:absolute; left:0; right:0; bottom:calc(9% + 84px); text-align:center; font-size:15px; }
.tv { width:20px; height:15px; border:3px solid var(--plum); border-radius:4px; background:#9ef; display:inline-block; position:relative; flex:0 0 auto; }
.tv::after { content:""; position:absolute; left:3px; right:3px; bottom:-7px; height:3px; background:var(--plum); }

/* share */
#share { background:rgba(40,15,40,.6); pointer-events:auto; }
#share .panel { position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); background:none; display:flex; flex-direction:column; align-items:center; gap:8px; max-width:92vw; max-height:94vh; padding:6px; }
#share img.card { max-width:80vw; max-height:60vh; object-fit:contain; border-radius:10px; border:3px solid var(--plum); -webkit-user-select:auto; user-select:auto; -webkit-touch-callout:default; pointer-events:auto; }
#share .hint { font-size:14px; text-align:center; color:var(--plum); }
#share .row { display:flex; gap:12px; }
