:root{
  --grass1:#8fdc6a; --grass2:#4fb64a; --navy:#1c3354; --ink:#14243d;
  --blue:#3a9cff; --red:#ff5a4a; --gold:#ffd23f; --white:#fff;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent;user-select:none;-webkit-user-select:none}
html,body{margin:0;height:100%;overflow:hidden;background:#5cc052;font-family:'Baloo 2',system-ui,sans-serif;color:var(--ink)}
#app{position:fixed;inset:0;background:linear-gradient(#5aaeea 0%,#8ccaf2 42%,#cfe8f7 52%,#8fd06a 53%,#5fae45 75%,#3f8f38 100%)}
#gl,#cv{position:absolute;inset:0;width:100%;height:100%;touch-action:none}
#gl{pointer-events:none}
.hidden{display:none!important}

/* HUD */
.hud{position:absolute;left:50%;transform:translateX(-50%);width:min(100%,560px);padding:10px 12px;z-index:5}
#hudTop{top:env(safe-area-inset-top,0);display:flex;align-items:center;gap:8px}
#hudBottom{bottom:env(safe-area-inset-bottom,0);display:flex;flex-direction:column;gap:8px}
.iconbtn{width:40px;height:40px;border-radius:12px;border:none;background:var(--navy);color:#fff;font:700 18px 'Baloo 2';box-shadow:0 4px 0 #0c1a2e;cursor:pointer;flex:none}
.card{position:relative;flex:1;display:flex;align-items:center;gap:10px;padding:6px 10px 6px 6px;border-radius:18px;background:rgba(255,255,255,.92);box-shadow:0 4px 0 rgba(0,0,0,.18);border:3px solid transparent;transition:border-color .2s,transform .2s}
.card.active{transform:scale(1.02)}
.card.opp.active{border-color:var(--red)}
.card.me.active{border-color:var(--blue)}
.avatar{width:48px;height:48px;border-radius:14px;overflow:hidden;flex:none;display:grid;place-items:center}
.opp .avatar{background:linear-gradient(#ffb199,#ff6b57)}
.me .avatar{background:linear-gradient(#a9dcff,#4aa6ff)}
.avatar img{width:100%;height:100%;object-fit:cover}
.info{flex:1;min-width:0}
.name{font-weight:800;font-size:16px;line-height:1.1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.stats{display:flex;gap:5px;margin-top:3px;flex-wrap:wrap}
.pill{font-size:12px;font-weight:700;background:#eef2f8;border-radius:999px;padding:1px 8px}
.pill.fence{background:#ffe9d2}
.boosts{position:absolute;right:10px;top:6px;display:flex;gap:3px}
.boosts img{width:20px;height:20px;object-fit:contain}
.pill img{height:12px;vertical-align:-1px}
.boosts .used{filter:grayscale(1);opacity:.3}
.timer{position:absolute;left:12px;right:12px;bottom:3px;height:4px;border-radius:4px;background:rgba(0,0,0,.08);overflow:hidden;opacity:0}
.card.active .timer{opacity:1}
.timer i{display:block;height:100%;width:100%;background:var(--blue);transform-origin:left}
.opp .timer i{background:var(--red)}
.timer i.low{background:#ff2d2d}
.ping{display:flex;align-items:center;gap:4px;font-size:12px;font-weight:700;color:#fff;background:rgba(20,36,61,.55);padding:3px 8px;border-radius:999px;flex:none}
.dot{width:8px;height:8px;border-radius:50%;background:#4dff6a;box-shadow:0 0 6px #4dff6a;display:inline-block}

.bubble{position:absolute;left:58px;padding:6px 12px;background:#fff;border-radius:14px;font-weight:700;font-size:14px;box-shadow:0 4px 12px rgba(0,0,0,.2);white-space:nowrap;opacity:0;transform:scale(.6);transition:all .2s cubic-bezier(.3,1.6,.6,1);pointer-events:none;z-index:9}
.opp .bubble{top:100%;margin-top:6px}
.me .bubble{bottom:100%;margin-bottom:6px}
.bubble.show{opacity:1;transform:scale(1)}

.actions{display:flex;gap:10px;align-items:flex-end;justify-content:center}
.act{position:relative;border:none;cursor:pointer;color:#fff;font:800 14px 'Baloo 2';text-shadow:0 1px 0 rgba(0,0,0,.3);transition:transform .08s,filter .2s}
.act:active{transform:translateY(3px)}
.act:disabled{filter:grayscale(.85) brightness(.9);opacity:.6;cursor:default}
.act .badge{position:absolute;top:-6px;right:-4px;min-width:24px;height:24px;border-radius:12px;background:#fff;color:var(--ink);font-size:13px;display:grid;place-items:center;box-shadow:0 2px 0 rgba(0,0,0,.25);text-shadow:none;padding:0 5px}
.fencebtn{flex:1;max-width:190px;height:64px;border-radius:20px;background:linear-gradient(#ffc15e,#ff8a1f);box-shadow:0 6px 0 #b8560c,0 10px 18px rgba(0,0,0,.25),inset 0 2px 0 rgba(255,255,255,.5);display:flex;align-items:center;justify-content:center;gap:6px;font-size:18px}
.fencebtn img{height:38px;filter:drop-shadow(0 2px 2px rgba(0,0,0,.3))}
.fencebtn.on{background:linear-gradient(#ffe08a,#ffb020);outline:3px solid #fff;outline-offset:-3px}
.orb{width:68px;height:68px;border-radius:50%;background:radial-gradient(circle at 35% 30%,#ff7fbf 0%,#ff2e93 55%,#c8146a 100%);box-shadow:0 0 0 4px #fff,0 0 18px rgba(255,46,147,.75),0 6px 0 4px #9c0f52;display:grid;place-items:center;margin-bottom:14px}
.orb img{width:44px;height:44px;object-fit:contain;filter:drop-shadow(0 2px 2px rgba(0,0,0,.35))}
.orb .cap{position:absolute;bottom:-22px;left:50%;transform:translateX(-50%);white-space:nowrap;font-size:12px}
.orb.on{box-shadow:0 0 0 4px #ffd23f,0 0 26px rgba(255,210,63,.95),0 6px 0 4px #9c0f52;animation:pulse 1s ease-in-out infinite}
.orb:disabled{box-shadow:0 0 0 4px #e3e3e3,0 6px 0 4px #8a8a8a}
@keyframes pulse{50%{transform:scale(1.07)}}
.coach{position:absolute;left:50%;bottom:calc(env(safe-area-inset-bottom) + 122px);transform:translateX(-50%);z-index:30;width:min(88vw,360px);
  background:#fff;color:#24324a;border-radius:18px;padding:10px 14px 11px;font:800 15px/1.3 'Baloo 2',sans-serif;text-align:center;
  box-shadow:0 6px 0 rgba(0,0,0,.14),0 10px 24px rgba(0,0,0,.18);pointer-events:none;animation:coachIn .35s ease-out}
.coach b{color:#e0702a}
.coach .cs{display:block;font-size:11.5px;color:#7a879b;font-weight:700;margin-bottom:2px;letter-spacing:.3px}
@keyframes coachIn{from{opacity:0;transform:translate(-50%,10px)}}
.tut-pulse{animation:tutGlow 1s ease-in-out infinite !important}
@keyframes tutGlow{50%{transform:scale(1.1);filter:drop-shadow(0 0 10px #ffe14a) brightness(1.15)}}
.res-rm{font:800 14px 'Baloo 2';color:#405068;margin:-4px 0 8px;text-align:center}
#btnRematch{margin-bottom:10px}
#btnRematch:disabled{filter:grayscale(.6);opacity:.75}
.chat{width:46px;height:46px;border-radius:14px;background:linear-gradient(#5ab8ff,#2f86e8);box-shadow:0 5px 0 #1a5aa8;font-size:22px;margin-bottom:14px}
.confirm{display:flex;align-items:center;gap:8px;background:rgba(255,255,255,.95);border-radius:20px;padding:8px;box-shadow:0 6px 0 rgba(0,0,0,.15);animation:pop .2s}
.cf{border:none;border-radius:14px;font:800 18px 'Baloo 2';color:#fff;cursor:pointer;height:48px}
.cf.no{width:48px;background:#94a3b8;box-shadow:0 4px 0 #64748b}
.cf.yes{padding:0 22px;background:linear-gradient(#7be05a,#3fb53a);box-shadow:0 4px 0 #2a7f27}
.cf.yes:disabled{filter:grayscale(1);opacity:.5}
.cf-info{flex:1;text-align:center;font-weight:700;font-size:14px;line-height:1.2}
.cf-info b{font-size:18px}
.cf-info .good{color:#16a34a}.cf-info .badv,.cf-info b.badv{color:#dc2626}
#hint{min-height:18px;text-align:center;color:#fff;font-weight:700;font-size:13px;text-shadow:0 1px 2px rgba(0,0,0,.4)}
#quick{position:absolute;bottom:100%;right:12px;background:#fff;border-radius:16px;padding:8px;display:grid;grid-template-columns:1fr 1fr;gap:6px;box-shadow:0 8px 24px rgba(0,0,0,.25);width:260px}
#quick button{border:none;background:#eef4ff;border-radius:10px;padding:6px;font:700 13px 'Baloo 2';cursor:pointer}

#banner{position:absolute;left:50%;top:21%;transform:translate(-50%,-50%) scale(.5);opacity:0;z-index:8;pointer-events:none;font:800 22px 'Baloo 2';color:#fff;padding:6px 22px;border-radius:999px;background:rgba(20,36,61,.85);white-space:nowrap;transition:opacity .25s,transform .25s cubic-bezier(.3,1.6,.6,1)}
#banner.show{opacity:1;transform:translate(-50%,-50%) scale(1)}

/* SCREENS */
.screen{position:absolute;inset:0;z-index:10;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;padding:20px;background:linear-gradient(rgba(255,255,255,0) 40%,rgba(20,60,20,.28))}
.logo{text-align:center}
.logo img{width:min(74vw,330px);filter:drop-shadow(0 8px 6px rgba(0,0,0,.25));animation:pop .5s cubic-bezier(.3,1.6,.6,1)}
.logo .tag{margin-top:2px;font-weight:700;color:#fff;font-size:16px;text-shadow:0 2px 0 rgba(0,0,0,.35)}
.duo{display:flex;align-items:flex-end;justify-content:center;height:220px}
.duo canvas{width:190px;height:220px;cursor:pointer}
.duo .vs{font:800 34px 'Baloo 2';color:#fff;-webkit-text-stroke:2px var(--ink);paint-order:stroke fill;margin-bottom:70px}
@keyframes bob{50%{transform:translateY(-8px)}}
.trophy{font-weight:800;font-size:18px;background:rgba(255,255,255,.9);padding:4px 16px;border-radius:999px}
.big{border:none;border-radius:20px;padding:14px 48px;font:800 26px 'Baloo 2';color:#fff;background:linear-gradient(#ffd84a,#ffaa00);box-shadow:0 7px 0 #c47a00;text-shadow:0 2px 0 rgba(0,0,0,.25);cursor:pointer}
.big:active{transform:translateY(4px);box-shadow:0 3px 0 #c47a00}
.online{color:#fff;font-weight:700;display:flex;align-items:center;gap:4px;text-shadow:0 1px 2px rgba(0,0,0,.3)}
.link{background:none;border:none;color:#fff;font:700 16px 'Baloo 2';text-decoration:underline;cursor:pointer;text-shadow:0 1px 2px rgba(0,0,0,.3)}
.panel .link{color:#2f6bb8;text-shadow:none}
.panel{background:#fff;border-radius:24px;padding:20px 22px;max-width:440px;width:100%;box-shadow:0 10px 0 rgba(0,0,0,.15);text-align:center}
.panel h2{margin:0 0 6px;font-size:28px}
.panel ul{text-align:left;padding-left:4px;list-style:none;margin:0 0 16px}
.panel li{margin:8px 0;font-size:15px;line-height:1.3}

.radar{position:relative;width:200px;height:200px;display:grid;place-items:center}
.radar canvas{width:130px;height:150px;z-index:2}
.ring{position:absolute;inset:0;border-radius:50%;border:4px solid rgba(255,255,255,.7);animation:ping 2s ease-out infinite}
.ring.r2{animation-delay:.66s}.ring.r3{animation-delay:1.33s}
@keyframes ping{0%{transform:scale(.3);opacity:1}100%{transform:scale(1.2);opacity:0}}
.mm-title{font:800 26px 'Baloo 2';color:#fff;text-shadow:0 3px 0 rgba(0,0,0,.25)}
.mm-time{font:700 18px 'Baloo 2';color:#fff;opacity:.9}
.tip{max-width:360px;text-align:center;background:rgba(255,255,255,.9);padding:10px 16px;border-radius:16px;font-weight:600;min-height:48px}

.vs-row{display:flex;align-items:center;gap:6px;width:100%;max-width:480px;justify-content:center}
.vs-card{flex:1;max-width:190px;border-radius:22px;padding:12px 8px;text-align:center;color:#fff;box-shadow:0 8px 0 rgba(0,0,0,.2)}
.vs-card canvas{width:100%;height:160px;display:block}
.vs-card.me{background:linear-gradient(#5db7ff,#2a7ee0);animation:slideL .5s cubic-bezier(.3,1.4,.6,1)}
.vs-card.opp{background:linear-gradient(#ff8a72,#e8432f);animation:slideR .5s cubic-bezier(.3,1.4,.6,1)}
.vs-card .n{font:800 20px 'Baloo 2';white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.vs-card .t{font-weight:700}
.vs-mid{font:800 44px 'Baloo 2';color:var(--gold);-webkit-text-stroke:3px var(--ink);paint-order:stroke fill;animation:pop .5s .3s both cubic-bezier(.3,1.8,.6,1)}
.coin{font:800 22px 'Baloo 2';color:#fff;background:rgba(20,36,61,.8);padding:8px 22px;border-radius:999px;animation:pop .4s .8s both}
@keyframes slideL{from{transform:translateX(-120%)}}
@keyframes slideR{from{transform:translateX(120%)}}
@keyframes pop{from{transform:scale(0)}}

.res{display:flex;flex-direction:column;align-items:center;gap:8px}
.res-title{font:800 40px 'Baloo 2';color:var(--gold);-webkit-text-stroke:3px var(--ink);paint-order:stroke fill;animation:pop .5s cubic-bezier(.3,1.8,.6,1)}
.res-title.lose{color:#9fb3c8}
#resImg{width:170px;height:180px}
.res-tro{font:800 26px 'Baloo 2'}
.res-sub{color:#56657a;font-weight:600}

.big.green{background:linear-gradient(#7be05a,#3fb53a);box-shadow:0 7px 0 #2a7f27;display:flex;flex-direction:column;align-items:center;line-height:1.05}
.big.green:active{box-shadow:0 3px 0 #2a7f27}
.big small{font-size:14px;opacity:.9}
#home .big{min-width:250px}

/* level select */
#levels{justify-content:flex-start;padding-top:calc(14px + env(safe-area-inset-top,0))}
.lv-head{display:flex;align-items:center;gap:10px;width:100%;max-width:460px}
.lv-title{flex:1;font:800 28px 'Baloo 2';color:#fff;text-shadow:0 3px 0 rgba(0,0,0,.25)}
.lv-stars{background:rgba(255,255,255,.92);border-radius:999px;padding:3px 12px;font-weight:700}
.lv-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:10px;width:100%;max-width:460px;overflow-y:auto;padding:6px 4px 30px;flex:1;align-content:start}
.lv{aspect-ratio:1;border:none;border-radius:16px;background:linear-gradient(#5aa2ee,#2f78d0);box-shadow:0 5px 0 #1d4f94;color:#fff;font:800 22px 'Baloo 2';cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;line-height:1;text-shadow:0 2px 0 rgba(0,0,0,.25)}
.lv .st{font-size:11px;letter-spacing:-1px;margin-top:3px;color:#ffd23f}
.lv .st i{font-style:normal;color:rgba(255,255,255,.35)}
.lv.cur{background:linear-gradient(#ffd84a,#ffaa00);box-shadow:0 5px 0 #c47a00;animation:bob 1.4s ease-in-out infinite}
.lv.lock{background:#7d8ea6;box-shadow:0 5px 0 #56657a;cursor:default;font-size:18px}
.lv:not(.lock):active{transform:translateY(3px);box-shadow:0 2px 0 #1d4f94}

/* solo extras */
.solo .ping .dot,.solo #btnChat{display:none}
.solo .ping{background:var(--navy);font-size:15px;padding:4px 12px;font-weight:800}
.solo .card .timer{display:none}
.res-stars{display:flex;gap:6px;font-size:52px;line-height:1}
.res-stars span{color:#dfe5ee;-webkit-text-stroke:2px #b8c3d3;transition:transform .3s}
.res-stars span.on{color:#ffd23f;-webkit-text-stroke:2px #c48a00;animation:pop .45s both cubic-bezier(.3,1.8,.6,1)}
.res-stars span:nth-child(2){font-size:64px;margin-top:-10px}
.res-goals{list-style:none;padding:0;margin:0;text-align:left;font-weight:600;font-size:14px}
.res-goals li{margin:2px 0}

@media (max-height:700px){
  .logo .l1{font-size:56px}.logo .l2{font-size:64px}.duo{height:160px}.duo canvas{width:140px;height:160px}
  .avatar{width:40px;height:40px}.orb{width:58px;height:58px}.orb img{width:38px;height:38px}.fencebtn{height:56px}
}

/* polish */
.opp .name{padding-right:50px}
.fencebtn{white-space:nowrap;font-size:16px;padding:0 10px}
.fencebtn img{height:32px}

/* exit modal + mute */
.modal{position:absolute;inset:0;z-index:30;display:grid;place-items:center;padding:20px;background:rgba(10,20,40,.55)}
.panel.md{max-width:340px;display:flex;flex-direction:column;align-items:center;gap:14px;position:relative;animation:pop .25s cubic-bezier(.3,1.6,.6,1)}
.md-text{font:800 22px 'Baloo 2';line-height:1.2;padding:6px 18px 0}
.md-row{display:flex;gap:10px;width:100%}
.md-row .big{flex:1;padding:10px 8px;font-size:20px}
.big.grey{background:linear-gradient(#c9d3df,#97a6b8);box-shadow:0 7px 0 #6b7a8c}
.iconbtn.mute{position:absolute;top:calc(12px + env(safe-area-inset-top));right:12px}
.md-mute{position:absolute;top:8px;right:8px;transform:scale(.8)}

/* character style picker */
.style-pick{display:flex;gap:4px;padding:4px;background:rgba(20,36,61,.55);border-radius:999px;margin-top:-6px}
.style-pick button{border:none;border-radius:999px;padding:5px 14px;font:800 14px 'Baloo 2';color:#fff;background:transparent;cursor:pointer}
.style-pick button.on{background:#fff;color:var(--ink);box-shadow:0 2px 0 rgba(0,0,0,.2)}

/* ===== compact gameplay HUD (more room for the board) ===== */
.hud{padding:8px 10px}
#hudTop{gap:6px}
#hudTop .iconbtn{width:40px;height:40px}
.card.opp{padding:4px 8px 4px 4px;gap:8px;border-width:2px;border-radius:14px}
.card.opp .avatar{width:34px;height:34px;border-radius:10px}
.card.opp .name{font-size:14px;padding-right:0}
.card.opp .stats{margin-top:0;align-items:center}
.card.opp .stats .pill:last-child{display:none}            /* steps: already shown as badge on the board */
.card.opp .boosts{position:static;margin-left:auto}
.card.opp .info{display:flex;align-items:center;gap:6px}
.card.opp .info .name{flex:1;min-width:0}
.card.opp .boosts img{width:18px;height:18px}
.card.active{transform:none}
/* my card → slim status strip: name · hint · timer */
#hudBottom{gap:8px}
.card.me{padding:4px 12px;min-height:32px;border-radius:12px;border-width:2px;gap:8px}
.card.me .avatar,.card.me .stats{display:none}
.card.me .info{flex:none}
.card.me .name{font-size:14px;display:flex;align-items:center;gap:5px}
.card.me .name::before{content:'';width:9px;height:9px;border-radius:50%;background:var(--blue)}
#hint{flex:1;min-width:0;text-align:right;color:#405068;text-shadow:none;font-size:12.5px;font-weight:700;min-height:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.card.me .bubble{left:12px}
/* action row: one 56px line, captions inside the buttons */
.actions{align-items:stretch;gap:8px}
.fencebtn{height:56px;max-width:none}
.orb{width:74px;height:56px;border-radius:18px;margin-bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:0;box-shadow:0 0 0 3px #fff,0 0 14px rgba(255,46,147,.6),0 5px 0 3px #9c0f52}
.orb img{width:28px;height:28px}
.orb .cap{position:static;transform:none;font-size:11px;line-height:1.1}
.orb.on{box-shadow:0 0 0 3px #ffd23f,0 0 22px rgba(255,210,63,.95),0 5px 0 3px #9c0f52}
.orb:disabled{box-shadow:0 0 0 3px #e3e3e3,0 5px 0 3px #8a8a8a}
.chat{height:56px;width:48px;margin-bottom:0}
.confirm{min-height:56px;padding:4px}
.cf{height:46px}
@media (max-height:700px){.orb{width:66px;height:52px}.fencebtn{height:52px}}
.card.opp .stats .pill:first-child:not(.fence){display:none}   /* trophies live on the VS / result screens */
/* UX round: rotate fence, turn label, countdown */
.cf.rot{width:48px;font-size:24px;background:linear-gradient(#ffc15e,#ff8a1f);box-shadow:0 4px 0 #b8560c}
.card.me.active .name{color:#1f6fd1}
.tleft{font:800 14px 'Baloo 2';color:#e11d2a;white-space:nowrap}
.tleft:empty{display:none}
.card.me.warn{border-color:#ff2d2d;animation:warnPulse .5s ease-in-out infinite alternate}
@keyframes warnPulse{to{box-shadow:0 0 0 3px rgba(255,45,45,.35),0 4px 0 rgba(0,0,0,.18)}}

/* settings */
#settings{z-index:40}
.panel.set{gap:10px;max-width:320px}
.panel.set h2{margin:0}
.tg{width:100%;display:flex;align-items:center;justify-content:space-between;border:none;background:#eef3f9;border-radius:14px;padding:10px 14px;font:800 17px 'Baloo 2';color:var(--ink);cursor:pointer}
.tg i{position:relative;width:48px;height:28px;border-radius:14px;background:#c3cdd9;transition:background .2s;flex:none}
.tg i::after{content:'';position:absolute;top:3px;left:3px;width:22px;height:22px;border-radius:50%;background:#fff;box-shadow:0 2px 3px rgba(0,0,0,.25);transition:transform .2s}
.tg.on i{background:#3fb53a}
.tg.on i::after{transform:translateX(20px)}
.big.set-how{width:100%;padding:10px;font-size:20px;background:linear-gradient(#5ab8ff,#2f86e8);box-shadow:0 6px 0 #1a5aa8}

/* ---------- character customize ---------- */
.cu-open{border:none;border-radius:999px;padding:6px 18px;font:800 15px 'Baloo 2';color:#fff;background:rgba(20,36,61,.55);cursor:pointer;margin-top:-6px;box-shadow:0 3px 0 rgba(0,0,0,.2)}
.cu-open:active{transform:translateY(2px)}
#custom{justify-content:flex-start;gap:10px;overflow-y:auto;padding-top:calc(14px + env(safe-area-inset-top))}
.cu-stage{position:relative;width:200px;height:230px;flex:none;touch-action:none;cursor:grab}
.cu-stage canvas{width:100%;height:100%}
.cu-hint{position:absolute;bottom:0;left:0;right:0;text-align:center;font:700 12px 'Baloo 2';color:rgba(255,255,255,.85);text-shadow:0 1px 2px rgba(0,0,0,.4)}
.cu-opts{width:100%;max-width:420px;display:flex;flex-direction:column;gap:8px;flex:none}
.cu-row{background:rgba(255,255,255,.92);border-radius:16px;padding:7px 10px;box-shadow:0 4px 0 rgba(20,36,61,.18)}
.cu-row h3{margin:0 0 5px;font:800 14px 'Baloo 2';color:var(--ink)}
.cu-list{display:flex;flex-wrap:wrap;gap:6px}
.cu-chip{border:2px solid #d6e0ec;border-radius:12px;background:#fff;padding:3px 10px;font:700 14px 'Baloo 2';color:var(--ink);cursor:pointer}
.cu-chip.on{border-color:#2f86e8;background:#e6f2ff}
.cu-sw{width:30px;height:30px;border-radius:50%;border:3px solid #fff;box-shadow:0 0 0 2px #d6e0ec;cursor:pointer;padding:0;display:grid;place-items:center;font:800 14px 'Baloo 2';color:#8a96a8;background:#fff}
.cu-sw.on{box-shadow:0 0 0 3px #2f86e8}
.cu-done{flex:none;min-width:220px;margin-bottom:12px}
@media (max-height:700px){.cu-stage{height:180px;width:160px}}

/* ---------- game modes ---------- */
.modes{display:flex;gap:8px;width:100%;max-width:340px;justify-content:center}
.modes button{flex:1;border:none;border-radius:16px;padding:6px 4px 7px;font:800 13px 'Baloo 2';color:#fff;background:linear-gradient(var(--mc),var(--md));box-shadow:0 4px 0 rgba(0,0,0,.25);opacity:.62;transform:scale(.94);transition:transform .15s,opacity .15s;cursor:pointer;display:flex;flex-direction:column;align-items:center;line-height:1.1;text-shadow:0 1px 0 rgba(0,0,0,.25)}
.modes button .mi{font-size:22px;line-height:1.2}
.modes button.on{opacity:1;transform:scale(1.04);box-shadow:0 0 0 3px #fff,0 5px 0 3px rgba(0,0,0,.22)}
#home{gap:10px}
#home .duo{height:180px}#home .duo canvas{width:160px;height:180px}
@media (max-height:740px){#home .duo{height:130px}#home .duo canvas{width:120px;height:130px}}
/* 4-player HUD: three compact chips */
.qopps{flex:1;display:flex;gap:5px;min-width:0}
.qchip{position:relative;flex:1;min-width:0;display:flex;align-items:center;gap:4px;padding:3px 5px 5px 3px;border-radius:12px;background:rgba(255,255,255,.94);border:2px solid var(--tc);box-shadow:0 3px 0 rgba(0,0,0,.18);transition:transform .2s,box-shadow .2s}
.qchip.active{transform:scale(1.06);box-shadow:0 0 0 2px #fff,0 0 12px var(--tc)}
.qchip .qav{width:28px;height:28px;border-radius:8px;flex:none;background:var(--tc);object-fit:cover}
.qchip .qi{min-width:0;display:flex;flex-direction:column;line-height:1.05}
.qchip b{font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--ink)}
.qchip span{font-size:11px;font-weight:700;color:#5a6a80;display:flex;align-items:center;gap:1px;white-space:nowrap}
.qchip span img{width:14px;height:14px}
.qchip .timer{left:6px;right:6px;bottom:2px;height:3px}
.qchip.active .timer{opacity:1}
.qchip .timer i{background:var(--tc)}
.qchip .bubble{left:0;top:100%;margin-top:6px;font-size:13px}
.quad .ping{display:none}
.res-goals li.me{font-weight:800;color:var(--blue)}
.practice .ping{display:none}

/* ---------- VS screen, 4 players ---------- */
#versus4{gap:12px;padding:12px}
.v4{position:relative;display:grid;grid-template-columns:1fr 1fr;gap:6px;width:100%;max-width:420px;flex:none}
.v4q{position:relative;height:min(31vh,250px);border-radius:20px;background:linear-gradient(160deg,var(--qa),var(--qb));box-shadow:0 6px 0 rgba(0,0,0,.2);overflow:hidden;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;padding-bottom:8px}
.v4q::before{content:'';position:absolute;inset:0;background:repeating-linear-gradient(135deg,rgba(255,255,255,.09) 0 14px,transparent 14px 28px)}
.v4q canvas{position:absolute;left:0;right:0;top:4px;margin:auto;width:100%;height:calc(100% - 40px)}
.v4q[data-p="1"]{animation:v4a .5s cubic-bezier(.3,1.4,.6,1) both}
.v4q[data-p="2"]{animation:v4b .5s .08s cubic-bezier(.3,1.4,.6,1) both}
.v4q[data-p="3"]{animation:v4c .5s .16s cubic-bezier(.3,1.4,.6,1) both}
.v4q[data-p="0"]{animation:v4d .5s .24s cubic-bezier(.3,1.4,.6,1) both}
@keyframes v4a{from{transform:translate(-110%,-60%)}}@keyframes v4b{from{transform:translate(110%,-60%)}}
@keyframes v4c{from{transform:translate(-110%,60%)}}@keyframes v4d{from{transform:translate(110%,60%)}}
.v4n{position:relative;z-index:1;background:#fff;border-radius:12px;padding:2px 10px;font:800 15px 'Baloo 2';color:var(--ink);box-shadow:0 3px 0 rgba(0,0,0,.18);max-width:92%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.v4n small{font-size:12px;color:#7a8799;margin-left:4px}
.v4vs{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);font:800 56px 'Baloo 2';line-height:.9;color:var(--gold);-webkit-text-stroke:4px var(--ink);paint-order:stroke fill;text-align:center;z-index:2;animation:v4vs .5s .45s both cubic-bezier(.3,1.8,.6,1);filter:drop-shadow(0 4px 0 rgba(0,0,0,.25))}
.v4vs span{display:block;font-size:30px;-webkit-text-stroke:0}
@keyframes v4vs{from{transform:translate(-50%,-50%) scale(0) rotate(-30deg)}}
.v4mode{font:800 14px 'Baloo 2';color:#fff;background:linear-gradient(#9b6bff,#6338c4);padding:4px 14px;border-radius:999px;box-shadow:0 3px 0 rgba(0,0,0,.2);animation:pop .4s 1s both}
/* ---------- result podium, 4 players ---------- */
.podium{display:flex;align-items:flex-end;justify-content:center;gap:4px;width:100%;margin:2px 0 4px}
.pd{flex:1;max-width:84px;display:flex;flex-direction:column;align-items:center}
.pd canvas{width:84px;height:100px;display:block;margin-bottom:-6px}
.pd .blk{width:100%;border-radius:10px 10px 4px 4px;font:800 22px 'Baloo 2';color:#fff;text-shadow:0 2px 0 rgba(0,0,0,.25);display:grid;place-items:center;box-shadow:inset 0 -5px 0 rgba(0,0,0,.15)}
.pd.p1 canvas{width:96px;height:114px}
.pd.p1 .blk{height:62px;background:linear-gradient(#ffd84a,#f0a800)}
.pd.p2 .blk{height:44px;background:linear-gradient(#dfe7f1,#9fb0c6)}
.pd.p3 .blk{height:30px;background:linear-gradient(#f3b98a,#c9773e)}
.pd.p4 .blk{height:18px;font-size:14px;background:linear-gradient(#c9d3df,#97a6b8)}
.pd.p4{opacity:.85}
.res-goals li .d{float:right;font-weight:800}
.res-goals li .d.up{color:#26a64a}.res-goals li .d.dn{color:#e0392a}
.res-goals li .d{margin-left:10px}
#podium:not(.hidden) ~ .res-goals{width:100%;max-width:280px}

/* ---------- level select (concept) ---------- */
.lv-head{padding-top:env(safe-area-inset-top)}
.lv-title{display:flex;flex-direction:column;align-items:center;line-height:1;-webkit-text-stroke:2px var(--ink);paint-order:stroke fill}
.lv-sub{margin-top:4px;font:800 12px 'Baloo 2';-webkit-text-stroke:0;text-shadow:none;background:linear-gradient(#2f86e8,#1a5aa8);padding:2px 10px;border-radius:999px;box-shadow:0 2px 0 rgba(0,0,0,.2)}
.lv-stars{font:800 15px 'Baloo 2';box-shadow:0 3px 0 rgba(0,0,0,.18)}
.lv-grid{padding-top:56px;gap:14px 10px}
.lv{position:relative;border-radius:14px;background:linear-gradient(#6fc1ff 0%,#3b93ea 55%,#2a78d2 100%);box-shadow:inset 0 3px 0 rgba(255,255,255,.45),0 5px 0 #1b4f93;font-size:24px;-webkit-text-stroke:1.5px #154078;paint-order:stroke fill;justify-content:flex-start;padding-top:8%}
.lv .st{position:absolute;bottom:-9px;left:0;right:0;font-size:13px;letter-spacing:0;-webkit-text-stroke:1px #a86b00;text-shadow:none}
.lv .st i{color:#dfe7f1;-webkit-text-stroke:1px #9aa9bd}
.lv.cur{background:linear-gradient(#ffe066,#ffb000);box-shadow:inset 0 3px 0 rgba(255,255,255,.55),0 5px 0 #c47a00,0 0 0 3px #fff;-webkit-text-stroke:1.5px #9a5a00;animation:none;z-index:2}
.lv.lock{background:linear-gradient(#b3bfcf,#8c9bb0);box-shadow:inset 0 3px 0 rgba(255,255,255,.35),0 5px 0 #5e6d82;-webkit-text-stroke:1.5px #5e6d82;color:#eef2f7;font-size:20px}
.lv.lock::after{content:'🔒';position:absolute;bottom:5%;font-size:13px;-webkit-text-stroke:0}
.lv.boss{background:linear-gradient(#ffe9a6,#f3c14a);box-shadow:inset 0 3px 0 rgba(255,255,255,.6),0 5px 0 #b07a12;-webkit-text-stroke:1.5px #8a5a00;font-size:16px}
.lv.boss::before{content:'🏆';font-size:22px;-webkit-text-stroke:0;line-height:1}
.lv.boss.lock{background:linear-gradient(#d9cfae,#b5a67a);box-shadow:inset 0 3px 0 rgba(255,255,255,.4),0 5px 0 #7d7150}
.lv.boss.lock::after{content:none}
.lv-hero{position:absolute;width:58px;height:68px;left:50%;bottom:44%;transform:translateX(-50%);pointer-events:none;z-index:3}
.lv.cur{justify-content:flex-end;padding:0 0 6%;font-size:20px}
/* ---------- matchmaking (concept) ---------- */
.mm-mode{font:800 15px 'Baloo 2';color:#fff;padding:4px 16px;border-radius:999px;background:linear-gradient(var(--mc,#2f86e8),var(--md,#1a5aa8));box-shadow:0 3px 0 rgba(0,0,0,.2)}
.mm-slots{display:flex;gap:10px;justify-content:center}
.mslot{width:62px;display:flex;flex-direction:column;align-items:center;gap:2px;font:800 13px 'Baloo 2';color:#fff;text-shadow:0 2px 0 rgba(0,0,0,.3)}
.mslot .av{width:58px;height:58px;border-radius:50%;border:4px solid var(--tc,#fff);background:#fff;overflow:hidden;box-shadow:0 4px 0 rgba(0,0,0,.2);display:grid;place-items:center}
.mslot .av img{width:100%;height:100%;object-fit:cover}
.mslot.empty .av{background:rgba(255,255,255,.18);border:3px dashed rgba(255,255,255,.9);box-shadow:none;font-size:24px;color:#fff}
.mslot.empty .nm::before{content:'';display:inline-block;width:10px;height:10px;border:2px solid #fff;border-top-color:transparent;border-radius:50%;animation:spin .8s linear infinite}
.mslot.in .av{animation:pop .35s cubic-bezier(.3,1.8,.6,1)}
.mslot .nm{max-width:64px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
@keyframes spin{to{transform:rotate(360deg)}}
.tip{display:flex;align-items:center;gap:8px;text-align:left;box-shadow:0 4px 0 rgba(0,0,0,.12)}
/* ---------- settings (concept) ---------- */
.panel.set{gap:8px;padding:16px 16px 12px}
.set-x{position:absolute;top:10px;right:10px;width:34px;height:34px;border-radius:50%;border:none;background:linear-gradient(#ff7a6a,#e0392a);color:#fff;font:800 17px 'Baloo 2';box-shadow:0 3px 0 #a52418;cursor:pointer}
.tg{padding:6px 10px 6px 6px;box-shadow:inset 0 -2px 0 rgba(0,0,0,.06)}
.tg span{display:flex;align-items:center;gap:10px}
.tg .ic{width:32px;height:32px;border-radius:10px;display:grid;place-items:center;font-size:17px;background:color-mix(in srgb,var(--ic) 22%,#fff);box-shadow:inset 0 0 0 2px color-mix(in srgb,var(--ic) 40%,#fff)}
.set-how-box{width:100%;background:#eef3f9;border-radius:16px;padding:6px 8px 8px;margin-top:4px}
.set-cap{font:800 14px 'Baloo 2';margin:-16px auto 6px;width:max-content;background:#fff;border-radius:999px;padding:1px 14px;box-shadow:0 2px 0 rgba(0,0,0,.1)}
.mcards{display:flex;gap:6px}
.mcard{flex:1;border:none;border-radius:12px;background:#fff;padding:0 0 6px;overflow:hidden;cursor:pointer;box-shadow:0 3px 0 rgba(0,0,0,.12);display:flex;flex-direction:column;align-items:center;font:700 11px 'Baloo 2';color:var(--ink);line-height:1.15}
.mcard .mh{width:100%;padding:2px 0;color:#fff;font:800 12px 'Baloo 2';background:linear-gradient(var(--mc),var(--md))}
.mcard svg{width:62px;height:62px;margin:4px 0 2px}
.mcard .mt{padding:0 4px}
.set-ver{font-size:12px;color:#8a99ad;font-weight:700}

/* ---------- friends room ---------- */
.home-pills{display:flex;gap:8px;margin-top:-6px}
.home-pills .cu-open{margin-top:0}
#room{justify-content:flex-start;gap:10px;padding-top:calc(12px + env(safe-area-inset-top))}
.room-sp{width:40px;flex:none}
button.lv-sub{border:none;color:#fff;cursor:pointer}
button.lv-sub::after{content:' ▾'}
.lv-subs{display:flex;gap:6px;justify-content:center;flex-wrap:wrap}
#roomObst{background:linear-gradient(#5cb85c,#2e8b3e)}
#roomObst.off{background:linear-gradient(#8a99ad,#5d6b7e)}
.room-code{display:flex;gap:8px;width:100%;max-width:400px}
.rc-box{flex:1;display:flex;align-items:center;justify-content:center;gap:6px;background:#fff;border-radius:14px;padding:6px 10px;font:700 15px 'Baloo 2';box-shadow:0 3px 0 rgba(0,0,0,.15)}
.rc-box b{font-size:19px;letter-spacing:2px}
.rc-box button{border:none;background:#eef3f9;border-radius:8px;width:30px;height:28px;font:800 15px 'Baloo 2';color:var(--ink);cursor:pointer}
.rc-inv{border:none;border-radius:14px;padding:6px 14px;font:800 15px 'Baloo 2';color:#fff;background:linear-gradient(#7be05a,#3fb53a);box-shadow:0 4px 0 #2a7f27;cursor:pointer;white-space:nowrap}
.rc-inv:active{transform:translateY(2px);box-shadow:0 2px 0 #2a7f27}
.room-grid{display:grid;grid-template-columns:1fr 1fr;gap:6px 10px;width:100%;max-width:400px}
.seat{position:relative;height:208px;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;padding-bottom:4px}
.seat canvas{position:absolute;left:0;right:0;top:0;margin:auto;width:130px;height:150px;z-index:2}
.ped{position:absolute;left:50%;bottom:58px;width:128px;height:38px;transform:translateX(-50%);border-radius:50%;background:radial-gradient(ellipse at 50% 35%,#fff 0 46%,var(--tc) 48% 100%);box-shadow:0 9px 0 color-mix(in srgb,var(--tc) 70%,#000),0 14px 14px rgba(0,0,0,.25)}
.seat-n{position:relative;z-index:3;background:#fff;border-radius:10px;padding:1px 10px;font:800 15px 'Baloo 2';box-shadow:0 3px 0 rgba(0,0,0,.15);max-width:96%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.seat-st{position:relative;z-index:3;margin-top:3px;font:800 12px 'Baloo 2';color:#fff;padding:1px 10px;border-radius:999px;background:#3fb53a;box-shadow:0 2px 0 rgba(0,0,0,.2)}
.seat-st.wait{background:#ff9a2a}
.seat-add{display:none}
.seat.empty canvas,.seat.empty .seat-n,.seat.empty .seat-st,.seat.empty .ped{display:none}
.seat.empty .seat-add{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;position:absolute;inset:14px 10px 10px;border:3px dashed rgba(255,255,255,.95);border-radius:50%/40%;background:rgba(255,255,255,.22);font:800 42px 'Baloo 2';line-height:1;color:#fff;text-shadow:0 2px 0 rgba(0,0,0,.25);cursor:pointer}
.seat.empty .seat-add small{font-size:12px;line-height:1.2;text-align:center}
.seat-x{display:none;position:absolute;top:4px;right:6px;z-index:4;width:26px;height:26px;border-radius:50%;border:none;background:rgba(20,36,61,.6);color:#fff;font:800 13px 'Baloo 2';cursor:pointer}
.seat.guest .seat-x{display:block}
.room-two .seat{height:230px}
.room-msg{min-height:20px;font:700 14px 'Baloo 2';color:#fff;text-shadow:0 2px 0 rgba(0,0,0,.3);text-align:center}
#btnRoomStart{min-width:250px}
#btnRoomStart:disabled{filter:grayscale(.7);opacity:.75}
@media (max-height:740px){.seat{height:180px}.seat canvas{height:124px;width:110px}.ped{bottom:54px;width:110px}}
/* ---------- friends room: online (server) bits ---------- */
#roomNet{display:flex;align-items:center;justify-content:center;font-size:16px}
.room-join{display:flex;gap:8px;width:100%;max-width:400px}
.room-join input{flex:1;min-width:0;border:none;border-radius:14px;padding:7px 12px;font:700 15px 'Baloo 2';color:var(--ink);background:rgba(255,255,255,.92);box-shadow:inset 0 2px 0 rgba(0,0,0,.08);letter-spacing:1px}
.room-join input::placeholder{letter-spacing:0;color:#7d8aa0}
.room-join button{border:none;border-radius:14px;padding:6px 18px;font:800 15px 'Baloo 2';color:#fff;background:linear-gradient(#5ab8ff,#2f86e8);box-shadow:0 4px 0 #1a5aa8;cursor:pointer}
.room-join button:active{transform:translateY(2px);box-shadow:0 2px 0 #1a5aa8}
.guest-view .seat.empty .seat-add{cursor:default}
.guest-view .seat.empty .seat-add small{visibility:hidden}
.seat-n{cursor:default}
.seat[data-i="0"] .seat-n{cursor:pointer}
@media (max-height:740px){.room-join input,.room-join button{padding-top:4px;padding-bottom:4px}}

/* ===== in-match HUD, option A: one VS bar on top (me left · opponent right) ===== */
#hudTop{align-items:flex-start}
.vsbar{flex:1;min-width:0;display:flex;align-items:stretch;gap:0;position:relative}
.hs{position:relative;flex:1;min-width:0;display:flex;align-items:center;gap:6px;padding:4px 8px 4px 4px;
  background:linear-gradient(#3d9cf0,#1f6fd1);border:2.5px solid #fff;color:#fff;box-shadow:0 4px 0 rgba(0,0,0,.18);transition:transform .2s,box-shadow .2s,filter .2s}
.hs.me{border-radius:999px 14px 14px 999px;margin-right:-10px}
.hs.opp{flex-direction:row-reverse;padding:4px 4px 4px 8px;border-radius:14px 999px 999px 14px;margin-left:-10px;background:linear-gradient(#ff7a8e,#e0394f)}
.hs.opp .hi{align-items:flex-end;text-align:right}
.hs:not(.active){filter:saturate(.75) brightness(.95)}
.hs.active{box-shadow:0 0 0 2px rgba(255,255,255,.9),0 0 16px var(--tc),0 4px 0 rgba(0,0,0,.18);z-index:1}
.hav{position:relative;width:44px;height:44px;flex:none}
.hav img{position:absolute;inset:4px;width:36px;height:36px;border-radius:50%;object-fit:cover;background:rgba(255,255,255,.35)}
.hav svg{position:absolute;inset:0;width:100%;height:100%;transform:rotate(-90deg)}
.hav circle{fill:none;stroke-width:3.4}
.hav .rbg{stroke:rgba(255,255,255,.35)}
.hav .rfg{stroke:#fff;stroke-linecap:round;stroke-dasharray:100;stroke-dashoffset:0;opacity:0;transition:stroke .2s}
.hs.active .rfg{opacity:1}
.hav .rfg.low{stroke:#ffe14a}
.hi{min-width:0;display:flex;flex-direction:column;line-height:1.1}
.hn{font:800 14px 'Baloo 2',sans-serif;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%;text-shadow:0 1px 0 rgba(0,0,0,.25)}
.hst{display:flex;align-items:center;gap:3px;margin-top:1px}
.hst .hfb{display:flex;align-items:center;gap:2px;background:rgba(0,0,0,.22);border-radius:999px;padding:0 6px 0 4px;font:800 13px 'Baloo 2';font-style:normal}
.hst img{width:16px;height:16px;object-fit:contain}
.hst .hfb img{width:15px;height:13px}
.hst img.used,.hst .sk.used img{filter:grayscale(1);opacity:.35}
.sk{display:inline-flex;align-items:center}.hfm,.fbar,.sk em{display:none}
.vsmid{position:relative;z-index:2;align-self:center;flex:none;width:34px;height:34px;border-radius:50%;display:grid;place-items:center;
  background:linear-gradient(#ffe066,#ffb300);border:2.5px solid #fff;font:900 13px 'Baloo 2';color:#7a3d00;box-shadow:0 3px 0 rgba(0,0,0,.2)}
/* 4 players: four compact seats in one row */
.quad .vsbar{gap:5px}
.quad .hs{flex-direction:column;gap:1px;padding:4px 2px 3px;border-radius:14px;margin:0;background:linear-gradient(color-mix(in srgb,var(--tc) 75%,#fff),var(--tc))}
.quad .hs .hi{align-items:center;text-align:center}
.quad .hav{width:36px;height:36px}.quad .hav img{inset:3px;width:30px;height:30px}
.quad .hn{font-size:11.5px}
.quad .hst img:not(.hfb img){width:13px;height:13px}
.quad .hst .hfb{font-size:11.5px;padding:0 4px 0 3px}
.ping{position:absolute;right:12px;top:calc(100% - 4px);font-size:11px;padding:1px 7px}
.solo .ping{top:calc(100% - 2px)}
/* bottom: just the turn line + buttons */
.card.me .timer{display:none}
/* chat bubbles over the pawns */
#bubbles{position:absolute;inset:0;pointer-events:none;z-index:4;overflow:hidden}
.pbub{position:absolute;left:0;top:0;max-width:150px;padding:5px 11px;border-radius:14px;background:#fff;color:var(--ink);font:800 14px/1.2 'Baloo 2',sans-serif;
  box-shadow:0 3px 0 rgba(0,0,0,.12),0 6px 14px rgba(0,0,0,.18);border:2.5px solid var(--tc,#fff);opacity:0;transform-origin:var(--tx,50%) 100%;transition:opacity .15s;white-space:normal;overflow-wrap:anywhere;text-align:center}
.pbub::after{content:'';position:absolute;left:var(--tx,50%);bottom:-8px;width:12px;height:12px;margin-left:-6px;background:#fff;border:solid var(--tc,#fff);border-width:0 2.5px 2.5px 0;transform:rotate(45deg)}
.pbub.down{transform-origin:var(--tx,50%) 0}
.pbub.down::after{bottom:auto;top:-8px;border-width:2.5px 0 0 2.5px}
.pbub.show{opacity:1;animation:bubPop .28s cubic-bezier(.3,1.6,.6,1)}
@keyframes bubPop{from{scale:.5}}

/* ===== in-match action buttons, redesigned by Codex (docs/buttons_codex.css) ===== */
/* Kích thước chung cho hai thanh thao tác */
#hudBottom {
  --action-height: 54px;
  --action-depth: 5px;
  --action-icon: 26px;
  --action-round: 60px;
  --action-gap: 8px;
}

#hudBottom #actions,
#hudBottom #confirm {
  display: flex;
  align-items: center;
  gap: var(--action-gap);
  box-sizing: border-box;
  min-height: calc(var(--action-height) + var(--action-depth));
  padding: 0 0 var(--action-depth);
}

#hudBottom #actions {
  justify-content: center;
}

#hudBottom #confirm {
  padding-inline: 5px;
  border-radius: 20px;
  background: linear-gradient(#fff, #e6eef9);
  box-shadow: inset 0 0 0 2px #fff, 0 3px 0 rgb(20 36 61 / .22);
}

/* Mặt bóng, viền trắng và đáy nổi */
#hudBottom :is(#actions, #confirm) > :is(.act, .cf) {
  --depth: var(--action-depth);
  --ring: 0 0 0 0 transparent;
  --glow: 0 0 0 transparent;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 0;
  max-width: none;
  height: var(--action-height);
  margin: 0;
  padding: 0;
  appearance: none;
  border: 2px solid #fff;
  border-radius: 18px;
  outline: none;
  outline-offset: 0;
  background:
    radial-gradient(ellipse 48% 56% at 24% 0%, rgb(255 255 255 / .48), transparent),
    linear-gradient(var(--face-top), var(--face-bottom));
  box-shadow:
    inset 0 2px 0 rgb(255 255 255 / .32),
    inset 0 -3px 0 rgb(20 36 61 / .13),
    0 var(--depth) 0 var(--base),
    0 calc(var(--depth) + 3px) 5px rgb(20 36 61 / .26),
    var(--ring),
    var(--glow);
  color: #fff;
  font: 800 16px/1 'Baloo 2', system-ui, sans-serif;
  text-shadow: 0 1px 2px var(--base), 0 1px 0 var(--base);
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .09s ease-out, box-shadow .12s ease-out, border-color .12s ease-out;
}

#hudBottom #actions > .fencebtn {
  --face-top: #ffc050;
  --face-bottom: #ec680a;
  --base: #a74608;
  flex: 1;
  gap: 5px;
  padding-inline: 7px 14px;
  font-size: 16px;
}

#hudBottom #actions > .orb {
  flex-direction: column;
  gap: 1px;
  width: var(--action-round);
  border-radius: 999px;
  animation: none;
}

#hudBottom #actions > :where(#btnDash) {
  --face-top: #ff82be;
  --face-bottom: #c72579;
  --base: #891653;
}

#hudBottom #actions > :where(#btnTor) {
  --face-top: #56e7cc;
  --face-bottom: #008679;
  --base: #005c55;
}

#hudBottom #actions > .chat {
  --face-top: var(--blue, #3a9cff);
  --face-bottom: #175dc8;
  --base: #10448d;
  width: var(--action-height);
  border-radius: 999px;
  font-size: 23px;
}

:is(.solo, .practice) #hudBottom #actions > #btnChat,
#hudBottom:is(.solo, .practice) #actions > #btnChat {
  display: none;
}

#hudBottom #actions > .act > img {
  display: block;
  flex: none;
  width: var(--action-icon);
  height: var(--action-icon);
  object-fit: contain;
  filter: drop-shadow(0 2px 1px rgb(20 36 61 / .32));
}

#hudBottom #actions > .fencebtn > img {
  width: clamp(26px, 8vw, 34px);
  height: clamp(26px, 8vw, 34px);
}

#hudBottom #actions > .orb > .cap {
  position: static;
  inset: auto;
  transform: none;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

#hudBottom #actions > .act > .badge {
  position: absolute;
  top: -4px;
  right: -3px;
  display: grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 0 rgb(20 36 61 / .25);
  color: var(--ink, #14243d);
  font: 800 12px/1 'Baloo 2', system-ui, sans-serif;
  text-shadow: none;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* Thanh xác nhận vị trí rào */
#hudBottom #confirm > .cf {
  height: calc(var(--action-height) - 8px);
  border-radius: 14px;
}

#hudBottom #confirm > .cf.no {
  --face-top: #ff8c9b;
  --face-bottom: var(--red, #ff5a4a);
  --base: #a32c3a;
  width: 44px;
}

#hudBottom #confirm > .cf.rot {
  --face-top: #ffc050;
  --face-bottom: #ec680a;
  --base: #a74608;
  width: 44px;
  font-size: 24px;
}

#hudBottom #confirm > .cf.yes {
  --face-top: #75dc71;
  --face-bottom: #288839;
  --base: #1b6229;
  padding-inline: 12px;
}

#hudBottom #confirm > .cf-info {
  flex: 1;
  min-width: 0;
  color: var(--ink, #14243d);
  text-align: center;
  overflow-wrap: anywhere;
  font: 700 12px/1.15 'Baloo 2', system-ui, sans-serif;
}

#hudBottom #confirm > .cf-info b {
  font-size: 14px;
}

#hudBottom #confirm .good {
  color: #087544;
}

#hudBottom #confirm .badv {
  color: #b51c36;
}

/* Đang chọn, nhấn lún và hết lượt */
#hudBottom #actions > .act.on:enabled {
  --ring: 0 0 0 1px #ffd34d;
  --glow: 0 0 12px rgb(255 205 61 / .82);
  border-color: #ffe272;
  z-index: 1;
}

#hudBottom :is(#actions, #confirm) > :is(.act, .cf):enabled:active {
  --depth: 1px;
  transform: translateY(calc(var(--action-depth) - var(--depth)));
}

#hudBottom :is(#actions, #confirm) > :is(.act, .cf):focus-visible {
  outline: 2px solid var(--ink, #14243d);
  outline-offset: 3px;
}

#hudBottom :is(#actions, #confirm) > :is(.act, .cf):disabled {
  --face-top: #a0a6af;
  --face-bottom: #59616c;
  --base: #414853;
  border-color: #e9edf2;
  filter: none;
  opacity: 1;
  cursor: default;
}

#hudBottom #actions > .act:disabled > img {
  filter: grayscale(1) drop-shadow(0 2px 1px rgb(20 36 61 / .35));
}

@media (max-height: 700px) {
  #hudBottom {
    --action-height: 48px;
    --action-depth: 4px;
    --action-icon: 23px;
    --action-round: 56px;
    --action-gap: 7px;
  }
}

/* ===== UI redesign A (Codex): tokens, primitives, home, modal, settings, how ===== */

:root {
  --ui-ink: #1f3354;
  --ui-sub: #5d6f8c;
  --ui-panel-top: #ffffff;
  --ui-panel-bot: #eaf2fd;
  --ui-panel-edge: #b8c9e2;
  --ui-radius: 26px;
  --ui-depth: 6px;

  --b-top: #5fb6ff;
  --b-bot: #1f74e0;
  --b-base: #1550a8;
  --g-top: #8be86a;
  --g-bot: #34ad3a;
  --g-base: #247a29;
  --o-top: #ffc95a;
  --o-bot: #f07c12;
  --o-base: #a94c07;
  --gr-top: #c3cfdd;
  --gr-bot: #8796ab;
  --gr-base: #5f6d82;
  --r-top: #ff8a8a;
  --r-bot: #e23b4a;
  --r-base: #9e1f2c;
  --p-top: #b48cff;
  --p-bot: #7a4ae6;
  --p-base: #4f2aa6;

  --ui-navy-top: #476c9c;
  --ui-navy-bot: #213b60;
  --ui-navy-base: #10213b;
  --ui-gloss: radial-gradient(ellipse 65% 85% at 20% 0%, rgb(255 255 255 / .48), transparent 76%);
}

/* Nút bóng và đáy nổi */
:is(.big, .big.green, .big.grey),
#app .iconbtn,
#home .home-pills .cu-open,
#home #modePick > button,
#settings .set-x,
#settings #setHow {
  --offset: var(--depth);
  --press: 0px;
  --ring: 0 0 0 0 transparent;
  appearance: none;
  border: 2px solid var(--button-edge, #fff);
  background: var(--ui-gloss), linear-gradient(var(--face-top), var(--face-bot));
  box-shadow:
    inset 0 2px 0 rgb(255 255 255 / .24),
    inset 0 -2px 0 rgb(20 36 61 / .12),
    0 var(--offset) 0 var(--base),
    0 calc(var(--offset) + 3px) 8px rgb(16 33 59 / .24),
    var(--ring);
  color: #fff;
  text-shadow: 0 1px 0 var(--base), 0 2px 3px var(--base);
  transform: translateY(var(--press));
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .09s ease-out, box-shadow .12s ease-out, border-color .12s ease-out;
}

:is(.big, .big.green, .big.grey):active:not(:disabled),
#app .iconbtn:active:not(:disabled),
#home .home-pills .cu-open:active,
#home #modePick > button:active,
#settings .set-x:active,
#settings #setHow:active:not(:disabled) {
  --offset: 0px;
  --press: var(--depth);
}

.big {
  --face-top: var(--o-top);
  --face-bot: var(--o-bot);
  --base: var(--o-base);
  --depth: var(--ui-depth);
  min-height: 44px;
  padding: 9px clamp(14px, 5vw, 32px);
  border-radius: 19px;
  font: 800 clamp(19px, 5.5vw, 26px)/1.1 'Baloo 2', system-ui, sans-serif;
}

.big.green {
  --face-top: var(--g-top);
  --face-bot: var(--g-bot);
  --base: var(--g-base);
  justify-content: center;
  gap: 2px;
}

.big.grey {
  --face-top: var(--gr-top);
  --face-bot: var(--gr-bot);
  --base: var(--gr-base);
}

.big small {
  font: 800 clamp(12px, 3.5vw, 14px)/1.1 'Baloo 2', system-ui, sans-serif;
  opacity: 1;
}

.big:disabled {
  --offset: 2px;
  --face-top: var(--gr-top);
  --face-bot: var(--gr-bot);
  --base: var(--gr-base);
  opacity: .76;
  cursor: default;
}

#app .iconbtn {
  --face-top: var(--ui-navy-top);
  --face-bot: var(--ui-navy-bot);
  --base: var(--ui-navy-base);
  --depth: 4px;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 13px;
  font: 800 19px/1 'Baloo 2', system-ui, sans-serif;
}

.link,
.panel .link {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  padding: 6px 14px;
  border: 2px solid rgb(255 255 255 / .82);
  border-radius: 999px;
  background: var(--ui-gloss), linear-gradient(#3c6494, #294a73);
  box-shadow: 0 2px 0 var(--ui-navy-base);
  color: #fff;
  font: 800 15px/1.15 'Baloo 2', system-ui, sans-serif;
  text-shadow: 0 1px 2px var(--ui-navy-base);
  text-decoration: none;
  touch-action: manipulation;
}

.link:active {
  transform: translateY(2px);
  box-shadow: none;
}

:is(.big, .iconbtn, .link):focus-visible,
#home :is(.cu-open, #modePick > button):focus-visible,
#settings :is(.set-x, .tg, .mcard):focus-visible {
  outline: 2px solid var(--ui-ink);
  outline-offset: 2px;
}

.panel {
  padding: clamp(14px, 4vw, 22px);
  border: 2px solid #fff;
  border-radius: var(--ui-radius);
  background: linear-gradient(var(--ui-panel-top), var(--ui-panel-bot));
  box-shadow: 0 var(--ui-depth) 0 var(--ui-panel-edge), 0 12px 24px rgb(16 33 59 / .25);
  color: var(--ui-ink);
}

.panel h2 {
  margin: 0 0 8px;
  color: var(--ui-ink);
  font: 800 clamp(24px, 6.5vw, 30px)/1.08 'Baloo 2', system-ui, sans-serif;
  text-shadow: 0 2px 0 #fff;
}

.modal,
#how {
  padding:
    calc(10px + env(safe-area-inset-top, 0px))
    calc(12px + env(safe-area-inset-right, 0px))
    calc(16px + env(safe-area-inset-bottom, 0px))
    calc(12px + env(safe-area-inset-left, 0px));
}

.modal {
  background: rgb(13 29 52 / .59);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.modal > .panel,
.modal > .panel.md {
  min-width: 0;
  animation: ui-a-pop .3s both cubic-bezier(.22, .8, .28, 1);
}

@keyframes ui-a-pop {
  0% { opacity: 0; transform: translateY(9px) scale(.92); }
  72% { opacity: 1; transform: translateY(-2px) scale(1.018); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

#banner {
  top: max(21%, calc(env(safe-area-inset-top, 0px) + 84px));
  width: max-content;
  max-width: min(88vw, 420px);
  padding: 7px 17px;
  border: 2px solid #fff;
  background: var(--ui-gloss), linear-gradient(var(--ui-navy-top), var(--ui-navy-bot));
  box-shadow: 0 4px 0 var(--ui-navy-base), 0 8px 14px rgb(16 33 59 / .25);
  font: 800 clamp(15px, 4.6vw, 22px)/1.16 'Baloo 2', system-ui, sans-serif;
  text-align: center;
  text-shadow: 0 2px 0 var(--ui-navy-base);
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Trang chủ */
#home {
  --hero-height: clamp(106px, calc(27dvh - 55px), 206px);
  --home-gap: clamp(6px, calc(2dvh - 7px), 13px);
  gap: var(--home-gap);
  padding:
    calc(10px + env(safe-area-inset-top, 0px))
    calc(14px + env(safe-area-inset-right, 0px))
    calc(14px + env(safe-area-inset-bottom, 0px))
    calc(14px + env(safe-area-inset-left, 0px));
  background: linear-gradient(180deg, transparent 45%, rgb(15 46 40 / .24) 73%, rgb(15 42 34 / .48));
}

#home .logo img {
  display: block;
  width: min(69vw, 310px);
  height: auto;
  margin-inline: auto;
}

#home .logo .tag {
  margin-top: 3px;
  font: 800 clamp(13px, 3.8vw, 17px)/1.15 'Baloo 2', system-ui, sans-serif;
  text-shadow: 0 2px 0 #28486a, 0 3px 7px rgb(16 33 59 / .48);
}

#home .duo,
#home .duo canvas {
  height: var(--hero-height);
}

#home .duo canvas {
  width: calc(var(--hero-height) * .89);
}

#home #btnSettings {
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: calc(10px + env(safe-area-inset-right, 0px));
}

#home .home-pills,
#home #modePick {
  display: grid;
  width: min(100%, 352px);
  margin: 0 0 4px;
  gap: 8px;
}

#home .home-pills {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#home .home-pills .cu-open {
  --face-top: var(--ui-navy-top);
  --face-bot: var(--ui-navy-bot);
  --base: var(--ui-navy-base);
  --depth: 4px;
  min-height: 44px;
  margin: 0;
  padding: 4px 6px;
  border-radius: 999px;
  font: 800 clamp(13px, 3.75vw, 16px)/1.1 'Baloo 2', system-ui, sans-serif;
}

#home #modePick {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#home #modePick > button {
  --face-top: color-mix(in srgb, var(--mc) 70%, #fff);
  --face-bot: var(--mc);
  --base: var(--md);
  --depth: 4px;
  --button-edge: rgb(255 255 255 / .7);
  justify-content: center;
  gap: 2px;
  min-height: clamp(48px, 7.7dvh, 61px);
  padding: 4px 3px;
  border-radius: 14px;
  font: 800 clamp(12px, 3.4vw, 15px)/1.1 'Baloo 2', system-ui, sans-serif;
  opacity: 1;
}

#home #modePick > button.on {
  --face-top: color-mix(in srgb, var(--mc) 72%, #fff);
  --face-bot: var(--md);
  --base: color-mix(in srgb, var(--md) 78%, var(--ui-ink));
  --button-edge: #fff;
  --depth: 5px;
  --ring: 0 0 0 2px var(--base), 0 0 0 3px rgb(255 255 255 / .8);
}

#home #modePick .mi {
  font-size: clamp(17px, 5vw, 22px);
  line-height: 1;
}

#home .trophy {
  padding: 4px 13px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: linear-gradient(var(--ui-panel-top), var(--ui-panel-bot));
  box-shadow: 0 3px 0 var(--ui-panel-edge), 0 5px 8px rgb(16 33 59 / .18);
  color: var(--ui-ink);
  font: 800 15px/1.1 'Baloo 2', system-ui, sans-serif;
}

#home :is(#btnSolo, #btnPlay) {
  width: min(100%, 294px);
  min-width: 0;
  min-height: clamp(49px, 7.8dvh, 66px);
  margin-bottom: 5px;
  padding: 6px 10px;
  font-size: clamp(21px, 6.1vw, 28px);
}

#home #btnSolo {
  min-height: clamp(54px, 8.25dvh, 72px);
  margin-top: 2px;
}

#home .online {
  justify-content: center;
  gap: 5px;
  color: #fff;
  font: 800 clamp(13px, 3.6vw, 16px)/1.2 'Baloo 2', system-ui, sans-serif;
  text-shadow: 0 1px 3px #173a2c, 0 2px 5px #173a2c;
}

#home .online .dot {
  flex: none;
  width: 9px;
  height: 9px;
  border: 1px solid #fff;
  background: #67ef71;
  box-shadow: 0 0 7px #67ef71;
}

/* Thoát trận và cài đặt */
#modal .panel.md {
  gap: 12px;
  padding: 17px 13px 18px;
}

#modal .md-text {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 40px;
  padding: 0 49px;
  color: var(--ui-ink);
  font: 800 clamp(19px, 5.6vw, 23px)/1.12 'Baloo 2', system-ui, sans-serif;
}

#modal .md-row {
  gap: 8px;
}

#modal .md-row .big {
  min-width: 0;
  min-height: 47px;
  padding: 6px;
  font-size: clamp(16px, 5vw, 20px);
}

#modal #mdStay,
#settings #setHow {
  --face-top: var(--b-top);
  --face-bot: var(--b-bot);
  --base: var(--b-base);
}

#modal .md-mute {
  top: 9px;
  right: 9px;
}

#settings .panel.set {
  max-width: 360px;
  gap: clamp(5px, 1dvh, 9px);
  padding: 11px clamp(10px, 3.4vw, 16px) 10px;
}

#settings .set h2 {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 44px;
  margin: 0 0 4px;
  padding-inline: 48px;
}

#settings .set-x {
  --face-top: var(--r-top);
  --face-bot: var(--r-bot);
  --base: var(--r-base);
  --depth: 3px;
  position: absolute;
  top: 8px;
  right: 9px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  font: 800 18px/1 'Baloo 2', system-ui, sans-serif;
}

#settings .tg {
  min-height: 44px;
  gap: 6px;
  padding: 4px 7px 4px 5px;
  border: 2px solid #fff;
  border-radius: 14px;
  background: linear-gradient(#fff, #e5eefb);
  box-shadow: 0 2px 0 var(--ui-panel-edge);
  color: var(--ui-ink);
  font: 800 clamp(14px, 3.85vw, 17px)/1.1 'Baloo 2', system-ui, sans-serif;
  text-align: left;
  touch-action: manipulation;
}

#settings .tg:active {
  transform: translateY(2px);
  box-shadow: none;
}

#settings .tg span {
  gap: 7px;
  min-width: 0;
}

#settings .tg .ic {
  flex: none;
  width: 30px;
  height: 30px;
  border: 1px solid #fff;
  border-radius: 9px;
  background: var(--ui-gloss), linear-gradient(#fff, color-mix(in srgb, var(--ic) 28%, white));
  box-shadow: 0 1px 0 color-mix(in srgb, var(--ic) 55%, #fff);
  font-size: 16px;
}

#settings .tg i {
  width: 50px;
  height: 28px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: linear-gradient(var(--gr-bot), var(--gr-top));
  box-shadow: inset 0 2px 3px rgb(16 33 59 / .23);
}

#settings .tg i::after {
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: linear-gradient(#fff, #edf4fc);
}

#settings .tg.on i {
  background: var(--ui-gloss), linear-gradient(var(--g-top), var(--g-bot));
  box-shadow: inset 0 -2px 0 rgb(36 122 41 / .32);
}

#settings .tg.on i::after {
  transform: translateX(22px);
}

#settings .set-how-box {
  margin: 2px 0 0;
  padding: 5px 6px 8px;
  border: 2px solid #fff;
  border-radius: 17px;
  background: linear-gradient(#dce8f8, #edf4fd);
  box-shadow: 0 2px 0 var(--ui-panel-edge);
}

#settings .set-cap {
  margin: 0 auto 5px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 0 var(--ui-panel-edge);
  color: var(--ui-ink);
  font: 800 13px/1.45 'Baloo 2', system-ui, sans-serif;
}

#settings .mcards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

#settings .mcard {
  min-width: 0;
  min-height: 44px;
  padding: 0 0 4px;
  border: 2px solid #fff;
  border-radius: 11px;
  background: linear-gradient(#fff, #f1f6fd);
  box-shadow: 0 3px 0 var(--ui-panel-edge);
  color: var(--ui-ink);
  font: 800 11px/1.13 'Baloo 2', system-ui, sans-serif;
  touch-action: manipulation;
}

#settings .mcard:active {
  transform: translateY(3px);
  box-shadow: none;
}

#settings .mcard .mh {
  display: grid;
  place-items: center;
  min-height: 22px;
  padding: 2px;
  background: var(--ui-gloss), linear-gradient(var(--mc), var(--md));
  color: #fff;
  font: 800 clamp(10px, 2.9vw, 12px)/1.05 'Baloo 2', system-ui, sans-serif;
  text-shadow: 0 1px 2px var(--md);
}

#settings .mcard svg {
  width: clamp(43px, 8dvh, 62px);
  height: clamp(43px, 8dvh, 62px);
  margin: 3px 0 2px;
}

#settings .mcard .mt {
  padding-inline: 3px;
}

#settings #setHow {
  min-height: clamp(44px, 7.2dvh, 56px);
  padding: 5px 8px;
  font-size: clamp(17px, 5vw, 21px);
}

#settings .set-ver {
  margin-top: 5px;
  color: var(--ui-sub);
  font: 700 12px/1.1 'Baloo 2', system-ui, sans-serif;
}

/* Hướng dẫn */
#how {
  background: linear-gradient(rgb(18 40 67 / .34), rgb(18 44 46 / .54));
}

#how .panel {
  padding: clamp(10px, 1.9dvh, 19px) clamp(10px, 3.5vw, 17px);
}

#how .panel h2 {
  margin-bottom: clamp(6px, 1.2dvh, 12px);
}

#how .panel ul {
  display: grid;
  gap: clamp(3px, .7dvh, 7px);
  margin: 0 0 clamp(7px, 1.5dvh, 14px);
  padding: 0;
}

#how .panel li {
  margin: 0;
  padding: clamp(3px, .65dvh, 7px) 7px;
  border: 1px solid #fff;
  border-radius: 10px;
  background: rgb(255 255 255 / .66);
  box-shadow: 0 1px 0 #d7e3f3;
  color: var(--ui-ink);
  font-size: clamp(13px, 2dvh, 16px);
  line-height: 1.22;
}

#how .panel li b {
  font-weight: 800;
}

#how :is(#btnHowOk, #btnTut) {
  display: grid;
  place-items: center;
  width: min(100%, 290px);
  margin-inline: auto;
}

#how #btnHowOk {
  --face-top: var(--b-top);
  --face-bot: var(--b-bot);
  --base: var(--b-base);
  margin-bottom: 9px;
  padding: 6px 10px;
}

#how #btnTut {
  padding: 5px 8px;
  font-size: clamp(13px, 4vw, 16px);
}

@media (prefers-reduced-motion: reduce) {
  .modal > .panel,
  .modal > .panel.md,
  #home .logo img {
    animation: none;
  }

  #banner,
  #settings .tg i,
  #settings .tg i::after {
    transition: none;
  }
}

/* ===== UI redesign B (Codex): levels, custom, room ===== */

:is(#levels, #custom, #room) {
  --b-panel: linear-gradient(var(--ui-panel-top, #ffffff), var(--ui-panel-bot, #eaf2fd));
  --b-edge: var(--ui-panel-edge, #b8c9e2);
  --b-gloss: radial-gradient(ellipse 66% 78% at 22% 0%, rgb(255 255 255 / .58), transparent 78%);
  --b-blue: #5fb6ff;
  --b-blue-bot: #1f74e0;
  --b-blue-base: #1550a8;
  --b-green: #8be86a;
  --b-green-bot: #34ad3a;
  --b-green-base: #247a29;
  --b-grey: #c3cfdd;
  --b-grey-bot: #8796ab;
  --b-grey-base: #5f6d82;
  --b-orange: #ffc95a;
  --b-orange-bot: #f07c12;
  --b-orange-base: #a94c07;
  --b-purple: #b48cff;
  --b-purple-bot: #7a4ae6;
  --b-purple-base: #4f2aa6;
  --b-red: #ff8a8a;
  --b-red-bot: #e23b4a;
  --b-red-base: #9e1f2c;
  --b-gap: clamp(6px, 1.15dvh, 11px);
  justify-content: flex-start;
  gap: var(--b-gap);
  padding:
    max(8px, env(safe-area-inset-top, 0px))
    max(12px, env(safe-area-inset-right, 0px))
    max(10px, env(safe-area-inset-bottom, 0px))
    max(12px, env(safe-area-inset-left, 0px));
  overflow: hidden;
  color: var(--ui-ink, #1f3354);
}

/* Dải tiêu đề và mặt nút dùng trong ba màn */
:is(#levels, #custom, #room) .lv-head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 6px;
  width: 100%;
  max-width: 460px;
  flex: none;
  padding: 6px;
  border: 2px solid #fff;
  border-radius: var(--ui-radius, 26px);
  background: var(--b-gloss), var(--b-panel);
  box-shadow: 0 4px 0 var(--b-edge), 0 7px 12px rgb(31 51 84 / .16);
}

#levels .lv-head {
  grid-template-columns: 44px minmax(0, 1fr) auto;
}

:is(#levels, #custom, #room) .lv-head .lv-title {
  gap: 3px;
  color: var(--ui-ink, #1f3354);
  font: 800 clamp(19px, 5.7vw, 26px)/1.06 'Baloo 2', sans-serif;
  text-align: center;
  text-shadow: 0 1px 0 #fff;
  -webkit-text-stroke: 0;
}

:where(#levels, #custom, #room) :is(
  .lv-head .iconbtn, .lv-sub, :where(#lvGrid) .lv, #stylePick button, .cu-chip,
  #btnCuDone, #btnCopyCode, #btnInvite, #btnJoin, .seat-x,
  .seat-st, #btnRoomStart, #btnRoomLeave
) {
  --b-depth: 3px;
  min-height: 44px;
  border: 2px solid #fff;
  border-radius: 14px;
  background: var(--b-gloss), linear-gradient(
    var(--b-top, var(--b-blue)), var(--b-bot, var(--b-blue-bot))
  );
  box-shadow: inset 0 2px 0 rgb(255 255 255 / .28),
    0 var(--b-depth) 0 var(--b-base, var(--b-blue-base));
  color: #fff;
  font: 800 14px/1 'Baloo 2', sans-serif;
  text-shadow: 0 1px 2px var(--b-base, var(--b-blue-base));
  touch-action: manipulation;
}

:where(#levels, #custom, #room) :is(
  .lv-head .iconbtn, button.lv-sub, :where(#lvGrid) .lv, #stylePick button, .cu-chip,
  #btnCuDone, #btnCopyCode, #btnInvite, #btnJoin, .seat-x, #btnRoomStart, #btnRoomLeave
):enabled:active {
  transform: translateY(2px);
  box-shadow: inset 0 2px 0 rgb(255 255 255 / .23),
    0 calc(var(--b-depth) - 2px) 0 var(--b-base, var(--b-blue-base));
}

:is(#levels, #custom, #room) :is(button, input):focus-visible {
  outline: 2px solid var(--ui-ink, #1f3354);
  outline-offset: 2px;
}

:is(#levels, #custom, #room) .lv-head .iconbtn {
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 24px;
}

#custom .lv-head #btnCuRand {
  --b-top: var(--b-purple);
  --b-bot: var(--b-purple-bot);
  --b-base: var(--b-purple-base);
  font-size: 19px;
}

:is(#levels, #custom, #room) .lv-head .lv-sub {
  min-height: 0;
  margin: 0;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 12px;
}

#levels .lv-stars,
#room #roomNet {
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--b-panel);
  box-shadow: 0 2px 0 var(--b-edge);
  color: var(--ui-ink, #1f3354);
  white-space: nowrap;
}

#levels .lv-stars {
  padding: 5px 7px;
  font: 800 13px/1 'Baloo 2', sans-serif;
}

/* Lưới 50 màn cuộn bên trong, dải tiêu đề đứng yên */
#levels #lvGrid {
  min-height: 0;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-content: start;
  gap: 8px 6px;
  margin-top: 4px;
  padding: 8px 7px 12px;
  border: 2px solid #fff;
  border-radius: var(--ui-radius, 26px);
  background: var(--b-panel);
  box-shadow: 0 4px 0 var(--b-edge);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 8px;
}

#levels #lvGrid .lv {
  --b-depth: 4px;
  width: 100%;
  min-width: 44px;
  height: clamp(54px, 16.4vw, 70px);
  aspect-ratio: auto;
  justify-content: center;
  gap: 2px;
  padding: 2px;
  font-size: 22px;
  -webkit-text-stroke: 0;
}

#levels #lvGrid .lv .st {
  position: static;
  color: #ffe07e;
  font: 800 12px/1 'Baloo 2', sans-serif;
  text-shadow: 0 1px 1px var(--b-base, var(--b-blue-base));
  -webkit-text-stroke: 0;
}

#levels #lvGrid .lv .st i {
  color: #fff;
  opacity: .65;
  -webkit-text-stroke: 0;
}

#levels #lvGrid .lv.boss {
  --b-top: var(--b-purple);
  --b-bot: var(--b-purple-bot);
  --b-base: var(--b-purple-base);
}

#levels #lvGrid .lv.boss::before {
  font-size: 14px;
}

#levels #lvGrid .lv.lock {
  --b-top: var(--b-grey);
  --b-bot: var(--b-grey-bot);
  --b-base: var(--b-grey-base);
  color: #fff;
  font-size: 19px;
  opacity: 1;
  cursor: default;
}

#levels #lvGrid .lv.lock::after {
  position: static;
  font-size: 11px;
  line-height: 1;
}

#levels #lvGrid .lv.cur {
  --b-top: var(--b-orange);
  --b-bot: var(--b-orange-bot);
  --b-base: var(--b-orange-base);
  justify-content: flex-end;
  padding-bottom: 3px;
  font-size: 17px;
  animation: none;
}

#levels #lvGrid .lv.cur::before {
  content: none;
}

#levels #lvHero {
  width: clamp(33px, 9.6vw, 43px);
  height: auto;
  aspect-ratio: 58 / 68;
  top: 0;
  bottom: auto;
  pointer-events: none;
}

/* Sân xoay và các hàng tuỳ chọn */
#custom .cu-stage {
  display: grid;
  place-items: center;
  width: min(100%, 420px);
  height: clamp(90px, 23dvh, 222px);
  min-height: 90px;
  flex: 0 1 auto;
  padding-bottom: 20px;
  border: 2px solid #fff;
  border-radius: var(--ui-radius, 26px);
  background: radial-gradient(ellipse at 50% 72%, #d9edff, transparent 68%), var(--b-panel);
  box-shadow: 0 4px 0 var(--b-edge);
}

#custom .cu-stage #cuPreview {
  display: block;
  width: auto;
  height: 100%;
  min-height: 0;
  aspect-ratio: 20 / 23;
}

#custom .cu-hint {
  inset: auto auto 3px 50%;
  margin: 0;
  padding: 2px 10px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #fff;
  color: var(--ui-sub, #5d6f8c);
  font: 800 12px/1.2 'Baloo 2', sans-serif;
  text-shadow: none;
  white-space: nowrap;
  pointer-events: none;
}

#custom #stylePick {
  flex: none;
  gap: 4px;
  width: min(100%, 420px);
  margin: 0;
  padding: 3px 4px 6px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--b-panel);
  box-shadow: 0 3px 0 var(--b-edge);
}

#custom #stylePick button {
  --b-top: var(--b-grey);
  --b-bot: var(--b-grey-bot);
  --b-base: var(--b-grey-base);
  flex: 1 1 0;
  padding: 0 5px;
  border-radius: 999px;
}

#custom #stylePick button.on,
#custom #cuOpts .cu-chip.on {
  --b-top: var(--b-purple);
  --b-bot: var(--b-purple-bot);
  --b-base: var(--b-purple-base);
}

#custom #cuOpts {
  gap: 0;
  padding: 2px 5px;
  border: 2px solid #fff;
  border-radius: var(--ui-radius, 26px);
  background: var(--b-panel);
  box-shadow: 0 4px 0 var(--b-edge);
}

#custom #cuOpts .cu-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 2px;
  padding: 1px 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

#custom #cuOpts .cu-row + .cu-row {
  border-top: 1px solid var(--b-edge);
}

#custom #cuOpts h3 {
  margin: 0;
  padding-left: 2px;
  color: var(--ui-ink, #1f3354);
  font: 800 11px/1.1 'Baloo 2', sans-serif;
}

#custom #cuOpts .cu-list {
  gap: 0 2px;
}

#custom #cuOpts .cu-chip {
  --b-depth: 2px;
  min-width: 44px;
  padding: 0 4px;
  font-size: 12px;
  white-space: nowrap;
}

#custom #cuOpts .cu-sw {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 5px solid transparent;
  border-radius: 50%;
  background-clip: padding-box;
  background-image: var(--b-gloss);
  box-shadow: inset 0 0 0 2px #fff, inset 0 -4px 0 rgb(31 51 84 / .30);
  color: var(--ui-sub, #5d6f8c);
  background-color: #fff;
  touch-action: manipulation;
}

#custom #cuOpts .cu-sw[style] {
  /* Màu nội tuyến giữ nguyên, viền trong tạo độ nổi */
  box-shadow: inset 0 0 0 2px #fff, inset 0 -4px 0 rgb(31 51 84 / .32);
}

#custom #cuOpts .cu-sw.on {
  outline: 2px solid var(--b-purple-base);
  outline-offset: -3px;
}

#custom #cuOpts .cu-sw.on:focus-visible {
  outline: 2px dashed var(--ui-ink, #1f3354);
  outline-offset: -1px;
}

#custom #cuOpts .cu-sw:active {
  transform: translateY(2px);
}

#custom #btnCuDone,
#room #btnRoomStart {
  --b-depth: var(--ui-depth, 6px);
  --b-top: var(--b-green);
  --b-bot: var(--b-green-bot);
  --b-base: var(--b-green-base);
  justify-content: center;
  width: min(100%, 290px);
  min-width: 0;
  flex: none;
  min-height: 46px;
  margin: 0;
  padding: 4px 12px;
  border-radius: 18px;
  font-size: 20px;
}

/* Phòng chơi, mã mời và ghế */
#room .lv-head .lv-subs {
  gap: 4px;
  flex-wrap: nowrap;
}

#room .lv-head button.lv-sub {
  position: relative;
  min-width: 44px;
  min-height: 44px;
  padding: 0 7px;
  cursor: pointer;
}

#room .lv-head #roomMode {
  isolation: isolate;
}

#room .lv-head #roomMode::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: inherit;
  background: var(--b-gloss);
  content: '';
  pointer-events: none;
}

#room .lv-head #roomObst {
  --b-top: var(--b-green);
  --b-bot: var(--b-green-bot);
  --b-base: var(--b-green-base);
  background: var(--b-gloss), linear-gradient(var(--b-top), var(--b-bot));
}

#room .lv-head #roomObst.off {
  --b-top: var(--b-grey);
  --b-bot: var(--b-grey-bot);
  --b-base: var(--b-grey-base);
}

#room #roomNet {
  width: 38px;
  height: 30px;
  justify-self: center;
  font-size: 14px;
}

#room.net #roomNet {
  background: linear-gradient(#fff, #dff8db);
  box-shadow: 0 2px 0 var(--b-green-base);
}

#room :is(.room-code, #roomGrid, .room-join, .room-msg) {
  width: 100%;
  max-width: 420px;
}

#room :is(.room-code, .room-join) {
  flex: none;
  gap: 7px;
}

#room .rc-box {
  min-width: 0;
  gap: 5px;
  padding: 1px 3px 3px 8px;
  border: 2px solid #fff;
  background: var(--b-panel);
  box-shadow: 0 3px 0 var(--b-edge);
  color: var(--ui-ink, #1f3354);
  font-size: 13px;
  white-space: nowrap;
}

#room .rc-box b {
  font-variant-numeric: tabular-nums;
  font-size: 20px;
}

#room #btnCopyCode {
  width: 44px;
  height: 44px;
  flex: none;
  padding: 0;
  font-size: 18px;
}

#room #btnInvite {
  --b-top: var(--b-green);
  --b-bot: var(--b-green-bot);
  --b-base: var(--b-green-base);
  padding-inline: 10px;
}

#room #roomGrid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(108px, 1fr);
  gap: 7px 8px;
  flex: 0 1 clamp(224px, 38dvh, 364px);
  min-height: 223px;
}

#room #roomGrid.room-two {
  flex-basis: clamp(157px, 30dvh, 278px);
  min-height: 150px;
}

#room #roomGrid .seat {
  height: auto;
  min-width: 0;
  min-height: 0;
  gap: 2px;
  padding: 3px 3px 4px;
  border: 2px solid #fff;
  border-radius: 20px;
  background: var(--b-gloss), var(--b-panel);
  box-shadow: 0 3px 0 var(--b-edge);
}

#room #roomGrid .seat .st3d {
  top: auto;
  bottom: 39px;
  width: auto;
  height: clamp(52px, calc(100% - 53px), 116px);
  aspect-ratio: 13 / 15;
  pointer-events: none;
}

#room #roomGrid.room-two .seat .st3d {
  height: clamp(90px, calc(100% - 61px), 168px);
}

#room #roomGrid .ped {
  bottom: 42px;
  width: min(72%, 116px);
  height: clamp(15px, 3dvh, 28px);
  border: 2px solid #fff;
  background: var(--b-gloss),
    radial-gradient(ellipse at 50% 39%, #fff 0 46%, var(--tc, #5fb6ff) 49%);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--tc, #5fb6ff) 65%, #1f3354);
}

#room #roomGrid .seat-n {
  max-width: 100%;
  padding: 2px 7px;
  border: 1px solid var(--b-edge);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 0 var(--b-edge);
  color: var(--ui-ink, #1f3354);
  font: 800 13px/1 'Baloo 2', sans-serif;
}

#room #roomGrid .seat[data-i="0"] .seat-n {
  position: absolute;
  inset: auto 4px 19px;
  min-height: 44px;
  align-content: end;
  padding: 0 4px 3px;
  border-color: transparent;
  background: linear-gradient(transparent 55%, #fff 55%) padding-box;
  box-shadow: none;
  text-align: center;
  cursor: pointer;
}

#room #roomGrid .seat-st {
  --b-depth: 2px;
  --b-top: var(--b-green);
  --b-bot: var(--b-green-bot);
  --b-base: var(--b-green-base);
  min-height: 0;
  margin: 0;
  padding: 2px 6px;
  border-width: 1px;
  border-radius: 999px;
  font-size: 11px;
  white-space: nowrap;
}

#room #roomGrid .seat-st.wait {
  --b-top: var(--b-orange);
  --b-bot: var(--b-orange-bot);
  --b-base: var(--b-orange-base);
}

#room #roomGrid .seat.empty {
  border-color: transparent;
  background: none;
  box-shadow: none;
}

#room #roomGrid .seat.empty .seat-add {
  inset: -2px;
  gap: 4px;
  min-height: 44px;
  border: 2px dashed #fff;
  border-radius: 20px;
  background: var(--b-gloss), linear-gradient(#f5faff, #cfe5fe);
  box-shadow: 0 3px 0 var(--b-blue-base);
  color: var(--b-blue-base);
  font-size: 32px;
  text-shadow: 0 1px 0 #fff;
  touch-action: manipulation;
}

#room #roomGrid .seat.empty .seat-add small {
  color: var(--ui-ink, #1f3354);
  font-size: 12px;
}

#room:not(.guest-view) #roomGrid .seat.empty .seat-add:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--b-blue-base);
}

#room.guest-view #roomGrid .seat.empty .seat-add {
  color: var(--ui-sub, #5d6f8c);
  box-shadow: 0 3px 0 var(--b-edge);
  cursor: default;
}

#room #roomGrid .seat-x {
  --b-top: var(--b-red);
  --b-bot: var(--b-red-bot);
  --b-base: var(--b-red-base);
  top: 2px;
  right: 2px;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
}

#room .room-join #joinCode {
  min-height: 44px;
  padding: 4px 10px;
  border: 2px solid #fff;
  background: var(--b-panel);
  box-shadow: inset 0 2px 0 rgb(31 51 84 / .09), 0 3px 0 var(--b-edge);
  color: var(--ui-ink, #1f3354);
  font: 800 16px/1 'Baloo 2', sans-serif;
}

#room #joinCode::placeholder {
  color: var(--ui-sub, #5d6f8c);
  font-size: 13px;
}

#room #btnJoin {
  min-width: 64px;
  padding: 0 10px;
}

#room .room-msg {
  min-height: 0;
  flex: none;
  padding: 3px 8px;
  border-radius: 12px;
  background: var(--b-panel);
  color: var(--ui-ink, #1f3354);
  font: 800 13px/1.15 'Baloo 2', sans-serif;
  text-shadow: none;
  overflow-wrap: anywhere;
}

#room .room-msg:empty {
  display: none;
}

#room #btnRoomStart:disabled {
  --b-top: var(--b-grey);
  --b-bot: var(--b-grey-bot);
  --b-base: var(--b-grey-base);
  filter: none;
  opacity: 1;
  cursor: default;
  transform: none;
}

#room #btnRoomLeave {
  --b-top: var(--b-grey);
  --b-bot: var(--b-grey-bot);
  --b-base: var(--b-grey-base);
  flex: none;
  min-width: 104px;
  margin-top: 2px;
  padding: 0 12px;
  border-radius: 999px;
  text-decoration: none;
}

/* ===== UI redesign C (Codex): matchmaking, versus, result, coach ===== */

/* Mặt bóng, viền trắng và đáy nổi dùng trong nhóm C. */
:is(#match, #versus, #versus4, #result, #coach, #quick) {
  --c-shine: radial-gradient(ellipse 70% 85% at 18% 0%, rgb(255 255 255 / .46), transparent 76%);
  --c-panel: linear-gradient(var(--ui-panel-top, #ffffff), var(--ui-panel-bot, #eaf2fd));
  --c-depth: var(--ui-depth, 6px);
  --c-radius: var(--ui-radius, 26px);
}

:is(#match, #versus, #versus4, #result) {
  --c-pad: clamp(12px, 4vw, 20px);
  padding: max(var(--c-pad), env(safe-area-inset-top, 0px))
           max(var(--c-pad), env(safe-area-inset-right, 0px))
           max(calc(var(--c-pad) + var(--c-depth)), env(safe-area-inset-bottom, 0px))
           max(var(--c-pad), env(safe-area-inset-left, 0px));
  gap: clamp(10px, 2dvh, 18px);
  overflow: hidden;
}

#match,
#versus4 {
  background:
    radial-gradient(ellipse at 50% 32%, rgb(95 182 255 / .27), transparent 65%),
    linear-gradient(160deg, rgb(18 53 94 / .94), rgb(21 37 68 / .97));
}

#versus {
  background:
    radial-gradient(ellipse at 12% 38%, rgb(61 156 240 / .44), transparent 58%),
    radial-gradient(ellipse at 90% 52%, rgb(224 57 79 / .43), transparent 58%),
    linear-gradient(113deg, #142e54 0 49.7%, #fff3 49.7% 50.3%, #49253f 50.3%);
}

:is(
  #match .mm-mode, #match .mm-time,
  #versus .vs-card, #versus .vs-mid, #versus .coin,
  #versus4 .v4q, #versus4 .v4vs, #versus4 .coin, #versus4 .v4mode,
  #result .res-tro, #result .pd .blk,
  #match #btnCancel, #result #btnRematch, #result #btnAgain, #result #btnHome, #quick button
) {
  border: 2px solid #fff;
  background: var(--c-shine), linear-gradient(var(--c-top), var(--c-bot));
  box-shadow: inset 0 -2px 0 rgb(20 36 61 / .13), 0 var(--c-lift, var(--c-depth)) 0 var(--c-base);
}

:is(#match .tip, #result .panel.res, #coach, #quick) {
  color: var(--ui-ink, #1f3354);
  border: 2px solid var(--ui-panel-edge, #b8c9e2);
  background: var(--c-panel);
  box-shadow: inset 0 0 0 2px rgb(255 255 255 / .85), 0 var(--c-depth) 0 var(--ui-panel-edge, #b8c9e2);
}

/* Tìm trận */
#match .mm-mode {
  --c-top: var(--mc, var(--ui-blue-top, #5fb6ff));
  --c-bot: var(--md, var(--ui-blue-bot, #1f74e0));
  --c-base: #142b4e;
  --c-lift: 4px;
  padding: 5px 18px;
  font: 800 15px/1.25 'Baloo 2', sans-serif;
  text-shadow: 0 1px 2px var(--c-base);
}

#match .radar {
  --c-radar-size: clamp(124px, 23dvh, 196px);
  width: var(--c-radar-size);
  height: var(--c-radar-size);
  flex: none;
  isolation: isolate;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(95 182 255 / .38), transparent 68%);
}

#match .radar .ring {
  inset: 7%;
  border-width: 2px;
  border-color: #b9eaff;
  box-shadow: 0 0 14px rgb(95 182 255 / .48), inset 0 0 12px rgb(95 182 255 / .24);
}

#match .radar canvas.st3d {
  width: 90%;
  height: 90%;
}

#match #mmSlots {
  width: min(100%, 344px);
  gap: clamp(6px, 2vw, 10px);
}

#match #mmSlots .mslot {
  width: 74px;
  min-width: 0;
  gap: 7px;
  font: 800 13px/1.15 'Baloo 2', sans-serif;
}

#match #mmSlots .av {
  width: clamp(45px, 13vw, 58px);
  height: auto;
  aspect-ratio: 1;
  border: 2px solid #fff;
  border-radius: 16px;
  background: var(--c-shine), linear-gradient(#fff, var(--tc, #5fb6ff));
  box-shadow: 0 4px 0 var(--tc, #1550a8);
  color: var(--ui-ink, #1f3354);
  font-size: 21px;
  text-shadow: none;
}

#match #mmSlots .empty .av {
  background: linear-gradient(rgb(255 255 255 / .19), rgb(255 255 255 / .07));
  border: 2px dashed rgb(219 238 255 / .76);
  color: #e5f3ff;
  box-shadow: 0 4px 0 rgb(13 29 53 / .5);
}

#match #mmSlots .nm {
  max-width: 100%;
  min-height: 16px;
}

#match .mm-title {
  text-align: center;
  font: 800 clamp(23px, 6.6vw, 31px)/1.12 'Baloo 2', sans-serif;
  text-shadow: 0 2px 0 #132844;
}

#match .mm-time {
  --c-top: #45678f;
  --c-bot: #213a60;
  --c-base: #132844;
  --c-lift: 3px;
  min-width: 68px;
  padding: 3px 10px;
  border-radius: 999px;
  opacity: 1;
  text-align: center;
  font: 800 17px/1.2 'Baloo 2', sans-serif;
  font-variant-numeric: tabular-nums;
}

#match .tip {
  width: min(100%, 348px);
  min-height: 48px;
  padding: 8px 13px;
  border-radius: 18px;
  font: 700 14px/1.28 'Baloo 2', sans-serif;
  overflow-wrap: anywhere;
}

/* Đối đầu hai và bốn người */
#versus .vs-row {
  position: relative;
  max-width: 420px;
  gap: 12px;
  padding-block-end: var(--c-depth);
}

#versus .vs-card {
  min-width: 0;
  max-width: none;
  padding: 8px 8px 12px;
  border-width: 3px;
  border-radius: var(--c-radius);
  color: #fff;
  text-shadow: 0 1px 2px var(--c-base);
}

#versus .vs-card.me {
  --c-top: #3d9cf0;
  --c-bot: #1f6fd1;
  --c-base: var(--ui-blue-base, #1550a8);
  transform-origin: right center;
}

#versus .vs-card.opp {
  --c-top: #ff7a8e;
  --c-bot: #e0394f;
  --c-base: var(--ui-red-base, #9e1f2c);
  transform-origin: left center;
}

#versus .vs-card canvas.st3d {
  width: min(100%, 188px);
  height: auto;
  aspect-ratio: 1;
  margin-inline: auto;
}

#versus .vs-card .n {
  font: 800 18px/1.15 'Baloo 2', sans-serif;
}

#versus .vs-card .t {
  display: inline-block;
  max-width: 100%;
  margin-top: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgb(20 36 61 / .27);
  font: 800 14px/1.2 'Baloo 2', sans-serif;
}

:is(#versus .vs-mid, #versus4 .v4vs) {
  --c-top: #ffe066;
  --c-bot: #ffb300;
  --c-base: #ad6700;
  --c-lift: 4px;
  position: absolute;
  left: 50%;
  top: 42%;
  translate: -50% -50%;
  z-index: 3;
  display: grid;
  place-content: center;
  width: clamp(52px, 14vw, 62px);
  aspect-ratio: 1;
  border-width: 3px;
  border-radius: 50%;
  color: #713a00;
  font: 800 26px/.95 'Baloo 2', sans-serif;
  -webkit-text-stroke: 0;
  text-shadow: 0 1px 0 rgb(255 255 255 / .65);
}

:is(#versus .coin, #versus4 .coin) {
  --c-top: #365987;
  --c-bot: #203759;
  --c-base: #132640;
  --c-lift: 4px;
  max-width: 100%;
  padding: 8px 16px;
  text-align: center;
  overflow-wrap: anywhere;
  font: 800 18px/1.2 'Baloo 2', sans-serif;
  text-shadow: 0 1px 2px var(--c-base);
}

#versus4 .v4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 10px;
  max-width: 420px;
}

#versus4 .v4q {
  --c-top: var(--qa, var(--ui-blue-top, #5fb6ff));
  --c-bot: var(--qb, var(--ui-blue-bot, #1f74e0));
  --c-base: #213653;
  --c-base: color-mix(in srgb, var(--c-bot) 64%, #14243d);
  height: clamp(140px, 25dvh, 218px);
  border-radius: var(--c-radius);
  padding: 4px 6px 8px;
}

#versus4 .v4q::before {
  background: radial-gradient(ellipse at 50% 100%, rgb(32 44 70 / .24), transparent 60%);
  pointer-events: none;
}

#versus4 .v4q canvas.st3d {
  width: min(calc(100% - 12px), clamp(100px, calc(25dvh - 40px), 178px));
  height: auto;
  aspect-ratio: 1;
}

#versus4 .v4n {
  max-width: 100%;
  padding: 4px 8px;
  background: var(--c-panel);
  color: var(--ui-ink, #1f3354);
  box-shadow: 0 2px 0 rgb(20 36 61 / .24);
  font: 800 13px/1.2 'Baloo 2', sans-serif;
}

#versus4 .v4n small {
  margin-left: 2px;
  font-size: 11px;
  color: var(--ui-sub, #5d6f8c);
}

#versus4 .v4vs {
  top: 50%;
  translate: none;
  row-gap: 1px;
  font-size: 22px;
  filter: none;
}

#versus4 .v4vs span {
  font-size: 15px;
}

#versus4 .v4mode {
  --c-top: var(--ui-purple-top, #b48cff);
  --c-bot: var(--ui-purple-bot, #7a4ae6);
  --c-base: var(--ui-purple-base, #4f2aa6);
  --c-lift: 4px;
  padding: 4px 13px;
  font: 800 14px/1.2 'Baloo 2', sans-serif;
  text-shadow: 0 1px 2px var(--c-base);
}

/* Kết quả, bục và mục tiêu */
#result {
  background:
    radial-gradient(ellipse at 50% 24%, rgb(95 182 255 / .21), transparent 65%),
    rgb(18 38 59 / .70);
}

#result .panel.res {
  justify-content: center;
  max-width: 400px;
  gap: clamp(6px, 1.1dvh, 10px);
  padding: clamp(10px, 2dvh, 18px) clamp(12px, 4vw, 20px);
  border-radius: var(--c-radius);
}

#result .res-title {
  color: #ffe066;
  font: 800 clamp(27px, 8vw, 38px)/1.08 'Baloo 2', sans-serif;
  -webkit-text-stroke: 2.5px #784507;
  text-shadow: 0 3px 0 #784507;
}

#result .res-title.lose {
  color: #dce6f2;
  -webkit-text-stroke-color: #485f7e;
  text-shadow: 0 3px 0 #485f7e;
}

#result #resImg.st3d {
  display: block;
  width: clamp(100px, 22dvh, 190px);
  height: auto;
  aspect-ratio: 1;
  flex: none;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 58%, rgb(95 182 255 / .26), transparent 70%);
}

#result .podium {
  gap: clamp(5px, 2vw, 9px);
  max-width: 336px;
  margin: 0 0 4px;
  padding-top: 2px;
}

#result .pd {
  min-width: 0;
  opacity: 1;
}

#result .pd canvas.st3d {
  width: min(100%, clamp(54px, 11dvh, 84px));
  height: auto;
  aspect-ratio: 1;
  margin-bottom: -4px;
  z-index: 1;
}

#result .pd.p1 canvas.st3d {
  width: min(100%, clamp(62px, 13dvh, 94px));
}

#result .pd .blk {
  --c-lift: 4px;
  height: var(--c-step);
  border-radius: 12px 12px 8px 8px;
  font: 800 19px/1 'Baloo 2', sans-serif;
  text-shadow: 0 1px 2px var(--c-base);
}

#result .pd.p1 {
  --c-top: #ffe066;
  --c-bot: #ffb300;
  --c-base: #ad6700;
  --c-step: 48px;
}

#result .pd.p1 .blk {
  color: #713a00;
  text-shadow: 0 1px 0 #fff8;
}

#result .pd.p2 {
  --c-top: var(--ui-grey-top, #c3cfdd);
  --c-bot: var(--ui-grey-bot, #8796ab);
  --c-base: var(--ui-grey-base, #5f6d82);
  --c-step: 37px;
}

#result .pd.p3 {
  --c-top: var(--ui-orange-top, #ffc95a);
  --c-bot: var(--ui-orange-bot, #f07c12);
  --c-base: var(--ui-orange-base, #a94c07);
  --c-step: 29px;
}

#result .pd.p4 {
  --c-top: #9cacbf;
  --c-bot: #677b97;
  --c-base: #465a75;
  --c-step: 23px;
}

#result #resStars {
  align-items: center;
  gap: 7px;
  font-size: clamp(33px, 5.8dvh, 49px);
}

#result #resStars span {
  color: #dce5f2;
  -webkit-text-stroke: 1.5px var(--ui-panel-edge, #b8c9e2);
}

#result #resStars span:nth-child(2) {
  margin-top: 0;
  font-size: 1.2em;
}

#result #resStars span.on {
  color: #ffd23f;
  -webkit-text-stroke-color: #a85e00;
  text-shadow: 0 2px 0 #a85e00;
}

#result .res-tro {
  --c-top: #ffe066;
  --c-bot: #ffb300;
  --c-base: #ad6700;
  --c-lift: 3px;
  padding: 4px 14px;
  border-radius: 999px;
  color: #713a00;
  font: 800 21px/1.05 'Baloo 2', sans-serif;
}

#result .res-sub {
  max-width: 100%;
  color: var(--ui-sub, #5d6f8c);
  font: 700 14px/1.2 'Baloo 2', sans-serif;
  overflow-wrap: anywhere;
}

#result .res-sub:empty {
  display: none;
}

#result .res-goals,
#result #podium:not(.hidden) ~ .res-goals {
  display: grid;
  gap: 4px;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

#result .res-goals li {
  margin: 0;
  padding: 4px 8px;
  border: 1px solid var(--ui-panel-edge, #b8c9e2);
  border-radius: 10px;
  background: var(--c-panel);
  color: var(--ui-ink, #1f3354);
  font: 700 13px/1.18 'Baloo 2', sans-serif;
  overflow-wrap: anywhere;
}

#result .res-goals li.me {
  border-color: #9bc8f6;
  background: linear-gradient(#f4faff, #dceeff);
  color: var(--ui-blue-base, #1550a8);
  font-weight: 800;
}

#result .res-goals li .d {
  float: none;
  display: inline-block;
  margin-left: 5px;
  white-space: nowrap;
}

#result .res-goals li .d.up {
  color: var(--ui-green-base, #247a29);
}

#result .res-goals li .d.dn {
  color: var(--ui-red-base, #9e1f2c);
}

#result #rmInfo {
  max-width: 100%;
  margin: 0;
  padding: 3px 9px;
  border: 1px solid #eab55e;
  border-radius: 12px;
  background: linear-gradient(#fff8e6, #ffedc1);
  color: #794408;
  font: 800 13px/1.2 'Baloo 2', sans-serif;
  overflow-wrap: anywhere;
}

/* Bong bóng hướng dẫn và chat nhanh */
#coach {
  width: min(88vw, 364px, calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 24px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 126px);
  padding: 8px 12px 10px;
  border-radius: var(--c-radius);
  font: 800 15px/1.24 'Baloo 2', sans-serif;
}

#coach::after {
  content: '';
  position: absolute;
  left: calc(50% - 7px);
  bottom: -8px;
  width: 14px;
  height: 14px;
  transform: rotate(45deg);
  border-right: 2px solid var(--ui-panel-edge, #b8c9e2);
  border-bottom: 2px solid var(--ui-panel-edge, #b8c9e2);
  background: var(--ui-panel-bot, #eaf2fd);
}

#coach .cs {
  width: fit-content;
  margin: 0 auto 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e3efff;
  color: var(--ui-blue-base, #1550a8);
  font: 800 12px/1.2 'Baloo 2', sans-serif;
  letter-spacing: .03em;
}

#coach b {
  color: var(--ui-orange-base, #a94c07);
}

#quick {
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: calc(100% + 8px);
  width: min(286px, calc(100% - max(12px, env(safe-area-inset-left, 0px)) - max(12px, env(safe-area-inset-right, 0px))));
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 9px 9px 13px;
  border-radius: var(--c-radius);
}

/* Nút có vùng chạm 44px và phản hồi nhấn lún. */
:is(#match #btnCancel, #result #btnRematch, #result #btnAgain, #result #btnHome, #quick button) {
  --c-lift: 4px;
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  margin: 0 0 var(--c-lift);
  padding: 6px 14px;
  appearance: none;
  border-radius: 16px;
  color: #fff;
  font: 800 16px/1.12 'Baloo 2', sans-serif;
  text-align: center;
  text-decoration: none;
  text-shadow: 0 1px 2px var(--c-base), 0 1px 0 var(--c-base);
  cursor: pointer;
  touch-action: manipulation;
  transition: translate .1s ease-out, box-shadow .1s ease-out;
}

:is(#match #btnCancel, #result #btnHome, #result #btnRematch:disabled) {
  --c-top: var(--ui-grey-top, #c3cfdd);
  --c-bot: var(--ui-grey-bot, #8796ab);
  --c-base: var(--ui-grey-base, #5f6d82);
}

#match #btnCancel {
  min-width: 116px;
}

#result #btnRematch {
  --c-top: var(--ui-green-top, #8be86a);
  --c-bot: var(--ui-green-bot, #34ad3a);
  --c-base: var(--ui-green-base, #247a29);
}

:is(#result #btnAgain, #quick button) {
  --c-top: var(--ui-blue-top, #5fb6ff);
  --c-bot: var(--ui-blue-bot, #1f74e0);
  --c-base: var(--ui-blue-base, #1550a8);
}

:is(#result #btnRematch, #result #btnAgain) {
  width: min(100%, 250px);
}

#result #btnHome {
  min-width: 128px;
  font-size: 15px;
}

#result #btnRematch:disabled {
  filter: none;
  opacity: 1;
  cursor: default;
}

#quick button {
  --c-lift: 3px;
  font-size: 14px;
  margin: 0;
  padding-inline: 5px;
}

:is(#match #btnCancel, #result #btnRematch, #result #btnAgain, #result #btnHome, #quick button):enabled:active {
  transform: none;
  translate: 0 calc(var(--c-lift) - 1px);
  box-shadow: inset 0 -1px 0 rgb(20 36 61 / .12), 0 1px 0 var(--c-base);
}

:is(#match #btnCancel, #result #btnRematch, #result #btnAgain, #result #btnHome, #quick button):focus-visible {
  outline: 3px solid #1550a8;
  outline-offset: 2px;
}

#match #btnCancel:focus-visible {
  outline-color: #ffe066;
}

@media (max-height: 700px) {
  #match,
  #versus4 {
    gap: 10px;
  }

  #result .panel.res {
    gap: 6px;
    padding-block: 10px;
  }

  #result #resImg.st3d {
    width: clamp(100px, 20dvh, 140px);
  }

  #result .res-goals li {
    padding-block: 3px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #match .radar .ring,
  #match #mmSlots .mslot.in .av,
  #match #mmSlots .mslot.empty .nm::before,
  #versus .vs-card,
  #versus .vs-mid,
  #versus .coin,
  #versus4 .v4q[data-p],
  #versus4 .v4vs,
  #versus4 .coin,
  #versus4 .v4mode,
  #result .res-title,
  #result #resStars span.on,
  #coach {
    animation: none;
  }

  #match .radar .ring.r2 {
    inset: 20%;
    opacity: .65;
  }

  #match .radar .ring.r3 {
    inset: 32%;
    opacity: .4;
  }
}

/* ===== UI redesign: integration fixes ===== */
#home #modePick > button:not(.on){opacity:.6;filter:saturate(.7)}
#home #modePick > button.on{--ring:0 0 0 3px #fff,0 0 14px rgb(255 255 255 / .75);--face-bot:var(--mc);transform:translateY(var(--press)) scale(1.04)}
#modal .md-text{text-align:center}
#result :is(#btnRematch,#btnAgain){font-size:clamp(18px,5.4vw,22px);min-height:52px}

/* ===== wide screens (layout C): board on the left, one sidebar on the right ===== */
#side{display:none}
body.wide #side:not(.hidden){display:flex}
body.wide #side{position:absolute;z-index:6;top:16px;right:16px;bottom:16px;width:clamp(320px,28vw,380px);flex-direction:column;gap:10px;padding:12px;
  border:2px solid #fff;border-radius:26px;background:linear-gradient(rgb(255 255 255 / .95),rgb(234 242 253 / .95));
  box-shadow:0 6px 0 var(--ui-panel-edge,#b8c9e2),0 14px 30px rgb(16 33 59 / .3);overflow:hidden}
body.wide #side .hud{position:static;transform:none;left:auto;width:auto;padding:0}
body.wide #hudTop{flex-wrap:wrap;align-items:center;gap:8px}
body.wide #hudTop #btnMenu{order:1}
body.wide #hudTop .ping{order:2;position:static;margin-left:auto;font-size:12px;padding:3px 10px;background:var(--ui-navy-bot,#213b60)}
body.wide #vsBar{order:3;flex:1 0 100%;flex-direction:column;gap:8px}

body.wide #vsBar .hs{flex-direction:row;margin:0;border-radius:18px;padding:6px 10px 6px 6px;gap:10px;
  background:radial-gradient(ellipse 60% 80% at 15% 0%,rgb(255 255 255 / .35),transparent 75%),linear-gradient(color-mix(in srgb,var(--tc) 70%,#fff),var(--tc));
  box-shadow:0 4px 0 color-mix(in srgb,var(--tc) 60%,#14243d)}
body.wide #vsBar .hs.active{box-shadow:0 0 0 3px #fff,0 0 18px var(--tc),0 4px 0 color-mix(in srgb,var(--tc) 60%,#14243d)}
body.wide #vsBar .hs .hi{align-items:stretch;text-align:left;flex:1}
body.wide #vsBar .hav{width:54px;height:54px}
body.wide #vsBar .hav img{inset:5px;width:44px;height:44px}
body.wide #vsBar .hn{font-size:16px}
body.wide #vsBar .hst{flex-wrap:wrap;gap:5px;margin-top:4px}
body.wide #vsBar .hst .hfb{gap:4px;padding:2px 8px 2px 5px;font-size:14px}
body.wide #vsBar .hst .hfb img{width:18px;height:15px}
body.wide #vsBar .hfm{display:inline;font-style:normal;font-size:12px;opacity:.8;margin-left:-3px}
body.wide #vsBar .fbar{display:block;width:40px;height:6px;margin-left:2px;border-radius:3px;background:rgb(0 0 0 / .28);overflow:hidden}
body.wide #vsBar .fbar b{display:block;height:100%;width:100%;background:linear-gradient(#fff3a8,#ffd23f);transition:width .3s}
body.wide #vsBar .sk{gap:3px;padding:2px 8px 2px 4px;border-radius:999px;background:rgb(0 0 0 / .22);font:800 12px/1.2 'Baloo 2',sans-serif}
body.wide #vsBar .sk img{width:16px;height:16px}
body.wide #vsBar .sk em{display:inline;font-style:normal}
body.wide #vsBar .sk.used{background:rgb(0 0 0 / .12)}
body.wide #vsBar .sk.used em{text-decoration:line-through;opacity:.6}
body.wide #hudBottom{gap:8px}
body.wide #hudBottom #btnChat{display:none}
body.wide #hudBottom #actions{justify-content:stretch}
body.wide .sd-box{flex:1;min-height:0;display:flex;flex-direction:column;gap:8px;padding:8px;border:2px solid #fff;border-radius:18px;background:#fff;box-shadow:inset 0 0 0 1px #dbe6f4}
.sd-tabs{display:flex;gap:4px;padding:3px;border-radius:999px;background:#e3ecf8}
.sd-tabs button{position:relative;flex:1;min-height:34px;border:0;border-radius:999px;background:none;color:#5d6f8c;font:800 14px 'Baloo 2',sans-serif;cursor:pointer}
.sd-tabs button.on{background:linear-gradient(#5fb6ff,#1f74e0);color:#fff;box-shadow:0 2px 0 #1550a8;text-shadow:0 1px 1px #1550a8}
.sd-tabs button.new::after{content:'';position:absolute;top:6px;right:14px;width:8px;height:8px;border-radius:50%;background:#e23b4a}
.sd-pane{flex:1;min-height:0;display:flex;flex-direction:column}
.sd-pane.hidden{display:none!important}
.sd-list{flex:1;min-height:0;margin:0;padding:0 2px;list-style:none;overflow-y:auto;overscroll-behavior:contain;color:#1f3354;font:700 13.5px/1.3 'Baloo 2',sans-serif}
.sd-list li{display:flex;align-items:center;flex-wrap:wrap;gap:4px;padding:4px 6px;border-radius:8px}
.sd-list li:nth-child(odd){background:#f2f6fc}
.sd-list li b{font-weight:800}
.sd-list .sd-empty{justify-content:center;color:#8a99ad;background:none!important;padding:14px 0}
.sd-dot{width:9px;height:9px;border-radius:50%;background:var(--tc);flex:none}
.sd-n{min-width:20px;color:#8a99ad;font-size:11.5px;text-align:right;margin-right:2px}
body.wide #side #quick{position:static;display:grid;width:auto;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;margin:6px 0 0;padding:0;border:0;background:none;box-shadow:none}
body.wide #side #quick button{min-height:34px;margin:0 0 3px;padding:2px 4px;font-size:13px;border-radius:12px}
body.wide .solo #side #quick{display:none}
body.wide .sd-keys{color:#5d6f8c;font:700 12px/1.3 'Baloo 2',sans-serif;text-align:center}
body.wide .sd-keys b{display:inline-block;min-width:18px;padding:0 4px;border-radius:5px;background:#fff;border:1px solid #c9d6e8;box-shadow:0 1px 0 #c9d6e8;color:#1f3354;font-weight:800}
body.wide #banner,body.wide #coach{left:calc(var(--sideL,100%) / 2)}
@media (max-height:700px){body.wide .sd-keys{display:none}}
body.wide #vsBar .hst{display:grid;grid-template-columns:1.25fr 1fr 1fr;gap:4px}
body.wide #vsBar .hst > span{justify-content:center;min-width:0;white-space:nowrap;padding:3px 4px}
body.wide #vsBar .fbar{width:24px}
body.wide #vsBar .sk{font-size:11.5px}
/* VS divider between me and the opponents */
.quad .vsmid{display:none}
body.wide #vsBar .vsmid{display:flex;align-self:stretch;align-items:center;gap:10px;width:auto;height:30px;margin:-2px 4px;padding:0;border:0;border-radius:0;background:none;box-shadow:none}
body.wide #vsBar .vsmid::before,body.wide #vsBar .vsmid::after{content:'';flex:1;height:4px;border-radius:2px}
body.wide #vsBar .vsmid::before{background:linear-gradient(90deg,transparent,#3d9cf0)}
body.wide #vsBar .vsmid::after{background:linear-gradient(90deg,#e0394f,transparent)}
body.wide #vsBar .vsmid b{display:block;font:italic 900 28px/1 'Baloo 2',sans-serif;letter-spacing:1px;color:#ffd23f;transform:skewX(-8deg);
  -webkit-text-stroke:2px #7a3d00;paint-order:stroke fill;text-shadow:0 3px 0 #7a3d00,0 0 14px rgb(255 190 40 / .7)}

/* ===== lobby: phones keep one column; wide screens get two side panels ===== */
.hm-mid{display:contents}
.hm-side{display:none}
body.wide #home{flex-direction:row;align-items:center;justify-content:center;gap:clamp(20px,3vw,44px)}
body.wide #home .hm-mid{display:flex;flex-direction:column;align-items:center;gap:var(--home-gap);width:min(420px,34vw);flex:none}
body.wide #home{--hero-height:clamp(150px,calc(30dvh - 20px),250px)}
body.wide #home #btnRoom{display:none}
body.wide #home .home-pills{grid-template-columns:1fr;width:min(100%,220px)}
body.wide #home .online{display:none}
body.wide .hm-side{display:flex;flex-direction:column;gap:14px;width:clamp(250px,22vw,310px);flex:none}
.hm-card{padding:14px;border:2px solid #fff;border-radius:22px;background:linear-gradient(#fff,#eaf2fd);
  box-shadow:0 5px 0 #b8c9e2,0 12px 24px rgb(16 33 59 / .22);color:#1f3354;font:700 14px/1.3 'Baloo 2',sans-serif}
.hm-cap{margin:0 0 8px;font:800 17px/1.1 'Baloo 2',sans-serif;color:#1f3354}
.hm-who{display:flex;align-items:center;gap:10px}
.hm-av{width:54px;height:54px;border-radius:16px;border:2px solid #fff;background:linear-gradient(#a9dcff,#4aa6ff);box-shadow:0 3px 0 #1550a8;object-fit:cover}
.hm-who b{display:block;font:800 18px/1.1 'Baloo 2',sans-serif;max-width:190px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.hm-who span{font:800 13px 'Baloo 2';color:#a85e00}
.hm-tro{margin:10px 0 4px;font:800 15px 'Baloo 2'}
.hm-tro b{font-size:26px;color:#a85e00;vertical-align:-2px}
.hm-bar{height:10px;border-radius:5px;background:#dbe6f4;box-shadow:inset 0 1px 2px rgb(0 0 0 / .12);overflow:hidden}
.hm-bar i{display:block;height:100%;border-radius:5px;background:linear-gradient(#ffe066,#ffb300);transition:width .4s}
.hm-next{margin-top:3px;color:#5d6f8c;font-size:12.5px}
.hm-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:6px;margin-top:10px}
.hm-stats span{display:flex;flex-direction:column;align-items:center;padding:4px 0;border-radius:12px;background:#fff;box-shadow:inset 0 0 0 1px #dbe6f4;color:#5d6f8c;font-size:12px}
.hm-stats b{color:#1f3354;font:800 18px/1.1 'Baloo 2'}
.hm-rule{display:flex;flex-direction:column;align-items:center;text-align:center}
.hm-rule .hm-cap{align-self:flex-start}
.hm-mode{width:100%;border-radius:14px;overflow:hidden;background:#fff;box-shadow:inset 0 0 0 2px #fff,0 3px 0 #b8c9e2}
.hm-mode .mh{padding:4px;background:linear-gradient(var(--mc),var(--md));color:#fff;font:800 14px 'Baloo 2';text-shadow:0 1px 2px var(--md)}
.hm-mode svg{display:block;width:96px;height:96px;margin:6px auto}
.hm-rule p{margin:8px 0;color:#405068;font-size:13.5px}
.hm-rule .link{min-height:40px;font-size:14px}
.hm-join{display:flex;gap:6px}
.hm-join input{flex:1;min-width:0;height:44px;padding:0 10px;border:2px solid #fff;border-radius:14px;background:#fff;box-shadow:inset 0 2px 0 rgb(31 51 84 / .08),0 3px 0 #b8c9e2;color:#1f3354;font:800 18px 'Baloo 2';letter-spacing:2px;user-select:text;-webkit-user-select:text}
.hm-join input::placeholder{font-size:14px;letter-spacing:0;color:#8a99ad}
.hm-join button,.hm-new{border:2px solid #fff;border-radius:14px;color:#fff;font:800 16px 'Baloo 2';cursor:pointer;text-shadow:0 1px 2px rgb(0 0 0 / .3)}
.hm-join button{padding:0 14px;background:linear-gradient(#5fb6ff,#1f74e0);box-shadow:0 4px 0 #1550a8}
.hm-new{width:100%;min-height:44px;margin-top:10px;background:linear-gradient(#8be86a,#34ad3a);box-shadow:0 4px 0 #247a29}
:is(.hm-join button,.hm-new):active{transform:translateY(3px);box-shadow:0 1px 0 #1550a8}
.hm-on{display:flex;align-items:center;justify-content:center;gap:5px;margin-top:10px;color:#405068;font-size:13.5px}
.hm-top ol{margin:0;padding:0;list-style:none}
.hm-top li{display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:12px;font-size:14px}
.hm-top li:nth-child(odd){background:#f2f6fc}
.hm-top li.me{background:linear-gradient(#e3f2ff,#cfe6ff);box-shadow:inset 0 0 0 2px #7fc0ff}
.hm-top li b{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.hm-rk{width:24px;text-align:center;font:800 15px 'Baloo 2';color:#8a99ad}
.hm-t{font:800 13px 'Baloo 2';color:#a85e00;white-space:nowrap}
.hm-top .hm-empty{justify-content:center;text-align:center;color:#8a99ad;background:none!important;font-size:13px}

/* ===== review fixes (mobile) ===== */
/* modes: all three stay bright; the picked one gets a ✓ and a white ring */
#home #modePick > button:not(.on){opacity:1;filter:none}
#home #modePick > button{position:relative}
#home #modePick > button.on::after{content:'✓';position:absolute;top:-8px;right:-6px;width:22px;height:22px;border-radius:50%;display:grid;place-items:center;
  background:#fff;color:#1f9b3a;font:900 14px/1 'Baloo 2';box-shadow:0 2px 0 rgb(0 0 0 / .2);text-shadow:none}
/* locked milestone levels: trophy moves to the corner so the lock shows too */
#levels #lvGrid .lv.boss.lock::before{position:absolute;top:3px;right:5px;font-size:13px}
/* secondary buttons: light outline style, never the grey of a disabled button */
#match #btnCancel{background:rgb(255 255 255 / .12);border:2px solid #fff;box-shadow:0 3px 0 rgb(0 0 0 / .25);color:#fff}
:is(#result #btnHome,#room #btnRoomLeave){background:#fff;border:2px solid #b8c9e2;box-shadow:0 3px 0 #b8c9e2;color:#1f3354;text-shadow:none}
/* character style tabs: the other style stays readable */
#custom #stylePick button:not(.on){background:#fff;color:#1f3354;text-shadow:none;box-shadow:0 3px 0 #b8c9e2;border-color:#dbe6f4}
/* picked colour swatch: a clear ✓ */
#custom #cuOpts .cu-sw{position:relative}
#custom #cuOpts .cu-sw.on::after{content:'✓';position:absolute;right:-4px;bottom:-4px;width:18px;height:18px;border-radius:50%;display:grid;place-items:center;
  background:#7a4ae6;color:#fff;font:900 12px/1 'Baloo 2';border:2px solid #fff}
/* server badge in the room has words now */
#room #roomNet{width:auto;padding:0 8px;font:800 11.5px/26px 'Baloo 2';white-space:nowrap}
/* settings: mode card captions bigger */
#settings .mcard .mt{font-size:13px;line-height:1.15}
#room .lv-head{grid-template-columns:44px minmax(0,1fr) auto}
body.wide #home .hm-l{order:0}
body.wide #home .hm-mid{order:1}
body.wide #home .hm-r{order:2}
body.wide #home .trophy{display:none}
body.wide #home .logo img{width:min(30vw,300px)}
body.wide #home{--hero-height:clamp(130px,calc(26dvh - 20px),230px)}
#levels #lvGrid .lv.boss.lock::after{content:'🔒'}
/* wide: the action bar sits under the board, centred in the space left of the sidebar */
body.wide #hudBottom{left:calc(var(--sideL,100%) / 2);width:min(560px,calc(var(--sideL,100%) - 48px));bottom:12px}
body.wide #hudBottom #cardMe{box-shadow:0 3px 0 rgb(0 0 0 / .15)}

/* ===== UX pass 3: turn notice, fence tip, distance chips, keys, result bar ===== */
#cardMe.flash{animation:turnFlash .9s ease-out}
@keyframes turnFlash{0%{box-shadow:0 0 0 0 rgba(255,214,74,.95),0 4px 0 rgba(0,0,0,.15)}40%{box-shadow:0 0 0 7px rgba(255,214,74,.75),0 4px 0 rgba(0,0,0,.15);transform:translateY(-2px)}100%{box-shadow:0 0 0 0 rgba(255,214,74,0),0 4px 0 rgba(0,0,0,.15)}}
.tleft{color:#2f6bb8}
#cardMe.warn .tleft{color:#e11d2a}
#hint.tip{color:#c45a10}
.ghtip{position:absolute;left:0;top:0;z-index:40;pointer-events:none;padding:5px 10px;border-radius:12px;background:rgba(20,36,61,.9);color:#fff;font:700 13px 'Baloo 2',sans-serif;white-space:nowrap;box-shadow:0 3px 10px rgba(0,0,0,.25)}
.ghtip b{color:#fff}.ghtip b.good{color:#7dff8a}.ghtip b.badv,.ghtip .badv{color:#ff8f8f}
/* steps-left chip + leader crown on the player cards */
.hnr{display:flex;align-items:center;gap:4px;min-width:0;max-width:100%}
.hs.opp .hnr{justify-content:flex-end}
.quad .hs .hnr{justify-content:center}
.hdist{flex:none;font:800 11px/1 'Baloo 2',sans-serif;font-style:normal;padding:2px 5px;border-radius:8px;background:rgba(255,255,255,.85);color:#14243d}
.hdist:empty{display:none}
.hs.lead .hdist{background:#ffd84a;color:#713a00}
.hs.lead .hav::after{content:'👑';position:absolute;top:-11px;left:50%;transform:translateX(-50%);font-size:14px;line-height:1;filter:drop-shadow(0 1px 1px rgba(0,0,0,.35))}
.hav{position:relative}
.quad .hdist{font-size:10px;padding:1px 4px}
body.wide #vsBar .hdist{font-size:13px;padding:2px 7px}
/* keyboard hints on the action buttons (wide screens only) */
.act kbd{display:none}
body.wide .act kbd{display:block;position:absolute;left:-6px;top:-8px;min-width:20px;height:20px;padding:0 5px;border-radius:6px;background:#fff;color:#14243d;font:800 12px/20px 'Baloo 2',sans-serif;text-shadow:none;box-shadow:0 2px 0 #9fb3cc;pointer-events:none}
/* history lines that point at something on the board */
#moveLog li.pk{cursor:default}
#moveLog li.pk:hover{background:rgba(255,216,74,.28);border-radius:8px}
/* unread count on the chat tab */
.sd-tabs button.new[data-n]::after{content:attr(data-n);width:auto;height:16px;min-width:16px;padding:0 4px;top:3px;right:8px;border-radius:8px;color:#fff;font:800 11px/16px 'Baloo 2',sans-serif;text-align:center}
/* result: progress toward the next rank */
.res-bar{width:min(100%,300px);margin:2px auto 8px;text-align:center}
.res-bar .rb-track{height:12px;border-radius:8px;background:rgba(20,36,61,.12);overflow:hidden;box-shadow:inset 0 2px 3px rgba(0,0,0,.12)}
.res-bar .rb-track b{display:block;height:100%;width:0;border-radius:8px;background:linear-gradient(#ffe27a,#f5a623);transition:width 1s cubic-bezier(.2,.8,.2,1)}
.res-bar span{display:block;margin-top:3px;font:700 13px 'Baloo 2',sans-serif;color:#5d6f8c}
#result #btnAgain.green{--c-top:var(--ui-green-top,#8be86a);--c-bot:var(--ui-green-bot,#34ad3a);--c-base:var(--ui-green-base,#247a29)}
/* home: replay the guided tutorial */
.tut-home{font-size:15px;margin-top:2px}
/* 4 players on a phone: the steps chip sits on the card corner so names keep their room */
body:not(.wide) .quad .hs{position:relative}
body:not(.wide) .quad .hdist{position:absolute;top:3px;right:3px;font-size:10px;box-shadow:0 1px 0 rgba(0,0,0,.15)}
/* lobby: the right column matches the left one (same top, same height); the leaderboard fills the rest */
body.wide #home .hm-r .hm-top{flex:1;min-height:0;display:flex;flex-direction:column}
body.wide #home .hm-r #hmTop{flex:1;min-height:0;overflow:auto}
/* lobby (wide): smaller logo so the middle column lines up with the side columns */
body.wide #home .logo img{width:min(16vw,170px)}
body.wide #home{--hero-height:clamp(96px,calc(17dvh - 20px),160px)}
/* the tutorial link moves into the rules card on wide screens */
body.wide #home .hm-mid #btnTutHome{display:none}
.hm-links{display:flex;justify-content:center;gap:14px;flex-wrap:wrap}
body.wide #home .hm-links{flex-wrap:nowrap;gap:8px}
body.wide #home .hm-links .link{flex:1;min-width:0;padding-inline:6px;white-space:nowrap;font-size:13px}
/* lobby (wide): the logo sits in a header strip on top; the middle column is the hero + buttons */
body.wide #home .hm-mid .logo{position:absolute;top:clamp(8px,1.6dvh,16px);left:clamp(16px,2.5vw,36px);transform:none;margin:0;z-index:2}
body.wide #home .logo img{width:clamp(120px,11vw,150px)}
body.wide #home .logo .tag{display:none}
body.wide #home{--hero-height:clamp(150px,calc(34dvh - 20px),290px)}

/* ===================== lobby v2: mode cards with per-mode medals ===================== */
#home.hv2{justify-content:flex-start;align-items:stretch;gap:clamp(6px,1.3dvh,12px);overflow:hidden}
#home.hv2 .hv-bar{display:flex;align-items:center;gap:8px;width:100%;max-width:460px;margin:0 auto}
.hv-me{flex:1;min-width:0;display:flex;align-items:center;gap:8px;padding:4px 14px 4px 4px;border:2px solid #fff;border-radius:999px;background:linear-gradient(#fff,#eaf2fd);
  box-shadow:0 3px 0 #b8c9e2,0 6px 14px rgb(16 33 59 / .16);color:#14243d;font:inherit;text-align:left;cursor:pointer}
.hv-me img{width:40px;height:40px;flex:none;border-radius:50%;background:linear-gradient(#cfe6ff,#8cc6ff);object-fit:cover}
.hv-me span{min-width:0}
.hv-me b{display:block;font:800 15px/1.1 'Baloo 2',sans-serif;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.hv-me small{display:block;font:700 12px/1.2 'Baloo 2',sans-serif;color:#5d6f8c;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.hv-ib{width:44px;height:44px;flex:none;display:grid;place-items:center;border:3px solid #fff;border-radius:14px;background:linear-gradient(#5fb6ff,#1f74e0);
  box-shadow:0 4px 0 #1550a8;color:#fff;font:800 20px/1 'Baloo 2',sans-serif;cursor:pointer;padding:0}
.hv-ib:active,.hv-me:active{transform:translateY(3px)}
#home.hv2 .hv-logo{text-align:center;flex:none}
#home.hv2 .hv-logo img{display:block;height:clamp(64px,13dvh,116px);width:auto;margin:0 auto;filter:drop-shadow(0 6px 5px rgba(0,0,0,.25));animation:pop .5s cubic-bezier(.3,1.6,.6,1)}
.hv-hero{position:relative;flex:1 1 auto;min-height:90px;display:flex;align-items:flex-end;justify-content:center;width:100%;max-width:460px;margin:0 auto}
.hv-hero canvas{height:100%;max-height:270px;aspect-ratio:.89;cursor:pointer}
.hv-cu{position:absolute;right:8px;bottom:12px;padding:5px 12px;border:2px solid #fff;border-radius:14px;background:#22324d;color:#fff;font:800 13px 'Baloo 2',sans-serif;box-shadow:0 3px 0 #0d1626;cursor:pointer}
/* mode cards */
#home.hv2 #modePick{display:grid;grid-template-columns:1fr 1fr;gap:10px;width:100%;max-width:460px;margin:0 auto}
#home.hv2 #modePick > button.hv-mode{position:relative;display:block;min-height:118px;margin:0;padding:12px 14px;border:3px solid #fff;border-radius:22px;overflow:hidden;text-align:left;
  color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.3);font:inherit;opacity:1;filter:none;transform:none;cursor:pointer;
  background:linear-gradient(160deg,var(--c) 0%,var(--d) 100%);box-shadow:0 5px 0 var(--d),0 10px 18px rgba(0,0,0,.18)}
#home.hv2 #modePick > button.hv-mode:active{transform:translateY(3px);box-shadow:0 2px 0 var(--d)}
#home.hv2 #modePick > button.hv-mode::after{content:none}
.hv-mode.race{--c:#4aa3ff;--d:#1a5aa8;grid-column:1/-1;min-height:124px!important;padding-right:118px!important}
.hv-mode.duel{--c:#ffa24a;--d:#c45a10}.hv-mode.quad{--c:#b08bff;--d:#6338c4}
.hv-mode h3{margin:0;font:800 21px/1 'Baloo 2',sans-serif}
.hv-mode.race h3{font-size:28px}
.hv-mode .mi{display:block;font-size:22px;line-height:1.1}
.hv-mode.race .mi{display:none}
.hv-mode p{margin:3px 0 0;font:700 13px/1.2 'Baloo 2',sans-serif;opacity:.95}
.hv-mode .rk{display:inline-flex;align-items:center;gap:6px;margin-top:9px;padding:3px 10px 3px 4px;border-radius:14px;background:rgba(255,255,255,.96);color:#14243d;text-shadow:none;font:800 13.5px 'Baloo 2',sans-serif;white-space:nowrap;max-width:100%}
.hv-mode .rk i{width:26px;height:26px;display:grid;place-items:center;border-radius:9px;font-style:normal;font-size:16px;background:linear-gradient(#fff2b8,#ffcf4a);box-shadow:inset 0 -2px 0 rgba(0,0,0,.12)}
.hv-mode .rk.new i{background:#e6edf6}
.hv-mode .rk em{font-style:normal;color:#b36b00}
.hv-mode .mb{position:absolute;right:12px;top:50%;width:96px;transform:translateY(-50%) rotate(-6deg);filter:drop-shadow(0 3px 0 rgba(0,0,0,.25))}
.hv-mode .mb svg{display:block;width:100%;height:auto}
.hv-mode .go{display:none}
.hv-online{display:flex;align-items:center;justify-content:center;gap:5px;color:#fff;font:800 13px 'Baloo 2',sans-serif;text-shadow:0 1px 3px #173a2c}
.hv-online .dot{width:9px;height:9px;border-radius:50%;border:1px solid #fff;background:#67ef71;box-shadow:0 0 7px #67ef71}
@media (max-height:700px){.hv-mode.race{min-height:104px!important}#home.hv2 #modePick > button.hv-mode{min-height:100px}.hv-mode .rk{margin-top:6px}}

/* wide lobby: logo top-left, buttons top-right, hero in the middle, three cards in a row */
body.wide #home.hv2{flex-direction:column;align-items:center;justify-content:flex-start;padding:14px 28px 22px;gap:14px}
body.wide #home.hv2 .hv-bar{position:absolute;top:18px;right:24px;width:auto;max-width:none;margin:0}
body.wide .hv-bar .hv-me{order:2;flex:none;max-width:280px}
body.wide .hv-bar #btnRoom{order:1}body.wide .hv-bar #btnSettings{order:3}
body.wide #home.hv2 .hv-logo{position:absolute;left:28px;top:12px}
body.wide #home.hv2 .hv-logo img{height:clamp(70px,11dvh,96px)}
body.wide .hv-hero{flex:1 1 auto;min-height:150px;max-width:520px;margin-top:clamp(70px,11dvh,100px)}
body.wide .hv-hero canvas{max-height:300px}
body.wide #home.hv2 #modePick{grid-template-columns:1.35fr 1fr 1fr;gap:18px;max-width:1080px}
body.wide .hv-mode.race{grid-column:auto;padding-right:150px!important}
body.wide #home.hv2 #modePick > button.hv-mode{min-height:clamp(150px,22dvh,190px);padding:16px 18px}
body.wide .hv-mode h3{font-size:27px}body.wide .hv-mode.race h3{font-size:30px}
body.wide .hv-mode p{font-size:15px}
body.wide .hv-mode .mb{width:120px;right:18px}
body.wide .hv-mode .go{display:block;position:absolute;right:14px;bottom:12px;padding:2px 10px;border-radius:999px;background:rgba(0,0,0,.22);font:800 13px 'Baloo 2',sans-serif}
body.wide .hv-mode.race .go{right:20px}
body.wide .hv-online{position:absolute;left:30px;bottom:18px}

/* ===================== one mode ===================== */
#mode{justify-content:flex-start;align-items:stretch;gap:10px;padding:calc(12px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));overflow-y:auto;overscroll-behavior:contain;
  background:linear-gradient(180deg,transparent 45%,rgb(15 46 40 / .24) 73%,rgb(15 42 34 / .48))}
.md-band{display:flex;align-items:center;gap:10px;width:100%;max-width:460px;margin:0 auto;flex:none}
.md-tt{flex:1;min-width:0;text-align:center}
.md-tt h2{margin:0;color:#fff;font:800 26px/1.05 'Baloo 2',sans-serif;text-shadow:0 2px 0 var(--md),0 3px 6px rgba(0,0,0,.3);white-space:nowrap}
.md-tt p{display:none}
.md-tabs{display:none}
.md-cols{display:flex;flex-direction:column;gap:10px;width:100%;max-width:460px;margin:0 auto}
.md-c{display:flex;flex-direction:column;gap:10px;min-height:0}
.md-l{display:none}
.md-card{padding:12px 14px;border:2px solid #fff;border-radius:20px;background:linear-gradient(#fff,#eef4fc);box-shadow:0 4px 0 #b8c9e2,0 8px 18px rgba(0,0,0,.12);color:#14243d;font:700 14px/1.3 'Baloo 2',sans-serif}
.md-cap{margin:0 0 6px;font:800 16px/1.1 'Baloo 2',sans-serif;color:#1f3354;display:flex;align-items:center;gap:6px}
.md-rank .r1{display:flex;align-items:center;gap:12px}
.md-rank .ic{width:54px;height:54px;flex:none;display:grid;place-items:center;border-radius:16px;font-size:32px;background:linear-gradient(#fff2b8,#ffcf4a);box-shadow:inset 0 -3px 0 rgba(0,0,0,.12)}
.md-rank .nm{font:800 22px/1 'Baloo 2',sans-serif}
.md-rank .pts{font:800 17px 'Baloo 2',sans-serif;color:#b36b00;margin-top:2px}
.md-rank .bar{height:10px;border-radius:8px;background:#e3eaf4;overflow:hidden;margin:9px 0 3px}
.md-rank .bar b{display:block;height:100%;background:linear-gradient(#ffe27a,#f5a623);transition:width .4s}
.md-rank .sub{font-size:12.5px;color:#5d6f8c}
.md-rank .ladder{display:flex;justify-content:space-between;margin-top:8px;padding-top:7px;border-top:2px dashed #e3eaf4}
.md-rank .ladder span{width:20%;display:flex;flex-direction:column;align-items:center;text-align:center;font-size:11px;font-weight:800;line-height:1.1;color:#8a99ad}
.md-rank .ladder i{font-style:normal;font-size:20px;filter:grayscale(1);opacity:.55}
.md-rank .ladder .done i{filter:none;opacity:1}
.md-rank .ladder .cur{color:#14243d}.md-rank .ladder .cur i{filter:none;opacity:1;transform:scale(1.25)}
.md-rank .ladder small{font-size:10px;color:#a3b0c2}
#mode .big{width:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;line-height:1.05;min-height:64px;padding:8px 10px}
#mode .big small{margin-top:2px}
#mode #btnPlay{font-size:26px}
#mode #btnSolo{font-size:21px}
.md-join{display:flex;gap:6px}
.md-join input{flex:1;min-width:0;height:42px;padding:0 10px;border:2px solid #cfd9e8;border-radius:12px;background:#fff;color:#1f3354;font:800 17px 'Baloo 2',sans-serif;letter-spacing:2px;user-select:text;-webkit-user-select:text}
.md-join input::placeholder{font-size:13.5px;letter-spacing:0;color:#8a99ad}
.md-join button{flex:none;padding:0 12px;min-height:42px;border:2px solid #fff;border-radius:12px;color:#fff;font:800 15px 'Baloo 2',sans-serif;text-shadow:0 1px 2px rgba(0,0,0,.3);background:linear-gradient(#5fb6ff,#1f74e0);box-shadow:0 3px 0 #1550a8;cursor:pointer}
.md-join button.g{background:linear-gradient(#8be86a,#34ad3a);box-shadow:0 3px 0 #247a29}
.md-join button:active{transform:translateY(2px);box-shadow:none}
.md-top ol,.md-live ul{margin:0;padding:0;list-style:none}
.md-top li{display:flex;align-items:center;gap:8px;padding:5px 8px;border-radius:10px;font-size:14px}
.md-top li:nth-child(odd){background:#f2f6fc}
.md-top li.me{background:linear-gradient(#e3f2ff,#cfe6ff);box-shadow:inset 0 0 0 2px #7fc0ff}
.md-top li b{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.md-top .ri{font-size:15px}
.md-top .hm-rk{width:26px;text-align:center;font:800 14px 'Baloo 2',sans-serif;color:#5d6f8c}
.md-top .hm-t{font:800 13px 'Baloo 2',sans-serif;color:#a85e00;white-space:nowrap}
:is(.md-top,.md-live) .hm-empty{display:block;justify-content:center;text-align:center;color:#8a99ad;background:none!important;font-size:13px;padding:8px}
.md-lv{margin-left:auto;font-size:12px;color:#e23b4a;animation:lvb 1.6s infinite}
@keyframes lvb{50%{opacity:.45}}
.md-live li{display:grid;grid-template-columns:minmax(0,1fr) 34px minmax(0,1fr) 54px 46px;align-items:center;gap:4px;min-height:44px;padding:6px 6px;border-radius:12px;font-size:13px}
.md-live li:nth-child(odd){background:#f2f6fc}
.md-live li.hm-empty{display:block}
.md-live .p1,.md-live .p2{display:flex;align-items:center;gap:4px;min-width:0;white-space:nowrap}
.md-live .p1{justify-content:flex-end}
.md-live .p1 b,.md-live .p2 b{overflow:hidden;text-overflow:ellipsis}
.md-live i{font-style:normal}
.md-live .vsx{justify-self:center;padding:0 6px;border-radius:8px;background:linear-gradient(#ff7a59,#e23b4a);box-shadow:0 2px 0 #a8202e;color:#fff;font:800 13px 'Baloo 2',sans-serif}
.md-live .st{font-size:11px;color:#8a99ad;text-align:right;white-space:nowrap}
.md-live .xem{border:none;border-radius:9px;padding:4px 0;background:linear-gradient(#5fb6ff,#1f74e0);box-shadow:0 2px 0 #1550a8;color:#fff;font:800 12px 'Baloo 2',sans-serif;cursor:pointer}
.md-live .xem:active{transform:translateY(2px);box-shadow:none}
.md-rule{text-align:center}
.md-rule .hm-mode{background:none;box-shadow:none}
.md-rule svg{display:block;width:110px;height:110px;margin:0 auto}
.md-rule p{margin:6px 0;color:#405068;font-size:13.5px}
.md-rule .link{font-size:14px}

/* wide: coloured band + three columns */
body.wide #mode{padding:0;gap:0;overflow:auto}
body.wide .md-band{max-width:none;height:96px;padding:0 28px;gap:16px;background:linear-gradient(90deg,var(--mc),var(--md));border-bottom:4px solid #fff;box-shadow:0 6px 18px rgba(0,0,0,.2);color:#fff}
body.wide .md-band .hv-ib{background:rgba(255,255,255,.2);box-shadow:none}
body.wide .md-tt{flex:1;text-align:left}
body.wide .md-tt h2{font-size:38px;text-shadow:0 3px 0 rgba(0,0,0,.25)}
body.wide .md-tt p{display:block;margin:2px 0 0;font:700 15px/1.2 'Baloo 2',sans-serif;opacity:.95;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
body.wide .md-tabs{display:flex;gap:6px}
body.wide .md-tabs button{padding:6px 14px;border:none;border-radius:12px;background:rgba(0,0,0,.18);color:#fff;font:800 14px 'Baloo 2',sans-serif;cursor:pointer}
body.wide .md-tabs button.on{background:#fff;color:var(--md)}
body.wide .md-cols{display:grid;grid-template-columns:clamp(240px,22vw,300px) minmax(0,1fr) clamp(300px,30vw,400px);gap:clamp(16px,2.2vw,28px);max-width:1280px;padding:20px clamp(18px,2.8vw,36px) 26px;flex:1;min-height:0;align-items:stretch}
body.wide .md-l{display:flex}
body.wide .md-c > .md-card:last-child{flex:1}
body.wide .md-hero{flex:none;height:clamp(170px,30dvh,250px);display:flex;align-items:center;justify-content:center;border:3px solid rgba(255,255,255,.7);border-radius:24px;background:rgba(255,255,255,.35)}
body.wide .md-hero canvas{height:92%;aspect-ratio:.89}
body.wide #mode .big{min-height:clamp(64px,10dvh,84px)}
body.wide #mode #btnPlay{font-size:32px}body.wide #mode #btnSolo{font-size:26px}
body.wide #mode .big small{font-size:15px}
body.wide .md-top li{padding:6px 10px}
body.wide .md-top{flex:none!important}

/* watching a match: nothing to press */
body.spect #actions,body.spect #quick,body.spect #sdTabs,body.spect .sd-keys,body.spect #cardMe .stats{display:none!important}
body.wide #home.hv2 #btnRoom{display:grid}
#home.hv2 .hv-hero{margin-bottom:4px}

/* ===== painted icons + team review fixes ===== */
img.ico{width:1.25em;height:1.25em;vertical-align:-.28em;margin-right:.15em;object-fit:contain;pointer-events:none}
.hv-ib img.bi{width:30px;height:30px;object-fit:contain;pointer-events:none;filter:drop-shadow(0 1px 1px rgb(0 0 0 / .25))}
.hv-cu{display:inline-flex;align-items:center;gap:4px;min-height:44px;padding:4px 14px 4px 10px;font-size:14px}
.hv-cu img.ico{width:26px;height:26px;margin:0}
/* mode cards: painted icon, chips line up at the bottom */
#home.hv2 #modePick > button.hv-mode{display:flex;flex-direction:column;align-items:flex-start}
.hv-mode img.mi{display:block;width:40px;height:40px;object-fit:contain;margin:-4px 0 2px -2px;filter:drop-shadow(0 2px 2px rgb(0 0 0 / .25))}
.hv-mode.race img.mi{display:none}
.hv-mode .rk{margin-top:auto!important;padding-top:3px;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.hv-mode p{margin-bottom:8px}
.hv-mode .rk img.ri{width:26px;height:26px;flex:none;object-fit:contain;border-radius:9px;background:linear-gradient(#fff6d6,#ffe08a);padding:2px}
.hv-mode .rk.new img.ri{background:#e6edf6}
.hv-mode .rk em{display:inline-flex;align-items:center;gap:2px}
.hv-mode .rk em img.ico{margin:0;width:18px;height:18px}
.hv-mode .rk .rn{overflow:hidden;text-overflow:ellipsis}
@media (max-width:400px){.hv-mode:not(.race) .rk{font-size:12px;gap:4px;padding-right:8px}}
body.wide #home.hv2 #modePick{grid-template-columns:1.5fr 1fr 1fr}
body.wide .hv-mode img.mi{width:46px;height:46px}
body.wide .hv-mode.race h3{font-size:32px}
/* mode screen */
.md-tt h2{display:flex;align-items:center;justify-content:center;gap:6px}
.md-tt h2 img.hi{width:34px;height:34px;object-fit:contain;filter:drop-shadow(0 2px 2px rgb(0 0 0 / .3))}
body.wide .md-tt h2{justify-content:flex-start;font-size:clamp(26px,2.9vw,38px)}
body.wide .md-tt h2 img.hi{width:48px;height:48px}
body.wide .md-tt p{font-size:14px}
body.wide .md-band{position:sticky;top:0;z-index:5}
body.wide .md-tabs button{display:inline-flex;align-items:center;gap:4px;min-height:44px;padding:4px 14px 4px 8px;white-space:nowrap}
body.wide .md-tabs img.ico{width:26px;height:26px;margin:0}
.md-cap img.ico{width:24px;height:24px;margin:0}
.md-rank .ic{background:linear-gradient(#fff6d6,#ffe08a)}
.md-rank .ic img.ri{width:46px;height:46px;object-fit:contain}
.md-rank .pts{display:flex;align-items:center;gap:3px}
.md-rank .pts img.ico{width:22px;height:22px;margin:0}
.md-rank .sub{display:flex;flex-direction:column;gap:1px;font-size:13px;color:#475569}
.md-rank .sub b{color:#1f3354;font-size:14px}
.md-rank .ladder span{color:#566882}
.md-rank .ladder small{color:#6b7a90}
.md-rank .ladder img.li{width:30px;height:30px;object-fit:contain;filter:grayscale(1) brightness(1.1);opacity:.5;margin-bottom:1px}
.md-rank .ladder .done img.li{filter:none;opacity:.9}
.md-rank .ladder .cur{background:#e3f0ff;border-radius:10px;box-shadow:inset 0 0 0 2px #9ccaff;padding:3px 0;color:#14243d}
.md-rank .ladder .cur img.li{filter:none;opacity:1;transform:scale(1.15)}
.md-join input,.md-join button{min-height:46px;height:46px}
.md-join{gap:8px}
.md-top .ri,.md-live .ri{width:22px;height:22px;object-fit:contain;flex:none}
.md-top .hm-t{display:inline-flex;align-items:center;gap:2px}
.md-top .hm-t img.ico{width:18px;height:18px;margin:0}
:is(.md-top,.md-live) .hm-empty{color:#566882;font-size:14px}
.md-live .st{color:#566882}
.md-live .xem{display:inline-flex;align-items:center;justify-content:center;gap:2px;min-height:36px;padding:0 4px}
.md-live .xem img.xi{width:18px;height:18px;object-fit:contain}
.md-live li{grid-template-columns:minmax(0,1fr) 34px minmax(0,1fr) 54px 58px}
.md-live .xem:disabled{opacity:.6}
.md-live:not(.on) .md-lv{display:none}
@media (max-width:420px){.md-live li{grid-template-columns:minmax(0,1fr) 30px minmax(0,1fr) 58px}.md-live .st{display:none}}
body.wide .md-top li{min-height:38px;font-size:15px}
body.wide .md-top .hm-t{font-size:14px}
body.wide .md-live li{font-size:14px;min-height:48px}
body.wide .md-cap{font-size:18px}
/* phones in portrait wider than 600 (tablets): a little more room */
@media (min-width:600px){body:not(.wide) :is(#home.hv2 .hv-bar,#home.hv2 #modePick,.hv-hero,.md-band,.md-cols){max-width:580px}}
@media (max-width:1100px){body.wide .md-cols{grid-template-columns:clamp(220px,21vw,300px) minmax(0,1fr) clamp(280px,29vw,340px)}}
:is(.hv-me,.hv-ib,.hv-cu,.md-tabs button,.md-join button,.md-live .xem,.hv-mode):focus-visible{outline:3px solid #ffd23f;outline-offset:2px}
body.wide #home.hv2{padding-bottom:30px}
body.wide .hv-online{bottom:6px}
/* icons a size smaller */
.hv-ib img.bi{width:24px;height:24px}
.hv-cu img.ico{width:20px;height:20px}
.hv-mode img.mi{width:30px;height:30px;margin:-2px 0 2px -1px}
body.wide .hv-mode img.mi{width:34px;height:34px}
.hv-mode .rk img.ri{width:22px;height:22px;border-radius:7px}
.hv-mode .rk em img.ico{width:15px;height:15px}
.md-tt h2 img.hi{width:28px;height:28px}
body.wide .md-tt h2 img.hi{width:38px;height:38px}
body.wide .md-tabs img.ico{width:20px;height:20px}
.md-cap img.ico{width:20px;height:20px}
.md-rank .ic img.ri{width:38px;height:38px}
.md-rank .pts img.ico{width:18px;height:18px}
.md-rank .ladder img.li{width:24px;height:24px}
.md-top .ri,.md-live .ri{width:18px;height:18px}
.md-top .hm-t img.ico{width:15px;height:15px}
.md-live .xem img.xi{width:15px;height:15px}
img.ico{width:1.1em;height:1.1em;vertical-align:-.22em}

/* ===== customize v2: tabs + fence skins ===== */
#custom.cu2{padding:max(8px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));overflow:hidden;align-items:stretch}
#custom.cu2 .cu-wrap{display:flex;flex-direction:column;gap:var(--b-gap);width:100%;max-width:460px;margin:0 auto;flex:1;min-height:0}
#custom.cu2 .cu-left,#custom.cu2 .cu-right{display:flex;flex-direction:column;gap:var(--b-gap);min-height:0}
#custom.cu2 .cu-right{flex:1}
#custom.cu2 .lv-head{max-width:none}
#custom.cu2 .cu-sp{width:44px}
#custom.cu2 .cu-stage{position:relative;display:block;width:100%;height:clamp(170px,31dvh,260px);padding:0;flex:none;overflow:hidden;border:3px solid #fff;border-radius:26px;background:radial-gradient(ellipse 70% 62% at 50% 46%,#ffffff,#dff0ff 72%);box-shadow:0 5px 0 var(--b-edge)}
#custom.cu2 #cuStage canvas{position:absolute;inset:6px 0 auto;width:100%;height:calc(100% - 30px);aspect-ratio:auto;display:block}
#custom.cu2 #cuStage #cuFence{inset:0;height:100%}
#custom.cu2 #cuStage canvas[hidden]{display:none}
#custom.cu2 .cu-hint{position:absolute;inset:auto auto 7px 50%;transform:translateX(-50%);max-width:calc(100% - 20px);overflow:hidden;text-overflow:ellipsis;padding:1px 10px;border-radius:999px;background:#fff;color:#475569;font:800 12px/1.3 'Baloo 2',sans-serif;box-shadow:0 1px 0 #c9d6e8}
#custom.cu2 .cu-dice{position:absolute;top:8px;right:8px;width:44px;height:44px;border:none;border-radius:14px;background:#fff;box-shadow:0 3px 0 #b8c9e2;font-size:21px;cursor:pointer;touch-action:manipulation}
#custom.cu2 .cu-dice:active{transform:translateY(2px);box-shadow:0 1px 0 #b8c9e2}
#custom.cu2 .cu-tabs{display:grid;grid-template-columns:repeat(4,1fr);gap:6px;flex:none}
#custom.cu2 .cu-tabs button{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;height:58px;border:2px solid #fff;border-radius:16px;background:rgba(255,255,255,.8);color:#405068;font:800 13px/1 'Baloo 2',sans-serif;cursor:pointer;box-shadow:0 3px 0 rgba(31,51,84,.18);touch-action:manipulation}
#custom.cu2 .cu-tabs button b{font-size:22px;line-height:1.05}
#custom.cu2 .cu-tabs button.on{background:linear-gradient(#ffd66b,#ffae1a);color:#5a3300;box-shadow:0 4px 0 #c47a00;transform:translateY(-2px)}
#custom.cu2 .cu-dot{position:absolute;top:5px;right:9px;width:10px;height:10px;border-radius:50%;background:#ff4b4b;border:2px solid #fff}
#custom.cu2 .cu-dot[hidden]{display:none}
#custom.cu2 .cu-panel{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;background:linear-gradient(#fff,#eef4fc);border:2px solid #fff;border-radius:22px;box-shadow:0 4px 0 var(--b-edge);padding:12px 12px 14px;display:flex;flex-direction:column;gap:14px}
#custom.cu2 .cu-sec h4{margin:0 0 7px;font:800 15px/1.1 'Baloo 2',sans-serif;color:#1f3354}
#custom.cu2 .cu-cards{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}
#custom.cu2 .cu-cards.two{grid-template-columns:1fr 1fr}
#custom.cu2 .cu-card{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;min-height:72px;padding:6px 4px;border:none;border-radius:16px;background:#fff;box-shadow:inset 0 0 0 2px #dbe6f4,0 3px 0 #cfd9e8;color:#1f3354;font:800 13px/1.1 'Baloo 2',sans-serif;cursor:pointer;touch-action:manipulation}
#custom.cu2 .cu-cards.two .cu-card{flex-direction:row;min-height:50px;gap:8px;font-size:15px}
#custom.cu2 .cu-card i{font-style:normal;font-size:30px;line-height:1.1}
#custom.cu2 .cu-cards.two .cu-card i{font-size:22px}
#custom.cu2 :is(.cu-card,.cu-fc).on{background:#f4efff;box-shadow:inset 0 0 0 3px #7a4ae6,0 3px 0 #7a4ae6}
#custom.cu2 :is(.cu-card,.cu-fc,.cu-sw).on::after{content:'✓';position:absolute;right:-5px;top:-5px;width:20px;height:20px;border-radius:50%;background:#7a4ae6;color:#fff;font:900 12px/18px 'Baloo 2',sans-serif;text-align:center;border:2px solid #fff;outline:none}
#custom.cu2 .cu-sws{display:flex;flex-wrap:wrap;gap:9px}
#custom.cu2 .cu-sw{position:relative;width:46px;height:46px;flex:none;padding:0;border-radius:50%;border:4px solid #fff;outline:none;box-shadow:0 0 0 2px #cfd9e8,0 3px 0 rgba(0,0,0,.12);background-color:#fff;background-image:none;color:#8a96a8;font:800 16px 'Baloo 2',sans-serif;cursor:pointer;touch-action:manipulation}
#custom.cu2 .cu-sw.on{box-shadow:0 0 0 3px #7a4ae6,0 3px 0 rgba(0,0,0,.12)}
#custom.cu2 .cu-sw.on::after{top:auto;bottom:-7px;right:-7px}
#custom.cu2 .cu-fgrid{display:grid;grid-template-columns:1fr 1fr;gap:10px}
#custom.cu2 .cu-fc{position:relative;display:flex;flex-direction:column;align-items:center;gap:1px;padding:4px 6px 8px;border:none;border-radius:18px;background:#fff;box-shadow:inset 0 0 0 2px #dbe6f4,0 3px 0 #cfd9e8;color:#1f3354;cursor:pointer;touch-action:manipulation}
#custom.cu2 .cu-fc img{width:100%;max-width:170px;aspect-ratio:240/110;object-fit:contain;pointer-events:none}
#custom.cu2 .cu-fc b{font:800 14px/1.15 'Baloo 2',sans-serif}
#custom.cu2 .cu-fc small{font:700 11.5px/1.2 'Baloo 2',sans-serif;color:#566882;text-align:center}
#custom.cu2 .cu-fc.lock img{filter:grayscale(.85) brightness(1.08);opacity:.55}
#custom.cu2 .cu-fc.lock.peek{box-shadow:inset 0 0 0 3px #f5a524,0 3px 0 #f5a524}
#custom.cu2 .cu-fc.lock.peek img{filter:none;opacity:1}
#custom.cu2 .cu-fc .lk{position:absolute;top:5px;right:8px;font-size:15px}
#custom.cu2 .cu-fc .new{position:absolute;top:6px;left:8px;background:#ff5c5c;color:#fff;border-radius:8px;padding:0 6px;font:800 11px/1.5 'Baloo 2',sans-serif}
#custom.cu2 .cu-note{margin:0;background:#fff7d6;border:2px dashed #f5c242;border-radius:14px;padding:6px 10px;font:700 12.5px/1.35 'Baloo 2',sans-serif;color:#6b4e00}
#custom.cu2 #btnCuDone{width:100%;max-width:none;min-height:54px;font-size:22px}
#custom.cu2 :is(.cu-tabs button,.cu-card,.cu-fc,.cu-sw,.cu-dice):focus-visible{outline:2px solid #1f3354;outline-offset:2px}
@media (max-height:680px){#custom.cu2 .cu-stage{height:clamp(140px,26dvh,200px)}#custom.cu2 .cu-tabs button{height:50px}#custom.cu2 .cu-tabs button b{font-size:19px}}
/* wide: preview left, tabs + options right */
body.wide #custom.cu2 .cu-wrap{display:grid;grid-template-columns:minmax(0,1fr) minmax(420px,560px);gap:28px;max-width:1180px;padding:8px 12px 6px}
body.wide #custom.cu2 .cu-left{min-height:0}
body.wide #custom.cu2 .cu-stage{flex:1;height:auto}
body.wide #custom.cu2 .cu-fgrid{grid-template-columns:repeat(3,1fr)}
body.wide #custom.cu2 .cu-tabs button{height:64px;font-size:14px}
body.wide #custom.cu2 #cuStage #cuPreview{inset:10% 18% auto;width:64%;height:78%}

/* settings: rows stand out from the panel */
#settings .panel.set{background:linear-gradient(#dfeafa,#c9dbf1)}
#settings .tg{background:#fff;border:2px solid #fff;box-shadow:0 0 0 1.5px #b9cbe3,0 4px 0 #9fb5d3}
#settings .tg .ic{background:color-mix(in srgb,var(--ic) 26%,#fff);border:2px solid color-mix(in srgb,var(--ic) 55%,#fff);box-shadow:none}
#settings .tg i{background:#7d8ea6;border-color:#fff;box-shadow:inset 0 2px 3px rgb(16 33 59 / .35),0 0 0 1px #6b7c94}
#settings .tg.on i{background:linear-gradient(#6fd862,#2fa33a);box-shadow:inset 0 -2px 0 rgb(36 122 41 / .4),0 0 0 1px #2a8f33}
#settings .set-how-box{background:#fff;box-shadow:0 0 0 1.5px #b9cbe3,0 4px 0 #9fb5d3}

/* ===== room v2: header · options · code · seats (fill) · start · join (mobile) / seats left + panel right (web) ===== */
#room.rm2{padding:max(8px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));align-items:stretch;overflow:hidden}
#room.rm2 .rm-wrap{display:flex;flex-direction:column;gap:10px;width:100%;max-width:440px;margin:0 auto;flex:1;min-height:0}
#room.rm2 .rm-side{display:contents}
#room.rm2 .lv-head{order:0;max-width:none;grid-template-columns:44px minmax(0,1fr) 88px}
#room.rm2 .lv-head .lv-title{font-size:clamp(20px,6vw,26px)}
#room.rm2 #roomNet{justify-self:end;height:30px;padding:0 9px;border-radius:999px}
#room.rm2 .rm-opts{order:1;display:grid;grid-template-columns:1fr 1fr;gap:8px;flex:none}
#room.rm2 .room-code{order:2;display:flex;gap:8px;width:100%;max-width:none;flex:none}
#room.rm2 #roomGrid{order:3;flex:1 1 auto;min-height:0;max-width:none;grid-auto-rows:1fr;gap:10px}
#room.rm2 #roomGrid.room-two{flex-basis:auto;min-height:0}
#room.rm2 .room-msg{order:4;max-width:none}
#room.rm2 #btnRoomStart{order:5;width:100%;min-height:54px;font-size:22px}
#room.rm2 .rm-jt{order:6}
#room.rm2 .room-join{order:7;display:none;width:100%;max-width:none}
#room.rm2.join-open .room-join{display:flex}
/* pills */
#room.rm2 .rm-pill{position:relative;display:flex;align-items:center;justify-content:center;gap:4px;min-height:44px;padding:0 10px;border:2px solid #fff;border-radius:999px;color:#fff;font:800 14.5px/1 'Baloo 2',sans-serif;text-shadow:0 1px 2px rgb(0 0 0 / .3);box-shadow:inset 0 2px 0 rgb(255 255 255 / .3),0 3px 0 rgb(31 51 84 / .35);cursor:pointer;white-space:nowrap;overflow:hidden;touch-action:manipulation}
#room.rm2 .rm-pill::after{content:'▾';font-size:12px;opacity:.9}
#room.rm2 #roomObst{background:linear-gradient(#6fd862,#2fa33a)}
#room.rm2 #roomObst.off{background:linear-gradient(#a9b6c8,#76869c)}
#room.rm2 .rm-pill:active{transform:translateY(2px)}
/* code + invite */
#room.rm2 .rc-box{flex:1;display:flex;align-items:center;gap:8px;min-width:0;min-height:52px;padding:4px 5px 4px 12px;border:2px solid #fff;border-radius:16px;background:#fff;box-shadow:0 0 0 1.5px #b9cbe3,0 4px 0 #9fb5d3;color:#475569;font:800 13px/1 'Baloo 2',sans-serif}
#room.rm2 .rc-box b{flex:1;color:#1f3354;font:800 26px/1 'Baloo 2',sans-serif;letter-spacing:3px;font-variant-numeric:tabular-nums}
#room.rm2 #btnCopyCode{width:42px;height:42px;min-height:0}
#room.rm2 #btnInvite{flex:none;min-height:52px;padding:0 14px;border-radius:16px;font-size:15px}
/* seats */
#room.rm2 #roomGrid .seat{border-radius:22px}
#room.rm2 #roomGrid .seat .st3d{height:clamp(60px,calc(100% - 62px),220px)}
#room.rm2 #roomGrid.room-two .seat .st3d{height:clamp(90px,calc(100% - 62px),260px)}
#room.rm2 #roomGrid .seat.empty{background:rgba(255,255,255,.55);border:2px dashed #fff;box-shadow:none}
/* join toggle + row */
#room.rm2 .rm-jt{flex:none;align-self:center;min-height:40px;padding:0 16px;border:none;border-radius:999px;background:rgba(255,255,255,.9);box-shadow:0 3px 0 rgb(31 51 84 / .2);color:#1f3354;font:800 14px/1 'Baloo 2',sans-serif;cursor:pointer;touch-action:manipulation}
#room.rm2.join-open .rm-jt{background:#1f3354;color:#fff}
#room.rm2 .room-join #joinCode{flex:1;background:#fff;letter-spacing:2px}
/* wide: seats on the left, everything else in a panel on the right */
body.wide #room.rm2 .rm-wrap{display:grid;grid-template-columns:minmax(0,1fr) 380px;grid-template-rows:auto minmax(0,1fr);gap:16px 24px;max-width:1160px;padding:6px 0}
body.wide #room.rm2 .lv-head{grid-column:1/-1}
body.wide #room.rm2 #roomGrid{grid-column:1;grid-row:2}
body.wide #room.rm2 .rm-side{grid-column:2;grid-row:2;display:flex;flex-direction:column;gap:12px;align-self:start;padding:14px;border:2px solid #fff;border-radius:24px;background:linear-gradient(#ffffffee,#e6effbee);box-shadow:0 5px 0 #9fb5d3}
body.wide #room.rm2 .rm-jt{display:none}
body.wide #room.rm2 .room-join{display:flex;padding-top:12px;border-top:2px dashed #c9d8ec}
body.wide #room.rm2 .room-join::before{content:'Vào phòng khác';align-self:center;flex:none;color:#475569;font:800 13px 'Baloo 2',sans-serif}
#room.rm2 #roomGrid.room-two{grid-auto-rows:minmax(0,310px);align-content:center}
body.wide #room.rm2 #roomGrid.room-two{grid-auto-rows:minmax(0,420px)}
body.wide #room.rm2 #roomGrid .seat .st3d{height:clamp(90px,calc(100% - 64px),340px)}
body.wide #room.rm2 .rm-pill{font-size:15px}

/* headers float on the scene: no panel behind them */
:is(#levels,#custom,#room) .lv-head{background:none;border:none;box-shadow:none;padding:0 2px}
:is(#levels,#custom,#room) .lv-head .lv-title{color:#fff;text-shadow:0 2px 0 #1a5aa8,0 3px 8px rgb(0 0 0 / .3)}
#levels .lv-head .lv-sub{text-shadow:none}
/* room: join-by-code card */
#room.rm2 .rm-joincard{order:7;flex:none;display:flex;flex-direction:column;gap:6px;padding:8px 10px 10px;border:2px solid #fff;border-radius:18px;background:#fff;box-shadow:0 0 0 1.5px #b9cbe3,0 4px 0 #9fb5d3}
#room.rm2 .rm-jl{color:#1f3354;font:800 14px/1.1 'Baloo 2',sans-serif;padding-left:2px}
#room.rm2 .rm-joincard .room-join{display:flex;gap:8px}
#room.rm2 .room-join #joinCode{flex:1;min-height:46px;border:2px solid #b9cbe3;border-radius:12px;background:#f4f8fd;box-shadow:inset 0 2px 0 rgb(31 51 84 / .08);font:800 20px/1 'Baloo 2',sans-serif;letter-spacing:4px;text-align:center;color:#1f3354}
#room.rm2 .room-join #joinCode::placeholder{letter-spacing:0;font-size:14px;color:#7d8aa0}
#room.rm2 #btnJoin{flex:none;min-height:46px;padding:0 14px;font-size:15px}
body.wide #room.rm2 .rm-joincard{padding:12px 0 0;border:none;border-top:2px dashed #c9d8ec;border-radius:0;background:none;box-shadow:none}
body.wide #room.rm2 .room-join::before{content:none}
/* global floating toast */
#toast{position:fixed;left:50%;top:calc(env(safe-area-inset-top,0px) + 74px);z-index:200;max-width:min(92vw,520px);padding:9px 18px;border:2px solid rgb(255 255 255 / .85);border-radius:18px;background:rgba(20,36,61,.92);color:#fff;font:800 15px/1.25 'Baloo 2',sans-serif;text-align:center;box-shadow:0 8px 22px rgb(0 0 0 / .28);pointer-events:none;opacity:0;transform:translate(-50%,-16px) scale(.96);transition:opacity .22s,transform .3s cubic-bezier(.3,1.5,.6,1)}
#toast.show{opacity:1;transform:translate(-50%,0) scale(1)}
#toast:empty{display:none}
#toast{width:max-content}
#settings .set-lang{display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%;min-height:44px;padding:4px 7px 4px 5px;border:2px solid #fff;border-radius:14px;background:#fff;box-shadow:0 0 0 1.5px #b9cbe3,0 4px 0 #9fb5d3;color:var(--ui-ink,#1f3354);font:800 clamp(14px,3.85vw,17px)/1.1 'Baloo 2',system-ui,sans-serif;cursor:pointer}
#settings .set-lang span{display:flex;align-items:center;gap:7px;min-width:0}
#settings .set-lang .ic{flex:none;width:30px;height:30px;display:grid;place-items:center;border-radius:9px;font-size:16px;background:color-mix(in srgb,var(--ic) 26%,#fff);border:2px solid color-mix(in srgb,var(--ic) 55%,#fff)}
#settings #setLang{flex:none;max-width:52%;min-height:36px;padding:0 28px 0 10px;border:2px solid #b9cbe3;border-radius:10px;background:#f4f8fd url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%231f3354' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 9px center;color:#1f3354;font:800 15px 'Baloo 2',system-ui,sans-serif;appearance:none;-webkit-appearance:none;cursor:pointer}

/* web mode screen: cards hug their content instead of stretching to the bottom */
body.wide .md-cols{align-items:start;align-content:start}
body.wide .md-c{min-height:0;max-height:100%}
body.wide .md-c > .md-card:last-child{flex:0 1 auto;min-height:0}
body.wide .md-live{overflow:auto}

/* web room: seats start at the top, next to the side panel */
body.wide #room.rm2 #roomGrid{align-self:start;align-content:start}
/* web customize: tabs line up with the top of the character box */
body.wide #custom.cu2 .cu-wrap{grid-template-rows:auto minmax(0,1fr);row-gap:var(--b-gap,10px)}
body.wide #custom.cu2 .cu-left{display:contents}
body.wide #custom.cu2 .cu-left > .lv-head{grid-column:1;grid-row:1}
body.wide #custom.cu2 .cu-stage{grid-column:1;grid-row:2;min-height:0}
body.wide #custom.cu2 .cu-right{grid-column:2;grid-row:2;min-height:0}
/* rename field (Customize → Character) */
#custom.cu2 .cu-nrow{position:relative}
#custom.cu2 #cuName{width:100%;box-sizing:border-box;min-height:46px;padding:0 40px 0 14px;border:2px solid #c9d8ec;border-radius:14px;background:#fff;color:#1f3354;font:800 17px 'Baloo 2',sans-serif;outline:none}
#custom.cu2 #cuName:focus{border-color:#7c5cf0;box-shadow:0 0 0 3px rgb(124 92 240 / .18)}
#custom.cu2 .cu-nok{position:absolute;right:12px;top:50%;transform:translateY(-50%);font-size:16px;pointer-events:none;opacity:.7}

/* settings → move to another device */
#settings .set-rc em{flex:none;margin-left:auto;padding-right:6px;color:#7d8ea8;font:800 24px/1 'Baloo 2',sans-serif;font-style:normal}
#rcBox{z-index:60}
#rcBox .rc-panel{width:min(380px,calc(100vw - 32px));max-width:380px;gap:12px;padding:18px 16px 16px;border:3px solid #fff;border-radius:26px;background:linear-gradient(#f7fbff,#e4eefb);box-shadow:0 6px 0 #9fb5d3,0 16px 40px rgb(0 0 0 / .3);color:#1f3354}
#rcBox h2{margin:0 36px;font:800 22px/1.15 'Baloo 2',sans-serif;text-align:center;color:#1f3354}
#rcBox .rc-sec{width:100%;display:flex;flex-direction:column;gap:8px;padding:12px;border-radius:18px;background:#fff;box-shadow:0 2px 0 #c9d8ec;box-sizing:border-box}
#rcBox .rc-cap{font:800 15px 'Baloo 2',sans-serif}
#rcBox .rc-code{display:flex;align-items:center;gap:8px}
#rcBox .rc-code b{flex:1;padding:8px 0;border:2px dashed #c9d8ec;border-radius:14px;background:#f4f8fd;text-align:center;font:800 28px/1 'Baloo 2',ui-monospace,monospace;letter-spacing:.12em;color:#1f3354}
#rcBox .rc-code button{flex:none;width:48px;height:48px;border:none;border-radius:14px;background:linear-gradient(#5aa8ff,#2f74e0);box-shadow:0 3px 0 #1d4f9e;color:#fff;font:800 22px/1 sans-serif;cursor:pointer}
#rcBox .rc-row{display:flex;gap:8px}
#rcBox #rcIn{flex:1;min-width:0;min-height:48px;padding:0 10px;border:2px solid #c9d8ec;border-radius:14px;background:#f4f8fd;color:#1f3354;text-align:center;font:800 20px 'Baloo 2',ui-monospace,monospace;letter-spacing:.1em;outline:none;text-transform:uppercase}
#rcBox #rcIn:focus{border-color:#2f86e8;background:#fff}
#rcBox #rcGo{flex:none;width:auto;min-height:48px;margin:0;padding:0 14px;font-size:16px}
#rcBox .rc-note{margin:0;color:#5b6b82;font:700 12.5px/1.35 'Baloo 2',sans-serif}
#rcBox .rc-note.warn{color:#b45309}
#rcBox .rc-qr{align-self:center;width:156px;height:156px;padding:6px;border-radius:14px;background:#fff;box-shadow:0 0 0 2px #c9d8ec}
#rcBox .rc-qr:empty{background:#f4f8fd}
#rcBox .rc-qr svg{display:block;width:100%;height:100%}
/* opened from a QR: only the restore part */
#rcBox.rc-scan .rc-sec:not(.rc-in){display:none}
#rcBox .rc-panel{max-height:calc(100dvh - 24px);overflow-y:auto}
