:root {
    --red: #FF3B30;
    --green: #4CD964;
    --yellow: #FFCC00;
    --blue: #007AFF;
    --red-dark: #C62828;
    --green-dark: #2E7D32;
    --yellow-dark: #F9A825;
    --blue-dark: #1565C0;
    --bg-color: #0F172A;
    --panel-bg: rgba(255, 255, 255, 0.08);
    --text-color: #F8FAFC;
    --border-color: #1E293B;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Poppins', sans-serif;
    user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

/* --- UI Overlay (Menus) --- */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.3s;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.hidden {
    display: none !important;
}

.menu-container {
    background: linear-gradient(180deg, #0044b3 0%, #001a4d 100%);
    border: 3px solid #0050b3;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(255, 255, 255, 0.1);
    position: relative;
    display: flex;
    flex-direction: column;
}

.menu-title {
    font-size: 40px;
    color: #ffcc00;
    margin-bottom: 20px;
    text-shadow: 2px 2px 0px #000, -2px -2px 0px #000, 2px -2px 0px #000, -2px 2px 0px #000, 0px 5px 10px rgba(0, 0, 0, 0.5);
    letter-spacing: 2px;
    font-weight: 900;
}

.lk-title {
    color: #ffcc00;
    font-size: 28px;
    font-weight: 900;
    text-transform: uppercase;
    text-shadow: 2px 2px 0px #000, -2px -2px 0px #000, 2px -2px 0px #000, -2px 2px 0px #000;
    margin-bottom: 0;
}

/* DASHBOARD BUTTONS */
.dashboard-grid {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
}

.btn-dashboard {
    position: relative;
    width: 130px;
    height: 100px;
    background: linear-gradient(180deg, #0066cc 0%, #004499 100%);
    border: 4px solid #f9a825;
    border-radius: 15px;
    box-shadow: inset 0 5px 10px rgba(255, 255, 255, 0.2), inset 0 -5px 10px rgba(0, 0, 0, 0.3), 0 5px 15px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.1s;
}

.btn-dashboard:active {
    transform: scale(0.95);
}

.btn-dashboard .btn-icon {
    font-size: 45px;
    margin-top: 10px;
    filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.5));
}

.btn-dashboard .btn-label {
    position: absolute;
    bottom: -15px;
    background: linear-gradient(180deg, #ffee58 0%, #f9a825 100%);
    color: white;
    font-weight: 900;
    font-size: 13px;
    padding: 4px 12px;
    border-radius: 20px;
    border: 2px solid #fff;
    text-shadow: 1px 1px 2px #000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
}

/* SELECT GAME LIST */
.select-header {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    margin-bottom: 30px;
}

.select-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.select-row {
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: transform 0.1s;
}

.select-row:active {
    transform: scale(0.98);
}

.select-row.disabled {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(1);
}

.row-icon {
    width: 80px;
    height: 80px;
    background: #0050b3;
    border: 3px solid #ffcc00;
    border-radius: 15px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 45px;
}

.icon-classic {
    color: #fff;
}

.icon-team {
    color: #fff;
}

.icon-quick {
    color: #ffcc00;
}

.row-pill {
    flex: 1;
    background: linear-gradient(180deg, #0066cc 0%, #004499 100%);
    border: 4px solid #ffcc00;
    border-radius: 40px;
    height: 65px;
    display: flex;
    align-items: center;
    padding: 0 15px;
    color: white;
    font-weight: 900;
    font-size: 22px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5), 0 0 10px rgba(255, 204, 0, 0.3);
    text-shadow: 1px 1px 2px #000;
}

.row-pill .check-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #002244;
    border: 3px solid #ffcc00;
    margin-right: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: transparent;
    font-size: 20px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.8);
}

.select-row.active .check-circle {
    background: #ffcc00;
    color: #000;
}

