.game-container {
    max-width: min(600px, 95vw);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.5rem, 2vw, 1rem);
}

#game-board {
    display: grid;
    grid-template-rows: repeat(6, auto);
    gap: clamp(3px, 0.5vw, 8px);
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
}

.word-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: clamp(4px, 1vw, 8px);
    margin-bottom: clamp(1px, 0.2vw, 3px);
    position: relative;
    justify-content: center;
    width: fit-content;
    margin: 0 auto;
}

/* Style for previous game rows in the final game */
.word-row.previous-game-row {
    opacity: 0.9;
    position: relative;
}

/* Indicator for previous game rows */
.word-row.previous-game-row::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background-color: #0EA5E9;
    border-radius: 50%;
    box-shadow: 0 0 6px #0EA5E9;
}

/* Style for active rows in the final game */
.word-row.active-row {
    position: relative;
}

/* Highlight active rows with a subtle glow */
.word-row.active-row::before {
    content: '';
    position: absolute;
    left: -16px;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: #0EA5E9;
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(14, 165, 233, 0.8);
    animation: pulseActiveRow 2s infinite;
}

@keyframes pulseActiveRow {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

.letter-tile {
    width: 50px;
    height: 50px;
    border: 2px solid var(--bs-border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: bold;
    text-transform: uppercase;
    background-color: transparent;
    transition: all 0.3s ease-in-out;
    cursor: move;
    border-radius: 8px;  /* Rounded corners like buttons */
    position: relative;  /* For colorblind symbols */
}

.letter-tile:not(:empty) {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);  /* Add shadow when tile has content */
    border: 1px solid var(--bs-border-color);  /* Match button border style */
    background-color: var(--bs-dark);  /* Dark background to match theme */
    color: var(--bs-light);  /* Light text color */
}

.letter-tile.letter-correct {
    background-color: #538d4e;
    border-color: #538d4e;
    color: white;
    box-shadow: 0 4px 6px rgba(83, 141, 78, 0.2);  /* Green-tinted shadow */
}

.letter-tile.letter-wrong-position {
    background-color: #c9b458;
    border-color: #c9b458;
    color: white;
    box-shadow: 0 4px 6px rgba(201, 180, 88, 0.2);  /* Yellow-tinted shadow */
}

.letter-tile.letter-incorrect {
    background-color: #2a2e38; /* Darker gray for better distinction */
    border-color: #444;
    color: #9a9a9a; /* Lighter/desaturated text color */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

/* Add a diagonal line overlay for incorrect letters */
.letter-tile.letter-incorrect::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: linear-gradient(135deg, 
        transparent 45%, 
        rgba(255, 255, 255, 0.1) 45%, 
        rgba(255, 255, 255, 0.1) 55%, 
        transparent 55%);
    pointer-events: none;
}

/* Slightly reduce opacity for incorrect tiles */
.letter-tile.letter-incorrect {
    opacity: 0.85;
}

#alphabet {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    margin-top: 10px;
    margin-bottom: 0px !important;
    width: 100%;
}

.keyboard-wrapper {
    display: grid;
    grid-template-rows: repeat(3, auto);
    gap: clamp(4px, 1vw, 8px);
    width: 100%;
    max-width: min(600px, 98vw);
    margin: 0 auto;
    padding: 0 clamp(2px, 1vw, 8px);
    box-sizing: border-box;
}

.alphabet-row {
    display: grid;
    gap: clamp(3px, 0.8vw, 8px);
    justify-content: center;
    width: 100%;
    margin-bottom: clamp(3px, 0.5vw, 6px);
}

/* First row - 10 letters */
.alphabet-row:nth-child(1) {
    grid-template-columns: repeat(10, minmax(32px, 48px));
    max-width: fit-content;
    justify-content: center;
}

/* Second row - 9 letters */
.alphabet-row:nth-child(2) {
    grid-template-columns: repeat(9, minmax(32px, 48px));
    max-width: fit-content;
    justify-content: center;
    margin: 0 auto clamp(3px, 0.5vw, 6px) auto;
}

/* Third row - 7 letters + 2 special buttons */
.alphabet-row:nth-child(3) {
    grid-template-columns: minmax(60px, 80px) repeat(7, minmax(32px, 48px)) minmax(60px, 80px);
    max-width: fit-content;
    justify-content: center;
}

