*{
    box-sizing:border-box;
    margin:0;
    padding:0;
    -webkit-tap-highlight-color:transparent;
}

html,
body{
    width:100%;
    height:100%;
    overflow:hidden;
}

body{
    display:flex;
    align-items:center;
    justify-content:center;
    background:#2c3e50;
    font-family:Arial;
    user-select:none;
    -webkit-user-select:none;
    -ms-user-select:none;
    touch-action:manipulation;
}

/* ================= CONTAINER ================= */

.ludo-container{

    width:450px;

    padding-top:55px;

    text-align:center;

    color:white;
}

/* ================= BÀN CỜ ================= */

.ludo{
    width:450px;
    height:450px;
    background-image:url('banco.jpg');
    background-size:100% 100%;
    background-repeat:no-repeat;
    position:relative;
    border:5px solid #fff;
    border-radius:10px;
    box-shadow:0 0 25px rgba(255,255,255,0.2);
}

/* ================= QUÂN CỜ 3D ================= */

.player-piece{
    width:26px;
    height:26px;
    position:absolute;

    border-radius:50%;

    transform:translate(-50%,-50%);

    transition:
        transform .25s ease,
        box-shadow .25s ease;

    z-index:10;

    /* VIỀN NGOÀI */
    border:2px solid rgba(255,255,255,0.95);

    /* BÓNG ĐỔ */
    box-shadow:
        inset 0 2px 4px rgba(255,255,255,0.85),
        inset 0 -4px 6px rgba(0,0,0,0.45),
        0 3px 7px rgba(0,0,0,0.6),
        0 0 8px rgba(255,255,255,0.25);

    overflow:hidden;
}

/* ÁNH SÁNG PHẢN CHIẾU */

.player-piece::before{
    content:'';

    position:absolute;

    top:3px;
    left:4px;

    width:55%;
    height:35%;

    border-radius:50%;

    background:rgba(255,255,255,0.78);

    filter:blur(1px);

    transform:rotate(-15deg);
}

/* HIỆU ỨNG KHI TỚI LƯỢT */

.player-piece.highlight{
    cursor:pointer;

    animation:spin 1s infinite linear;

    z-index:20;

    border:2px solid #ffffff;

    box-shadow:
        inset 0 2px 4px rgba(255,255,255,0.95),
        inset 0 -4px 6px rgba(0,0,0,0.55),
        0 0 12px #ffffff,
        0 0 24px rgba(255,255,255,0.9),
        0 4px 10px rgba(0,0,0,0.75);
}

/* ================= XOAY QUÂN ================= */

@keyframes spin{

    0%{
        transform:translate(-50%,-50%) rotate(0deg) scale(1);
    }

    50%{
        transform:translate(-50%,-50%) rotate(180deg) scale(1.22);
    }

    100%{
        transform:translate(-50%,-50%) rotate(360deg) scale(1);
    }
}

/* ================= QUÂN VÀNG ================= */

