    :root{
      --bg1:#5b21b6;
      --bg2:#db2777;
      --panel:rgba(255,255,255,.14);
      --panel-border:rgba(255,255,255,.22);
      --text:#fff;
      --shadow:0 24px 60px rgba(28,8,55,.30);
      --cell-gap:7px;
      --selection-safe-area:6px;
      --grid-half-gap:-3.5px;
    }

    *{box-sizing:border-box}

    .update-notice{
      position:fixed;
      z-index:50;
      left:50%;
      bottom:max(16px,env(safe-area-inset-bottom));
      display:flex;
      align-items:center;
      gap:10px;
      width:min(calc(100% - 28px),360px);
      padding:10px 12px;
      border:1px solid rgba(255,255,255,.28);
      border-radius:14px;
      background:rgba(35,17,62,.94);
      box-shadow:0 12px 30px rgba(17,3,38,.35);
      color:#fff;
      font-size:13px;
      transform:translateX(-50%);
    }
    .update-notice[hidden]{display:none}
    .update-notice button{
      min-height:34px;
      margin-left:auto;
      padding:5px 11px;
      border:0;
      border-radius:9px;
      background:#ffe366;
      color:#542145;
      font:inherit;
      font-weight:900;
      cursor:pointer;
    }
    .build-version{
      position:fixed;
      z-index:40;
      right:10px;
      bottom:max(8px,env(safe-area-inset-bottom));
      color:rgba(255,255,255,.52);
      font-size:10px;
      font-weight:800;
      letter-spacing:.04em;
      pointer-events:none;
    }
    body{
      margin:0;
      min-height:100vh;
      display:flex;
      align-items:center;
      justify-content:center;
      font-family:Inter,ui-rounded,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
      color:var(--text);
      background:
        radial-gradient(circle at 15% 15%,rgba(255,255,255,.18),transparent 22%),
        radial-gradient(circle at 85% 80%,rgba(255,255,255,.10),transparent 25%),
        linear-gradient(135deg,var(--bg1),var(--bg2));
      overflow-x:hidden;
    }

    body::before,body::after{
      content:"";
      position:fixed;
      width:300px;height:300px;border-radius:50%;
      background:rgba(255,255,255,.07);
      pointer-events:none;
    }
    body::before{top:-120px;left:-80px}
    body::after{bottom:-130px;right:-80px}

    .sidebar,.game-card{
      background:var(--panel);
      border:1px solid var(--panel-border);
      box-shadow:var(--shadow);
      backdrop-filter:blur(18px);
      -webkit-backdrop-filter:blur(18px);
    }

    .sidebar{border-radius:28px;padding:26px}
    .game-card{border-radius:30px;padding:18px}

    .eyebrow{
      display:inline-flex;
      padding:7px 11px;
      border-radius:999px;
      background:rgba(255,255,255,.14);
      font-size:12px;font-weight:900;
      letter-spacing:.1em;text-transform:uppercase;
    }

    h1{
      margin:17px 0 10px;
      font-size:clamp(34px,5vw,52px);
      line-height:.95;letter-spacing:-.05em;
    }

    .subtitle{
      margin:0;
      color:rgba(255,255,255,.83);
      line-height:1.5;
      font-size:14px;
    }

    .stats{
      display:grid;
      grid-template-columns:repeat(3,1fr);
      gap:11px;
      margin:20px 0 14px;
    }

    .stat{
      padding:15px;
      border-radius:19px;
      background:rgba(255,255,255,.11);
      border:1px solid rgba(255,255,255,.11);
    }

    .stat .label{
      font-size:11px;
      text-transform:uppercase;
      letter-spacing:.09em;
      font-weight:900;
      color:rgba(255,255,255,.68);
    }

    .stat .value{
      margin-top:4px;
      font-size:25px;
      font-weight:1000;
    }

    .progress-label{
      display:flex;justify-content:space-between;
      margin-bottom:7px;
      font-size:12px;
      color:rgba(255,255,255,.82);
    }

    .progress{
      height:11px;padding:2px;border-radius:999px;
      background:rgba(255,255,255,.14);
      overflow:hidden;
    }

    .progress > div{
      height:100%;width:0;border-radius:999px;
      background:linear-gradient(90deg,#fde047,#fff7ae);
      transition:width .3s ease;
    }

    .primary{
      width:100%;
      border:0;border-radius:15px;
      padding:13px 15px;
      cursor:pointer;
      font:inherit;font-weight:1000;
      color:#68235e;
      background:linear-gradient(180deg,#fff6bf,#facc15);
      box-shadow:0 8px 20px rgba(35,10,20,.16);
    }

    .rules{
      margin-top:18px;
      display:grid;
      gap:8px;
    }

    .rule{
      display:grid;
      grid-template-columns:34px 1fr;
      gap:9px;
      align-items:center;
      font-size:12px;
      color:rgba(255,255,255,.78);
    }

    .rule-icon{
      width:34px;height:34px;border-radius:11px;
      display:flex;align-items:center;justify-content:center;
      background:rgba(255,255,255,.12);
      font-size:17px;font-weight:1000;
    }


    .mode-line{
      margin:10px 0 0;
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:10px;
      font-size:12px;
      color:rgba(255,255,255,.78);
    }

    .mode-name{
      display:inline-flex;
      padding:6px 9px;
      border-radius:999px;
      background:rgba(255,255,255,.11);
      border:1px solid rgba(255,255,255,.10);
      font-weight:900;
    }

    .secondary{
      width:100%;
      margin-top:8px;
      border:1px solid rgba(255,255,255,.16);
      border-radius:15px;
      padding:11px 15px;
      cursor:pointer;
      font:inherit;
      font-weight:900;
      color:#fff;
      background:rgba(255,255,255,.09);
    }

    .mode-overlay{
      position:absolute;
      inset:0;
      z-index:40;
      display:flex;
      align-items:center;
      justify-content:center;
      padding:22px;
      border-radius:24px;
      background:rgba(30,9,52,.76);
      backdrop-filter:blur(9px);
      opacity:0;
      pointer-events:none;
      transition:opacity .2s ease;
    }

    .mode-overlay.show{
      opacity:1;
      pointer-events:auto;
    }

    .mode-card{
      width:min(430px,94%);
      max-height:min(92dvh,760px);
      overflow-y:auto;
      -webkit-overflow-scrolling:touch;
      padding:25px;
      border-radius:25px;
      text-align:center;
      background:rgba(255,255,255,.14);
      border:1px solid rgba(255,255,255,.19);
      box-shadow:0 20px 50px rgba(20,5,38,.30);
    }

    .mode-card h2{
      margin:0 0 7px;
      font-size:30px;
    }

    .mode-card > p{
      margin:0 0 17px;
      color:rgba(255,255,255,.80);
      line-height:1.45;
      font-size:13px;
    }

    .mode-options{
      display:grid;
      grid-template-columns:1fr;
      gap:10px;
    }

    .mode-option{
      border:1px solid rgba(255,255,255,.16);
      border-radius:19px;
      padding:16px 12px;
      color:#fff;
      background:rgba(255,255,255,.10);
      cursor:pointer;
      font:inherit;
      text-align:left;
    }

    .mode-option:hover{
      background:rgba(255,255,255,.16);
    }

    .mode-option b{
      display:block;
      font-size:16px;
      margin-bottom:5px;
    }

    .mode-option span{
      display:block;
      color:rgba(255,255,255,.70);
      font-size:11px;
      line-height:1.4;
    }

    .best-pill{
      display:inline-flex;
      margin-top:13px;
      padding:7px 10px;
      border-radius:999px;
      background:rgba(253,224,71,.12);
      border:1px solid rgba(253,224,71,.18);
      font-size:12px;
      font-weight:900;
    }


    /* ===== Online Leaderboard ===== */
    .online-name-box{
      margin-top:14px;
      padding:12px;
      border-radius:16px;
      background:rgba(255,255,255,.09);
      border:1px solid rgba(255,255,255,.13);
      text-align:left;
    }

    .online-name-box label{
      display:block;
      margin-bottom:6px;
      font-size:11px;
      font-weight:900;
      color:rgba(255,255,255,.78);
    }

    .online-name-input{
      width:100%;
      border:1px solid rgba(255,255,255,.22);
      border-radius:12px;
      padding:11px 12px;
      background:rgba(255,255,255,.12);
      color:#fff;
      font:inherit;
      outline:none;
    }

    .online-name-input::placeholder{color:rgba(255,255,255,.52)}
    .online-name-input:focus{border-color:rgba(255,255,255,.55)}

    .feedback-settings{
      display:flex;
      gap:8px;
      margin-top:8px;
    }
    .feedback-settings label{
      flex:1;
      min-height:34px;
      display:flex;
      align-items:center;
      justify-content:center;
      gap:5px;
      padding:6px 8px;
      border:1px solid rgba(255,255,255,.15);
      border-radius:11px;
      background:rgba(255,255,255,.08);
      color:rgba(255,255,255,.86);
      font-size:10px;
      font-weight:800;
      cursor:pointer;
      white-space:nowrap;
    }
    .feedback-settings input{accent-color:#ffe66d}

    .online-status{
      min-height:18px;
      margin-top:6px;
      font-size:11px;
      color:rgba(255,255,255,.72);
    }

    .embedded-board{
      margin-top:12px;
      padding:12px;
      border-radius:16px;
      background:rgba(20,5,35,.18);
      border:1px solid rgba(255,255,255,.12);
      text-align:left;
    }

    .embedded-board-head{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:8px;
      margin-bottom:8px;
    }

    .embedded-board-head b{font-size:12px}
    .embedded-board-head span{font-size:10px;color:rgba(255,255,255,.65)}

    .embedded-list{display:grid;gap:6px}

    .embedded-row{
      display:grid;
      grid-template-columns:28px 1fr auto;
      gap:7px;
      align-items:center;
      padding:7px 8px;
      border-radius:10px;
      background:rgba(255,255,255,.075);
      font-size:11px;
    }

    .embedded-rank{font-weight:1000;text-align:center}
    .embedded-name{
      font-weight:800;
      overflow:hidden;
      text-overflow:ellipsis;
      white-space:nowrap;
    }
    .embedded-score{font-weight:1000}
    .embedded-empty{
      text-align:center;
      padding:10px 4px;
      color:rgba(255,255,255,.62);
      font-size:11px;
    }

    .online-leaderboard-btn{
      width:100%;
      margin-top:10px;
      border:1px solid rgba(255,255,255,.18);
      border-radius:14px;
      padding:10px 14px;
      background:rgba(255,255,255,.10);
      color:#fff;
      font:inherit;
      font-weight:900;
      cursor:pointer;
    }

    .online-overlay{
      position:fixed;
      inset:0;
      z-index:3000;
      display:flex;
      align-items:center;
      justify-content:center;
      padding:20px;
      background:rgba(20,5,39,.90);
      backdrop-filter:none;
      -webkit-backdrop-filter:none;
      opacity:0;
      pointer-events:none;
      transition:opacity .2s ease;
    }

    .online-overlay.show{
      opacity:1;
      pointer-events:auto;
    }

    .online-card{
      width:min(430px,94vw);
      max-height:min(680px,88vh);
      overflow:auto;
      border-radius:26px;
      padding:22px;
      color:#fff;
      background:linear-gradient(155deg,#9252c4 0%,#643294 49%,#351457 100%);
      border:1px solid rgba(255,255,255,.32);
      box-shadow:0 24px 60px rgba(20,5,35,.52);
    }

    .online-card h2{margin:0 0 5px;text-align:center}
    .online-sub{
      text-align:center;
      color:rgba(255,255,255,.72);
      font-size:12px;
      margin-bottom:14px;
    }

    .online-list{display:grid;gap:8px}

    .online-row{
      display:grid;
      grid-template-columns:42px 1fr auto;
      gap:8px;
      align-items:center;
      padding:10px 11px;
      border-radius:14px;
      background:linear-gradient(135deg,#6b398e,#51246f);
      border:1px solid rgba(255,255,255,.11);
    }

    .online-rank{font-weight:1000;text-align:center}
    .online-name{
      font-weight:900;
      overflow:hidden;
      text-overflow:ellipsis;
      white-space:nowrap;
    }
    .online-score{font-weight:1000}
    .online-empty{
      text-align:center;
      padding:18px;
      color:rgba(255,255,255,.72);
    }

    .online-actions{
      display:grid;
      grid-template-columns:1fr;
      gap:8px;
      margin-top:14px;
    }

    .online-actions button{
      border:0;
      border-radius:13px;
      padding:11px 12px;
      font:inherit;
      font-weight:900;
      cursor:pointer;
    }

    .online-change{
      background:rgba(255,255,255,.12);
      color:#fff;
      border:1px solid rgba(255,255,255,.15)!important;
    }

    .online-close{
      background:linear-gradient(180deg,#fff7c8,#ffd43b);
      color:#702452;
    }

    .board-wrap{
      position:relative;
      contain:layout paint;
      isolation:isolate;
      padding:12px;
      border-radius:24px;
      background:rgba(38,14,67,.25);
      border:1px solid rgba(255,255,255,.12);
    }

    .board{
      position:relative;
      z-index:1;
      display:grid;
      grid-template-columns:repeat(8,1fr);
      gap:var(--cell-gap);
      padding:var(--selection-safe-area);
      aspect-ratio:1;
      border-radius:18px;
      background:#18243e;
      user-select:none;
      touch-action:none;
      contain:layout paint style;
    }

    /* Grid tĩnh dùng đúng thuật toán CSS Grid của board.
       Không đo/toạ độ bằng JS nên không bị sai số pixel lẻ giữa Safari và Chromium. */
    .board-grid{
      position:absolute;
      inset:0;
      z-index:0;
      pointer-events:none;
      display:grid;
      grid-template-columns:repeat(8,1fr);
      grid-template-rows:repeat(8,1fr);
      gap:var(--cell-gap);
      padding:var(--selection-safe-area);
    }
    .board-grid-cell{position:relative}
    /* Mỗi cạnh chung chỉ được vẽ một lần: liền mạch như grid, không thành ô kính. */
    .board-grid-cell::before{
      content:"";
      position:absolute;
      inset:var(--grid-half-gap);
      border-top:1px solid rgba(197,222,255,.13);
      border-left:1px solid rgba(197,222,255,.13);
    }
    .board-grid-cell:nth-last-child(-n + 8)::before{
      border-bottom:1px solid rgba(197,222,255,.18);
    }
    .board-grid-cell:nth-child(8n)::after{
      content:"";
      position:absolute;
      top:var(--grid-half-gap);
      right:var(--grid-half-gap);
      bottom:var(--grid-half-gap);
      width:1px;
      background:rgba(197,222,255,.18);
    }

    .fx-layer{
      position:absolute;
      inset:0;
      z-index:5;
      overflow:hidden;
      pointer-events:none;
      contain:layout paint style;
    }

    .candy{
      position:relative;
      z-index:1;
      border:0;background:transparent;padding:0;
      min-width:0;aspect-ratio:1;
      cursor:pointer;
      outline:none;
      -webkit-tap-highlight-color:transparent;
      transition:transform .14s ease,filter .14s ease,opacity .14s ease;
    }

    .candy::before{
      content:"";
      position:absolute;inset:-5%;
      border-radius:24%;
      background-image:url("../assets/candy-units-v1.png?v=6.0.8");
      background-repeat:no-repeat;
      background-size:600% 500%;
      background-position:var(--sprite-x,0%) var(--sprite-y,0%);
    }

    .candy::after{
      content:none;
      position:absolute;
      width:23%;height:11%;left:24%;top:18%;
      border-radius:50%;
      background:radial-gradient(ellipse,rgba(255,255,255,.38),rgba(255,255,255,0) 72%);
      opacity:.48;
      pointer-events:none;
    }

    /* Sheet columns: blue, yellow, purple, green, red, orange.
       Game types keep their existing order: red, yellow, green, blue, purple, orange. */
    .candy.type-0{--sprite-x:80%}
    .candy.type-1{--sprite-x:20%}
    .candy.type-2{--sprite-x:60%}
    .candy.type-3{--sprite-x:0%}
    .candy.type-4{--sprite-x:40%}
    .candy.type-5{--sprite-x:100%}
    .candy.special-row{--sprite-y:25%;--boom-glow:#fff0a8}
    .candy.special-col{--sprite-y:50%;--boom-glow:#9fe6ff}
    .candy.special-square{--sprite-y:75%;--boom-glow:#eeb5ff}
    .candy.special-cross{--sprite-y:100%;--boom-glow:#ffc1e6}

    .candy.selected{z-index:4;transform:scale(1.07);filter:brightness(1.13)}
    .candy.selected::before{
      filter:brightness(1.16) drop-shadow(0 0 7px rgba(255,255,255,.52));
    }
    .candy:focus-visible::before{
      filter:brightness(1.16) drop-shadow(0 0 7px rgba(255,255,255,.52));
    }

    .candy.hint:not(.selected){
      z-index:3;
      /* Hai nhịp chớp mỗi giây, chỉ tồn tại trên đúng hai viên được gợi ý. */
      animation:hintPulse .5s ease-in-out infinite;
    }
    @keyframes hintPulse{
      0%,100%{transform:scale(1);filter:brightness(1)}
      50%{transform:scale(1.055);filter:brightness(1.24)}
    }

    /* Boom dùng sprite riêng, còn CSS tạo độ sâu, ánh sáng và nhịp chuyển động. */
    .candy.special-row,
    .candy.special-col,
    .candy.special-square,
    .candy.special-cross,
    .candy.special-map{
      z-index:2;
      isolation:isolate;
    }

    .candy.special-row::before,
    .candy.special-col::before,
    .candy.special-square::before,
    .candy.special-cross::before{
      animation:specialDepth 2.9s ease-in-out infinite,boomGlow 3.4s ease-in-out infinite;
    }

    .candy.special-map{--boom-glow:#fff1a4;border-radius:50%;overflow:visible}
    .special-map::before{
      inset:-5%;
      border-radius:50%;
      background-image:
        radial-gradient(circle,transparent 57%,rgba(255,255,255,.24) 72%,transparent 74%),
        url("../assets/map-bomb-v2.png?v=6.0.8");
      background-size:100% 100%;
      background-position:center;
      box-shadow:
        0 0 17px rgba(255,255,255,.7),
        0 6px 15px rgba(20,6,35,.34);
      animation:mapIdleSpin 4s linear infinite,boomGlow 3.4s ease-in-out infinite;
    }

    .candy.special-row::after,
    .candy.special-col::after,
    .candy.special-square::after,
    .candy.special-cross::after,
    .candy.special-map::after{
      content:"";
      display:block;
      width:30%;height:14%;left:23%;top:15%;
      border-radius:50%;
      background:radial-gradient(ellipse,rgba(255,255,255,.8),rgba(255,255,255,0) 72%);
      opacity:0;
      transform:scale(.65);
      animation:specialGlimmer 2.9s ease-in-out infinite;
      pointer-events:none;
    }
    .candy.special-col::after{animation-delay:.32s}
    .candy.special-square::after{animation-delay:.68s}
    .candy.special-cross::after{animation-delay:1s}
    .candy.special-map::after{animation-delay:1.32s}
    .candy.special-map::after{
      width:31%;height:15%;left:23%;top:14%;
    }

    /* Special nằm sau rule selected, nên nhắc lại ring chọn để không bị ghi đè. */
    .candy.selected.special-row::before,
    .candy.selected.special-col::before,
    .candy.selected.special-square::before,
    .candy.selected.special-cross::before,
    .candy.selected.special-map::before{
      filter:brightness(1.18) drop-shadow(0 0 9px rgba(255,255,255,.68));
    }

    @keyframes specialGlimmer{
      0%,22%,100%{opacity:0;transform:scale(.65)}
      40%{opacity:.82;transform:scale(1.12)}
      57%{opacity:.16;transform:scale(1.34)}
    }
    @keyframes specialDepth{
      0%,100%{transform:translate3d(0,0,0) scale(1)}
      46%{transform:translate3d(0,-1px,0) scale(1.018)}
    }
    @keyframes boomGlow{
      0%,100%{filter:brightness(1) drop-shadow(0 0 0 transparent)}
      48%{filter:brightness(1.12) drop-shadow(0 0 8px var(--boom-glow)) drop-shadow(0 0 3px rgba(255,255,255,.75))}
    }
    @keyframes mapIdleSpin{to{transform:rotate(360deg)}}

    @media (prefers-reduced-motion:reduce){
      .candy.special-row::after,
      .candy.special-col::after,
      .candy.special-square::after,
      .candy.special-cross::after,
      .candy.special-map::after{animation:none;opacity:0}
      .candy.special-row::before,
      .candy.special-col::before,
      .candy.special-square::before,
      .candy.special-cross::before,
      .special-map::before{animation:none}
      .candy.hint:not(.selected){animation:none}
    }

    .candy.matched{animation:pop .28s ease forwards}
    .candy.blast{z-index:8;animation:blast .34s cubic-bezier(.15,.76,.28,1) forwards}
    /* Khi match-5 phóng lên lớp cinematic, ẩn bản gốc để không thành hai quả cầu. */
    .candy.special-map.blast{visibility:hidden}

    @keyframes pop{
      0%{transform:scale(1);opacity:1}
      55%{transform:scale(1.2) rotate(7deg);opacity:1}
      100%{transform:scale(.06) rotate(-10deg);opacity:0}
    }
    @keyframes blast{
      0%{transform:scale(1);filter:brightness(1);opacity:1}
      36%{transform:scale(1.42) rotate(5deg);filter:brightness(2.2) saturate(1.35);opacity:1}
      62%{transform:scale(.82) rotate(-3deg);filter:brightness(1.8);opacity:.88}
      100%{transform:scale(.03) rotate(8deg);filter:brightness(2.5);opacity:0}
    }

    /* FX V5.2: chỉ tạo DOM ngắn hạn khi bom nổ, không có animation loop nền. */
    .fx-beam,
    .fx-cell-burst,
    .fx-map-wave,
    .fx-map-orb,
    .fx-particle,
    .fx-score-popup{position:absolute;pointer-events:none}

    .fx-map-orb{
      z-index:12;
      border-radius:50%;
      background-image:
        radial-gradient(circle,transparent 54%,rgba(255,255,255,.28) 70%,transparent 74%),
        url("../assets/map-bomb-v2.png?v=6.0.8");
      background-position:center;
      background-size:100% 100%;
      box-shadow:
        inset 0 0 0 2px rgba(255,255,255,.62),
        inset 0 -12px 18px rgba(31,6,37,.35),
        0 0 0 6px rgba(255,247,177,.16),
        0 0 28px rgba(255,235,131,.8),
        0 0 58px rgba(255,108,202,.55);
      will-change:transform,opacity;
    }

    .fx-score-popup{
      z-index:9;
      min-width:max-content;
      padding:5px 9px;
      border-radius:999px;
      color:#8d2b70;
      background:rgba(255,255,255,.96);
      border:1px solid rgba(255,255,255,.8);
      box-shadow:0 6px 16px rgba(33,8,63,.28);
      font-size:clamp(13px,3.6vw,17px);
      font-weight:1000;
      line-height:1;
      transform:translate(-50%,-50%);
      animation:scoreFloat .82s cubic-bezier(.18,.78,.24,1) forwards;
    }
    .fx-score-popup.combo{
      color:#7b235f;
      background:linear-gradient(180deg,#fffbd8,#ffe66d);
      font-size:clamp(14px,4vw,19px);
      box-shadow:0 7px 19px rgba(83,20,96,.34);
    }
    @keyframes scoreFloat{
      0%{opacity:0;transform:translate(-50%,-26%) scale(.72)}
      22%{opacity:1;transform:translate(-50%,-50%) scale(1.08)}
      70%{opacity:1;transform:translate(-50%,-83%) scale(1)}
      100%{opacity:0;transform:translate(-50%,-118%) scale(.96)}
    }

    .fx-beam{
      border-radius:999px;
      opacity:0;
      background:linear-gradient(90deg,transparent 0%,var(--fx-color) 17%,#fff 50%,var(--fx-color) 83%,transparent 100%);
      box-shadow:0 0 8px var(--fx-color),0 0 20px var(--fx-color),0 0 34px rgba(255,255,255,.72);
      mix-blend-mode:screen;
    }
    .fx-beam-row{transform-origin:center;animation:beamRow .38s cubic-bezier(.17,.76,.2,1) forwards}
    .fx-beam-col{
      transform-origin:center;
      background:linear-gradient(0deg,transparent 0%,var(--fx-color) 17%,#fff 50%,var(--fx-color) 83%,transparent 100%);
      animation:beamCol .38s cubic-bezier(.17,.76,.2,1) forwards;
    }
    @keyframes beamRow{
      0%{opacity:0;transform:scaleX(.04)}
      24%{opacity:1;transform:scaleX(.36)}
      62%{opacity:.94;transform:scaleX(1)}
      100%{opacity:0;transform:scaleX(1.04)}
    }
    @keyframes beamCol{
      0%{opacity:0;transform:scaleY(.04)}
      24%{opacity:1;transform:scaleY(.36)}
      62%{opacity:.94;transform:scaleY(1)}
      100%{opacity:0;transform:scaleY(1.04)}
    }

    .fx-cell-burst{
      border:2px solid var(--fx-color);
      border-radius:50%;
      opacity:0;
      transform:translate(-50%,-50%) scale(.16);
      box-shadow:0 0 0 3px rgba(255,255,255,.22),0 0 17px var(--fx-color),inset 0 0 14px rgba(255,255,255,.62);
      animation:cellBurst .42s cubic-bezier(.12,.72,.2,1) forwards;
    }
    .fx-cell-burst-square{border-radius:28%;animation:cellBurstSquare .42s cubic-bezier(.12,.72,.2,1) forwards}
    .fx-cell-burst-cross{border-width:3px}
    .fx-cell-burst-map{border-width:4px;box-shadow:0 0 0 5px rgba(255,255,255,.24),0 0 26px var(--fx-color),inset 0 0 20px rgba(255,255,255,.78)}
    @keyframes cellBurst{
      0%{opacity:0;transform:translate(-50%,-50%) scale(.16)}
      26%{opacity:1}
      100%{opacity:0;transform:translate(-50%,-50%) scale(1.08)}
    }
    @keyframes cellBurstSquare{
      0%{opacity:0;transform:translate(-50%,-50%) rotate(45deg) scale(.16)}
      26%{opacity:1}
      100%{opacity:0;transform:translate(-50%,-50%) rotate(45deg) scale(1.08)}
    }

    .fx-map-wave{
      border:3px solid rgba(255,255,255,.9);
      border-radius:18px;
      opacity:0;
      background:radial-gradient(circle at 50% 50%,rgba(255,255,255,.48),var(--fx-color) 17%,transparent 64%);
      box-shadow:inset 0 0 26px var(--fx-color),0 0 24px var(--fx-color);
      animation:mapWave .5s cubic-bezier(.13,.74,.2,1) forwards;
    }
    @keyframes mapWave{
      0%{opacity:0;transform:scale(.16)}
      28%{opacity:.92}
      100%{opacity:0;transform:scale(1.03)}
    }

    .fx-particle{
      width:clamp(4px,1.1vw,7px);height:clamp(4px,1.1vw,7px);
      margin:-3px;
      border-radius:50%;
      opacity:0;
      background:var(--fx-color);
      box-shadow:0 0 8px var(--fx-color),0 0 3px #fff;
      animation:particleBurst .46s cubic-bezier(.14,.7,.25,1) var(--fx-delay) forwards;
    }
    @keyframes particleBurst{
      0%{opacity:0;transform:translate3d(0,0,0) scale(.4)}
      18%{opacity:1}
      100%{opacity:0;transform:translate3d(var(--fx-x),var(--fx-y),0) scale(.05)}
    }

    .board-wrap.impact{animation:boardImpact .26s cubic-bezier(.2,.76,.3,1)}
    .stat.impact{animation:statImpact .28s cubic-bezier(.18,.82,.28,1)}
    .stat.score-bump{animation:scoreBump .32s cubic-bezier(.18,.82,.28,1)}
    .stat.moves-spent{animation:movesSpent .3s cubic-bezier(.18,.82,.28,1)}
    .stat.moves-gain{animation:movesGain .36s cubic-bezier(.18,.82,.28,1)}
    @keyframes boardImpact{
      0%,100%{transform:translate3d(0,0,0)}
      24%{transform:translate3d(-2px,1px,0)}
      48%{transform:translate3d(3px,-1px,0)}
      72%{transform:translate3d(-1px,0,0)}
    }
    @keyframes statImpact{
      0%,100%{transform:scale(1);filter:brightness(1)}
      35%{transform:scale(1.08);filter:brightness(1.28)}
      70%{transform:scale(.98);filter:brightness(1.08)}
    }
    @keyframes scoreBump{
      0%,100%{transform:scale(1);filter:brightness(1)}
      42%{transform:scale(1.075);filter:brightness(1.32)}
      72%{transform:scale(.99);filter:brightness(1.06)}
    }
    @keyframes movesSpent{
      0%,100%{transform:scale(1);filter:brightness(1)}
      38%{transform:scale(.96);filter:brightness(.84)}
      70%{transform:scale(1.035);filter:brightness(1.1)}
    }
    @keyframes movesGain{
      0%,100%{transform:scale(1);filter:brightness(1)}
      36%{transform:scale(1.095);filter:brightness(1.42)}
      72%{transform:scale(.99);filter:brightness(1.1)}
    }


    .fireworks{
      position:fixed;
      inset:0;
      pointer-events:none;
      z-index:999;
      overflow:hidden;
      opacity:0;
      transition:opacity .2s ease;
    }

    .fireworks.show{opacity:1}

    .firework{
      position:absolute;
      width:8px;
      height:8px;
      border-radius:50%;
      background:#fff;
      box-shadow:
        0 -70px 0 #ff4d6d,
        50px -50px 0 #ffd43b,
        70px 0 0 #51cf66,
        50px 50px 0 #4dabf7,
        0 70px 0 #c77dff,
        -50px 50px 0 #ff922b,
        -70px 0 0 #f8f9fa,
        -50px -50px 0 #ff6b6b,
        0 -105px 0 #74c0fc,
        75px -75px 0 #da77f2,
        105px 0 0 #69db7c,
        75px 75px 0 #ffe066,
        0 105px 0 #faa2c1,
        -75px 75px 0 #ffa94d,
        -105px 0 0 #91a7ff,
        -75px -75px 0 #63e6be;
      transform:scale(.1);
      opacity:0;
      animation:fireworkBurst 1.35s ease-out forwards;
    }

    @keyframes fireworkBurst{
      0%{
        transform:scale(.05);
        opacity:0;
      }
      18%{
        opacity:1;
      }
      100%{
        transform:scale(1.15);
        opacity:0;
      }
    }

    .love-popup{
      position:fixed;
      inset:0;
      z-index:1000;
      display:flex;
      align-items:center;
      justify-content:center;
      padding:24px;
      background:rgba(31,10,50,.55);
      backdrop-filter:blur(8px);
      -webkit-backdrop-filter:blur(8px);
      opacity:0;
      pointer-events:none;
      transition:opacity .25s ease;
    }

    .love-popup.show{
      opacity:1;
      pointer-events:auto;
    }

    .love-card{
      width:min(520px,92vw);
      text-align:center;
      padding:34px 28px 28px;
      border-radius:30px;
      background:
        radial-gradient(circle at 20% 10%,rgba(255,255,255,.26),transparent 28%),
        linear-gradient(145deg,rgba(255,255,255,.22),rgba(255,255,255,.12));
      border:1px solid rgba(255,255,255,.28);
      box-shadow:0 28px 70px rgba(28,8,55,.38);
      transform:scale(.82) translateY(24px);
      transition:transform .35s cubic-bezier(.2,.9,.2,1.2);
    }

    .love-popup.show .love-card{
      transform:scale(1) translateY(0);
    }

    .love-heart{
      font-size:64px;
      line-height:1;
      margin-bottom:12px;
      animation:heartBeat 1s ease-in-out infinite;
    }

    @keyframes heartBeat{
      0%,100%{transform:scale(1)}
      50%{transform:scale(1.13)}
    }

    .love-card h2{
      margin:0 0 10px;
      font-size:clamp(30px,6vw,48px);
      line-height:1.08;
      letter-spacing:-.04em;
    }

    .love-card p{
      margin:0 0 22px;
      font-size:clamp(18px,4vw,28px);
      font-weight:900;
      line-height:1.35;
      color:#fff;
      text-shadow:0 2px 10px rgba(0,0,0,.18);
    }

    .love-close{
      border:0;
      border-radius:16px;
      padding:13px 20px;
      min-width:180px;
      font:inherit;
      font-weight:1000;
      cursor:pointer;
      color:#7a235f;
      background:linear-gradient(180deg,#fff8c8,#ffd43b);
      box-shadow:0 10px 24px rgba(44,11,52,.18);
    }

    .overlay{
      position:absolute;inset:0;
      z-index:20;
      display:flex;align-items:center;justify-content:center;
      padding:22px;border-radius:24px;
      background:rgba(30,9,52,.72);
      backdrop-filter:blur(8px);
      opacity:0;pointer-events:none;
      transition:opacity .2s ease;
    }
    .overlay.show{opacity:1;pointer-events:auto}
    .overlay-card{
      width:min(340px,90%);
      padding:24px;border-radius:23px;text-align:center;
      background:rgba(255,255,255,.14);
      border:1px solid rgba(255,255,255,.17);
    }
    .overlay h2{margin:0 0 8px;font-size:36px}
    .overlay p{margin:0 0 17px;color:rgba(255,255,255,.84);line-height:1.5}
    .result-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:7px;margin:-4px 0 17px}
    .result-stats div{min-width:0;padding:8px 4px;border-radius:12px;background:rgba(255,255,255,.10);border:1px solid rgba(255,255,255,.12)}
    .result-stats span{display:block;font-size:9px;color:rgba(255,255,255,.7);font-weight:800}
    .result-stats strong{display:block;margin-top:3px;font-size:16px;color:#fff6bf}

    .mini{
      text-align:center;margin-top:10px;
      font-size:12px;color:rgba(255,255,255,.62);
    }

    /* =====================================================
       COMPACT UI V3 — bố cục gọn như Vk Hứng Yêu Thương
       ===================================================== */
    html,body{
      width:100%;
      min-height:100%;
    }

    body{
      min-height:100dvh;
      align-items:flex-start;
      overflow-x:hidden;
    }

    body::before,
    body::after{
      display:none;
    }

    .app{
      width:min(520px,100%);
      display:flex;
      flex-direction:column;
      gap:8px;
      padding:10px;
      margin:0 auto;
    }

    .sidebar,
    .game-card{
      width:100%;
      border-radius:20px;
      backdrop-filter:none;
      -webkit-backdrop-filter:none;
      box-shadow:0 12px 30px rgba(28,8,55,.20);
    }

    .sidebar{
      order:1;
      padding:9px 11px 10px;
    }

    .game-card{
      order:2;
      padding:7px;
    }

    .hud-top{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:8px;
      margin-bottom:7px;
    }

    .mode-name{
      margin:0;
      min-height:42px;
      padding:8px 10px;
      font-size:13px;
      white-space:nowrap;
      align-items:center;
    }

    .hud-actions{
      display:flex;
      align-items:center;
      justify-content:flex-end;
      gap:5px;
      min-width:0;
    }

    .hud-btn{
      border:1px solid rgba(255,255,255,.14);
      border-radius:10px;
      min-height:42px;
      padding:8px 10px;
      background:rgba(255,255,255,.10);
      color:#fff;
      font:inherit;
      font-size:12px;
      font-weight:900;
      cursor:pointer;
      white-space:nowrap;
      touch-action:manipulation;
    }

    .hud-btn#restartBtn{width:42px;padding:0;font-size:20px;line-height:1}

    .stats{
      grid-template-columns:repeat(3,1fr);
      gap:7px;
      margin:0 0 7px;
    }

    .stat{
      min-width:0;
      padding:7px 8px;
      border-radius:13px;
    }

    .stat .label{
      font-size:8px;
      letter-spacing:.07em;
      white-space:nowrap;
    }

    .stat .value{
      margin-top:2px;
      font-size:clamp(18px,5vw,22px);
      overflow:hidden;
      text-overflow:ellipsis;
      white-space:nowrap;
    }

    .progress-label{
      margin:0 2px 4px;
      font-size:10px;
    }

    .progress{
      height:7px;
      padding:1px;
    }

    .eyebrow,
    .subtitle,
    .rules,
    .mini,
    h1{
      display:none !important;
    }

    .board-wrap{
      width:100%;
      padding:6px;
      border-radius:17px;
      overflow:hidden;
    }

    .board{
      width:100%;
      max-width:none;
      gap:5px;
    }

    /* Mode chooser nằm trên bàn nhưng không che nội dung lúc đang chơi. */
    .mode-overlay{
      padding:6px;
      border-radius:17px;
      backdrop-filter:none;
      -webkit-backdrop-filter:none;
      overflow:hidden;
    }

    .mode-card{
      width:100%;
      height:100%;
      max-height:100%;
      overflow:hidden;
      padding:9px;
      border-radius:16px;
      display:flex;
      flex-direction:column;
      justify-content:center;
      background:rgba(52,18,80,.78);
      box-shadow:none;
    }

    .mode-card h2{
      margin:0 0 6px;
      font-size:18px;
      line-height:1.1;
    }

    .mode-card > p{
      display:none;
    }

    .mode-options{
      grid-template-columns:1fr 1fr !important;
      gap:6px;
      margin:0;
    }

    .mode-option{
      min-width:0;
      padding:8px 7px;
      border-radius:12px;
      text-align:center;
    }

    .mode-option b{
      margin:0 0 3px;
      font-size:12px;
      line-height:1.2;
    }

    .mode-option span{
      font-size:9px;
      line-height:1.2;
    }

    .online-name-box{
      margin-top:6px;
      padding:7px 8px;
      border-radius:11px;
    }

    .online-name-box label{
      margin-bottom:4px;
      font-size:9px;
    }

    .online-name-input{
      padding:7px 9px;
      border-radius:9px;
      font-size:12px;
    }

    .online-status{
      min-height:0;
      margin-top:3px;
      font-size:8px;
      line-height:1.15;
    }

    .embedded-board{
      margin-top:6px;
      padding:6px;
      border-radius:11px;
    }

    .embedded-board-head{
      margin-bottom:4px;
    }

    .embedded-board-head b{
      font-size:10px;
    }

    .embedded-board-head span{
      font-size:8px;
    }

    .embedded-list{
      gap:3px;
    }

    .embedded-row{
      grid-template-columns:23px 1fr auto;
      gap:5px;
      min-height:19px;
      padding:3px 5px;
      border-radius:7px;
      font-size:9px;
      line-height:1.1;
    }

    .embedded-empty{
      padding:6px 3px;
      font-size:9px;
    }

    .online-leaderboard-btn{
      margin-top:6px;
      padding:7px 9px;
      border-radius:10px;
      font-size:10px;
    }

    .overlay{
      padding:10px;
      border-radius:17px;
      backdrop-filter:none;
    }

    .overlay-card{
      width:min(350px,94%);
      padding:20px 16px;
      border-radius:20px;
    }

    .overlay h2{
      font-size:29px;
    }

    .online-overlay,
    .love-popup{
      backdrop-filter:none;
      -webkit-backdrop-filter:none;
    }

    @media(max-width:380px){
      .app{
        padding:6px;
        gap:6px;
      }

      .sidebar{
        padding:7px 8px 8px;
      }

      .hud-top{
        margin-bottom:5px;
      }

      .stat{
        padding:6px 7px;
      }

      .stat .value{
        font-size:18px;
      }

      .board-wrap{
        padding:4px;
      }

      .board{
        gap:4px;
      }

      .mode-card{
        padding:7px;
      }

      .mode-card h2{
        font-size:16px;
        margin-bottom:4px;
      }

      .mode-option{
        padding:6px 5px;
      }

      .mode-option b{
        font-size:11px;
      }

      .mode-option span{
        font-size:8px;
      }

      .online-name-box{
        margin-top:4px;
        padding:5px 6px;
      }

      .online-name-input{
        padding:6px 8px;
        font-size:11px;
      }

      .online-status{
        display:none;
      }

      .embedded-board{
        margin-top:4px;
        padding:5px;
      }

      .embedded-row{
        min-height:17px;
        padding:2px 4px;
        font-size:8px;
      }

      .online-leaderboard-btn{
        margin-top:4px;
        padding:6px 7px;
        font-size:9px;
      }
    }

  
    /* Top 10 chỉ để xem; đổi tên chỉ ở màn chọn chế độ. */
    .online-actions{
      grid-template-columns:1fr;
    }

    /* =====================================================
       V5.5.2 — Lobby tách khỏi board, gameplay chỉ còn HUD + bàn chơi.
       ===================================================== */
    .app.mode-lobby-open .game-card{display:none}
    .app.mode-lobby-leaving .game-card{display:none}
    .app.mode-lobby-open .sidebar,
    .app.mode-lobby-leaving .sidebar{display:none}
    .mode-overlay{
      order:2;
      position:static;
      inset:auto;
      z-index:auto;
      display:none;
      padding:0;
      border-radius:0;
      background:none;
      backdrop-filter:none;
      -webkit-backdrop-filter:none;
      opacity:1;
      pointer-events:auto;
      overflow:visible;
    }
    .mode-overlay.show{display:block}
    .mode-overlay.leaving{pointer-events:none}
    .mode-card{
      width:100%;height:auto;max-height:none;
      overflow:visible;
      padding:0;
      border:0;border-radius:0;
      display:grid;
      gap:10px;
      text-align:left;
      background:none;
      box-shadow:none;
    }
    .lobby-section{
      padding:14px;
      border:1px solid rgba(255,255,255,.17);
      border-radius:18px;
      background:linear-gradient(145deg,rgba(70,24,105,.80),rgba(41,12,76,.79));
      box-shadow:0 10px 24px rgba(27,5,54,.17);
    }
    .lobby-mode-section h2{
      margin:0 0 11px;
      text-align:center;
      font-size:22px;
      line-height:1.1;
    }
    .mode-options{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:9px}
    .mode-option{
      min-height:86px;
      padding:12px 8px;
      border-radius:15px;
      text-align:center;
      background:rgba(255,255,255,.10);
    }
    .mode-option b{margin-bottom:6px;font-size:14px}
    .mode-option span{font-size:10px;line-height:1.35}

    /* Xác nhận mode đủ lâu để mắt nhận ra trước khi lobby rời khỏi màn hình. */
    .mode-overlay.leaving .mode-option{animation:modeChoiceDim .25s ease forwards}
    .mode-overlay.leaving[data-selected-mode="classic"] #classicModeBtn,
    .mode-overlay.leaving[data-selected-mode="endless"] #endlessModeBtn{
      animation:modeChoiceConfirm .32s cubic-bezier(.18,.86,.3,1.18) forwards;
    }
    .mode-overlay.leaving .account-summary,
    .mode-overlay.leaving .lobby-settings,
    .mode-overlay.leaving .embedded-board{
      animation:lobbyExit .25s .25s cubic-bezier(.28,.05,.36,1) forwards;
    }
    .mode-overlay.leaving .lobby-mode-section{
      animation:lobbyExit .24s .28s cubic-bezier(.28,.05,.36,1) forwards;
    }
    @keyframes modeChoiceConfirm{
      0%{transform:scale(1);filter:brightness(1)}
      28%{transform:scale(.965);filter:brightness(.98)}
      66%{transform:scale(1.045);filter:brightness(1.2)}
      100%{transform:scale(1.025);filter:brightness(1.1)}
    }
    @keyframes modeChoiceDim{
      0%,52%{opacity:1;transform:scale(1)}
      100%{opacity:.32;transform:scale(.98)}
    }
    @keyframes lobbyExit{
      0%{opacity:1;transform:translate3d(0,0,0)}
      100%{opacity:0;transform:translate3d(0,-16px,0)}
    }
    .app.board-entering .game-card{
      animation:boardEnter .36s cubic-bezier(.16,.86,.28,1) both;
    }
    @keyframes boardEnter{
      from{opacity:0;transform:translate3d(0,18px,0) scale(.95)}
      to{opacity:1;transform:translate3d(0,0,0) scale(1)}
    }

    .online-name-box{margin:0;padding:14px}
    .online-name-box label,.lobby-settings h3{
      display:block;
      margin:0 0 8px;
      color:rgba(255,255,255,.91);
      font-size:13px;
      font-weight:1000;
    }
    .name-save-row{display:flex;gap:8px;align-items:stretch}
    .online-name-input{min-width:0;flex:1;padding:11px 12px;font-size:14px}
    .save-name-btn{
      flex:0 0 70px;
      border:0;border-radius:12px;
      padding:0 10px;
      color:#712453;
      background:linear-gradient(180deg,#fff7b6,#facc15);
      font:inherit;font-size:13px;font-weight:1000;
      cursor:pointer;
      touch-action:manipulation;
    }
    .online-status{min-height:17px;margin:6px 1px 0;font-size:10px;line-height:1.3}

    .lobby-settings{padding:13px 14px}
    .lobby-settings h3{margin-bottom:9px}
    .feedback-settings{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:0}
    .feedback-settings label{
      min-height:44px;
      padding:8px;
      justify-content:center;
      border-radius:12px;
      font-size:12px;
    }
    .embedded-board{margin:0;padding:14px}
    .embedded-board-head{margin-bottom:9px}
    .embedded-board-head b{font-size:15px}
    .embedded-board-head span{font-size:11px}
    .embedded-list{gap:5px}
    .embedded-row{min-height:35px;padding:7px 9px;border-radius:10px;font-size:12px}
    .online-leaderboard-btn{width:100%;margin-top:10px;padding:11px 12px;border-radius:12px;font-size:12px}

    .hud-btn#gameSettingsBtn,.hud-btn#hudLeaderboardBtn{
      width:42px;padding:0;font-size:18px;line-height:1;
    }
    .mode-lobby-open #gameSettingsBtn{display:none}

    /* Reset global tap highlight. Focus-visible vẫn giữ viền riêng cho bàn phím. */
    button,input,label{-webkit-tap-highlight-color:transparent}
    button:focus:not(:focus-visible),input:focus:not(:focus-visible){outline:none}
    button:focus-visible,input:focus-visible{
      outline:2px solid rgba(255,247,185,.92);
      outline-offset:2px;
    }
    .hud-btn:active,
    .mode-option:active,
    .save-name-btn:active,
    .online-leaderboard-btn:active,
    .online-close:active,
    .quick-settings-close:active,
    .feedback-settings label:active{
      transform:scale(.975);
      filter:brightness(1.12);
    }

    .quick-settings-overlay{
      position:fixed;inset:0;z-index:3500;
      display:flex;align-items:center;justify-content:center;
      padding:20px;
      background:rgba(22,5,45,.68);
      opacity:0;pointer-events:none;
      transition:opacity .18s ease;
    }
    .quick-settings-overlay.show{opacity:1;pointer-events:auto}
    .quick-settings-card{
      width:min(360px,100%);
      padding:18px;
      border:1px solid rgba(255,255,255,.20);
      border-radius:22px;
      background:linear-gradient(145deg,rgba(101,44,147,.97),rgba(49,17,90,.98));
      box-shadow:0 24px 60px rgba(20,4,42,.44);
    }
    .quick-settings-head{display:flex;align-items:center;justify-content:space-between;gap:12px}
    .quick-settings-head h2{margin:0;font-size:22px}
    .quick-settings-close{
      width:36px;height:36px;border:0;border-radius:11px;
      background:rgba(255,255,255,.12);color:#fff;
      font:inherit;font-size:25px;line-height:1;cursor:pointer;
    }
    .quick-settings-card p{margin:7px 0 15px;color:rgba(255,255,255,.74);font-size:12px}
    .feedback-settings-game{grid-template-columns:1fr}

    @media(prefers-reduced-motion:reduce){
      .mode-overlay.leaving .mode-option,
      .mode-overlay.leaving .online-name-box,
      .mode-overlay.leaving .lobby-settings,
      .mode-overlay.leaving .embedded-board,
      .mode-overlay.leaving .lobby-mode-section,
      .app.board-entering .game-card{animation:none}
    }

    @media(max-width:380px){
      .mode-card{gap:7px}
      .lobby-section,.online-name-box,.embedded-board{padding:11px}
      .lobby-mode-section h2{margin-bottom:8px;font-size:19px}
      .mode-option{min-height:74px;padding:9px 5px}
      .mode-option b{margin-bottom:4px;font-size:12px}
      .mode-option span{font-size:9px}
      .online-name-input{padding:9px 10px;font-size:13px}
      .save-name-btn{flex-basis:60px}
      .feedback-settings label{min-height:40px;font-size:11px}
      .embedded-row{min-height:31px;padding:5px 7px;font-size:11px}
    }

    /* V6 account & profile: không thêm animation nền để giữ FPS ổn định. */
    .profile-hud-btn{width:50px;min-height:48px;padding:0;font-size:22px;line-height:1}
    .account-summary{display:grid;grid-template-columns:42px minmax(0,1fr) auto;align-items:center;gap:10px}
    .account-summary-avatar{width:42px;height:42px;display:grid;place-items:center;border-radius:50%;background:linear-gradient(145deg,#f9d663,#ca6dca);background-size:cover;background-position:center;color:#fff;font-weight:900;box-shadow:inset 0 1px 0 rgba(255,255,255,.42)}
    .account-summary-avatar.has-avatar{font-size:0}
    .account-summary-copy{min-width:0;display:grid;gap:3px}
    .account-summary-copy b{font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
    .account-summary-copy span{font-size:11px;line-height:1.3;color:rgba(255,255,255,.72)}
    .account-summary .save-name-btn{min-width:98px;min-height:46px;flex-basis:auto;padding-inline:14px;font-size:14px}
    .account-overlay,.profile-overlay{position:fixed;inset:0;z-index:3600;display:flex;align-items:center;justify-content:center;padding:18px;background:rgba(20,5,42,.7);opacity:0;pointer-events:none;transition:opacity .18s ease}
    .account-overlay.show,.profile-overlay.show{opacity:1;pointer-events:auto}
    .account-card,.profile-card{position:relative;width:min(440px,100%);max-height:min(720px,calc(100dvh - 36px));overflow:auto;padding:22px;border:1px solid rgba(255,255,255,.25);border-radius:24px;background:linear-gradient(145deg,rgba(99,48,145,.98),rgba(43,17,78,.99));box-shadow:0 26px 72px rgba(9,2,28,.56);color:#fff}
    .profile-card{width:min(480px,100%)}
    .modal-x{position:absolute;right:14px;top:13px;width:34px;height:34px;border:0;border-radius:11px;background:rgba(255,255,255,.12);color:#fff;font-size:25px;line-height:1;cursor:pointer}
    .account-card h2,.profile-card h2{margin:0 38px 8px 0;font-size:24px}.account-card h3{margin:0 0 8px}.account-lead,.support-note{margin:0 0 16px;color:rgba(255,255,255,.76);font-size:13px;line-height:1.45}
    .auth-tabs{display:grid;grid-template-columns:1fr 1fr;gap:7px;margin-bottom:13px}.auth-tab{min-height:39px;border:1px solid rgba(255,255,255,.16);border-radius:11px;background:rgba(255,255,255,.08);color:#fff;font:inherit;font-weight:800;cursor:pointer}.auth-tab.active{background:rgba(255,224,112,.88);border-color:rgba(255,245,188,.85);color:#51225e}
    .auth-form{display:grid;gap:11px}.auth-form label{display:grid;gap:5px;font-size:12px;font-weight:700;color:rgba(255,255,255,.9)}.auth-form small{font-weight:400;color:rgba(255,255,255,.62)}
    .auth-form input,.auth-form textarea{width:100%;box-sizing:border-box;border:1px solid rgba(255,255,255,.22);border-radius:11px;padding:11px 12px;background:rgba(20,7,49,.32);color:#fff;font:inherit;outline:none}.auth-form textarea{resize:vertical}.auth-form input:focus,.auth-form textarea:focus{border-color:rgba(255,229,116,.86);box-shadow:0 0 0 2px rgba(255,223,96,.16)}
    .login-actions{display:grid;grid-template-columns:auto auto minmax(104px,1fr);align-items:center;gap:8px}.login-actions .primary{width:100%;min-height:42px}.auth-back{margin-top:13px}
    .text-action{justify-self:start;border:0;background:transparent;color:#ffe685;font:inherit;font-size:12px;font-weight:800;text-decoration:underline;cursor:pointer}.account-status{min-height:19px;margin:12px 0 0;font-size:12px;color:#d9ffbb}.account-status.error{color:#ffd0d8}
    .recovery-code{display:block;margin:14px 0;padding:13px 10px;border-radius:12px;background:rgba(15,5,42,.38);color:#ffe886;text-align:center;letter-spacing:.08em;font-size:18px}.recovery-confirm{display:flex;align-items:center;gap:8px;margin:14px 0;font-size:12px}.recovery-confirm input{width:18px;height:18px;accent-color:#f3c94d}
    .profile-head{display:flex;align-items:center;gap:10px;margin-bottom:17px}.profile-head h2{flex:1;margin:0;font-size:24px}.profile-head>span{margin-right:37px;border-radius:999px;background:rgba(255,225,109,.16);padding:5px 8px;color:#ffe985;font-size:10px;font-weight:900}
    .profile-guest{text-align:center}.profile-guest .profile-avatar{margin:10px auto}.profile-guest h3{margin:9px 0}.profile-guest p{font-size:13px;color:rgba(255,255,255,.72)}
    .profile-identity{display:grid;grid-template-columns:70px minmax(0,1fr);gap:13px;align-items:start}.profile-avatar{position:relative;width:70px;height:70px;display:grid;place-items:center;overflow:hidden;border:2px solid rgba(255,235,139,.7);border-radius:50%;background:linear-gradient(145deg,#ffce63,#a958bf);color:#fff;font-size:28px;font-weight:900}.profile-avatar-button{padding:0;cursor:pointer}.profile-avatar img{width:100%;height:100%;object-fit:cover}.profile-avatar em{position:absolute;right:1px;bottom:0;width:23px;height:23px;display:grid;place-items:center;border-radius:50%;background:#59338c;color:#fff;font-size:13px;font-style:normal}.profile-identity h3{margin:1px 0 3px;font-size:20px}.profile-identity span{font-size:11px;color:rgba(255,255,255,.66)}.profile-identity p{margin:8px 0;color:rgba(255,255,255,.8);font-size:12px;line-height:1.4}
    .season-panel,.profile-pair{margin-top:17px;border:1px solid rgba(255,255,255,.14);border-radius:16px;background:rgba(17,7,47,.26);padding:13px}.section-label,.section-title{display:flex;justify-content:space-between;gap:10px;font-size:10px;color:rgba(255,255,255,.65)}.section-label span,.profile-pair small{font-weight:900;letter-spacing:.05em}.section-label b{font-weight:700}.season-metrics,.profile-pair{display:grid;grid-template-columns:1fr 1fr;gap:12px}.season-metrics{margin-top:11px}.season-metrics div,.profile-pair div{display:grid;gap:4px}.season-metrics small,.profile-pair small{font-size:9px;color:rgba(255,255,255,.62)}.season-metrics strong,.profile-pair strong{font-size:21px;color:#fff5c0}.profile-pair{margin-top:10px}.section-title{margin:17px 2px 9px;font-size:12px}.section-title b{font-size:14px;color:#fff}
    .medal-totals{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}.medal-total{display:grid;place-items:center;gap:2px;padding:9px 5px;border:1px solid rgba(255,255,255,.13);border-radius:13px;background:rgba(20,7,49,.25)}.medal-total b{font-size:25px}.medal-total span{font-size:10px;color:rgba(255,255,255,.68)}.medal-total strong{font-size:17px}.profile-leaderboard-btn,.zalo-link{display:block;width:100%;box-sizing:border-box;margin-top:17px;border:0;border-radius:12px;padding:12px;background:linear-gradient(180deg,#fff29a,#f3c538);color:#57205a;text-align:center;font:inherit;font-size:13px;font-weight:900;text-decoration:none;cursor:pointer}.logout-action{display:block;margin:13px auto 0}.support-card{text-align:center}.support-card h2{margin-right:0}.support-card .zalo-link{margin:16px 0}.profile-edit-card h2{margin-bottom:17px}
    /* V6.0.4: cả tên và @username là nút mở profile công khai; không dùng text user trực tiếp làm HTML. */
    .online-player,.embedded-player{min-width:0;border:0;padding:0;background:transparent;color:inherit;text-align:left;font:inherit;cursor:pointer;touch-action:manipulation}
    .online-player{display:grid;gap:2px}.embedded-player{display:grid;gap:1px}
    .online-player-name,.embedded-player-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:900}
    .online-player-username,.embedded-player-username{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:rgba(255,255,255,.58);font-weight:700}
    .online-player-username{font-size:10px}.embedded-player-username{font-size:8px}
    .online-player:focus-visible,.embedded-player:focus-visible{outline:2px solid rgba(255,232,126,.9);outline-offset:3px;border-radius:5px}
    .online-player:active,.embedded-player:active{opacity:.72}
    .public-profile-status{min-height:22px;margin:10px 0;color:rgba(255,255,255,.74);font-size:13px;text-align:center}
    .public-profile-card .profile-identity{margin-top:4px}
    @media(max-width:380px){.account-summary{grid-template-columns:38px minmax(0,1fr)}.account-summary-avatar{width:38px;height:38px}.account-summary .save-name-btn{grid-column:2}.account-card,.profile-card{padding:18px 15px}.profile-head>span{font-size:8px}.profile-identity{grid-template-columns:62px minmax(0,1fr)}.profile-avatar{width:62px;height:62px}.season-metrics strong,.profile-pair strong{font-size:18px}.login-actions{grid-template-columns:1fr 1fr}.login-actions .primary{grid-column:1/-1}}

    /* V6.0.5: HUD chỉ xuất hiện khi đang chơi; các thao tác cùng kích thước. */
    .hud-actions{gap:4px}
    .hud-btn,
    .hud-btn#restartBtn,
    .hud-btn.profile-hud-btn,
    .hud-btn#gameSettingsBtn,
    .hud-btn#hudLeaderboardBtn,
    .hud-btn#homeBtn{
      width:42px;
      min-width:42px;
      min-height:42px;
      padding:0;
      border-color:rgba(255,255,255,.24);
      background:linear-gradient(145deg,rgba(255,255,255,.25),rgba(255,255,255,.11));
      box-shadow:inset 0 1px 0 rgba(255,255,255,.20),0 5px 12px rgba(34,8,68,.18);
      font-size:20px;
      line-height:1;
    }
    .hud-btn#gameSettingsBtn{display:block}
    .mode-name{max-width:80px;justify-content:center;text-align:center;overflow:hidden;text-overflow:ellipsis}
    @media(max-width:380px){
      .hud-btn,
      .hud-btn#restartBtn,
      .hud-btn.profile-hud-btn,
      .hud-btn#gameSettingsBtn,
      .hud-btn#hudLeaderboardBtn,
      .hud-btn#homeBtn{width:40px;min-width:40px;min-height:40px;font-size:18px}
      .mode-name{max-width:54px;min-height:40px;padding-inline:7px;font-size:12px}
    }
    .hud-btn#homeBtn{font-size:22px}
    .home-confirm-overlay{position:fixed;inset:0;z-index:3550;display:flex;align-items:center;justify-content:center;padding:18px;background:rgba(20,5,42,.78);opacity:0;pointer-events:none;transition:opacity .18s ease}
    .home-confirm-overlay.show{opacity:1;pointer-events:auto}
    .home-confirm-card{width:min(360px,100%);padding:21px;border:1px solid rgba(255,255,255,.25);border-radius:23px;background:linear-gradient(145deg,#7540a7,#3e195f);box-shadow:0 26px 72px rgba(9,2,28,.56);color:#fff;text-align:center}
    .home-confirm-card h2{margin:0;font-size:25px}.home-confirm-card p{margin:10px 0 18px;color:rgba(255,255,255,.78);font-size:13px;line-height:1.5}.home-confirm-actions{display:grid;grid-template-columns:1fr 1fr;gap:9px}.home-confirm-actions .secondary{margin:0;padding:12px 8px}.home-confirm-actions .primary{padding:12px 8px}
    .profile-password-action{display:block;margin:16px auto 0}.logout-action{margin-top:8px}