/* Tablet optimizations - better space utilization */
@media (min-width: 577px) and (max-width: 1024px) {
    .game-container {
        gap: clamp(2.4rem, 6vw, 4rem);
        max-width: min(700px, 90vw);
    }
    
    #game-board {
        gap: clamp(6px, 1vw, 12px);
        margin-bottom: 1rem;
    }
    
    .word-row {
        gap: clamp(6px, 1.2vw, 10px);
        margin-bottom: clamp(3px, 0.5vw, 6px);
    }
    
    .letter-tile {
        width: clamp(45px, 6vw, 58px) !important;
        height: clamp(45px, 6vw, 58px) !important;
        font-size: clamp(20px, 3vw, 28px) !important;
    }
    
    .alphabet-row {
        gap: 6px !important;
    }
    
    .alphabet-row:nth-child(1) {
        grid-template-columns: repeat(10, clamp(38px, 5vw, 48px));
    }
    
    .alphabet-row:nth-child(2) {
        grid-template-columns: repeat(9, clamp(38px, 5vw, 48px));
    }
    
    .alphabet-row:nth-child(3) {
        grid-template-columns: clamp(65px, 8vw, 80px) repeat(7, clamp(38px, 5vw, 48px)) clamp(65px, 8vw, 80px);
    }
    
    .alphabet-letter {
        height: clamp(40px, 5vw, 50px) !important;
        font-size: clamp(16px, 2.5vw, 20px) !important;
    }
    
    /* Reduce excessive top spacing by adjusting header area */
    .header-content {
        margin-bottom: clamp(1rem, 2vw, 1.5rem);
    }
    
    .progress-track {
        margin-bottom: clamp(1rem, 2vw, 1.5rem);
        height: clamp(60px, 8vw, 80px);
    }
    
    /* Tablet-specific zoom adjustments */
    .zoom-small {
        transform: scale(0.85) !important;
    }
    
    .zoom-normal {
        transform: scale(1.1) !important;
    }
    
    .zoom-large {
        transform: scale(1.25) !important;
    }
    
    .zoom-extra-large {
        transform: scale(1.4) !important;
    }
    
    /* Ensure racetrack scales proportionally on tablets */
    .zoom-large .progress-track,
    .zoom-extra-large .progress-track {
        height: clamp(50px, 6vw, 70px);
        margin-bottom: clamp(0.8rem, 1.5vw, 1.2rem);
    }
    
    /* Adjust vertical spacing for larger zoom levels */
    .zoom-large .game-container,
    .zoom-extra-large .game-container {
        gap: clamp(0.6rem, 1.2vw, 1.2rem);
    }
}

/* Desktop/Laptop optimizations - tighter spacing */
@media (min-width: 1025px) {
    .alphabet-row {
        gap: 8px !important;
    }
    
    .alphabet-row:nth-child(1) {
        grid-template-columns: repeat(10, 45px);
    }
    
    .alphabet-row:nth-child(2) {
        grid-template-columns: repeat(9, 45px);
    }
    
    .alphabet-row:nth-child(3) {
        grid-template-columns: 75px repeat(7, 45px) 75px;
    }
}

/* Mobile keyboard optimizations - ensure rows stay intact */
@media (max-width: 576px) {
    /* Scale down the entire keyboard container */
    .keyboard-wrapper {
        width: 100%;
        margin: 0 auto;
        box-sizing: border-box;
    }
    
    /* Styles for the mobile-specific keyboard layout */
    .alphabet-row.mobile-row {
        width: 100%;
        display: flex;
        justify-content: center;
        flex-wrap: nowrap !important;
        margin-bottom: 4px;
    }
    
    /* Special styling for mobile keyboards */
    .mobile-row .alphabet-letter {
        min-width: 30px;
        height: 45px;
        max-width: 30px;
        flex: 0 0 auto;
        margin: 0 2px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        border-radius: 6px;
    }
    
    /* First row specific styling */
    .alphabet-row.mobile-row[data-row="1"] {
        max-width: 96%;
        margin: 0 auto 4px auto;
    }
    
    /* Second row specific styling */
    .alphabet-row.mobile-row[data-row="2"] {
        max-width: 90%;
        margin: 0 auto 4px auto;
    }
    
    /* Make special buttons smaller but still visible on mobile */
    .mobile-row .special-button {
        padding: 0 4px;
        font-size: 11px;
        height: 36px;
        max-width: 50px;
    }
    
    /* Adjust the game board for mobile */
    #game-board {
        transform: scale(0.95);
        margin-bottom: 10px;
    }
    
    /* Make letter tiles slightly smaller on mobile */
    .letter-tile {
        min-width: 40px;
        height: 40px;
        font-size: 20px;
    }
}