[player-id="P1"]{
    background:
        radial-gradient(circle at 30% 30%,
        #fff8ae 0%,
        #f7d900 38%,
        #b8860b 100%);
}

/* ================= QUÂN XANH LÁ ================= */

[player-id="P2"]{
    background:
        radial-gradient(circle at 30% 30%,
        #b9ffd0 0%,
        #2ecc71 38%,
        #17693b 100%);
}

/* ================= QUÂN ĐỎ ================= */

[player-id="P3"]{
    background:
        radial-gradient(circle at 30% 30%,
        #ffc0bb 0%,
        #ff4d3d 38%,
        #8e140b 100%);
}

/* ================= QUÂN XANH DƯƠNG ================= */

[player-id="P4"]{
    background:
        radial-gradient(circle at 30% 30%,
        #bfe6ff 0%,
        #3498db 38%,
        #184f78 100%);
}

/* ================= BASE CHỚP LƯỢT ================= */

.player-base{
    width:40%;
    height:40%;
    position:absolute;
    opacity:0;
}

.player-base.highlight{
    opacity:0.85 !important;
    animation:superBlink .45s infinite;
    box-shadow:
        0 0 20px #fff,
        0 0 40px #fff,
        0 0 70px #fff;
}

@keyframes superBlink{

    0%{
        opacity:0.2;
        transform:scale(1);
    }

    50%{
        opacity:1;
        transform:scale(1.08);
    }

    100%{
        opacity:0.2;
        transform:scale(1);
    }
}

[player-id="P1"].player-base{
    bottom:0;
    left:0;
}

[player-id="P2"].player-base{
    top:0;
    left:0;
}

[player-id="P3"].player-base{
    top:0;
    right:0;
}

[player-id="P4"].player-base{
    bottom:0;
    right:0;
}

/* ================= UI ================= */

.game-ui{
    margin-top:14px;
}

.top-ui{
    display:flex;
    align-items:center;
    justify-content:center;
    gap:12px;
    margin-bottom:12px;
}

.bottom-ui{
    display:flex;
    align-items:center;
    justify-content:center;
    gap:12px;
}

/* ================= BUTTON ================= */

.roll-btn{
    background:linear-gradient(to bottom,#2ecc71,#27ae60);
    color:white;
    border:none;
    border-radius:10px;
    padding:10px 14px;
    font-size:15px;
    font-weight:bold;
    cursor:pointer;
    box-shadow:
        0 5px #1e8449,
        0 0 10px rgba(0,0,0,0.4);
}

.roll-btn:active{
    transform:translateY(3px);

    box-shadow:
        0 2px #1e8449;
}

#reset-btn{
    background:linear-gradient(to bottom,#ffffff,#d7d7d7);
    border:none;
    border-radius:12px;
    padding:10px 16px;
    font-size:15px;
    font-weight:bold;
    cursor:pointer;
    box-shadow:
        0 6px #888,
        0 0 12px rgba(0,0,0,0.5);
}

#reset-btn:active{
    transform:translateY(3px);

    box-shadow:
        0 2px #666;
}

/* ================= ICON LOA ================= */

#music-btn{
    width:46px;
    height:46px;
    border:none;
    border-radius:50%;
    cursor:pointer;
    font-size:22px;
    background:linear-gradient(to bottom,#ffe082,#f1c40f);
    box-shadow:
        0 5px #c39b00,
        0 0 10px rgba(0,0,0,0.4);
}

#music-btn:active{
    transform:translateY(3px);

    box-shadow:
        0 2px #c39b00;
}

/* ================= XÍ NGẦU ================= */

.dice-area{
    display:flex;
    gap:8px;
}

.dice-wrapper{
    perspective:500px;
    width:42px;
    height:42px;
}

.dice{
    width:42px;
    height:42px;
    position:relative;
    transform-style:preserve-3d;
    transition:transform 1s;
}

.face{
    position:absolute;
    width:42px;
    height:42px;
    background:white;
    border:2px solid #ccc;
    border-radius:8px;
}

.front{
    transform:translateZ(21px);
}

.back{
    transform:rotateX(180deg) translateZ(21px);
}

.right{
    transform:rotateY(90deg) translateZ(21px);
}

.left{
    transform:rotateY(-90deg) translateZ(21px);
}

.top{
    transform:rotateX(90deg) translateZ(21px);
}

.bottom{
    transform:rotateX(-90deg) translateZ(21px);
}

/* ================= CHẤM XÍ NGẦU ================= */

.front::after,
.back::before,
.back::after,
.right::before,
.left::before,
.top::before,
.bottom::before{
    content:'';
    position:absolute;
    background:#111;
    border-radius:50%;
}

.front::after{
    width:10px;
    height:10px;
    top:50%;
    left:50%;
    transform:translate(-50%,-50%);
}

.back::before{
    width:10px;
    height:10px;
    top:8px;
    left:8px;
}

.back::after{
    width:10px;
    height:10px;
    bottom:8px;
    right:8px;
}

.right::before{
    width:8px;
    height:8px;
    top:8px;
    left:8px;
    box-shadow:
        8px 8px #111,
        16px 16px #111;
}

.left::before{
    width:8px;
    height:8px;
    top:8px;
    left:8px;
    box-shadow:
        18px 0 #111,
        0 18px #111,
        18px 18px #111;
}

.top::before{
    width:8px;
    height:8px;
    top:8px;
    left:8px;
    box-shadow:
        18px 0 #111,
        9px 9px #111,
        0 18px #111,
        18px 18px #111;
}

.bottom::before{
    width:8px;
    height:8px;
    top:6px;
    left:6px;
    box-shadow:
        20px 0 #111,
        0 10px #111,
        20px 10px #111,
        0 20px #111,
        20px 20px #111;
}

/* ================= XOAY XÍ NGẦU ================= */

@keyframes rolling{

    0%{
        transform:rotateX(0deg) rotateY(0deg);
    }

    100%{
        transform:rotateX(360deg) rotateY(360deg);
    }
}

/* ================= TEXT ================= */

.result{
    font-size:28px;
    font-weight:bold;
    color:#f1c40f;
    min-width:50px;
}

.active-player{
    font-size:22px;
    font-weight:bold;
}

/* ================= CREDIT ================= */

.credit{
    margin-top:14px;
    text-align:center;
    font-size:13px;
    color:#FFD700;
    font-weight:bold;
    text-shadow:0 0 6px rgba(255,215,0,0.6);
}

/* ================= MOBILE ================= */

@media screen and (max-width:768px){

    html,
    body{
        overflow:auto;
    }

    body{
        padding:10px 0;
        align-items:flex-start;
    }

    .ludo-container{
        width:100%;
        max-width:375px;
        margin:auto;
    }

    .ludo{
        width:100vw;
        max-width:375px;
        height:100vw;
        max-height:375px;
        margin:auto;
    }

    .top-ui,
    .bottom-ui{
        gap:8px;
        flex-wrap:wrap;
    }

    .roll-btn,
    #reset-btn{
        font-size:13px;
        padding:8px 12px;
    }

    .result{
        font-size:24px;
    }

    .active-player{
        font-size:20px;
    }

    #music-btn{
        width:42px;
        height:42px;
        font-size:20px;
    }

    .player-piece{
        width:22px;
        height:22px;
    }
}

/* ================= NÚT HƯỚNG DẪN ================= */

#huongdan-btn{

    border:none;

    padding:10px 14px;

    border-radius:12px;

    cursor:pointer;

    font-size:15px;

    font-weight:bold;

    color:white;

    background:
        linear-gradient(to bottom,
        #ffcc33,
        #d4a017);

    box-shadow:
        0 5px #8c6b00,
        0 0 10px rgba(0,0,0,0.4);
}

#huongdan-btn:active{

    transform:translateY(3px);

    box-shadow:
        0 2px #8c6b00;
}

