/* ============================================================
   LUDO GAME - Complete Stylesheet
   Premium, modern design with gradients and animations
   ============================================================ */

/* ---- CSS Variables ---- */
:root {
    --red: #E53935;
    --red-light: #EF9A9A;
    --red-dark: #B71C1C;
    --green: #43A047;
    --green-light: #A5D6A7;
    --green-dark: #1B5E20;
    --yellow: #F9A825;
    --yellow-light: #FFF59D;
    --yellow-dark: #F57F17;
    --blue: #1E88E5;
    --blue-light: #90CAF9;
    --blue-dark: #0D47A1;
    --board-bg: #FFFDE7;
    --board-border: #5D4037;
    --cell-border: #BDBDBD;
    --bg-dark: #0f0f1a;
    --bg-gradient: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%);
    --card-bg: rgba(255,255,255,0.06);
    --card-border: rgba(255,255,255,0.1);
    --text-primary: #ffffff;
    --text-secondary: rgba(255,255,255,0.6);
    --cell-size: 40px;
    --board-size: 600px;
    --pawn-size: 26px;
    --transition-speed: 0.2s;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: 'Outfit', sans-serif; cursor: pointer; border: none; outline: none; }

/* ============================================================
   MENU SCREEN
   ============================================================ */
#menu-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
}
.menu-container {
    text-align: center;
    max-width: 420px;
    width: 100%;
    animation: fadeInUp 0.6s ease;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}
.game-title {
    font-size: 5rem;
    font-weight: 900;
    letter-spacing: 12px;
    background: linear-gradient(135deg, var(--red), var(--yellow), var(--green), var(--blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 4px 15px rgba(255,255,255,0.15));
    margin-bottom: 4px;
}
.game-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    letter-spacing: 6px;
    text-transform: uppercase;
    margin-bottom: 48px;
}
.section-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--text-secondary);
    margin-bottom: 14px;
    margin-top: 28px;
}
.section-label:first-child { margin-top: 0; }
.mode-buttons { display: flex; flex-direction: column; gap: 10px; }
.mode-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 24px;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    transition: all 0.25s ease;
    backdrop-filter: blur(10px);
}
.mode-btn:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.25);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}
.mode-btn:active { transform: translateY(0); }
.btn-icon { font-size: 1.3rem; }

/* ============================================================
   GAME SCREEN LAYOUT
   ============================================================ */
#game-screen {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 12px;
}
#game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    margin-bottom: 12px;
}
#back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    transition: all 0.2s;
}
#back-btn:hover { color: #fff; background: rgba(255,255,255,0.12); }
#turn-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 24px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}
#turn-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--red);
    box-shadow: 0 0 10px var(--red);
    transition: all 0.3s ease;
}
#header-spacer { width: 100px; }

#game-area {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 24px;
    flex: 1;
}

/* ---- Board ---- */
#board-wrapper {
    flex-shrink: 0;
    padding: 12px;
    background: linear-gradient(145deg, #4E342E, #3E2723);
    border-radius: 16px;
    box-shadow:
        0 20px 60px rgba(0,0,0,0.5),
        inset 0 1px 0 rgba(255,255,255,0.1),
        0 0 0 1px rgba(255,255,255,0.05);
}
#board {
    position: relative;
    width: var(--board-size);
    height: var(--board-size);
    display: grid;
    grid-template-columns: repeat(15, var(--cell-size));
    grid-template-rows: repeat(15, var(--cell-size));
    background: var(--board-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.1);
}

/* ---- Grid Cells ---- */
.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
}
.cell-path {
    background: #FFFFFF;
    border: 0.5px solid var(--cell-border);
}
.cell-base-red { background: var(--red); }
.cell-base-green { background: var(--green); }
.cell-base-yellow { background: var(--yellow); }
.cell-base-blue { background: var(--blue); }
.cell-home-red { background: var(--red-light); border: 0.5px solid rgba(229,57,53,0.3); }
.cell-home-green { background: var(--green-light); border: 0.5px solid rgba(67,160,71,0.3); }
.cell-home-yellow { background: var(--yellow-light); border: 0.5px solid rgba(249,168,37,0.3); }
.cell-home-blue { background: var(--blue-light); border: 0.5px solid rgba(30,136,229,0.3); }
.cell-start-red { background: var(--red-light) !important; }
.cell-start-green { background: var(--green-light) !important; }
.cell-start-yellow { background: var(--yellow-light) !important; }
.cell-start-blue { background: var(--blue-light) !important; }
.cell-center { background: transparent; }
.cell-safe::after {
    content: '★';
    position: absolute;
    font-size: 16px;
    color: rgba(0,0,0,0.15);
    pointer-events: none;
}
.cell-arrow {
    font-size: 14px;
    font-weight: 800;
    color: rgba(0,0,0,0.25);
    pointer-events: none;
}