/* Wider second row with more letters */
.alphabet-row-wider {
    max-width: 95%;
    margin: 0 auto;
}

/* Desktop/laptop specific improvements - only affects larger screens */
@media (min-width: 768px) {
    /* Make tiles much closer to race track */
    #game-board {
        margin-top: -80px !important;
    }
    
    /* Also reduce any padding above the game board */
    .game-container {
        padding-top: 0px !important;
    }
}

.alphabet-letter {
    width: 48px;
    height: 48px;
    border: 2px solid var(--bs-border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.7rem;
    font-weight: bold;
    text-transform: uppercase;
    background-color: var(--bs-dark);
    color: var(--bs-light);
    transition: all 0.3s ease-in-out;
    cursor: pointer;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin: 2px;
    flex-shrink: 0; /* Prevent shrinking */
}

.alphabet-letter:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.2);
}

.alphabet-letter:active {
    transform: scale(0.95);
}

.alphabet-letter.dragging {
    opacity: 0.5;
    transform: scale(1.1);
}

.alphabet-letter.letter-correct {
    background-color: #538d4e;
    border-color: #538d4e;
    color: white;
    box-shadow: 0 4px 6px rgba(83, 141, 78, 0.2);
}

.alphabet-letter.letter-wrong-position {
    background-color: #c9b458;
    border-color: #c9b458;
    color: white;
    box-shadow: 0 4px 6px rgba(201, 180, 88, 0.2);
}

.alphabet-letter.letter-incorrect {
    background-color: #2a2e38; /* Darker gray for better distinction */
    border-color: #444;
    color: #9a9a9a; /* Lighter/desaturated text color */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

/* Add a diagonal line overlay for incorrect letters */
.alphabet-letter.letter-incorrect::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: linear-gradient(135deg, 
        transparent 45%, 
        rgba(255, 255, 255, 0.1) 45%, 
        rgba(255, 255, 255, 0.1) 55%, 
        transparent 55%);
    pointer-events: none;
}

/* Slightly reduce opacity for incorrect keys */
.alphabet-letter.letter-incorrect {
    opacity: 0.85;
}

.alert {
    transition: all 0.3s ease-in-out;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    min-width: 300px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.game-container {
    position: relative;
}

.shuffled-word {
    font-size: 2.5rem;
    letter-spacing: 0.5rem;
    font-weight: bold;
}

#guess-input {
    font-size: 1.5rem;
    text-transform: uppercase;
}

.stats {
    background-color: var(--bs-dark);
    padding: 1rem;
    border-radius: 0.5rem;
}

.alphabet-used {
    opacity: 0.5;
    background-color: var(--bs-secondary);
}

.letter-tile.selected {
    border-color: var(--bs-primary);
    border-width: 3px;
}

/* Race track - sleek design based on reference image */
.race-track {
    width: 100%;
    height: 90px; /* Increased height for larger car */
    background: #0A0A1E;
    border-radius: 45px; /* Adjusted to match new height */
    position: relative;
    margin: 10px 0;
    overflow: hidden;
    border: 2px solid #0EA5E9;
    box-shadow: 
        inset 0 0 20px rgba(0, 0, 0, 0.5),
        0 0 15px rgba(14, 165, 233, 0.6);
}

/* Glowing track inner border */
.race-track::before {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    border-radius: 40px;
    border: 1px solid rgba(14, 165, 233, 0.5);
    box-shadow: 0 0 10px rgba(14, 165, 233, 0.3);
    pointer-events: none;
    z-index: 1;
}

/* Track dashed lines */
.track-lines {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 3px;
    background: repeating-linear-gradient(
        90deg,
        #0EA5E9,
        #0EA5E9 12px, 
        transparent 12px,
        transparent 24px
    );
    transform: translateY(-50%);
    opacity: 0.8;
    z-index: 2;
}

/* Checkpoint styling */
.checkpoint {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    background: #0A0A1E;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 12px;
    border: 2px solid #0EA5E9;
    z-index: 5;
}

