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

body {
    min-height: 100vh;
    font-family: 'Source Sans Pro', sans-serif;
    background-color: #0a0a0a;
    color: #f0f0f0;
    overflow-x: hidden;
    position: relative;
}

.background {
    background: rgba(3, 3, 3, 0.4);
    opacity: 1;
    position: fixed;
    width: 100%;
    height: 100%;
    z-index: -2;
}

.mist-overlay {
    background: url('../assets/images/mist-overlay.png') repeat;
    opacity: 0.9;
    position: fixed;
    width: 100%;
    height: 500vh;
    top: 0;
    left: 0;
    z-index: -1;
    animation: mistScroll 120s linear infinite;
}

@keyframes mistScroll {
    from { background-position: 0 0; }
    to { background-position: -500px 500px; }
}

/* Enhanced floating particles */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    animation: float 25s infinite linear;
    opacity: 0;
}

.particle.golden {
    background: radial-gradient(circle, rgba(222, 184, 135, 0.6) 0%, rgba(222, 184, 135, 0.1) 70%, transparent 100%);
    box-shadow: 0 0 4px rgba(222, 184, 135, 0.4);
}

.particle.purple {
    background: radial-gradient(circle, rgba(138, 43, 226, 0.5) 0%, rgba(138, 43, 226, 0.1) 70%, transparent 100%);
    box-shadow: 0 0 4px rgba(138, 43, 226, 0.3);
}

.particle.silver {
    background: radial-gradient(circle, rgba(192, 192, 192, 0.4) 0%, rgba(192, 192, 192, 0.08) 70%, transparent 100%);
    box-shadow: 0 0 3px rgba(192, 192, 192, 0.2);
}

@keyframes float {
    0% { 
        transform: translateY(100vh) translateX(0) rotate(0deg) scale(0.3); 
        opacity: 0; 
    }
    5% { 
        opacity: 0.6;
        transform: translateY(95vh) translateX(10px) rotate(18deg) scale(0.5);
    }
    50% {
        transform: translateY(50vh) translateX(var(--drift, 50px)) rotate(180deg) scale(0.8);
        opacity: 0.4;
    }
    95% { 
        opacity: 0.3; 
    }
    100% { 
        transform: translateY(-10vh) translateX(calc(var(--drift, 50px) * 2)) rotate(360deg) scale(0.1); 
        opacity: 0; 
    }
}

.header {
    text-align: center;
    padding: 3rem 2rem 2rem;
    backdrop-filter: blur(5px);
    background: rgba(0, 0, 0, 0.2);
    margin-bottom: 2rem;
    position: relative;
    z-index: 1;
}

h1 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 3.5rem;
    font-weight: 500;
    color: #f2f2f2;
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.7), 0 0 40px rgba(138, 43, 226, 0.2);
    margin-bottom: 0.5rem;
    animation: titleGlow 4s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    0% { text-shadow: 0 0 20px rgba(0, 0, 0, 0.7), 0 0 40px rgba(138, 43, 226, 0.2); }
    100% { text-shadow: 0 0 25px rgba(0, 0, 0, 0.8), 0 0 50px rgba(138, 43, 226, 0.4); }
}

.subtitle {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 300;
    font-style: italic;
    text-shadow: 0 0 10px rgba(138, 43, 226, 0.4), 0 0 20px rgba(138, 43, 226, 0.2);
    animation: subtitleGlow 6s ease-in-out infinite alternate;
}

@keyframes subtitleGlow {
    0% { 
        text-shadow: 0 0 10px rgba(138, 43, 226, 0.4), 0 0 20px rgba(138, 43, 226, 0.2);
        color: rgba(255, 255, 255, 0.9);
    }
    100% { 
        text-shadow: 0 0 15px rgba(138, 43, 226, 0.6), 0 0 30px rgba(138, 43, 226, 0.3);
        color: rgba(255, 255, 255, 1);
    }
}

.mobile-menu-button {
    display: none;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 1rem;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 auto 1rem;
    width: fit-content;
}

.mobile-menu-button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

.nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    width: 100%;
    max-width: 700px;
    margin: 2rem auto;
    padding: 0 2rem;
    position: relative;
    z-index: 1;
}

.nav-links {
    display: contents;
}

.nav a {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    color: #fff;
    text-decoration: none;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 400;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.nav a::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 0.5s;
}

