/* ============================================================
   🎲 LUDO — giao diện (mobile first). Mọi rule nằm dưới #modal-ludo / .ludo-* để không đụng phần khác.
   ============================================================ */
#modal-ludo{ z-index:9400; background:rgba(20,12,40,.55); padding:0; align-items:center; }
#modal-ludo .ludo-sheet{
  --lc-red:#ef4444; --lc-green:#22c55e; --lc-yellow:#f5b50a; --lc-blue:#3b82f6;
  width:100%; max-width:460px; height:100%; max-height:100dvh; display:flex; flex-direction:column;
  background:linear-gradient(180deg,#fff8fd 0%,#f4f0ff 100%); color:#241a3d; position:relative; overflow:hidden;
  padding-top:env(safe-area-inset-top,0px); padding-bottom:env(safe-area-inset-bottom,0px);
}
@media (min-width:520px){ #modal-ludo .ludo-sheet{ height:min(900px,96dvh); border-radius:26px; box-shadow:0 30px 80px -20px rgba(43,31,69,.55);} }
.ludo-top{ display:flex; align-items:center; gap:8px; padding:10px 12px 6px; }
.ludo-title{ font-family:'Baloo 2','Nunito',system-ui,sans-serif; font-weight:800; font-size:19px; flex:1; display:flex; align-items:center; gap:6px; }
.ludo-title small{ font-size:11px; font-weight:700; color:#8b7fab; background:#ffffffb8; padding:2px 8px; border-radius:99px; border:1px solid rgba(43,31,69,.1); }
.ludo-ibtn{ width:36px; height:36px; border-radius:12px; border:1px solid rgba(43,31,69,.12); background:#fff; font-size:17px; display:flex; align-items:center; justify-content:center; cursor:pointer; color:#4b3f72; box-shadow:0 2px 8px -4px rgba(43,31,69,.25); }
.ludo-ibtn:active{ transform:scale(.94); }
#ludo-body{ flex:1; overflow-y:auto; overflow-x:hidden; padding:4px 12px 14px; -webkit-overflow-scrolling:touch; }

/* nút */
.ludo-btn{ border:0; border-radius:16px; padding:13px 16px; font-weight:800; font-size:15px; cursor:pointer; width:100%;
  background:linear-gradient(120deg,#ff2e9a,#ff7a45); color:#fff; box-shadow:0 10px 22px -10px rgba(255,46,154,.7); transition:transform .12s, opacity .2s; }
.ludo-btn:active{ transform:scale(.97); }
.ludo-btn[disabled]{ opacity:.45; filter:grayscale(.4); pointer-events:none; }
.ludo-btn.alt{ background:#fff; color:#4b3f72; border:1px solid rgba(43,31,69,.14); box-shadow:0 4px 12px -8px rgba(43,31,69,.3); }
.ludo-btn.danger{ background:#fff; color:#ef4360; border:1px solid rgba(239,67,96,.35); box-shadow:none; }
.ludo-btn.sm{ padding:9px 12px; font-size:13px; border-radius:12px; width:auto; }
.ludo-row{ display:flex; gap:8px; margin-top:10px; }
.ludo-row > *{ flex:1; }

/* thẻ chọn game */
.ludo-hero{ background:#fff; border-radius:22px; padding:14px; border:1px solid rgba(43,31,69,.08); box-shadow:0 14px 30px -18px rgba(43,31,69,.4); }
.ludo-hero .illus{ width:min(220px,64%); margin:2px auto 8px; display:block; filter:drop-shadow(0 12px 14px rgba(43,31,69,.18)); }
.ludo-hero h3{ margin:0 0 4px; font-size:20px; font-weight:800; text-align:center; font-family:'Baloo 2','Nunito',system-ui,sans-serif; }
.ludo-hero p{ margin:0 0 12px; font-size:13px; line-height:1.45; color:#5c4f80; text-align:center; }
.ludo-cap{ display:flex; gap:8px; margin:6px 0 12px; }
.ludo-cap button{ flex:1; padding:10px 0; border-radius:14px; border:2px solid rgba(43,31,69,.1); background:#faf8ff; font-weight:800; font-size:14px; color:#5c4f80; cursor:pointer; }
.ludo-cap button.on{ border-color:#ff2e9a; background:#fff0f8; color:#d61a82; }
.ludo-note{ font-size:12px; color:#8b7fab; text-align:center; margin-top:8px; line-height:1.4; }
.ludo-empty-room{ text-align:center; padding:26px 12px; color:#5c4f80; font-weight:700; }

/* phòng chờ */
.ludo-slots{ display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:8px 0 6px; }
.ludo-slot{ background:#fff; border-radius:18px; padding:12px 10px; text-align:center; border:2px solid transparent; position:relative; box-shadow:0 8px 20px -14px rgba(43,31,69,.45); min-height:122px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px; }
.ludo-slot.empty{ background:rgba(255,255,255,.55); border:2px dashed rgba(43,31,69,.18); color:#8b7fab; font-weight:700; font-size:13px; box-shadow:none; }
.ludo-slot .nm{ font-weight:800; font-size:13px; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ludo-slot .st{ font-size:11px; font-weight:800; padding:2px 9px; border-radius:99px; background:#eef; color:#6b5fa0; }
.ludo-slot .st.ok{ background:#dcfce7; color:#15803d; }
.ludo-slot .crown{ position:absolute; top:6px; right:8px; font-size:16px; }
.ludo-slot .clr{ position:absolute; top:8px; left:8px; width:14px; height:14px; border-radius:50%; border:2px solid #fff; box-shadow:0 0 0 1.5px rgba(43,31,69,.2); }
.lv-red{ --c:var(--lc-red); } .lv-green{ --c:var(--lc-green); } .lv-yellow{ --c:var(--lc-yellow); } .lv-blue{ --c:var(--lc-blue); }
.ludo-slot[class*="lv-"]{ border-color:color-mix(in srgb,var(--c) 55%,#fff); }
.ludo-slot .clr{ background:var(--c,#ccc); }
.ludo-av{ width:48px; height:48px; border-radius:50%; object-fit:cover; background:#f1ecff; display:flex; align-items:center; justify-content:center; font-size:24px; overflow:hidden; border:3px solid var(--c,#e5def8); }
.ludo-av img{ width:100%; height:100%; object-fit:cover; display:block; }

/* thanh người chơi khi chơi */
.ludo-players{ display:grid; gap:6px; margin:2px 0 8px; }
.ludo-players.n2{ grid-template-columns:1fr 1fr; } .ludo-players.n3{ grid-template-columns:repeat(3,1fr); } .ludo-players.n4{ grid-template-columns:repeat(4,1fr); }
.ludo-pchip{ background:#fff; border-radius:16px; padding:7px 4px 6px; text-align:center; position:relative; border:2px solid rgba(43,31,69,.07); transition:transform .2s, box-shadow .2s, border-color .2s; min-width:0; }
.ludo-pchip .ludo-av{ width:38px; height:38px; font-size:19px; margin:0 auto; }
.ludo-pchip .nm{ font-size:11px; font-weight:800; margin-top:3px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; padding:0 2px; }
.ludo-pchip .sub{ font-size:10.5px; font-weight:700; color:#8b7fab; }
.ludo-pchip.turn{ border-color:var(--c); transform:translateY(-2px); box-shadow:0 10px 22px -10px var(--c); }
.ludo-pchip.out{ opacity:.45; filter:grayscale(1); }
.ludo-pchip .tm{ position:absolute; top:-7px; right:-4px; min-width:22px; height:22px; border-radius:11px; background:var(--c); color:#fff; font-size:11px; font-weight:800; display:none; align-items:center; justify-content:center; padding:0 5px; box-shadow:0 4px 8px -3px rgba(0,0,0,.35); }
.ludo-pchip.turn .tm{ display:flex; }
.ludo-pchip .tm.low{ background:#ef4360; animation:ludoBlink .6s infinite; }
.ludo-pchip .away{ position:absolute; top:3px; left:4px; font-size:11px; }
.ludo-pchip .me{ position:absolute; bottom:-6px; left:50%; transform:translateX(-50%); font-size:9px; font-weight:800; background:#241a3d; color:#fff; border-radius:99px; padding:1px 6px; }
@keyframes ludoBlink{ 50%{ opacity:.55; } }

/* bàn cờ */
.ludo-boardwrap{ position:relative; width:100%; aspect-ratio:1/1; border-radius:20px; background:#fff; padding:5px; box-shadow:0 18px 38px -20px rgba(43,31,69,.55), inset 0 0 0 1px rgba(43,31,69,.06); touch-action:manipulation; }
.ludo-board{ width:100%; height:100%; display:block; user-select:none; -webkit-user-select:none; -webkit-tap-highlight-color:transparent; }
.lp{ transition:transform .32s cubic-bezier(.3,.9,.3,1); cursor:default; }
.lp.hop{ transition:transform .13s linear; }
.lp.no-tr{ transition:none; }
.lp-ring{ fill:none; stroke:#fff; stroke-width:.09; opacity:0; }
.lp.can{ cursor:pointer; }
.lp.can .lp-ring{ opacity:1; stroke:#ff2e9a; animation:ludoRing 1s ease-in-out infinite; }
.lp.can .lp-body{ animation:ludoBob .7s ease-in-out infinite; }
@keyframes ludoRing{ 0%,100%{ stroke-width:.07; r:.5; } 50%{ stroke-width:.16; r:.58; } }
@keyframes ludoBob{ 50%{ transform:translateY(-.1px); } }
.lp.pop .lp-body{ animation:ludoPop .45s ease-out; }
@keyframes ludoPop{ 0%{ transform:scale(1); } 40%{ transform:scale(1.5) rotate(12deg); } 100%{ transform:scale(1); } }
.lp.fin .lp-body{ animation:ludoFin .7s ease-out; }
@keyframes ludoFin{ 0%{ transform:scale(1); } 50%{ transform:scale(1.6); filter:brightness(1.4); } 100%{ transform:scale(1); } }
.lp-ghost{ pointer-events:none; }

/* xúc xắc + thông báo */
.ludo-ctrl{ display:flex; align-items:center; gap:12px; margin-top:12px; }
.ludo-dicebox{ width:78px; height:78px; flex:none; border-radius:20px; background:#fff; border:3px solid #e5def8; position:relative; cursor:default; display:flex; align-items:center; justify-content:center; box-shadow:0 12px 22px -12px rgba(43,31,69,.5); transition:transform .15s, border-color .2s; }
.ludo-dicebox.ready{ border-color:#ff2e9a; cursor:pointer; animation:ludoDicePulse 1.1s ease-in-out infinite; }
.ludo-dicebox.rolling{ animation:ludoShake .12s linear infinite; }
@keyframes ludoDicePulse{ 50%{ transform:scale(1.07); box-shadow:0 0 0 7px rgba(255,46,154,.18), 0 12px 22px -12px rgba(43,31,69,.5);} }
@keyframes ludoShake{ 0%{ transform:rotate(-9deg) translateY(-2px);} 50%{ transform:rotate(9deg) translateY(2px);} 100%{ transform:rotate(-9deg) translateY(-2px);} }
.ludo-dicebox svg{ width:58px; height:58px; }
.ludo-dicebox.dim svg{ opacity:.35; }
.ludo-msg{ flex:1; min-width:0; }
.ludo-msg .big{ font-weight:800; font-size:15px; line-height:1.25; }
.ludo-msg .sm{ font-size:12px; color:#8b7fab; font-weight:700; margin-top:3px; min-height:16px; }
.ludo-msg.mine .big{ color:#d61a82; }
.ludo-feed{ margin-top:8px; font-size:12px; color:#5c4f80; background:rgba(255,255,255,.7); border-radius:12px; padding:7px 10px; min-height:30px; line-height:1.35; }
.ludo-foot{ display:flex; gap:8px; margin-top:10px; }
.ludo-watch{ text-align:center; font-size:12px; font-weight:800; color:#6b5fa0; background:#efeaff; border-radius:12px; padding:6px; margin-bottom:6px; }

/* kết thúc */
.ludo-end{ text-align:center; position:relative; }
.ludo-end .trophy{ font-size:64px; line-height:1; animation:ludoTrophy 1.4s ease-in-out infinite; display:block; margin-top:8px; }
@keyframes ludoTrophy{ 50%{ transform:translateY(-8px) rotate(4deg) scale(1.06); } }
.ludo-end h3{ margin:6px 0 2px; font-size:22px; font-weight:800; font-family:'Baloo 2','Nunito',system-ui,sans-serif; }
.ludo-end .sub{ font-size:13px; color:#5c4f80; margin-bottom:10px; font-weight:700; }
.ludo-rank{ display:flex; align-items:center; gap:10px; background:#fff; border-radius:16px; padding:9px 12px; margin-top:8px; text-align:left; border:2px solid rgba(43,31,69,.06); }
.ludo-rank.first{ border-color:#ffc94a; background:linear-gradient(120deg,#fffbea,#fff); }
.ludo-rank .no{ width:28px; height:28px; border-radius:50%; background:#241a3d; color:#fff; font-weight:800; font-size:13px; display:flex; align-items:center; justify-content:center; flex:none; }
.ludo-rank.first .no{ background:#f5b50a; }
.ludo-rank .info{ flex:1; min-width:0; }
.ludo-rank .info b{ display:block; font-size:14px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ludo-rank .info span{ font-size:11.5px; color:#8b7fab; font-weight:700; }
.ludo-rank .xp{ font-size:12px; font-weight:800; color:#d61a82; white-space:nowrap; }
.ludo-confetti{ position:absolute; left:0; right:0; top:0; height:0; pointer-events:none; overflow:visible; }
.ludo-confetti i{ position:absolute; top:-10px; font-style:normal; font-size:20px; animation:ludoFall linear forwards; }
@keyframes ludoFall{ to{ transform:translateY(420px) rotate(540deg); opacity:0; } }
.ludo-stats{ display:flex; gap:8px; margin-top:12px; }
.ludo-stats div{ flex:1; background:#fff; border-radius:14px; padding:8px 4px; font-size:11px; color:#8b7fab; font-weight:700; }
.ludo-stats b{ display:block; font-size:17px; color:#241a3d; }

/* thanh thu nhỏ */
.ludo-pill{ position:fixed; z-index:9390; right:12px; bottom:calc(env(safe-area-inset-bottom,0px) + 86px); display:flex; align-items:center; gap:8px; background:#241a3d; color:#fff; padding:8px 14px 8px 10px; border-radius:99px; font-weight:800; font-size:13px; box-shadow:0 14px 30px -10px rgba(36,26,61,.7); cursor:pointer; max-width:calc(100vw - 24px); }
.ludo-pill .dot{ width:24px; height:24px; border-radius:50%; background:var(--pc,#ff2e9a); display:flex; align-items:center; justify-content:center; font-size:14px; flex:none; }
.ludo-pill .tx{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ludo-pill.mine{ animation:ludoPill 1s ease-in-out infinite; background:linear-gradient(120deg,#ff2e9a,#ff7a45); }
@keyframes ludoPill{ 50%{ transform:scale(1.06); } }

@media (prefers-reduced-motion:reduce){
  .lp, .ludo-dicebox, .ludo-pill, .ludo-end .trophy, .lp.can .lp-ring, .lp.can .lp-body{ animation:none !important; transition:none !important; }
}