/* ---- Center Home Triangles ---- */
#center-home {
    position: absolute;
    width: calc(var(--cell-size) * 3);
    height: calc(var(--cell-size) * 3);
    left: calc(var(--cell-size) * 6);
    top: calc(var(--cell-size) * 6);
    z-index: 2;
    pointer-events: none;
}
.home-triangle {
    position: absolute;
    width: 100%;
    height: 100%;
}
.home-triangle.tri-green {
    background: var(--green);
    clip-path: polygon(0 0, 50% 50%, 100% 0);
}
.home-triangle.tri-yellow {
    background: var(--yellow);
    clip-path: polygon(100% 0, 50% 50%, 100% 100%);
}
.home-triangle.tri-blue {
    background: var(--blue);
    clip-path: polygon(0 100%, 50% 50%, 100% 100%);
}
.home-triangle.tri-red {
    background: var(--red);
    clip-path: polygon(0 0, 50% 50%, 0 100%);
}
.home-center-dot {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 8px rgba(0,0,0,0.2);
    z-index: 3;
}

/* ---- Base Inner White Boxes ---- */
.base-box {
    position: absolute;
    width: calc(var(--cell-size) * 4 - 8px);
    height: calc(var(--cell-size) * 4 - 8px);
    background: white;
    border-radius: 10px;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 8px;
    padding: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.base-box.base-red { left: calc(var(--cell-size) + 4px); top: calc(var(--cell-size) + 4px); }
.base-box.base-green { left: calc(var(--cell-size) * 10 + 4px); top: calc(var(--cell-size) + 4px); }
.base-box.base-yellow { left: calc(var(--cell-size) * 10 + 4px); top: calc(var(--cell-size) * 10 + 4px); }
.base-box.base-blue { left: calc(var(--cell-size) + 4px); top: calc(var(--cell-size) * 10 + 4px); }
.base-slot {
    border-radius: 50%;
    border: 3px solid rgba(0,0,0,0.08);
    background: rgba(0,0,0,0.03);
}

/* ---- Pawns ---- */
.pawn {
    position: absolute;
    width: var(--pawn-size);
    height: var(--pawn-size);
    border-radius: 50%;
    z-index: 10;
    cursor: default;
    transition: left var(--transition-speed) ease, top var(--transition-speed) ease;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 800;
    color: rgba(255,255,255,0.9);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.pawn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.4);
    border-bottom-color: rgba(0,0,0,0.2);
}
.pawn::after {
    content: '';
    position: absolute;
    width: 60%;
    height: 30%;
    top: 15%;
    left: 20%;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
}
.pawn-red {
    background: radial-gradient(circle at 35% 35%, #EF5350, var(--red-dark));
    box-shadow: 0 3px 8px rgba(183,28,28,0.5), 0 1px 3px rgba(0,0,0,0.3);
}
.pawn-green {
    background: radial-gradient(circle at 35% 35%, #66BB6A, var(--green-dark));
    box-shadow: 0 3px 8px rgba(27,94,32,0.5), 0 1px 3px rgba(0,0,0,0.3);
}
.pawn-yellow {
    background: radial-gradient(circle at 35% 35%, #FFEE58, var(--yellow-dark));
    box-shadow: 0 3px 8px rgba(245,127,23,0.5), 0 1px 3px rgba(0,0,0,0.3);
    color: rgba(0,0,0,0.6);
    text-shadow: none;
}
.pawn-blue {
    background: radial-gradient(circle at 35% 35%, #42A5F5, var(--blue-dark));
    box-shadow: 0 3px 8px rgba(13,71,161,0.5), 0 1px 3px rgba(0,0,0,0.3);
}
.pawn.movable {
    cursor: pointer;
    pointer-events: auto;
    animation: pawnGlow 0.8s ease-in-out infinite alternate;
}
@keyframes pawnGlow {
    0% { transform: scale(1); filter: brightness(1); }
    100% { transform: scale(1.2); filter: brightness(1.3); }
}
.pawn.movable::before {
    border-color: rgba(255,255,255,0.8);
}

/* ---- Side Panel ---- */
#side-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 220px;
    min-width: 220px;
}
#player-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.player-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    transition: all 0.3s ease;
}
.player-card.active {
    border-color: rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.1);
    box-shadow: 0 0 15px rgba(255,255,255,0.05);
}
.player-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
.player-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    flex: 1;
}
.player-card-home {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

/* ---- Dice ---- */
#dice-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 20px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    backdrop-filter: blur(10px);
}
#dice-container {
    perspective: 400px;
}
#dice {
    width: 72px;
    height: 72px;
    background: linear-gradient(145deg, #ffffff, #e8e8e8);
    border-radius: 14px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: 10px;
    box-shadow:
        0 6px 20px rgba(0,0,0,0.3),
        inset 0 1px 0 rgba(255,255,255,0.8),
        0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.1s;
    gap: 2px;
}
#dice.rolling {
    animation: diceShake 0.1s ease infinite;
}
@keyframes diceShake {
    0% { transform: rotateX(0deg) rotateZ(0deg); }
    25% { transform: rotateX(10deg) rotateZ(5deg); }
    50% { transform: rotateX(-5deg) rotateZ(-5deg); }
    75% { transform: rotateX(8deg) rotateZ(3deg); }
    100% { transform: rotateX(0deg) rotateZ(0deg); }
}
.dice-dot {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: transparent;
}
.dice-dot.active {
    background: radial-gradient(circle, #333, #111);
    box-shadow: inset 0 2px 3px rgba(0,0,0,0.4);
}
#roll-btn {
    width: 100%;
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 12px;
    transition: all 0.25s ease;
    box-shadow: 0 4px 15px rgba(118,75,162,0.4);
}
#roll-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(118,75,162,0.5);
}
#roll-btn:active:not(:disabled) { transform: translateY(0); }
#roll-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ---- Game Log ---- */
#game-log {
    flex: 1;
    max-height: 200px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px;
    overflow: hidden;
}
#game-log h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
#log-entries {
    max-height: 150px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