/* LK PILL BUTTONS (Next, Play, Back) */
.lk-pill-btn {
    background: linear-gradient(180deg, #0088ff 0%, #0055cc 100%);
    border: 3px solid #ffcc00;
    border-radius: 30px;
    color: white;
    font-size: 22px;
    font-weight: 900;
    padding: 10px 40px;
    cursor: pointer;
    box-shadow: inset 0 2px 10px rgba(255, 255, 255, 0.4), 0 5px 15px rgba(0, 0, 0, 0.5), 0 0 15px rgba(255, 204, 0, 0.3);
    text-shadow: 1px 1px 2px #000;
    transition: transform 0.1s;
    text-transform: uppercase;
}

.lk-pill-btn:active {
    transform: scale(0.95);
}

.lk-pill-btn.secondary {
    background: linear-gradient(180deg, #444 0%, #222 100%);
    border-color: #888;
    box-shadow: inset 0 2px 5px rgba(255, 255, 255, 0.2), 0 5px 10px rgba(0, 0, 0, 0.5);
    text-shadow: none;
}

.lk-pill-btn.huge {
    font-size: 28px;
    padding: 15px 60px;
    border-radius: 40px;
    width: 100%;
}

/* Color & Name Selection Grid */
.color-slots {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.color-slot {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 5px;
}

.color-slot.inactive {
    opacity: 0.5;
}

.color-check {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 4px solid #4caf50;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    color: transparent;
    background: rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.color-slot.active .color-check {
    background: #4caf50;
    color: white;
}

.color-slot.inactive .color-check {
    border-color: #4caf50;
    background: transparent;
}

.color-pin {
    width: 30px;
    height: 40px;
    display: flex;
    justify-content: center;
    font-size: 32px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.player-input-box {
    flex: 1;
    background: white;
    border: 2px dashed #ff0000;
    border-radius: 5px;
    padding: 10px 10px;
    color: #333;
    font-weight: bold;
    font-size: 16px;
    outline: none;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

.color-slot.inactive .player-input-box {
    background: #aaa;
    border-color: #555;
    color: #444;
}

/* Custom dashed border colors for inputs */
.slot-red .player-input-box {
    border-color: #d32f2f;
}

.slot-blue .player-input-box {
    border-color: #1976d2;
}

.slot-green .player-input-box {
    border-color: #388e3c;
}

.slot-yellow .player-input-box {
    border-color: #fbc02d;
}

.role-badge {
    background: #2196f3;
    color: white;
    padding: 5px 10px;
    border-radius: 10px;
    font-weight: 900;
    font-size: 12px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

/* Player Count Selector */
.player-count-selector {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.p-btn {
    width: 60px;
    height: 40px;
    background: #004499;
    border: 2px solid #ffcc00;
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
    cursor: pointer;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
}

.p-btn.active {
    background: #ffcc00;
    color: #000;
    box-shadow: inset 0 0 5px rgba(255, 255, 255, 0.3), 0 0 10px rgba(255, 204, 0, 0.6);
}

.p-btn.disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* --- Top Bar --- */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10;
}

.back-btn {
    color: #fff;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.game-status {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 1px;
}

.controls-row {
    display: flex;
    gap: 15px;
    align-items: center;
}

.icon-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s, transform 0.2s;
}

.icon-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* --- Main Layout --- */
.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
    position: relative;
    /* Move board slightly up to give room for players panel */
    margin-bottom: 20px;
}

/* --- The Ludo Board --- */
.ludo-board {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    grid-template-rows: repeat(15, 1fr);
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1;
    background: #fff;
    border: 12px solid #5d4037;
    /* Wooden feel border */
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4), inset 0 0 10px rgba(0, 0, 0, 0.5);
    position: relative;
    padding: 2px;
    gap: 1px;
    background-color: #5d4037;
}

.cell {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    /* Allows multiple tokens to sit inside */
}

/* Bases (4 corners, spans 6x6) */
.base {
    position: relative;
    border: 2px solid #333;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.base-inner {
    width: 75%;
    height: 75%;
    background: #fff;
    border-radius: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 15%;
    padding: 15%;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

.base.red {
    grid-column: 1 / 7;
    grid-row: 1 / 7;
    background: #ff5252;
    border: 4px solid #b71c1c;
}

.base.green {
    grid-column: 10 / 16;
    grid-row: 1 / 7;
    background: #4caf50;
    border: 4px solid #1b5e20;
}

.base.blue {
    grid-column: 1 / 7;
    grid-row: 10 / 16;
    background: #2196f3;
    border: 4px solid #1976d2;
}

.base.yellow {
    grid-column: 10 / 16;
    grid-row: 10 / 16;
    background: #ffeb3b;
    border: 4px solid #fbc02d;
}

.token-slot {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
}

.home-center {
    grid-column: 7 / 10;
    grid-row: 7 / 10;
    background: #333;
    clip-path: polygon(50% 50%, 0 0, 100% 0, 100% 100%, 0 100%, 0 0);
    position: relative;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 2px;
}

.home-center::after {
    content: '';
    position: absolute;
    inset: 0;
    background: conic-gradient(var(--yellow) 0deg 90deg,
            var(--blue) 90deg 180deg,
            var(--red) 180deg 270deg,
            var(--green) 270deg 360deg);
    transform: rotate(45deg);
    z-index: 1;
}

.home-center {
    z-index: 5;
    /* Establish stacking context */
}

.home-center .token {
    z-index: 10;
    /* Important so tokens are on top of center gradients! */
}

/* Path coloring */
.path-red {
    background: var(--red);
}

.path-green {
    background: var(--green);
}

.path-yellow {
    background: var(--yellow);
}

.path-blue {
    background: var(--blue);
}

/* Safe zones (Star markers) */
.safe-zone::before {
    content: '★';
    font-size: 20px;
    color: rgba(0, 0, 0, 0.3);
    position: absolute;
    z-index: 1;
}

/* Arrows */
.path-arrow {
    position: absolute;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.8);
    z-index: 1;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.cell.path-red {
    background-color: var(--red);
}

.cell.path-green {
    background-color: var(--green);
}

.cell.path-yellow {
    background-color: var(--yellow);
}

.cell.path-blue {
    background-color: var(--blue);
}

.cell.safe-zone {
    background-color: #cfd8dc !important;
}


/* --- Tokens --- */
.token {
    width: 65%;
    height: 65%;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    /* Pawn-like oval shape */
    position: relative;
    /* Must be relative to allow flex tiling! */
    box-shadow:
        inset -3px -6px 8px rgba(0, 0, 0, 0.4),
        /* Inner deep shadow */
        inset 3px 3px 6px rgba(255, 255, 255, 0.6),
        /* Inner top highlight */
        0 4px 6px rgba(0, 0, 0, 0.6);
    /* Drop shadow */
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* Snappy bouncy hop */
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.token::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 15%;
    width: 70%;
    height: 30%;
    background: radial-gradient(ellipse at top, rgba(255, 255, 255, 0.8), transparent);
    border-radius: 50%;
    pointer-events: none;
}

/* Hopping state for token jump animation */
.token.hopping {
    transform: scale(1.3) translateY(-10px);
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.6);
    z-index: 50 !important;
}

.token.stacked {
    width: 35%;
    height: 35%;
    margin: 1px;
}

.token.killing {
    animation: killSpin 0.5s ease-in-out forwards;
    z-index: 99 !important;
}

@keyframes killSpin {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }

    50% {
        transform: scale(1.5) rotate(360deg);
        opacity: 1;
    }

    100% {
        transform: scale(0) rotate(720deg);
        opacity: 0;
    }
}

.cell.capture-vibe {
    animation: flashRed 0.3s 2;
}

@keyframes flashRed {

    0%,
    100% {
        background: inherit;
    }

    50% {
        background: rgba(255, 0, 0, 0.5);
    }
}


.token.red {
    background: radial-gradient(circle at 40% 40%, #ff4d4d, #cc0000, #660000);
    border-bottom: 4px solid #800000;
}

.token.green {
    background: radial-gradient(circle at 40% 40%, #4dff4d, #00cc00, #006600);
    border-bottom: 4px solid #004d00;
}

.token.yellow {
    background: radial-gradient(circle at 40% 40%, #ffff4d, #cccc00, #808000);
    border-bottom: 4px solid #666600;
}

.token.blue {
    background: radial-gradient(circle at 40% 40%, #4d4dff, #0000cc, #000066);
    border-bottom: 4px solid #00004d;
}

.token.highlight {
    animation: bounce-token 0.6s infinite alternate cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 50;
    cursor: pointer;
}

@keyframes bounce-token {
    0% {
        transform: scale(1) translateY(0);
        box-shadow: 0 0 5px 2px rgba(255, 255, 255, 0.8);
    }

    100% {
        transform: scale(1.15) translateY(-15px);
        box-shadow: 0 15px 15px rgba(0, 0, 0, 0.4), 0 0 20px 8px rgba(255, 255, 255, 1);
    }
}

/* --- Game Area --- */
.game-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    position: relative;
    width: 100%;
    height: 100%;
    margin: 0 auto;
    overflow: hidden;
}

/* Corner Dice positioning */
.corner-dice {
    position: absolute;
    width: 100px;
    z-index: 10;
    pointer-events: none;
}

/* Specific Positions */
.corner-dice.red {
    top: 5%;
    left: 5%;
}

.corner-dice.green {
    top: 5%;
    right: 5%;
}

.corner-dice.blue {
    bottom: 5%;
    left: 5%;
}

.corner-dice.yellow {
    bottom: 5%;
    right: 5%;
}

.player-card {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s;
    width: 100%;
    pointer-events: auto;
}

.player-card.active {
    transform: scale(1.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    background: rgba(255, 255, 255, 0.2);
    z-index: 20;
}

.player-card.active.red {
    border-color: #ff5252;
}

.player-card.active.green {
    border-color: #4caf50;
}

.player-card.active.blue {
    border-color: #2196f3;
}

.player-card.active.yellow {
    border-color: #ffeb3b;
}

.player-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 5px;
}

.player-name {
    font-size: 14px;
    font-weight: 700;
}

.player-badge {
    font-size: 8px;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 8px;
    margin-top: 2px;
    font-weight: 600;
}

.player-level {
    font-size: 10px;
    color: #999;
    margin-bottom: 5px;
}

.dice-container {
    width: 50px;
    height: 50px;
    background: #fff;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    perspective: 500px;
    transform-style: preserve-3d;
}

.dice-face {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: 8px;
    gap: 2px;
}

/* Hide or Disable Dice if not current turn in JS */
.dice-container.disabled {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(1);
}

.dice-container.rolling {
    animation: diceShake 0.4s infinite alternate;
}

.dice-container.rolling .dice-face {
    animation: tumble3D 0.5s ease-out forwards;
}

@keyframes diceShake {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    25% {
        transform: translate(-3px, 3px) rotate(-5deg);
    }

    50% {
        transform: translate(3px, -3px) rotate(5deg);
    }

    75% {
        transform: translate(-3px, -3px) rotate(-5deg);
    }

    100% {
        transform: translate(3px, 3px) rotate(5deg);
    }
}

@keyframes tumble3D {
    0% {
        transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scale(0.8);
        opacity: 0.5;
    }

    25% {
        transform: rotateX(180deg) rotateY(90deg) rotateZ(45deg) scale(1.1);
        opacity: 1;
    }

    50% {
        transform: rotateX(360deg) rotateY(180deg) rotateZ(90deg) scale(1.2);
    }

    75% {
        transform: rotateX(540deg) rotateY(270deg) rotateZ(135deg) scale(1.1);
    }

    100% {
        transform: rotateX(720deg) rotateY(360deg) rotateZ(180deg) scale(1);
    }
}

.dot {
    background: #333;
    border-radius: 50%;
    width: 100%;
    height: 100%;
}

/* Dice dot placements via CSS Classes */
.dice-1 .dot:nth-child(1) {
    grid-column: 2;
    grid-row: 2;
}

.dice-2 .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 3;
}

.dice-2 .dot:nth-child(2) {
    grid-column: 3;
    grid-row: 1;
}

.dice-3 .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 3;
}

.dice-3 .dot:nth-child(2) {
    grid-column: 2;
    grid-row: 2;
}

.dice-3 .dot:nth-child(3) {
    grid-column: 3;
    grid-row: 1;
}

.dice-4 .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}

.dice-4 .dot:nth-child(2) {
    grid-column: 3;
    grid-row: 1;
}

.dice-4 .dot:nth-child(3) {
    grid-column: 1;
    grid-row: 3;
}

.dice-4 .dot:nth-child(4) {
    grid-column: 3;
    grid-row: 3;
}

.dice-5 .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}

.dice-5 .dot:nth-child(2) {
    grid-column: 3;
    grid-row: 1;
}

.dice-5 .dot:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
}

.dice-5 .dot:nth-child(4) {
    grid-column: 1;
    grid-row: 3;
}

.dice-5 .dot:nth-child(5) {
    grid-column: 3;
    grid-row: 3;
}

.dice-6 .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}