.nav a:hover::before {
    left: 100%;
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3), 0 0 20px rgba(138, 43, 226, 0.2);
}

.nav a.creative {
    border-color: rgba(138, 43, 226, 0.4);
}

.nav a.creative:hover {
    border-color: rgba(138, 43, 226, 0.8);
    background: rgba(138, 43, 226, 0.1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3), 0 0 25px rgba(138, 43, 226, 0.4);
}

.nav a.current {
    background: rgba(138, 43, 226, 0.2);
    border-color: rgba(138, 43, 226, 0.6);
    box-shadow: 0 0 15px rgba(138, 43, 226, 0.3);
}

/* FIX #5: Remove CSS !important usage - Increase specificity instead */
.nav a.cruxfade-link {
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.3s ease;
    padding: 0.5rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    backdrop-filter: blur(5px);
    background: transparent;
    box-shadow: none;
    transform: none;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav a.cruxfade-link:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.game-container {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto 2rem;
    position: relative;
    z-index: 1;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4), 0 0 30px rgba(138, 43, 226, 0.1);
}

.game-header {
    text-align: center;
    margin-bottom: 2rem;
}

.game-header h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 2.5rem;
    font-weight: 500;
    color: #f2f2f2;
    margin: 0 0 1rem 0;
}

.game-status {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.8);
    margin: 10px 0;
    min-height: 30px;
    padding: 0.5rem 1rem;
    background: rgba(138, 43, 226, 0.2);
    border: 1px solid rgba(138, 43, 226, 0.4);
    border-radius: 20px;
    display: inline-block;
}

.music-controls {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.music-btn {
    background: rgba(138, 43, 226, 0.3);
    color: #fff;
    border: 1px solid rgba(138, 43, 226, 0.5);
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    font-family: 'Source Sans Pro', sans-serif;
}

.music-btn::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 0.3s;
}

.music-btn:hover::before {
    left: 100%;
}

.music-btn:hover {
    background: rgba(138, 43, 226, 0.5);
    border-color: rgba(138, 43, 226, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3), 0 0 20px rgba(138, 43, 226, 0.4);
}

.music-btn.playing {
    background: rgba(76, 175, 80, 0.3);
    border-color: rgba(76, 175, 80, 0.5);
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.3);
    animation: musicPulse 2s ease-in-out infinite alternate;
}

.music-btn.playing:hover {
    background: rgba(76, 175, 80, 0.5);
    border-color: rgba(76, 175, 80, 0.8);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3), 0 0 20px rgba(76, 175, 80, 0.4);
}

@keyframes musicPulse {
    0% { 
        box-shadow: 0 0 15px rgba(76, 175, 80, 0.3);
    }
    100% { 
        box-shadow: 0 0 25px rgba(76, 175, 80, 0.6);
    }
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.8);
}

.volume-control span {
    font-size: 1.1rem;
}

.volume-control input[type="range"] {
    width: 100px;
    height: 5px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    -webkit-appearance: none;
}

.volume-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: rgba(138, 43, 226, 0.8);
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 10px rgba(138, 43, 226, 0.5);
}

.volume-control input[type="range"]::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: rgba(138, 43, 226, 0.8);
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 10px rgba(138, 43, 226, 0.5);
}

.chess-board-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px auto;
    width: fit-content;
}

.rank-labels {
    position: absolute;
    left: 2px;
    top: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    pointer-events: none;
    z-index: 5;
}

.rank-label {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8), 0 0 5px rgba(138, 43, 226, 0.6);
    width: 20px;
}

.board-and-files {
    position: relative;
}

.file-labels {
    position: absolute;
    bottom: 2px;
    left: 0;
    width: 100%;
    display: flex;
    pointer-events: none;
    z-index: 5;
}

.file-label {
    width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8), 0 0 5px rgba(138, 43, 226, 0.6);
    height: 20px;
}
.chess-board-container {
    position: relative;
    display: inline-block;
}