/* Activated checkpoint */
.checkpoint.reached {
    background: #0EA5E9;
    color: white;
    box-shadow: 0 0 10px 3px rgba(14, 165, 233, 0.7);
}

/* Checkpoint positions - evenly spaced */
.checkpoint-1 { left: 20%; }
.checkpoint-2 { left: 40%; }
.checkpoint-3 { left: 60%; }
.checkpoint-4 { left: 80%; }
.checkpoint.finish { 
    left: 90%; 
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
}

/* Mobile checkpoint positions */
@media (max-width: 576px) {
    /* More evenly spaced checkpoints */
    .checkpoint-1 { left: 20%; }
    .checkpoint-2 { left: 40%; }
    .checkpoint-3 { left: 60%; }
    .checkpoint-4 { left: 80%; }
    .checkpoint.finish { left: 95%; }
    
    /* Adjust car position for mobile */
    .car {
        width: 90px !important; /* Make car smaller on mobile */
    }
    
    /* Start position should be left edge */
    .car[style*="left: 0%"] {
        left: 0% !important;
    }
}
    
    /* Make checkpoint circles smaller */
    .checkpoint {
        width: 22px;
        height: 22px;
        font-size: 12px;
    }
    
    /* Adjust racetrack size */
    .race-track {
        height: 65px;
        margin-bottom: 10px;
    }
    
    /* Smaller finish flag */
    .checkpoint.finish img {
        width: 22px;
        height: 22px;
    }
}

/* Checkered flag */
.checkpoint.finish img {
    width: 28px;
    height: 28px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Car styling */
.car {
    position: absolute;
    left: 0%; /* Start at the very beginning of the track */
    top: 50%;
    transform: translateY(-50%);
    width: 160px; /* Increased width for larger sports car */
    height: 60px; /* Adjusted height to maintain aspect ratio */
    transition: left 1.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.8));
}

/* Style specifically for the car image */
.car img {
    object-fit: contain;
    width: 100%;
    height: 100%;
}

/* Car movement animation */
.car.moving {
    animation: carMove 1.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes carMove {
    0% { filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.8)); }
    50% { filter: drop-shadow(0 0 20px rgba(255, 255, 255, 1.0)); }
    100% { filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.8)); }
}

/* Particle effect for checkpoints */
.checkpoint-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #1E90FF;
    z-index: 15;
    pointer-events: none;
    box-shadow: 0 0 5px rgba(30, 144, 255, 0.8);
}
.special-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 10px;
    width: 100%;
    position: relative;
    text-align: center;
}

.special-button {
    height: 48px;
    font-size: 16px;
    padding: 0 15px;
    width: 100px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    color: white;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
    font-weight: bold;
    margin: 0 5px;
}

.special-button.enter {
    background-color: rgba(40, 167, 69, 0.35);
    border: 1px solid rgba(40, 167, 69, 0.8);
}

.special-button.enter:hover {
    background-color: rgba(40, 167, 69, 0.5);
    border-color: rgba(40, 167, 69, 0.9);
}

.special-button.delete {
    background-color: rgba(220, 53, 69, 0.35);
    border: 1px solid rgba(220, 53, 69, 0.8);
}

.special-button.delete:hover {
    background-color: rgba(220, 53, 69, 0.5);
    border-color: rgba(220, 53, 69, 0.9);
}

.special-button.hint {
    background-color: rgba(111, 66, 193, 0.35);
    border: 1px solid rgba(140, 104, 212, 0.8);
}

.special-button.hint:hover {
    background-color: rgba(111, 66, 193, 0.5);
    border-color: rgba(140, 104, 212, 0.9);
}

/* Row with special buttons (row 3) */
.row-with-special-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* Style special buttons to match the letters better */
.row-with-special-buttons .special-button {
    margin: 2px;
    border-radius: 4px;
    height: 40px;
    padding: 0 8px;
    min-width: 48px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Apply specific styles for Enter and Delete buttons */
.special-button.enter {
    margin-right: 8px;
}

.special-button.delete {
    margin-left: 8px;
}

/* Center the row 3 letters */
.row-with-special-buttons .alphabet-letter {
    flex: 0 0 auto;
}
/* Celebration styles */
.celebration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.firework {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: explode 1s ease-out forwards;
}

@keyframes explode {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(20);
        opacity: 0;
    }
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    animation: fall 3s linear forwards;
}