#log-entries::-webkit-scrollbar { width: 4px; }
#log-entries::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
.log-entry {
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(255,255,255,0.03);
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---- Winner Modal ---- */
#winner-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
}
.modal-content {
    position: relative;
    text-align: center;
    padding: 48px;
    background: linear-gradient(145deg, rgba(30,30,50,0.95), rgba(15,15,25,0.98));
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 24px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.6);
    animation: modalPop 0.4s ease;
}
@keyframes modalPop {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}
#winner-text { font-size: 2rem; font-weight: 800; margin-bottom: 8px; }
#winner-sub { color: var(--text-secondary); margin-bottom: 28px; font-size: 1rem; }
#play-again-btn {
    padding: 14px 36px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 14px;
    transition: all 0.25s;
    box-shadow: 0 4px 15px rgba(118,75,162,0.4);
}
#play-again-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(118,75,162,0.5); }

/* ---- Responsive ---- */
@media (max-width: 900px) {
    #game-area { flex-direction: column; align-items: center; }
    #side-panel { width: 100%; max-width: var(--board-size); flex-direction: row; flex-wrap: wrap; }
    #player-info { flex-direction: row; flex-wrap: wrap; flex: 1; }
    #dice-area { flex: 0; flex-direction: row; }
    #game-log { display: none; }
}
@media (max-width: 640px) {
    :root {
        --cell-size: 24px;
        --board-size: 360px;
        --pawn-size: 18px;
    }
    .game-title { font-size: 3.5rem; }
    #board-wrapper { padding: 8px; }
    .base-box { padding: 8px; gap: 4px; border-radius: 6px; }
    .cell-safe::after { font-size: 10px; }
    #dice { width: 56px; height: 56px; padding: 8px; border-radius: 10px; }
}
