/* ludo.css */

.custom-scrollbar::-webkit-scrollbar { width: 6px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 4px; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.5); }

/* Ludo Board Grid */
#ludo-board {
    display: grid;
    grid-template-columns: repeat(15, minmax(0, 1fr));
    grid-template-rows: repeat(15, minmax(0, 1fr));
    gap: 0px;
    background-color: transparent;
}

.ludo-cell {
    border: 1px solid #334155; /* border-slate-700 */
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.ludo-cell.safe-zone {
    background-color: rgba(255, 255, 255, 0.05);
}

.ludo-cell.safe-zone::after {
    content: '⭐';
    font-size: 10px;
    opacity: 0.3;
}

/* Home Bases */
.ludo-base {
    border-radius: 8px;
    z-index: 10;
}

.base-red { border-color: #ef4444; background-color: rgba(239, 68, 68, 0.15); }
.base-green { border-color: #22c55e; background-color: rgba(34, 197, 94, 0.15); }
.base-yellow { border-color: #eab308; background-color: rgba(234, 179, 8, 0.15); }
.base-blue { border-color: #3b82f6; background-color: rgba(59, 130, 246, 0.15); }

.base-spot {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    width: 80%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    align-self: center;
    justify-self: center;
    z-index: 12;
}

/* Home Paths */
.path-red { background-color: rgba(239, 68, 68, 0.2) !important; }
.path-green { background-color: rgba(34, 197, 94, 0.2) !important; }
.path-yellow { background-color: rgba(234, 179, 8, 0.2) !important; }
.path-blue { background-color: rgba(59, 130, 246, 0.2) !important; }

/* Center Goal */
.ludo-center {
    grid-column: 7 / 10;
    grid-row: 7 / 10;
    background: conic-gradient(
        from 315deg,
        #16a34a 0deg 90deg,
        #ca8a04 90deg 180deg,
        #2563eb 180deg 270deg,
        #dc2626 270deg 360deg
    );
    border: 1px solid #334155;
    position: relative;
}

/* Pieces */
.ludo-piece {
    position: relative;
    width: 80%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    z-index: 20;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3), inset -2px -2px 4px rgba(0,0,0,0.2);
    /* transform не транзиційимо — рухом керує FLIP-анімація з JS */
    transition: filter 0.3s, opacity 0.3s, box-shadow 0.3s;
    border: 2px solid white;
    align-self: center;
    justify-self: center;
}

.ludo-piece.valid-move {
    cursor: pointer;
    animation: pulseMove 1.5s infinite;
}

/* Виграна фішка — у фінішному центрі */
.ludo-piece.won {
    width: 48%;
    border-width: 1.5px;
    animation: wonGlow 2.2s ease-in-out infinite;
}
@keyframes wonGlow {
    0%, 100% { box-shadow: 0 0 5px rgba(250, 204, 21, 0.55), 0 0 10px rgba(250, 204, 21, 0.25); }
    50%      { box-shadow: 0 0 12px rgba(250, 204, 21, 0.95), 0 0 22px rgba(250, 204, 21, 0.5); }
}

/* Заморожена фішка — крижана накладка + glow */
.ludo-piece.frozen {
    box-shadow: 0 0 16px rgba(56, 189, 248, 1),
                inset 0 0 14px rgba(224, 242, 254, 0.85);
    border-color: #e0f2fe;
}
/* Світло-блакитна "крижана корка" поверх фішки */
.ludo-piece.frozen::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background:
        linear-gradient(135deg, rgba(224, 242, 254, 0.7) 0%, rgba(56, 189, 248, 0.35) 60%, rgba(14, 165, 233, 0.5) 100%),
        radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.7) 0%, transparent 35%);
    pointer-events: none;
    z-index: 22;
}
/* Бейдж зі сніжинкою — у куті фішки */
.frozen-indicator {
    position: absolute;
    top: -7px;
    right: -7px;
    width: 20px;
    height: 20px;
    background: rgba(15, 23, 42, 0.94);
    border: 1.5px solid #38bdf8;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    z-index: 31;
    pointer-events: none;
    box-shadow: 0 0 10px #38bdf8;
    animation: iceWiggle 1.6s ease-in-out infinite;
}
@keyframes iceWiggle {
    0%, 100% { transform: rotate(-12deg) scale(1); }
    50%      { transform: rotate(12deg) scale(1.18); }
}

/* Flash-анімація в момент заморозки */
.ludo-piece.just-frozen {
    animation: freezeBurst 0.7s ease-out;
}
@keyframes freezeBurst {
    0%   { box-shadow: 0 0 0 0 rgba(186, 230, 253, 0); }
    35%  { box-shadow: 0 0 30px 14px rgba(224, 242, 254, 1); }
    70%  { box-shadow: 0 0 22px 8px rgba(125, 211, 252, 0.85); }
    100% { box-shadow: 0 0 16px rgba(56, 189, 248, 1), inset 0 0 14px rgba(224, 242, 254, 0.85); }
}

/* Стек: декілька фішок в одній клітинці — менші, по кутах */
.ludo-piece.stacked {
    width: 52%;
    border-width: 1.5px;
}

@keyframes pulseMove {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,255,255,0.7); }
    70% { transform: scale(1.15); box-shadow: 0 0 0 10px rgba(255,255,255,0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}

.piece-red { background: radial-gradient(circle at 30% 30%, #f87171, #dc2626); }
.piece-green { background: radial-gradient(circle at 30% 30%, #4ade80, #16a34a); }
.piece-yellow { background: radial-gradient(circle at 30% 30%, #facc15, #ca8a04); }
.piece-blue { background: radial-gradient(circle at 30% 30%, #60a5fa, #2563eb); }

/* Shield Indicator */
.shield-indicator {
    position: absolute;
    width: 130%;
    height: 130%;
    border-radius: 50%;
    border: 2px solid #38bdf8;
    box-shadow: 0 0 10px #38bdf8;
    animation: spinShield 3s linear infinite;
    pointer-events: none;
}

@keyframes spinShield {
    0% { transform: rotate(0deg) scale(1); opacity: 0.8; }
    50% { transform: rotate(180deg) scale(1.1); opacity: 0.5; }
    100% { transform: rotate(360deg) scale(1); opacity: 0.8; }
}

/* Items */
.ludo-item {
    font-size: 1.2rem;
    align-self: center;
    justify-self: center;
    z-index: 15;
    animation: bounceItem 2s infinite ease-in-out;
}

@keyframes bounceItem {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Dice Roll Animation */
.dice-rolling {
    animation: shakeDice 0.5s;
}

@keyframes shakeDice {
    0% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-20deg) scale(1.1); }
    50% { transform: rotate(20deg) scale(1.2); }
    75% { transform: rotate(-10deg) scale(1.1); }
    100% { transform: rotate(0deg) scale(1); }
}