@keyframes fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
    }
}

.congrats-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2rem;
    border-radius: 1rem;
    text-align: center;
    z-index: 1001;
    font-size: 2rem;
    animation: fadeIn 0.5s ease-in;
}

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

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

/* Stats popup styling */
.stats-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.5s ease-in;
}

.stats-popup .stats-container {
    background: var(--bs-dark);
    padding: 2rem;
    border-radius: 1rem;
    max-width: 90%;
    width: 500px;
    margin: 1rem;
}

/* Animation for invalid word shake effect */
.invalid-word-shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
    100% { transform: translateX(0); }
}

/* Help button styles */
#help-button {
    font-size: 1rem;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
}

/* Colorblind mode toggle */
.colorblind-toggle {
    display: flex;
    align-items: center;
}

/* Custom Toggle Switch */
.colorblind-toggle-container {
    display: flex;
    align-items: center;
}

.custom-toggle-switch {
    position: relative;
    width: 50px;
    height: 24px;
}

.toggle-checkbox {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #333333;
    border: 2px solid white;
    border-radius: 24px;
    transition: .4s;
}

.toggle-button {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 1px;
    background-color: #00d4ff; /* Bright cyan blue slider button */
    border-radius: 50%;
    transition: .4s;
    box-shadow: 0 0 5px 2px rgba(0, 212, 255, 0.5);
}

.toggle-checkbox:checked + .toggle-slider {
    background-color: #0074D9; /* Blue background when checked */
    box-shadow: 0 0 5px rgba(0, 116, 217, 0.8);
}

.toggle-checkbox:checked + .toggle-slider .toggle-button {
    transform: translateX(24px);
    background-color: #00ff6a; /* Bright green when checked */
    box-shadow: 0 0 5px 2px rgba(0, 255, 106, 0.5);
}

.toggle-label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

/* Colorblind mode colors */
body.colorblind-mode .letter-correct, 
body.colorblind-mode .alphabet-letter.letter-correct,
.colorblind-mode .example-correct {
    background-color: #0074D9 !important; /* Blue instead of green */
    border-color: #0074D9 !important;
    color: white !important;
    position: relative;
}

body.colorblind-mode .letter-wrong-position,
body.colorblind-mode .alphabet-letter.letter-wrong-position,
.colorblind-mode .example-wrong-position {
    background-color: #FF851B !important; /* Orange instead of yellow */
    border-color: #FF851B !important;
    color: white !important;
    position: relative;
}

/* Add symbols for keyboard letters in colorblind mode */
body.colorblind-mode #alphabet .alphabet-letter.letter-correct::after {
    content: "✓";
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.7rem;
    z-index: 2;
    pointer-events: none;
}

body.colorblind-mode #alphabet .alphabet-letter.letter-wrong-position::after {
    content: "○";
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.7rem;
    z-index: 2;
    pointer-events: none;
}

body.colorblind-mode #alphabet .alphabet-letter.letter-incorrect::after {
    content: "✗";
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.7rem;
    z-index: 2;
    pointer-events: none;
}

/* Hide colorblind-only text by default and show in colorblind mode */
.colorblind-only {
    display: none;
    font-size: 0.9rem;
    font-style: italic;
    margin-left: 0.5rem;
    color: var(--bs-info);
}

body.colorblind-mode .colorblind-only,
.colorblind-mode .colorblind-only {
    display: inline-block;
}

/* Form-check-input (toggle) styling for Bootstrap 5 */
.form-check-input {
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.25) !important;
    border-color: rgba(255, 255, 255, 0.25) !important;
}

.form-check-input:checked {
    background-color: var(--bs-primary) !important;
    border-color: var(--bs-primary) !important;
}

/* Ensure colorblind toggle overrides other styles */
/* This selector is overridden by the one above */

/* Add symbols for colorblind mode - only for letter tiles in the game board */
body.colorblind-mode #game-board .letter-tile.letter-correct::after {
    content: "✓";
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.8rem;
    z-index: 2;
    pointer-events: none;
}

body.colorblind-mode #game-board .letter-tile.letter-wrong-position::after {
    content: "○";
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.8rem;
    z-index: 2;
    pointer-events: none;
}