.chess-board-mist {
    position: absolute;
    top: -20px;
    left: -20px;
    right: -20px;
    bottom: -20px;
    background: 
        radial-gradient(circle at 20% 80%, rgba(138, 43, 226, 0.4) 0%, transparent 60%),
        radial-gradient(circle at 80% 20%, rgba(138, 43, 226, 0.3) 0%, transparent 55%),
        radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 60% 70%, rgba(138, 43, 226, 0.25) 0%, transparent 45%),
        linear-gradient(45deg, rgba(138, 43, 226, 0.1) 0%, transparent 30%, rgba(138, 43, 226, 0.08) 50%, transparent 70%, rgba(138, 43, 226, 0.1) 100%);
    background-size: 
        300px 300px,
        250px 250px,
        180px 180px,
        220px 220px,
        80px 80px;
    animation: 
        mistFlow1 25s linear infinite,
        mistFlow2 30s linear infinite reverse,
        mistFlow3 20s linear infinite,
        mistFlow4 40s linear infinite,
        mistScroll2 35s linear infinite;
    pointer-events: none;
    z-index: 1;
    border-radius: 18px;
    opacity: 1;
}

@keyframes mistFlow1 {
    0% { background-position: 0px 0px, 0px 0px, 0px 0px, 0px 0px, 0px 0px; }
    100% { background-position: 300px 300px, 0px 0px, 0px 0px, 0px 0px, 0px 0px; }
}

@keyframes mistFlow2 {
    0% { background-position: 0px 0px, 0px 0px, 0px 0px, 0px 0px, 0px 0px; }
    100% { background-position: 0px 0px, 250px 250px, 0px 0px, 0px 0px, 0px 0px; }
}

@keyframes mistFlow3 {
    0% { background-position: 0px 0px, 0px 0px, 0px 0px, 0px 0px, 0px 0px; }
    100% { background-position: 0px 0px, 0px 0px, 180px 180px, 0px 0px, 0px 0px; }
}

@keyframes mistFlow4 {
    0% { background-position: 0px 0px, 0px 0px, 0px 0px, 0px 0px, 0px 0px; }
    100% { background-position: 0px 0px, 0px 0px, 0px 0px, 220px 220px, 0px 0px; }
}

@keyframes mistScroll2 {
    0% { background-position: 0px 0px, 0px 0px, 0px 0px, 0px 0px, 0px 0px; }
    100% { background-position: 0px 0px, 0px 0px, 0px 0px, 0px 0px, 80px 80px; }
}

.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 80px);
    grid-template-rows: repeat(8, 80px);
    border: 3px solid rgba(138, 43, 226, 0.8);
    border-radius: 15px;
    background: #f0d9b5;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(138, 43, 226, 0.7),
        0 0 80px rgba(138, 43, 226, 0.5),
        0 0 120px rgba(138, 43, 226, 0.3);
    animation: boardGlow 3s ease-in-out infinite alternate;
    position: relative;
    z-index: 2;
}

@keyframes boardGlow {
    0% { 
        box-shadow: 
            0 10px 30px rgba(0, 0, 0, 0.5),
            0 0 40px rgba(138, 43, 226, 0.7),
            0 0 80px rgba(138, 43, 226, 0.5),
            0 0 120px rgba(138, 43, 226, 0.3);
    }
    100% { 
        box-shadow: 
            0 10px 40px rgba(0, 0, 0, 0.7),
            0 0 60px rgba(138, 43, 226, 1),
            0 0 120px rgba(138, 43, 226, 0.8),
            0 0 180px rgba(138, 43, 226, 0.5);
    }
}

.game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5); /* Reduced from 0.8 to 0.5 */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.game-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.overlay-text {
    font-family: 'Bangers', cursive;
    font-size: 6rem;
    font-weight: 400;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.8); /* Reduced from #fff to rgba(255,255,255,0.8) */
    margin: 0;
    padding: 0;
}

.overlay-text.begin {
    color: rgba(76, 175, 80, 0.8); /* Reduced opacity from 1 to 0.8 */
    text-shadow: 
        0 0 15px rgba(76, 175, 80, 0.7), /* Reduced from 20px to 15px and opacity from 1 to 0.7 */
        0 0 30px rgba(76, 175, 80, 0.5), /* Reduced from 40px to 30px and opacity from 0.8 to 0.5 */
        0 0 45px rgba(76, 175, 80, 0.3), /* Reduced from 60px to 45px and opacity from 0.6 to 0.3 */
        2px 2px 4px rgba(0,0,0,0.4);
    animation: beginExpansion 2.5s ease-in-out forwards;
}