/* ================= BẢNG HƯỚNG DẪN ================= */

#huongdan-board{

    position:fixed;

    left:0;
    top:0;

    width:100%;
    height:100%;

    display:none;

    align-items:center;
    justify-content:center;

    background:rgba(0,0,0,0.6);

    z-index:999999;
}

/* ================= KHUNG ================= */

.huongdan-box{

    width:340px;

    max-width:92vw;

    max-height:90vh;

    overflow-y:auto;

    background:#a40000;

    border:5px solid gold;

    border-radius:16px;

    padding:18px;

    box-shadow:
        0 0 30px rgba(0,0,0,0.8);

    text-align:center;
}

/* ================= TIÊU ĐỀ ================= */

.huongdan-title{

    color:gold;

    font-size:22px;

    font-weight:bold;

    margin-bottom:18px;

    text-shadow:
        0 0 8px black;
}

/* ================= NỘI DUNG ================= */

.huongdan-content{

    color:white;

    font-size:15px;

    line-height:1.8;

    text-align:left;

    margin-bottom:18px;
}

/* ================= NÚT OK ================= */

#close-huongdan{

    width:100%;

    border:none;

    border-radius:12px;

    padding:12px;

    cursor:pointer;

    font-size:16px;

    font-weight:bold;

    color:#111;

    background:
        linear-gradient(to bottom,
        #ffe082,
        #f1c40f);

    box-shadow:
        0 5px #b7950b;
}

#close-huongdan:active{

    transform:translateY(3px);

    box-shadow:
        0 2px #b7950b;
}

/* ================= MOBILE ================= */