body.colorblind-mode #game-board .letter-tile.letter-incorrect::after {
    content: "✗";
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.8rem;
    z-index: 2;
    pointer-events: none;
}

/* Modal example tiles */
.example-tile {
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bs-border-color);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    color: white;
    font-weight: bold;
}

.example-correct {
    background-color: #538d4e;
    border-color: #538d4e;
}

.example-wrong-position {
    background-color: #c9b458;
    border-color: #c9b458;
}

.example-incorrect {
    background-color: #2a2e38; /* Darker gray for better distinction */
    border-color: #444;
    color: #9a9a9a; /* Lighter/desaturated text color */
    position: relative;
    overflow: hidden;
}

/* Add a diagonal line overlay for incorrect example tiles */
.example-incorrect::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: linear-gradient(135deg, 
        transparent 45%, 
        rgba(255, 255, 255, 0.1) 45%, 
        rgba(255, 255, 255, 0.1) 55%, 
        transparent 55%);
    pointer-events: none;
}

/* Make sure modal content is readable with dark theme */
.modal-content {
    border: 1px solid var(--bs-border-color);
}

.modal-header, .modal-footer {
    border-color: var(--bs-border-color);
}

.list-group-item {
    background-color: transparent;
    border-color: var(--bs-border-color);
}

/* Colorblind symbols in help modal */
.cb-symbol {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.7rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.colorblind-mode .cb-symbol {
    opacity: 1;
}

/* Responsive styles */
.game-title {
    font-size: 2rem;
    margin: 0;
}

.small-screen-text {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

/* Responsive tile sizes for small screens */
.small-screen .letter-tile {
    width: 50px;
    height: 50px;
    font-size: 1.75rem;
}

.small-screen .alphabet-letter {
    width: 48px;
    height: 48px;
    font-size: 1.6rem;
    margin: 2px;
}

.small-screen .race-track {
    height: 60px;
}

.small-screen .car {
    width: 120px;
    height: 48px;
}

.small-screen .car img {
    object-fit: contain;
}

.small-screen .checkpoint {
    width: 25px;
    height: 25px;
    font-size: 0.9rem;
}

.small-screen .game-title {
    font-size: 1.75rem;
}

.small-screen header {
    margin-bottom: 0.5rem !important;
}

.small-screen .mb-md-3, 
.small-screen .mb-3 {
    margin-bottom: 0.5rem !important;
}

/* Even smaller screens */
.very-small-screen .letter-tile {
    width: 42px;
    height: 42px;
    font-size: 1.4rem;
}

.very-small-screen .alphabet-letter {
    width: 42px;
    height: 42px;
    font-size: 1.3rem;
    margin: 2px;
}

.very-small-screen .alphabet-row-wider .alphabet-letter {
    width: 38px;
    height: 38px;
    font-size: 1.2rem;
    margin: 1px;
}

/* Fix for iPhone keyboard layout */
@media screen and (max-width: 375px) {
    .keyboard-wrapper {
        max-width: 100%;
        margin: 0 auto;
    }
    
    .alphabet-row {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        margin-bottom: 4px;
    }
    
    /* Ensure QWERTY layout is maintained */
    .alphabet-letter {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
        margin: 2px;
    }
    
    .special-button {
        height: 36px;
        min-width: 55px;
        font-size: 0.9rem;
        padding: 0 8px;
    }
}

.very-small-screen .race-track {
    height: 45px;
}

.very-small-screen .car {
    width: 110px;
    height: 44px;
}

.very-small-screen .car img {
    object-fit: contain;
}

.very-small-screen .checkpoint {
    width: 18px;
    height: 18px;
    font-size: 0.75rem;
}

.very-small-screen .game-title {
    font-size: 1.4rem;
}

.very-small-screen header {
    margin-bottom: 0.25rem !important;
}

.very-small-screen .small-screen-text {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.very-small-screen .mb-md-3, 
.very-small-screen .mb-3, 
.very-small-screen .mb-2,
.very-small-screen #game-board {
    margin-bottom: 0.25rem !important;
}

.very-small-screen .special-button {
    height: 40px;
    padding: 0 8px;
    font-size: 12px;
}

/* Small width screens */
@media (max-width: 575px) {
    .letter-tile {
        width: 45px;
        height: 45px;
        font-size: 1.5rem;
    }
    
    .alphabet-letter {
        width: 40px;
        height: 40px;
        font-size: 1.3rem;
        margin: 2px;
    }
    
    .alphabet-row-wider .alphabet-letter {
        width: 38px;
        height: 38px;
        font-size: 1.2rem;
    }
    
    /* Ensure the special buttons are properly sized on mobile */
    .special-button {
        height: 45px;
        width: 80px;
        font-size: 14px;
        padding: 0 10px;
        margin-top: 5px;
    }
    
    /* Improve spacing between rows */
    .alphabet-row {
        margin-bottom: 5px;
    }
}

/* Full viewport height game container */
.game-wrapper {
    height: 100vh;
    width: 100%;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.game-wrapper .container {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    overflow-y: auto;
    max-height: 100vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

@media (min-height: 700px) {
    .game-wrapper .container {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }
}

/* Hide scrollbar for cleaner appearance */
.game-wrapper .container::-webkit-scrollbar {
    width: 0.5rem;
}

.game-wrapper .container::-webkit-scrollbar-track {
    background: transparent;
}

.game-wrapper .container::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
}

/* Make sure the board is centered and fits screen */
.game-container {
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1 0 auto;
}

/* Add spacing between race track and game board */
.race-track {
    margin-bottom: 1rem;
}

/* Adjust the spacing depending on screen size */
.small-screen .race-track {
    margin-bottom: 0.75rem;
}

.very-small-screen .race-track {
    margin-bottom: 0.5rem;
}

/* Add box-sizing to all elements */
* {
    box-sizing: border-box;
}

/* Ensure bottom of screen is visible */
#alphabet {
    margin-bottom: 5px !important;
    padding-bottom: 0;
}

/* Improve layout stacking on smaller screens */
@media (max-height: 600px) {
    header {
        margin-bottom: 0 !important;
    }
    
    .race-track {
        margin-bottom: 0.25rem;
    }
    
    #game-board {
        margin-bottom: 0.25rem !important;
    }
    
    .alphabet-row {
        gap: 3px;
    }
    
    .row-tile {
        gap: 5px;
    }
}

/* Ultra compact mode for very small screens */
.ultra-compact .letter-tile {
    width: 35px;
    height: 35px;
    font-size: 1.1rem;
    margin: 0;
}

.ultra-compact .alphabet-letter {
    width: 34px;
    height: 34px;
    font-size: 1rem;
    margin: 1px;
}

.ultra-compact .alphabet-row-wider .alphabet-letter {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
    margin: 1px;
}

.ultra-compact .race-track {
    height: 35px;
    margin-bottom: 0.2rem !important;
}

.ultra-compact .car {
    width: 90px;
    height: 36px;
}

.ultra-compact .car img {
    object-fit: contain;
}

.ultra-compact .checkpoint {
    width: 14px;
    height: 14px;
    font-size: 0.65rem;
}

.ultra-compact .game-title {
    font-size: 1.1rem;
    margin: 0 !important;
}

.ultra-compact header {
    margin-bottom: 0 !important;
    padding: 0 !important;
}

.ultra-compact .small-screen-text {
    display: none; /* Hide descriptive text to save vertical space */
}

.ultra-compact .special-button {
    height: 32px;
    padding: 0 5px;
    font-size: 10px;
    width: 60px;
    margin: 0;
}

.ultra-compact .special-buttons {
    margin-top: 5px;
    gap: 5px;
    width: 100%;
    display: flex;
    justify-content: center;
}

.ultra-compact .alphabet-row {
    gap: 2px;
    margin-bottom: 2px;
}

.ultra-compact .row-tile {
    gap: 3px;
}

.ultra-compact #game-board {
    margin-bottom: 0 !important;
    gap: 3px;
}

.ultra-compact .word-row {
    margin-bottom: 1px;
}

.ultra-compact .d-flex.justify-content-between {
    margin-bottom: 0.1rem !important;
}

/* Very narrow screen adjustments */
.narrow-screen .d-flex.justify-content-between {
    flex-wrap: wrap;
    justify-content: center !important;
}

.narrow-screen .game-title {
    order: -1;
    width: 100%;
    text-align: center;
    margin-bottom: 0.5rem;
}

.narrow-screen .colorblind-toggle,
.narrow-screen #help-button {
    margin: 0 0.5rem;
}

.narrow-screen .alphabet-row {
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
}

.narrow-screen .alphabet-letter {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
    margin: 1px;
}