.overlay-text.check {
    color: rgba(255, 87, 34, 0.8); /* Reduced opacity from 1 to 0.8 */
    text-shadow: 
        0 0 15px rgba(255, 87, 34, 0.7), /* Reduced from 20px to 15px and opacity from 1 to 0.7 */
        0 0 30px rgba(255, 87, 34, 0.5), /* Reduced from 40px to 30px and opacity from 0.8 to 0.5 */
        0 0 45px rgba(255, 87, 34, 0.3), /* Reduced from 60px to 45px and opacity from 0.6 to 0.3 */
        2px 2px 4px rgba(0,0,0,0.4);
    animation: checkPulse 0.6s ease-in-out 3;
}

.overlay-text.checkmate {
    color: rgba(233, 30, 99, 0.8); /* Reduced opacity from 1 to 0.8 */
    text-shadow: 
        0 0 20px rgba(233, 30, 99, 0.7), /* Reduced from 30px to 20px and opacity from 1 to 0.7 */
        0 0 40px rgba(233, 30, 99, 0.5), /* Reduced from 60px to 40px and opacity from 0.8 to 0.5 */
        0 0 60px rgba(233, 30, 99, 0.3), /* Reduced from 90px to 60px and opacity from 0.6 to 0.3 */
        2px 2px 4px rgba(0,0,0,0.4);
    animation: checkmateExpand 3s ease-out forwards;
}

@keyframes beginExpansion {
    0% { 
        transform: scale(1);
        opacity: 1;
        filter: brightness(1);
    }
    30% { 
        transform: scale(1.3);
        opacity: 1;
        filter: brightness(1.2);
    }
    70% { 
        transform: scale(1);
        opacity: 1;
        filter: brightness(1);
    }
    100% { 
        transform: scale(1);
        opacity: 0;
        filter: brightness(1);
    }
}

@keyframes checkPulse {
    0%, 100% { 
        transform: scale(1);
        filter: brightness(1);
    }
    50% { 
        transform: scale(1.15);
        filter: brightness(1.3);
    }
}

@keyframes checkmateExpand {
    0% { 
        transform: scale(1);
        opacity: 1;
        filter: brightness(1);
    }
    80% { 
        transform: scale(1.4);
        opacity: 0.8;
        filter: brightness(1.3);
    }
    100% { 
        transform: scale(1.6);
        opacity: 0;
        filter: brightness(1.5);
    }
}

.checkmate-particle {
    position: fixed;
    pointer-events: none;
    z-index: 999;
    border-radius: 50%;
    animation: checkmateParticle 3s ease-out forwards;
}

@keyframes checkmateParticle {
    0% {
        transform: scale(0) rotate(0deg) translate(0, 0);
        opacity: 1;
    }
    20% {
        transform: scale(3) rotate(90deg) translate(calc(var(--final-x) * 0.3), calc(var(--final-y) * 0.3));
        opacity: 1;
    }
    50% {
        transform: scale(2) rotate(180deg) translate(calc(var(--final-x) * 0.7), calc(var(--final-y) * 0.7));
        opacity: 1;
    }
    80% {
        transform: scale(1.5) rotate(270deg) translate(var(--final-x), var(--final-y));
        opacity: 0.8;
    }
    100% {
        transform: scale(0.5) rotate(360deg) translate(calc(var(--final-x) * 1.5), calc(var(--final-y) * 1.5 - 200px));
        opacity: 0;
    }
}

.move-particle {
    position: absolute;
    pointer-events: none;
    z-index: 10;
    border-radius: 50%;
    animation: moveParticle 1s ease-out forwards;
}

.capture-particle {
    position: absolute;
    pointer-events: none;
    z-index: 10;
    border-radius: 50%;
    animation: captureParticle 1.5s ease-out forwards;
}

@keyframes moveParticle {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
    }
    20% {
        transform: scale(1.2) rotate(72deg);
        opacity: 1;
    }
    60% {
        transform: scale(1) rotate(216deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(0.3) rotate(360deg) translateY(-50px);
        opacity: 0;
    }
}

@keyframes captureParticle {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
    }
    25% {
        transform: scale(2) rotate(90deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.5) rotate(180deg);
        opacity: 1;
    }
    75% {
        transform: scale(1) rotate(270deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(0.2) rotate(360deg) translateY(-80px);
        opacity: 0;
    }
}

.square {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    z-index: 3;
}

.square.light {
    background-color: #f0d9b5;
}

.square.dark {
    background-color: #b58863;
}

.square.selected {
    background-color: rgba(138, 43, 226, 0.7) !important;
    box-shadow: inset 0 0 15px rgba(138, 43, 226, 0.8);
}

