:root {
    /* Color Palette */
    --bg-color: #0f172a;
    --primary-bg: #0f172a;
    --secondary-bg: #1e293b;
    --canvas-bg: #1a1f35;
    --text-color: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-secondary: #cbd5e1;
    --accent-color: #3b82f6;
    
    /* Glass Effect (From Sudoku) */
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-blur: 20px;
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 25px rgba(0, 255, 255, 0.5);
    --radius-lg: 16px;
    --radius-md: 12px;
    --spacing-lg: 2rem;
    --spacing-md: 1.5rem;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Player Colors */
    --color-red: #ef4444;
    --color-blue: #3b82f6;
    --color-green: #22c55e;
    --color-yellow: #eab308;
    
    /* Layout */
    --max-width: 1400px;
    --border-radius: 16px;
    --spacing: 1rem;
}

/* Game Screen Layout */
.game-layout {
    max-width: var(--max-width);
    margin: 0 auto;
}

.game-main {
    display: flex;
    justify-content: center;
    gap: 2rem;
    align-items: start;
    flex-wrap: wrap;
}

.game-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    width: 100%;
}

/* Players Panel (Horizontal) */
.players-panel {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    width: 100%;
    justify-content: center;
    flex-wrap: nowrap;
    align-items: center;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.game-controls {
    display: flex;
    gap: 0.5rem;
    margin-right: 0.5rem;
    flex-shrink: 0;
}



/* Game Mode Section */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.mode-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
}

.mode-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left var(--transition-slow);
}

.mode-card:hover::before {
    left: 100%;
}

.mode-card:hover {
    transform: translateY(-5px) scale(1.02);
    border-color: var(--accent-color);
    box-shadow: var(--shadow-glow);
}

.mode-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--accent-color);
}

.mode-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.mode-desc {
    color: #e2e8f0;
    font-size: 0.9rem;
}

.mode-features {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: auto;
}

.feature-tag {
    font-size: 0.75rem;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    color: #94a3b8;
}

.mode-status {
    font-size: 0.8rem;
    margin-top: 0.5rem;
    color: #94a3b8;
}

.mode-status.online {
    color: #4ade80;
}

/* Stat Card Update */
.stat-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    justify-content: center;
    flex: 1;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-color);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

/* Rule Card */
.rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.rule-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
}

.rule-card:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.3);
}

.rule-icon {
    font-size: 1.5rem;
    color: var(--accent-color);
    margin-bottom: 0.75rem;
}

.rule-title {
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #fff;
}

.rule-text {
    font-size: 0.85rem;
    color: #cbd5e1;
    line-height: 1.4;
}

/* Player Card Overrides for Ludo */
/* Ludo uses horizontal pills, unlike the vertical cards in shared CSS */
.player-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 2px solid var(--glass-border);
    border-radius: 50px;
    padding: 0.3rem 0.8rem 0.3rem 0.3rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
    flex: 0 1 auto;
    height: auto; /* Override shared height */
}

.player-card.active {
    border-color: currentColor;
    box-shadow: 0 0 10px currentColor;
    transform: scale(1.02);
}

.player-card[data-color="red"] { color: var(--color-red); }
.player-card[data-color="blue"] { color: var(--color-blue); }
.player-card[data-color="green"] { color: var(--color-green); }
.player-card[data-color="yellow"] { color: var(--color-yellow); }

.player-color-indicator {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-bottom: 0;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.2);
    position: relative;
}

/* Online Status Dot */
.player-color-indicator::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--bg-color);
    background-color: #94a3b8;
}

.player-card.online .player-color-indicator::after {
    background-color: #22c55e;
}

.player-card.away .player-color-indicator::after {
    background-color: #f59e0b;
}

.player-color-indicator.red { background: var(--color-red); }
.player-color-indicator.blue { background: var(--color-blue); }
.player-color-indicator.green { background: var(--color-green); }
.player-color-indicator.yellow { background: var(--color-yellow); }

.player-info {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
}

.player-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}

.player-status {
    display: none;
}

/* Board Container */
.board-container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 2rem;
}

.board-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    max-width: 100%;
}

#game-board {
    max-width: 500px;
    max-height: 500px;
    width: 100%;
    height: auto;
    background: var(--canvas-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

/* Dice Section */
.dice-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1));
    backdrop-filter: blur(20px);
    border: 2px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
}

.dice-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
    opacity: 0.5;
}

/* 3D Dice Container */
.scene {
    width: 120px;
    height: 120px;
    perspective: 600px;
    cursor: pointer;
    position: relative;
}

.scene:hover .cube:not(.rolling) {
    transform: translateZ(-60px) scale(1.05);
}

.scene[disabled],
#roll-dice-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    pointer-events: none;
}

.cube {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform: translateZ(-60px);
    /* Remove transition when not rolling to allow instant face changes */
}

.cube.rolling {
    animation: rollDice 0.6s infinite linear;
}