.dice-6 .dot:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
}

.dice-6 .dot:nth-child(3) {
    grid-column: 1;
    grid-row: 3;
}

.dice-6 .dot:nth-child(4) {
    grid-column: 3;
    grid-row: 1;
}

.dice-6 .dot:nth-child(5) {
    grid-column: 3;
    grid-row: 2;
}

.dice-6 .dot:nth-child(6) {
    grid-column: 3;
    grid-row: 3;
}

/* EMOJI SYSTEM */
.emoji-picker {
    position: fixed;
    bottom: 120px;
    right: 20px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    z-index: 2000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.emoji-btn {
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 12px;
    transition: background 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.emoji-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.emoji-bubble {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 24px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 100;
    pointer-events: none;
    animation: emojiPop 2s forwards;
}

@keyframes emojiPop {
    0% {
        transform: translate(-50%, 0) scale(0.5);
        opacity: 0;
    }

    20% {
        transform: translate(-50%, -20px) scale(1.2);
        opacity: 1;
    }

    80% {
        transform: translate(-50%, -40px) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -60px) scale(0.8);
        opacity: 0;
    }
}

/* THEMES */
body.theme-classic {
    background: #222;
    --red: #d32f2f;
    --green: #2e7d32;
    --yellow: #fbc02d;
    --blue: #1976d2;
}

body.theme-nature {
    background: #1b3022;
    --red: #a44a3f;
    --green: #4f772d;
    --yellow: #f19c79;
    --blue: #31572c;
}

body.theme-classic .ludo-board,
body.theme-nature .ludo-board {
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

body.theme-classic .cell.safe {
    background: #eee !important;
    color: #999;
}

body.theme-classic .cell.safe::after {
    opacity: 0.3;
}

.rolling {
    animation: diceRoll3D 0.6s ease-in-out;
}

@keyframes diceRoll3D {
    0% {
        transform: rotateX(0deg) rotateY(0deg) translateZ(0);
    }

    25% {
        transform: rotateX(180deg) rotateY(90deg) translateZ(50px);
    }

    50% {
        transform: rotateX(360deg) rotateY(180deg) translateZ(20px);
    }

    75% {
        transform: rotateX(540deg) rotateY(270deg) translateZ(50px);
    }

    100% {
        transform: rotateX(720deg) rotateY(360deg) translateZ(0);
    }
}

/* Message Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 500;
    transition: transform 0.3s;
    z-index: 2000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 650px) {

    /* Menu Scaling */
    .menu-container {
        width: 95%;
        padding: 20px 15px;
        box-sizing: border-box;
    }

    .menu-title {
        font-size: 32px;
    }

    .dashboard-grid {
        flex-wrap: wrap;
        gap: 10px;
    }

    .btn-dashboard {
        width: 100px;
        height: 85px;
    }

    .btn-dashboard .btn-icon {
        font-size: 35px;
    }

    .btn-dashboard .btn-label {
        font-size: 11px;
        bottom: -10px;
    }

    /* Top Bar Scaling */
    .top-bar {
        padding: 10px;
        gap: 5px;
    }

    .back-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .game-status {
        font-size: 14px;
        text-align: center;
    }

    .controls-row {
        gap: 8px;
    }

    .icon-btn {
        font-size: 20px;
    }

    /* Board and Grid Layout Constraints */
    .game-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto auto;
        gap: 10px;
        padding: 10px 5px;
        width: 100vw;
        max-width: 100vw;
        box-sizing: border-box;
        justify-content: center;
    }

    #board,
    .ludo-board {
        grid-column: 1 / 3;
        grid-row: 2;
        width: 95vw;
        max-width: 95vw;
        border-width: 5px;
        margin: 0 auto;
    }

    /* Player Cards Positioning */
    .corner-dice {
        position: relative !important;
        width: 100% !important;
        max-width: 140px;
        margin: 0 auto;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
    }

    .corner-dice.red {
        grid-column: 1;
        grid-row: 1;
    }

    .corner-dice.green {
        grid-column: 2;
        grid-row: 1;
    }

    .corner-dice.blue {
        grid-column: 1;
        grid-row: 3;
    }

    .corner-dice.yellow {
        grid-column: 2;
        grid-row: 3;
    }

    .player-card {
        padding: 4px;
        width: 100%;
        box-sizing: border-box;
    }

    .player-name {
        font-size: 11px;
    }

    .dice-container {
        width: 45px;
        height: 45px;
        margin-top: 5px;
    }
}