.square.valid-move {
    background-color: rgba(46, 204, 113, 0.6) !important;
    box-shadow: inset 0 0 10px rgba(46, 204, 113, 0.8);
}

.square.check {
    background-color: rgba(231, 76, 60, 0.8) !important;
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.6);
}

.square.ai-from {
    background-color: rgba(241, 196, 15, 0.6) !important;
    box-shadow: inset 0 0 15px rgba(241, 196, 15, 0.8);
    animation: aiMoveHighlight 2s ease-out;
}

.square.ai-to {
    background-color: rgba(241, 196, 15, 0.7) !important;
    box-shadow: inset 0 0 20px rgba(241, 196, 15, 0.9);
    animation: aiMoveHighlight 2s ease-out;
}

@keyframes aiMoveHighlight {
    0% {
        transform: scale(1.1);
        box-shadow: 0 0 25px rgba(241, 196, 15, 1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        box-shadow: inset 0 0 10px rgba(241, 196, 15, 0.5);
    }
}

.piece {
    user-select: none;
    transition: all 0.2s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
    font-weight: bold;
    position: relative;
    z-index: 4;
}

.piece:hover {
    transform: scale(1.1);
}

/* White pieces - bright with golden glow */
.piece.white {
    color: #fff;
    text-shadow: 
        0 0 8px rgba(255, 255, 255, 0.8),
        0 0 15px rgba(222, 184, 135, 0.6),
        0 2px 4px rgba(0, 0, 0, 0.8);
}

/* Black pieces - mystical purple glow */
.piece.black {
    color: #e8d5ff;
    text-shadow: 
        0 0 8px rgba(138, 43, 226, 0.9),
        0 0 15px rgba(138, 43, 226, 0.6),
        0 0 25px rgba(138, 43, 226, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.8);
}

.piece.white:hover {
    text-shadow: 
        0 0 12px rgba(255, 255, 255, 1),
        0 0 20px rgba(222, 184, 135, 0.8),
        0 2px 6px rgba(0, 0, 0, 0.8);
}

.piece.black:hover {
    text-shadow: 
        0 0 12px rgba(138, 43, 226, 1),
        0 0 20px rgba(138, 43, 226, 0.8),
        0 0 30px rgba(138, 43, 226, 0.6),
        0 2px 6px rgba(0, 0, 0, 0.8);
}

.controls {
    text-align: center;
    margin-top: 2rem;
}

.btn {
    background: rgba(138, 43, 226, 0.3);
    color: #fff;
    border: 1px solid rgba(138, 43, 226, 0.5);
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    margin: 0 10px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.btn::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 0.3s;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    background: rgba(138, 43, 226, 0.5);
    border-color: rgba(138, 43, 226, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3), 0 0 20px rgba(138, 43, 226, 0.4);
}

.btn:disabled {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.4);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn:disabled:hover {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.4);
    transform: none;
    box-shadow: none;
}

.move-history {
    margin-top: 2rem;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 0 5px rgba(138, 43, 226, 0.2);
}

/* FIX #8: Add CSS classes for move history (Code cleanup preparation) */
.move-history-container {
    font-family: 'Source Sans Pro', sans-serif; 
    line-height: 1.8; 
    font-size: 0.9rem;
}

.move-history-entry {
    margin-bottom: 0.5rem; 
    padding: 0.3rem; 
    background: rgba(255,255,255,0.05); 
    border-radius: 4px;
}

.move-history-entry.white {
    border-left: 3px solid rgba(222,184,135,0.6);
}

.move-history-entry.black {
    border-left: 3px solid rgba(138,43,226,0.6);
}

.move-number {
    color: rgba(255,255,255,0.5); 
    font-weight: bold; 
    margin-right: 0.5rem;
}

.move-notation.white {
    color: rgba(255,255,255,0.9);
}

.move-notation.black {
    color: rgba(180,120,255,1); /* Improved readability color */
}

/* FIX #7: Add CSS classes for color-coded special moves */
.move-check { color: rgba(255, 87, 34, 0.9); font-weight: bold; }
.move-checkmate { color: rgba(233, 30, 99, 1); font-weight: bold; }
.move-stalemate { color: rgba(255, 193, 7, 1); font-weight: bold; }
.move-castling { color: rgba(76, 175, 80, 0.9); font-weight: bold; }
.move-promotion { color: rgba(156, 39, 176, 0.9); font-weight: bold; }