@media screen and (max-width:768px){

    #huongdan-btn{

        font-size:13px;

        padding:8px 12px;
    }

    .huongdan-box{

        width:92vw;

        padding:14px;
    }

    .huongdan-title{

        font-size:19px;
    }

    .huongdan-content{

        font-size:14px;
    }
}

/* ================= TOP BAR ================= */

#top-mode-bar{

    position:absolute;

    top:-46px;

    left:0;

    display:flex;

    align-items:center;

    gap:12px;

    z-index:999;
}

/* ================= MODE BUTTON ================= */

#modegame-btn{

    border:none;

    padding:6px 11px;

    border-radius:9px;

    cursor:pointer;

    font-size:12px;

    font-weight:bold;

    color:white;

    background:
        linear-gradient(to bottom,
        #00d9ff,
        #0077aa);

    box-shadow:
        0 3px #005577,
        0 0 8px rgba(0,0,0,0.4);

    transition:
        transform .15s,
        filter .15s,
        box-shadow .15s;
}

#modegame-btn:hover{

    filter:brightness(1.08);
}

#modegame-btn:active{

    transform:translateY(2px);

    box-shadow:
        0 1px #005577;
}

/* ================= GAME TITLE ================= */

#game-title-top{

    font-size:20px;

    font-weight:bold;

    color:#dfffff;

    text-shadow:
        0 0 8px #00ffff,
        0 0 14px rgba(255,255,255,0.6);

    animation:titleGlow 2s infinite alternate;
}

@keyframes titleGlow{

    from{

        opacity:.7;

        transform:scale(1);
    }

    to{

        opacity:1;

        transform:scale(1.03);
    }
}

/* ================= MOBILE ================= */

@media screen and (max-width:768px){

    #top-mode-bar{

        top:-42px;

        gap:8px;
    }

    #modegame-btn{

        font-size:11px;

        padding:5px 9px;
    }

    #game-title-top{

        font-size:14px;
    }
}

/* ================= BOARD ================= */

#modegame-board{

    position:fixed;

    left:0;
    top:0;

    width:100%;
    height:100%;

    display:none;

    align-items:center;
    justify-content:center;

    background:rgba(0,0,0,0.65);

    z-index:999999;
}

/* ================= BOX ================= */

.modegame-box{

    width:360px;

    max-width:92vw;

    background:rgba(0,255,220,0.18);

    border:3px solid #00ffe1;

    border-radius:18px;

    padding:22px;

    backdrop-filter:blur(10px);

    box-shadow:
        0 0 30px rgba(0,255,220,0.6);

    text-align:center;
}

/* ================= TITLE ================= */

.modegame-title{

    font-size:24px;

    font-weight:bold;

    color:white;

    margin-bottom:20px;

    text-shadow:
        0 0 10px black;
}

/* ================= ROW ================= */

.mode-row{

    display:flex;

    align-items:center;

    justify-content:space-between;

    margin-bottom:16px;

    gap:10px;
}

.mode-row label{

    color:white;

    font-size:15px;

    font-weight:bold;

    text-align:left;
}

/* ================= SELECT ================= */

.mode-select{

    width:120px;

    padding:8px;

    border:none;

    border-radius:10px;

    font-size:14px;

    font-weight:bold;

    background:white;
}

/* ================= SAVE BUTTON ================= */

#save-modegame{

    width:100%;

    margin-top:10px;

    border:none;

    border-radius:12px;

    padding:12px;

    cursor:pointer;

    font-size:16px;

    font-weight:bold;

    background:
        linear-gradient(to bottom,
        #00ffcc,
        #00aa88);

    color:#022;

    box-shadow:
        0 5px #007766;
}

#save-modegame:active{

    transform:translateY(3px);

    box-shadow:
        0 2px #007766;
}

/* ================= MOBILE ================= */

@media screen and (max-width:768px){

    #modegame-btn{

        top:-54px;

        left:0;

        font-size:13px;

        padding:8px 12px;
    }

    .modegame-box{

        width:92vw;
    }

    .mode-row{

        flex-direction:column;

        align-items:flex-start;
    }

    .mode-select{

        width:100%;
    }
}