* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Josefin Sans', sans-serif;
    background: 
        radial-gradient(circle at 20% 30%, rgba(139, 69, 19, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(160, 82, 45, 0.1) 0%, transparent 50%),
        linear-gradient(135deg, #2c1810 0%, #3d2817 25%, #4a3420 50%, #3d2817 75%, #2c1810 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #f4f1e8;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(255, 215, 0, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(255, 215, 0, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

.game-container {
    background: 
        linear-gradient(145deg, #8b4513 0%, #a0522d 5%, #cd853f  15%, #daa520 25%, #cd853f 35%, #a0522d 50%, #8b4513 65%, #654321 80%, #5d4037 95%, #4a2c2a 100%);
    border-radius: 25px;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2);
    padding: 40px;
    max-width: 650px;
    width: 95%;
    text-align: center;
    position: relative;
    border: 3px solid #654321;
}

.game-container::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    background: 
        linear-gradient(145deg, rgba(205, 133, 63, 0.1) 0%, rgba(160, 82, 45, 0.05) 50%, rgba(101, 67, 33, 0.1) 100%);
    border-radius: 20px;
    pointer-events: none;
    z-index: 0;
}

.game-container > * {
    position: relative;
    z-index: 1;
}

/* Override z-index for dropdown elements to ensure they appear above everything */
.game-container .difficulty-selector,
.game-container .custom-select,
.game-container .select-items {
    z-index: 99999 !important;
}

header h1 {
    font-size: 3.2em;
    background: linear-gradient(45deg, #daa520, #ffd700, #ffed4e, #daa520);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    font-weight: 300;
    letter-spacing: 4px;
    text-transform: uppercase;
    animation: goldShimmer 3s ease-in-out infinite;
    text-shadow: 0 0 20px rgba(218, 165, 32, 0.3);
}

@keyframes goldShimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

header p {
    color: #d4af37;
    font-style: italic;
    margin-bottom: 25px;
    font-size: 1.1em;
    letter-spacing: 1px;
    font-weight: 300;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding: 20px 25px;
    background: 
        linear-gradient(145deg, rgba(139, 69, 19, 0.3) 0%, rgba(160, 82, 45, 0.2) 50%, rgba(101, 67, 33, 0.3) 100%);
    border-radius: 15px;
    border: 2px solid rgba(218, 165, 32, 0.3);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 5000;
}

.score-section {
    display: flex;
    gap: 30px;
    align-items: center;
}

.current-stats, .high-scores {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.difficulty-selector {
    margin-top: 5px;
    position: relative;
    z-index: 15000;
}

.difficulty-selector label {
    color: #d4af37;
    font-size: 0.9em;
    margin-right: 8px;
    font-weight: 300;
}

/* Custom Select Styling */
.custom-select {
    position: relative;
    display: inline-block;
    min-width: 150px;
    z-index: 10000;
}

.select-selected {
    background: linear-gradient(145deg, #8b4513 0%, #a0522d 25%, #cd853f 50%, #a0522d 75%, #8b4513 100%);
    color: #f4f1e8;
    border: 2px solid rgba(218, 165, 32, 0.4);
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 0.9em;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 3px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.1),
        inset 0 -1px 2px rgba(0, 0, 0, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.5px;
    padding-right: 32px;
    position: relative;
}

/* Custom dropdown arrow */
.select-selected:after {
    content: "";
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #f4f1e8;
    transition: transform 0.3s ease;
}

.select-selected.select-arrow-active:after {
    border-top: 6px solid transparent;
    border-bottom: 6px solid #f4f1e8;
    transform: translateY(-50%) rotate(180deg);
}

.select-selected:hover {
    background: linear-gradient(145deg, #daa520 0%, #b8860b 25%, #cd853f 50%, #b8860b 75%, #daa520 100%);
    border-color: rgba(218, 165, 32, 0.6);
    transform: translateY(-1px);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.4),
        inset 0 1px 2px rgba(255, 255, 255, 0.15),
        inset 0 -1px 2px rgba(0, 0, 0, 0.1);
    color: #2c1810;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.2);
}

.select-selected:hover:after {
    border-top-color: #2c1810;
}

.select-selected.select-arrow-active:hover:after {
    border-bottom-color: #2c1810;
}

/* Dropdown items container */
.select-items {
    position: fixed;
    background: linear-gradient(145deg, #8b4513 0%, #a0522d 25%, #654321 50%, #8b4513 75%, #5d4037 100%);
    z-index: 99999;
    border: 2px solid rgba(218, 165, 32, 0.4);
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.5),
        inset 0 1px 2px rgba(255, 255, 255, 0.05);
    overflow: hidden;
    min-width: 150px;
}

/* Individual dropdown items */
.select-items div {
    color: #f4f1e8;
    padding: 12px 16px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(218, 165, 32, 0.2);
    background: transparent;
}

.select-items div:last-child {
    border-bottom: none;
}

/* Hover state for dropdown items */
.select-items div:hover {
    background: linear-gradient(145deg, #daa520 0%, #b8860b 25%, #cd853f 50%, #b8860b 75%, #daa520 100%);
    color: #2c1810;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Selected item styling */
.select-items div.same-as-selected {
    background: linear-gradient(145deg, #ffd700 0%, #daa520 25%, #ffed4e 50%, #daa520 75%, #ffd700 100%);
    color: #2c1810;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.3);
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.15),
        0 1px 3px rgba(218, 165, 32, 0.4);
}

/* Hide dropdown by default */
.select-hide {
    display: none;
}

/* Show dropdown when active */
.select-items.select-show {
    display: block;
}

/* When dropdown is open, adjust main select styling */
.select-selected.select-arrow-active {
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    border-bottom-color: rgba(218, 165, 32, 0.6);
    box-shadow: 
        0 0 0 3px rgba(218, 165, 32, 0.3),
        0 8px 25px rgba(0, 0, 0, 0.5),
        inset 0 1px 2px rgba(255, 255, 255, 0.15);
}

.moves-counter, .score-display, .best-score, .fewest-moves {
    font-weight: 400;
    font-size: 1.1em;
    color: #f4f1e8;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.5px;
}

.best-score, .fewest-moves {
    font-size: 1em;
    color: #daa520;
    font-weight: 500;
}

.best-score span:first-child, .fewest-moves span:first-child {
    color: #d4af37;
    font-weight: 300;
}

#best-score, #fewest-moves {
    color: #ffd700;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 0 8px rgba(255, 215, 0, 0.3);
}

.score-breakdown {
    background: linear-gradient(145deg, rgba(139, 69, 19, 0.2), rgba(160, 82, 45, 0.1));
    border: 1px solid rgba(218, 165, 32, 0.2);
    border-radius: 12px;
    padding: 15px;
    margin-top: 15px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    text-align: left;
    max-width: 450px;
    margin: 15px auto 0;
    width: 100%;
}

.score-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    color: #f4f1e8;
    letter-spacing: 0.5px;
}

.score-line.total {
    border-top: 1px solid rgba(218, 165, 32, 0.3);
    margin-top: 8px;
    padding-top: 8px;
    font-weight: 600;
    color: #daa520;
    font-size: 1em;
}

.score-breakdown .score-line:last-child {
    margin-bottom: 0;
}

#new-game-btn {
    background: 
        linear-gradient(145deg, #daa520 0%, #b8860b 25%, #cd853f 50%, #b8860b 75%, #daa520 100%);
    color: #2c1810;
    border: 2px solid rgba(139, 69, 19, 0.3);
    padding: 12px 24px;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1em;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 
        0 6px 15px rgba(0, 0, 0, 0.4),
        inset 0 1px 2px rgba(255, 255, 255, 0.3),
        inset 0 -1px 2px rgba(0, 0, 0, 0.2);
}

#new-game-btn:hover {
    background: 
        linear-gradient(145deg, #ffd700 0%, #daa520 25%, #ffed4e 50%, #daa520 75%, #ffd700 100%);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 
        0 8px 20px rgba(0, 0, 0, 0.5),
        inset 0 1px 2px rgba(255, 255, 255, 0.4),
        inset 0 -1px 2px rgba(0, 0, 0, 0.1);
}

#new-game-btn:active {
    transform: translateY(-1px) scale(1.01);
}

.button-icon {
    width: 20px;
    height: 20px;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(7, 1fr);
    gap: 6px;
    background: 
        linear-gradient(145deg, #3c2414 0%, #4a2c1a 25%, #5d3926 50%, #4a2c1a 75%, #3c2414 100%);
    padding: 20px;
    border-radius: 20px;
    margin: 25px 0;
    max-width: 450px;
    margin-left: auto;
    margin-right: auto;
    border: 4px solid #2c1810;
    position: relative;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.7),
        inset 0 2px 4px rgba(255, 255, 255, 0.1),
        inset 0 -2px 4px rgba(0, 0, 0, 0.3);
    position: relative;
}

.game-board::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #8b4513, #cd853f, #daa520, #cd853f, #8b4513);
    border-radius: 22px;
    z-index: -1;
}

.game-board::after {
    content: '';
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    bottom: 12px;
    background: 
        radial-gradient(circle at 30% 30%, rgba(218, 165, 32, 0.1) 0%, transparent 70%),
        radial-gradient(circle at 70% 70%, rgba(139, 69, 19, 0.1) 0%, transparent 70%);
    border-radius: 15px;
    pointer-events: none;
    z-index: 0;
}

.cell {
    aspect-ratio: 1;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    background: #2c1810;
    min-height: 50px;
    z-index: 1;
}

/* Floating ball animation */
.cell.ball.floating-ball {
    z-index: 200;
    pointer-events: none;
    transform: scale(1.1);
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.7),
        0 8px 16px rgba(0, 0, 0, 0.5),
        inset -3px -3px 10px rgba(0, 0, 0, 0.4),
        inset 3px 3px 10px rgba(255, 255, 255, 0.3),
        0 0 20px rgba(255, 255, 255, 0.2);
}

/* Trail effect for floating balls */
.cell.ball.floating-ball::before {
    opacity: 0.6;
    transform: scale(1.3);
}

.cell.ball.floating-ball::after {
    opacity: 0.3;
    transform: scale(1.2);
}

/* Source empty space during movement */
.cell.empty.source {
    background: 
        radial-gradient(circle at 30% 30%, #4a2c1a 0%, #3c2414 30%, #2c1810 70%, #1a0f08 100%);
    box-shadow: 
        inset 0 4px 8px rgba(0, 0, 0, 0.6),
        inset 0 -2px 4px rgba(139, 69, 19, 0.2),
        0 2px 4px rgba(0, 0, 0, 0.3);
    border: 1px solid #1a0f08;
    animation: sourceGlow 0.6s ease-out;
}

@keyframes sourceGlow {
    0% { 
        box-shadow: 
            inset 0 4px 8px rgba(0, 0, 0, 0.6),
            inset 0 -2px 4px rgba(139, 69, 19, 0.2),
            0 2px 4px rgba(0, 0, 0, 0.3);
        opacity: 0.7;
    }
    50% { 
        box-shadow: 
            inset 0 4px 8px rgba(0, 0, 0, 0.6),
            inset 0 -2px 4px rgba(139, 69, 19, 0.4),
            0 2px 4px rgba(0, 0, 0, 0.3),
            0 0 15px rgba(218, 165, 32, 0.2);
        opacity: 1;
    }
    100% { 
        box-shadow: 
            inset 0 4px 8px rgba(0, 0, 0, 0.6),
            inset 0 -2px 4px rgba(139, 69, 19, 0.2),
            0 2px 4px rgba(0, 0, 0, 0.3);
        opacity: 1;
    }
}

/* Landing animation for balls */
.cell.ball.landing {
    animation: ballLanding 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes ballLanding {
    0% { 
        transform: scale(1.2) translateY(-10px);
        box-shadow: 
            0 25px 50px rgba(0, 0, 0, 0.8),
            0 10px 20px rgba(0, 0, 0, 0.6),
            inset -3px -3px 10px rgba(0, 0, 0, 0.4),
            inset 3px 3px 10px rgba(255, 255, 255, 0.3);
    }
    60% { 
        transform: scale(0.95);
        box-shadow: 
            0 8px 16px rgba(0, 0, 0, 0.4),
            0 3px 6px rgba(0, 0, 0, 0.3),
            inset -3px -3px 10px rgba(0, 0, 0, 0.4),
            inset 3px 3px 10px rgba(255, 255, 255, 0.2);
    }
    100% { 
        transform: scale(1);
        box-shadow: 
            0 12px 24px rgba(0, 0, 0, 0.5),
            0 4px 8px rgba(0, 0, 0, 0.3),
            inset -3px -3px 10px rgba(0, 0, 0, 0.4),
            inset 3px 3px 10px rgba(255, 255, 255, 0.2);
    }
}

/* Empty slot highlight during movement */
.cell.empty.target {
    background: 
        radial-gradient(circle at 30% 30%, #5d4037 0%, #4a2c1a 30%, #3c2414 70%, #2c1810 100%);
    box-shadow: 
        inset 0 4px 8px rgba(0, 0, 0, 0.6),
        inset 0 -2px 4px rgba(139, 69, 19, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.3),
        0 0 10px rgba(218, 165, 32, 0.3);
    border: 2px solid rgba(218, 165, 32, 0.5);
    animation: targetPulse 0.6s ease-out;
}

@keyframes targetPulse {
    0% { 
        box-shadow: 
            inset 0 4px 8px rgba(0, 0, 0, 0.6),
            inset 0 -2px 4px rgba(139, 69, 19, 0.2),
            0 2px 4px rgba(0, 0, 0, 0.3);
        transform: scale(1);
    }
    50% { 
        box-shadow: 
            inset 0 4px 8px rgba(0, 0, 0, 0.6),
            inset 0 -2px 4px rgba(139, 69, 19, 0.6),
            0 2px 4px rgba(0, 0, 0, 0.3),
            0 0 20px rgba(218, 165, 32, 0.5);
        transform: scale(1.05);
    }
    100% { 
        box-shadow: 
            inset 0 4px 8px rgba(0, 0, 0, 0.6),
            inset 0 -2px 4px rgba(139, 69, 19, 0.4),
            0 2px 4px rgba(0, 0, 0, 0.3),
            0 0 10px rgba(218, 165, 32, 0.3);
        transform: scale(1);
    }
}

.cell.empty {
    background: 
        radial-gradient(circle at 30% 30%, #4a2c1a 0%, #3c2414 30%, #2c1810 70%, #1a0f08 100%);
    box-shadow: 
        inset 0 4px 8px rgba(0, 0, 0, 0.6),
        inset 0 -2px 4px rgba(139, 69, 19, 0.2),
        0 2px 4px rgba(0, 0, 0, 0.3);
    border: 1px solid #1a0f08;
}

.cell.empty::before {
    content: '';
    position: absolute;
    top: 15%;
    left: 20%;
    width: 25%;
    height: 25%;
    background: rgba(218, 165, 32, 0.1);
    border-radius: 50%;
    filter: blur(2px);
}

.cell.ball {
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
        0 12px 24px rgba(0, 0, 0, 0.5),
        0 4px 8px rgba(0, 0, 0, 0.3),
        inset -3px -3px 10px rgba(0, 0, 0, 0.4),
        inset 3px 3px 10px rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

.cell.ball::before {
    content: '';
    position: absolute;
    top: 20%;
    left: 30%;
    width: 35%;
    height: 35%;
    background: 
        radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.3) 60%, transparent 100%);
    border-radius: 50%;
    filter: blur(1px);
    z-index: 2;
}

.cell.ball::after {
    content: '';
    position: absolute;
    bottom: 15%;
    right: 20%;
    width: 25%;
    height: 25%;
    background: 
        radial-gradient(circle, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.1) 60%, transparent 100%);
    border-radius: 50%;
    filter: blur(2px);
    z-index: 2;
}

.cell.ball:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 
        0 16px 32px rgba(0, 0, 0, 0.6),
        0 6px 12px rgba(0, 0, 0, 0.4),
        inset -3px -3px 10px rgba(0, 0, 0, 0.4),
        inset 3px 3px 10px rgba(255, 255, 255, 0.3),
        0 0 15px rgba(218, 165, 32, 0.4);
    border-color: rgba(218, 165, 32, 0.6);
}

.cell.ball:hover::after {
    box-shadow: 0 0 8px rgba(218, 165, 32, 0.3);
}

.cell.ball.moveable {
    animation: pulse 2s infinite;
}

.cell.ball.clustered {
    animation: clusterPulse 3s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes clusterPulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 
            0 8px 16px rgba(0, 0, 0, 0.3),
            inset -2px -2px 6px rgba(0, 0, 0, 0.3),
            inset 2px 2px 6px rgba(255, 255, 255, 0.4);
    }
    50% { 
        transform: scale(1.02);
        box-shadow: 
            0 12px 20px rgba(0, 0, 0, 0.4),
            inset -2px -2px 6px rgba(0, 0, 0, 0.3),
            inset 2px 2px 6px rgba(255, 255, 255, 0.4),
            0 0 15px rgba(102, 126, 234, 0.4);
    }
}

/* Premium Mastermind ball colors with luxury materials */
.ball.color-0 { 
    background: 
        radial-gradient(circle at 35% 35%, #ff6b6b 0%, #e55656 15%, #cc1e1e 45%, #b71c1c 70%, #8b0000 100%);
    border-color: rgba(204, 30, 30, 0.3);
} /* Ruby Red */

.ball.color-1 { 
    background: 
        radial-gradient(circle at 35% 35%, #4a90e2 0%, #357abd 15%, #1565c0 45%, #0d47a1 70%, #002171 100%);
    border-color: rgba(21, 101, 192, 0.3);
} /* Sapphire Blue */

.ball.color-2 { 
    background: 
        radial-gradient(circle at 35% 35%, #66bb6a 0%, #4caf50 15%, #2e7d32 45%, #1b5e20 70%, #0d4e11 100%);
    border-color: rgba(46, 125, 50, 0.3);
} /* Emerald Green */

.ball.color-3 { 
    background: 
        radial-gradient(circle at 35% 35%, #ffa726 0%, #ff9800 15%, #ef6c00 45%, #e65100 70%, #bf360c 100%);
    border-color: rgba(239, 108, 0, 0.3);
} /* Amber Gold */

.ball.color-4 { 
    background: 
        radial-gradient(circle at 35% 35%, #ab47bc 0%, #9c27b0 15%, #7b1fa2 45%, #4a148c 70%, #1a0033 100%);
    border-color: rgba(123, 31, 162, 0.3);
} /* Amethyst Purple */

.ball.color-5 { 
    background: 
        radial-gradient(circle at 35% 35%, #26c6da 0%, #00bcd4 15%, #0097a7 45%, #006064 70%, #003d3f 100%);
    border-color: rgba(0, 151, 167, 0.3);
} /* Turquoise */

.ball.color-6 { 
    background: 
        radial-gradient(circle at 35% 35%, #fff176 0%, #ffeb3b 15%, #fbc02d 45%, #f9a825 70%, #e65100 100%);
    border-color: rgba(251, 192, 45, 0.3);
} /* Citrine Yellow */

.ball.color-7 { 
    background: 
        radial-gradient(circle at 35% 35%, #ffffff 0%, #f5f5f5 15%, #e0e0e0 45%, #bdbdbd 70%, #757575 100%);
    border-color: rgba(189, 189, 189, 0.3);
} /* Pearl White */

.game-status {
    margin: 25px 0;
    font-size: 1.2em;
    min-height: 30px;
}

#game-message {
    color: #d4af37;
    font-weight: 400;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    line-height: 1.4;
}

#game-message.success {
    color: #66bb6a;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 0 10px rgba(102, 187, 106, 0.3);
    font-weight: 500;
}

#game-message.warning {
    color: #ffa726;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 0 10px rgba(255, 167, 38, 0.3);
    font-weight: 500;
}

#game-message.info {
    color: #4a90e2;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 0 10px rgba(74, 144, 226, 0.3);
    font-weight: 500;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.controls button {
    background: 
        linear-gradient(145deg, #8b4513 0%, #a0522d 25%, #cd853f 50%, #a0522d 75%, #8b4513 100%);
    color: #f4f1e8;
    border: 2px solid rgba(218, 165, 32, 0.2);
    padding: 12px 18px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 500;
    letter-spacing: 0.5px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.4),
        inset 0 1px 2px rgba(255, 255, 255, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.controls button:hover {
    background: 
        linear-gradient(145deg, #a0522d 0%, #cd853f 25%, #daa520 50%, #cd853f 75%, #a0522d 100%);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 
        0 6px 16px rgba(0, 0, 0, 0.5),
        inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

.controls button:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

@media (max-width: 500px) {
    .game-container {
        padding: 20px 15px;
        width: 95%;
    }
    
    header h1 {
        font-size: 2.2em;
        letter-spacing: 2px;
    }
    
    header p {
        font-size: 1em;
    }
    
    .game-info {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }
    
    .score-section {
        gap: 20px;
        justify-content: center;
    }
    
    .current-stats, .high-scores {
        text-align: center;
    }
    
    .moves-counter, .score-display, .best-score, .fewest-moves {
        font-size: 1em;
    }
    
    .controls {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .controls button {
        padding: 10px 14px;
        font-size: 0.9em;
    }
    
    .cell {
        min-height: 38px;
    }
    
    .game-board {
        max-width: 350px;
        padding: 15px;
    }
}

/* Rules Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: 
        linear-gradient(145deg, #8b4513 0%, #a0522d 5%, #cd853f 15%, #daa520 25%, #cd853f 35%, #a0522d 50%, #8b4513 65%, #654321 80%, #5d4037 95%, #4a2c2a 100%);
    border-radius: 25px;
    max-width: 550px;
    width: 92%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 
        0 25px 60px rgba(0, 0, 0, 0.6),
        0 10px 30px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 3px solid #654321;
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-60px) scale(0.85);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 35px;
    border-bottom: 2px solid rgba(101, 67, 33, 0.5);
    background: 
        linear-gradient(145deg, #daa520 0%, #b8860b 25%, #cd853f 50%, #b8860b 75%, #daa520 100%);
    color: #2c1810;
    border-radius: 22px 22px 0 0;
    box-shadow: 
        inset 0 1px 2px rgba(255, 255, 255, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.2);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.6em;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.close-btn {
    background: rgba(139, 69, 19, 0.3);
    border: 2px solid rgba(44, 24, 16, 0.3);
    color: #2c1810;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 2px 6px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

.close-btn:hover {
    background: rgba(160, 82, 45, 0.4);
    transform: scale(1.1);
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.4),
        inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

.close-btn svg {
    width: 24px;
    height: 24px;
}

.modal-body {
    padding: 35px 40px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 0 0 22px 22px;
}

.rules-section {
    margin-bottom: 30px;
}

.rules-section:last-child {
    margin-bottom: 0;
}

.rules-section h3 {
    color: #f4f1e8;
    margin-bottom: 15px;
    font-size: 1.3em;
    font-weight: 500;
    letter-spacing: 1px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.rules-section p {
    color: #d4af37;
    line-height: 1.6;
    margin-bottom: 12px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.rule-item {
    color: #f4f1e8;
    line-height: 1.6;
    margin-bottom: 10px;
    padding: 14px 18px 14px 28px;
    background: 
        linear-gradient(145deg, rgba(139, 69, 19, 0.3) 0%, rgba(160, 82, 45, 0.2) 50%, rgba(101, 67, 33, 0.3) 100%);
    border-radius: 12px;
    border-left: 4px solid #daa520;
    border: 1px solid rgba(218, 165, 32, 0.2);
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 2px 6px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.1);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.rule-item:hover {
    background: 
        linear-gradient(145deg, rgba(160, 82, 45, 0.4) 0%, rgba(205, 133, 63, 0.3) 50%, rgba(139, 69, 19, 0.4) 100%);
    transform: translateX(3px) scale(1.01);
    box-shadow: 
        0 4px 10px rgba(0, 0, 0, 0.4),
        inset 0 1px 2px rgba(255, 255, 255, 0.2);
    border-color: rgba(218, 165, 32, 0.4);
}

.rule-item::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: 
        radial-gradient(circle, #ffd700 0%, #daa520 100%);
    border-radius: 50%;
    box-shadow: 
        0 0 6px rgba(255, 215, 0, 0.5),
        0 2px 4px rgba(0, 0, 0, 0.3);
}

.color-legend {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.color-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1em;
    color: #d4af37;
    font-weight: 400;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.color-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.4),
        inset -2px -2px 6px rgba(0, 0, 0, 0.3),
        inset 2px 2px 6px rgba(255, 255, 255, 0.2);
}

/* Premium color dots matching ball colors */
.color-dot.color-0 { background: radial-gradient(circle at 35% 35%, #ff6b6b 0%, #e55656 15%, #cc1e1e 45%, #b71c1c 70%, #8b0000 100%); }
.color-dot.color-1 { background: radial-gradient(circle at 35% 35%, #4a90e2 0%, #357abd 15%, #1565c0 45%, #0d47a1 70%, #002171 100%); }
.color-dot.color-2 { background: radial-gradient(circle at 35% 35%, #66bb6a 0%, #4caf50 15%, #2e7d32 45%, #1b5e20 70%, #0d4e11 100%); }
.color-dot.color-3 { background: radial-gradient(circle at 35% 35%, #ffa726 0%, #ff9800 15%, #ef6c00 45%, #e65100 70%, #bf360c 100%); }
.color-dot.color-4 { background: radial-gradient(circle at 35% 35%, #ab47bc 0%, #9c27b0 15%, #7b1fa2 45%, #4a148c 70%, #1a0033 100%); }
.color-dot.color-5 { background: radial-gradient(circle at 35% 35%, #26c6da 0%, #00bcd4 15%, #0097a7 45%, #006064 70%, #003d3f 100%); }
.color-dot.color-6 { background: radial-gradient(circle at 35% 35%, #fff176 0%, #ffeb3b 15%, #fbc02d 45%, #f9a825 70%, #e65100 100%); }
.color-dot.color-7 { background: radial-gradient(circle at 35% 35%, #ffffff 0%, #f5f5f5 15%, #e0e0e0 45%, #bdbdbd 70%, #757575 100%); }

@media (max-width: 500px) {
    .modal-content {
        width: 95%;
        max-height: 85vh;
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .color-legend {
        grid-template-columns: 1fr;
    }
}