.game-instructions {
    margin-top: 2rem;
    padding: 1.5rem;
    background: rgba(138, 43, 226, 0.1);
    border: 1px solid rgba(138, 43, 226, 0.3);
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.game-instructions h3 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.4rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 1rem;
    text-align: center;
    text-shadow: 0 0 10px rgba(138, 43, 226, 0.5);
}

.instruction-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.instruction {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.instruction:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(138, 43, 226, 0.4);
    transform: translateY(-1px);
}

.instruction-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.instruction-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    line-height: 1.3;
    text-shadow: 0 0 5px rgba(138, 43, 226, 0.3);
}

.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 10;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.back-to-top:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.back-to-top.show {
    display: flex;
}

footer {
    text-align: center;
    padding: 3rem 2rem;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.7);
    font-family: 'Source Sans Pro', sans-serif;
    backdrop-filter: blur(5px);
    background: rgba(0, 0, 0, 0.2);
    margin-top: 2rem;
    position: relative;
    z-index: 1;
    text-shadow: 0 0 8px rgba(138, 43, 226, 0.3);
}

@media (max-width: 768px) {
    h1 {
        font-size: 2.5rem;
    }
    
    .mobile-menu-button {
        display: block;
    }

    .nav {
        grid-template-columns: 1fr;
        gap: 0.8rem;
        max-height: 60vh;
        overflow-y: auto;
        max-width: 400px;
    }

    .nav-links {
        display: none;
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }

    .nav-links.open {
        display: grid;
        animation: slideDown 0.3s ease;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    .nav a {
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
    }

    .game-container {
        padding: 1.5rem;
        margin: 0 1rem 2rem;
    }

    .chess-board {
        grid-template-columns: repeat(8, 60px);
        grid-template-rows: repeat(8, 60px);
        border-radius: 12px;
    }

    .chess-board-mist {
        top: -15px;
        left: -15px;
        right: -15px;
        bottom: -15px;
        border-radius: 15px;
    }

    .square {
        width: 60px;
        height: 60px;
        font-size: 38px;
    }

    .rank-label {
        height: 60px;
        font-size: 14px;
        width: 20px;
    }

    .file-label {
        width: 60px;
        font-size: 14px;
        height: 20px;
    }

    .overlay-text {
        font-size: 3rem;
    }

    .header {
        padding: 2rem 1rem 1rem;
    }

    .instruction-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .instruction {
        padding: 0.5rem;
    }

    .instruction-text {
        font-size: 0.85rem;
    }

    .music-controls {
        margin-top: 1rem;
        padding: 0.75rem;
    }

    .music-btn {
        font-size: 12px;
        padding: 8px 16px;
    }

    .volume-control input[type="range"] {
        width: 80px;
    }
}

@media (max-width: 480px) {
    .overlay-text {
        font-size: 2rem;
    }

    .chess-board {
        grid-template-columns: repeat(8, 45px);
        grid-template-rows: repeat(8, 45px);
        border-radius: 10px;
    }

    .chess-board-mist {
        top: -12px;
        left: -12px;
        right: -12px;
        bottom: -12px;
        border-radius: 13px;
    }

    .square {
        width: 45px;
        height: 45px;
        font-size: 28px;
    }

    .game-container {
        padding: 1.5rem 0.5rem;
        margin: 0 auto 2rem;
        max-width: 100vw;
        overflow-x: hidden;
        text-align: center;
    }

    .rank-label {
        height: 45px;
        font-size: 12px;
        width: 18px;
    }

    .file-label {
        width: 45px;
        font-size: 12px;
        height: 18px;
    }

    .game-instructions {
        padding: 1rem;
    }

    .instruction {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }

    .music-controls {
        margin-top: 0.75rem;
        padding: 0.5rem;
        gap: 0.75rem;
    }

    .music-btn {
        font-size: 11px;
        padding: 6px 12px;
    }

    .volume-control {
        gap: 0.3rem;
    }

    .volume-control input[type="range"] {
        width: 60px;
    }

    .volume-control span {
        font-size: 1rem;
    }
}

/* Game Settings Container - Side by side layout */
.game-settings-container {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Update existing music-controls to be half width */
.music-controls {
    flex: 1;
    min-width: 300px;
    max-width: 400px;
    margin-top: 0; /* Remove existing margin since container handles it */
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.music-controls h4 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0.75rem;
    text-align: center;
    text-shadow: 0 0 8px rgba(138, 43, 226, 0.4);
}

/* Difficulty Controls - Matching style */
.difficulty-controls {
    flex: 1;
    min-width: 300px;
    max-width: 400px;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.difficulty-controls h4 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0.75rem;
    text-align: center;
    text-shadow: 0 0 8px rgba(138, 43, 226, 0.4);
}

.difficulty-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.difficulty-btn {
    background: rgba(138, 43, 226, 0.2);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(138, 43, 226, 0.4);
    padding: 0.6rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    font-family: 'Source Sans Pro', sans-serif;
    font-weight: 500;
    text-align: center;
}

.difficulty-btn::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 0.3s;
}

.difficulty-btn:hover::before {
    left: 100%;
}

.difficulty-btn:hover {
    background: rgba(138, 43, 226, 0.3);
    border-color: rgba(138, 43, 226, 0.6);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2), 0 0 15px rgba(138, 43, 226, 0.3);
}