/* Add transition only when showing a specific face */
.cube.show-1,
.cube.show-2,
.cube.show-3,
.cube.show-4,
.cube.show-5,
.cube.show-6 {
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cube__face {
    position: absolute;
    width: 120px;
    height: 120px;
    border: 3px solid rgba(0, 0, 0, 0.15);
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 20px;
    box-shadow: 
        inset 0 0 30px rgba(0, 0, 0, 0.1),
        0 5px 15px rgba(0, 0, 0, 0.3);
    display: grid;
    padding: 15px;
}

/* Pip Layouts */
.cube__face--1 {
    grid-template: 1fr / 1fr;
}

.cube__face--2 {
    grid-template: repeat(2, 1fr) / 1fr;
}

.cube__face--2 .pip:first-child {
    align-self: start;
    justify-self: end;
}

.cube__face--2 .pip:last-child {
    align-self: end;
    justify-self: start;
}

.cube__face--3 {
    grid-template: repeat(3, 1fr) / 1fr;
}

.cube__face--3 .pip:nth-child(1) {
    align-self: start;
    justify-self: end;
}

.cube__face--3 .pip:nth-child(3) {
    align-self: end;
    justify-self: start;
}

.cube__face--4 {
    grid-template: repeat(2, 1fr) / repeat(2, 1fr);
}

.cube__face--5 {
    grid-template: repeat(3, 1fr) / repeat(3, 1fr);
}

.cube__face--5 .pip:nth-child(1) {
    grid-area: 1 / 1;
}

.cube__face--5 .pip:nth-child(2) {
    grid-area: 1 / 3;
}

.cube__face--5 .pip:nth-child(3) {
    grid-area: 2 / 2;
}

.cube__face--5 .pip:nth-child(4) {
    grid-area: 3 / 1;
}

.cube__face--5 .pip:nth-child(5) {
    grid-area: 3 / 3;
}

.cube__face--6 {
    grid-template: repeat(3, 1fr) / repeat(2, 1fr);
}

.cube__face--6 .pip:nth-child(odd) {
    justify-self: start;
}

.cube__face--6 .pip:nth-child(even) {
    justify-self: end;
}

/* Pip (Dot) Style */
.pip {
    width: 18px;
    height: 18px;
    background: radial-gradient(circle, #1e293b 60%, #0f172a 100%);
    border-radius: 50%;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.2);
    align-self: center;
    justify-self: center;
}

/* Position faces */
.cube__face--1  { transform: rotateY(  0deg) translateZ(60px); }
.cube__face--2  { transform: rotateY( 90deg) translateZ(60px); }
.cube__face--3  { transform: rotateY(180deg) translateZ(60px); }
.cube__face--4  { transform: rotateY(-90deg) translateZ(60px); }
.cube__face--5  { transform: rotateX( 90deg) translateZ(60px); }
.cube__face--6  { transform: rotateX(-90deg) translateZ(60px); }

/* Show specific faces */
.cube.show-1 { transform: translateZ(-60px) rotateY(   0deg); }
.cube.show-2 { transform: translateZ(-60px) rotateY( -90deg); }
.cube.show-3 { transform: translateZ(-60px) rotateY(-180deg); }
.cube.show-4 { transform: translateZ(-60px) rotateY(  90deg); }
.cube.show-5 { transform: translateZ(-60px) rotateX( -90deg); }
.cube.show-6 { transform: translateZ(-60px) rotateX(  90deg); }

/* Rolling Animation */
@keyframes rollDice {
    0% { 
        transform: translateZ(-60px) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
    }
    25% {
        transform: translateZ(-60px) rotateX(180deg) rotateY(180deg) rotateZ(90deg) scale(1.1);
    }
    50% {
        transform: translateZ(-60px) rotateX(360deg) rotateY(360deg) rotateZ(180deg) scale(1);
    }
    75% {
        transform: translateZ(-60px) rotateX(540deg) rotateY(540deg) rotateZ(270deg) scale(1.1);
    }
    100% { 
        transform: translateZ(-60px) rotateX(720deg) rotateY(720deg) rotateZ(360deg);
    }
}

/* Turn Indicator */
.turn-indicator {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
    text-align: center;
    padding: 0.75rem 1.5rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    min-width: 200px;
}

/* Modal Color Selection (Ludo specific) */
.color-selection {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.color-option {
    cursor: pointer;
}

.color-option input[type="radio"] {
    display: none;
}

.color-box {
    display: block;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 2px solid transparent;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    transition: all 0.3s ease;
}

.color-box.red { border-color: var(--color-red); }
.color-box.blue { border-color: var(--color-blue); }
.color-box.green { border-color: var(--color-green); }
.color-box.yellow { border-color: var(--color-yellow); }

.color-option input:checked + .color-box {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}


/* Room Card Overrides for Ludo */
.room-players {
    display: grid !important; /* Override shared flex */
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.room-player-slot {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    font-size: 0.875rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-color);
}

.room-player-slot.empty {
    opacity: 0.5;
}

.room-player-slot .color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.room-player-slot .color-dot.red { background: var(--color-red); }
.room-player-slot .color-dot.blue { background: var(--color-blue); }
.room-player-slot .color-dot.green { background: var(--color-green); }
.room-player-slot .color-dot.yellow { background: var(--color-yellow); }

/* ========= RESPONSIVE DESIGN ========= */

/* Tablet (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .board-container {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }
}

/* Mobile (max-width: 480px) */
@media (max-width: 480px) {
    .board-container {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }
    
    .game-notification {
        right: 10px;
        left: 10px;
        min-width: unset;
        max-width: unset;
        width: calc(100% - 20px);
    }
}