/* Active difficulty styling */
.difficulty-btn.active {
    background: rgba(138, 43, 226, 0.5);
    border-color: rgba(138, 43, 226, 0.8);
    box-shadow: 0 0 15px rgba(138, 43, 226, 0.4);
    color: #fff;
    font-weight: 600;
    transform: translateY(-1px);
}

.difficulty-btn.active:hover {
    background: rgba(138, 43, 226, 0.6);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3), 0 0 20px rgba(138, 43, 226, 0.5);
}

/* Difficulty-specific styling */
.difficulty-btn[data-difficulty="novice"] {
    border-color: rgba(76, 175, 80, 0.4);
    background: rgba(76, 175, 80, 0.2);
}

.difficulty-btn[data-difficulty="novice"]:hover,
.difficulty-btn[data-difficulty="novice"].active {
    border-color: rgba(76, 175, 80, 0.8);
    background: rgba(76, 175, 80, 0.4);
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.3);
}

.difficulty-btn[data-difficulty="knight"] {
    border-color: rgba(255, 152, 0, 0.4);
    background: rgba(255, 152, 0, 0.2);
}

.difficulty-btn[data-difficulty="knight"]:hover,
.difficulty-btn[data-difficulty="knight"].active {
    border-color: rgba(255, 152, 0, 0.8);
    background: rgba(255, 152, 0, 0.4);
    box-shadow: 0 0 15px rgba(255, 152, 0, 0.3);
}

.difficulty-btn[data-difficulty="grandmaster"] {
    border-color: rgba(233, 30, 99, 0.4);
    background: rgba(233, 30, 99, 0.2);
}

.difficulty-btn[data-difficulty="grandmaster"]:hover,
.difficulty-btn[data-difficulty="grandmaster"].active {
    border-color: rgba(233, 30, 99, 0.8);
    background: rgba(233, 30, 99, 0.4);
    box-shadow: 0 0 15px rgba(233, 30, 99, 0.3);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .game-settings-container {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }
    
    .difficulty-controls,
    .music-controls {
        max-width: 100%;
        min-width: auto;
        width: 100%;
    }
    
    .difficulty-selector {
        flex-direction: row;
        justify-content: space-between;
        gap: 0.3rem;
    }
    
    .difficulty-btn {
        flex: 1;
        padding: 0.5rem 0.3rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .difficulty-selector {
        flex-direction: column;
        gap: 0.4rem;
    }
    
    .difficulty-btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
    }
    
    .difficulty-controls h4,
    .music-controls h4 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
}

/* Enhanced Active Difficulty Styling - ADD to chess.css */

/* Make active difficulty MUCH more prominent */
.difficulty-btn.active {
    background: rgba(138, 43, 226, 0.8) !important; /* Much stronger background */
    border: 2px solid rgba(138, 43, 226, 1) !important; /* Thicker border */
    box-shadow: 
        0 0 25px rgba(138, 43, 226, 0.8),
        0 0 50px rgba(138, 43, 226, 0.6),
        inset 0 0 20px rgba(255, 255, 255, 0.2) !important; /* Inner glow */
    color: #fff !important;
    font-weight: 700 !important; /* Bolder text */
    transform: translateY(-3px) scale(1.05) !important; /* Larger and raised */
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8) !important; /* Text glow */
}

.difficulty-btn.active:hover {
    background: rgba(138, 43, 226, 0.9) !important;
    box-shadow: 
        0 5px 20px rgba(0, 0, 0, 0.4), 
        0 0 35px rgba(138, 43, 226, 1),
        0 0 70px rgba(138, 43, 226, 0.8),
        inset 0 0 25px rgba(255, 255, 255, 0.3) !important;
    transform: translateY(-3px) scale(1.05) !important;
}

/* Enhanced difficulty-specific active styling */
.difficulty-btn[data-difficulty="novice"].active {
    background: rgba(76, 175, 80, 0.8) !important;
    border: 2px solid rgba(76, 175, 80, 1) !important;
    box-shadow: 
        0 0 25px rgba(76, 175, 80, 0.8),
        0 0 50px rgba(76, 175, 80, 0.6),
        inset 0 0 20px rgba(255, 255, 255, 0.2) !important;
}

.difficulty-btn[data-difficulty="novice"].active:hover {
    background: rgba(76, 175, 80, 0.9) !important;
    box-shadow: 
        0 5px 20px rgba(0, 0, 0, 0.4), 
        0 0 35px rgba(76, 175, 80, 1),
        0 0 70px rgba(76, 175, 80, 0.8),
        inset 0 0 25px rgba(255, 255, 255, 0.3) !important;
}

.difficulty-btn[data-difficulty="knight"].active {
    background: rgba(255, 152, 0, 0.8) !important;
    border: 2px solid rgba(255, 152, 0, 1) !important;
    box-shadow: 
        0 0 25px rgba(255, 152, 0, 0.8),
        0 0 50px rgba(255, 152, 0, 0.6),
        inset 0 0 20px rgba(255, 255, 255, 0.2) !important;
}

.difficulty-btn[data-difficulty="knight"].active:hover {
    background: rgba(255, 152, 0, 0.9) !important;
    box-shadow: 
        0 5px 20px rgba(0, 0, 0, 0.4), 
        0 0 35px rgba(255, 152, 0, 1),
        0 0 70px rgba(255, 152, 0, 0.8),
        inset 0 0 25px rgba(255, 255, 255, 0.3) !important;
}

.difficulty-btn[data-difficulty="grandmaster"].active {
    background: rgba(233, 30, 99, 0.8) !important;
    border: 2px solid rgba(233, 30, 99, 1) !important;
    box-shadow: 
        0 0 25px rgba(233, 30, 99, 0.8),
        0 0 50px rgba(233, 30, 99, 0.6),
        inset 0 0 20px rgba(255, 255, 255, 0.2) !important;
}

.difficulty-btn[data-difficulty="grandmaster"].active:hover {
    background: rgba(233, 30, 99, 0.9) !important;
    box-shadow: 
        0 5px 20px rgba(0, 0, 0, 0.4), 
        0 0 35px rgba(233, 30, 99, 1),
        0 0 70px rgba(233, 30, 99, 0.8),
        inset 0 0 25px rgba(255, 255, 255, 0.3) !important;
}

/* Add visual indicator next to game status */
.game-status-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.difficulty-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    font-size: 0.9rem;
    font-weight: 600;
    text-shadow: 0 0 8px rgba(138, 43, 226, 0.4);
    transition: all 0.3s ease;
}

.difficulty-indicator.novice {
    border-color: rgba(76, 175, 80, 0.6);
    background: rgba(76, 175, 80, 0.2);
    color: rgba(76, 175, 80, 1);
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.3);
}

.difficulty-indicator.knight {
    border-color: rgba(255, 152, 0, 0.6);
    background: rgba(255, 152, 0, 0.2);
    color: rgba(255, 152, 0, 1);
    box-shadow: 0 0 15px rgba(255, 152, 0, 0.3);
}

.difficulty-indicator.grandmaster {
    border-color: rgba(233, 30, 99, 0.6);
    background: rgba(233, 30, 99, 0.2);
    color: rgba(233, 30, 99, 1);
    box-shadow: 0 0 15px rgba(233, 30, 99, 0.3);
}

/* Animate difficulty changes */
@keyframes difficultyChange {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.difficulty-btn.active {
    animation: difficultyChange 0.3s ease-out;
}

/* Mobile responsiveness for new elements */
@media (max-width: 768px) {
    .game-status-container {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .difficulty-indicator {
        font-size: 0.8rem;
        padding: 0.3rem 0.6rem;
    }
}

@media (max-width: 480px) {
    .difficulty-indicator {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
}
