body {
    font-family: 'Inter', sans-serif;
    touch-action: none; 
    overscroll-behavior-y: contain; 
}

/* New Initial Loading Screen Styles */
#initialLoadingScreen {
    /* Uses fixed positioning and inset-0 from Tailwind in HTML */
    transition: opacity 0.5s ease-out;
}

.loading-spinner.white-spinner {
    border-top-color: white;
}

.car {
    position: absolute;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2), inset 0 0 0 1px rgba(255,255,255,0.1); 
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.3);
    cursor: grab;
    transition: transform 0.1s ease-out, left 0.1s ease-out, top 0.1s ease-out; 
    border-radius: 4px; 
    /* The JavaScript calculates width/height like `cellSize - 4px` and position with `+2px`, effectively creating a 2px margin. */
    /* No explicit CSS margin needed here as JS handles the sizing for gaps. */
}
.car.dragging {
    opacity: 0.85; 
    z-index: 1000;
    cursor: grabbing;
    transition: none; 
    box-shadow: 0 4px 8px rgba(0,0,0,0.3), inset 0 0 0 1px rgba(255,255,255,0.1); 
}
.car.red-car {
    background: linear-gradient(135deg, #FF0000, #DC2626, #FF4444, #DC2626);
    background-size: 300% 300%;
    z-index: 10;
    border: 2px solid #F87171;
    box-shadow: 0 3px 6px rgba(0,0,0,0.25),
                inset 0 1px 1px rgba(255,255,255,0.5),
                inset 0 -1px 1px rgba(0,0,0,0.1),
                0 0 20px rgba(255, 0, 0, 0.4);
    animation: shimmer 4s infinite ease-in-out, glow 2s infinite alternate;
}

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

@keyframes glow {
    from {
        box-shadow: 0 3px 6px rgba(0,0,0,0.25),
                    inset 0 1px 1px rgba(255,255,255,0.5),
                    inset 0 -1px 1px rgba(0,0,0,0.1),
                    0 0 20px rgba(255, 0, 0, 0.4);
    }
    to {
        box-shadow: 0 3px 6px rgba(0,0,0,0.25),
                    inset 0 1px 1px rgba(255,255,255,0.5),
                    inset 0 -1px 1px rgba(0,0,0,0.1),
                    0 0 35px rgba(255, 0, 0, 0.6);
    }
}

.game-board-container {
    position: relative;
    width: 90vw; 
    height: 90vw; 
    max-width: 420px; 
    max-height: 420px;
    margin: auto; 
    background-color: #9CA3AF; 
    border-radius: 10px; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    /* Set initial opacity to 1, control visibility with the loading overlay */
    opacity: 1;
}

.game-board-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(156, 163, 175, 0.9);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 500;
    z-index: 20;
    opacity: 1;
    transition: opacity 0.3s ease-out;
}

.game-board-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.game-board {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(6, 1fr);
    width: 100%;
    height: 100%;
    background-color: #E5E7EB; 
    border: 1px solid #9CA3AF; 
    border-radius: 6px; 
    position: relative; /* This is important for car positioning */
    opacity: 0; /* Start as transparent */
    transition: opacity 0.4s ease-out; /* Add transition */
}

.grid-cell {
    background-color: #F3F4F6; 
    border-radius: 0px; 
    border: 1px solid #D1D5DB; 
    box-sizing: border-box; 
}
.exit-lane {
    position: absolute;
    background-image: linear-gradient(to right, rgba(76, 175, 80, 0.3), rgba(100, 200, 100, 0.5));
    pointer-events: none; 
    border-radius: 0 4px 4px 0; 
    border: 1px solid rgba(34, 139, 34, 0.4); 
    border-left: 2px dashed rgba(255, 255, 255, 0.6); 
    box-sizing: border-box; 
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.exit-lane::after {
    content: '→';
    font-size: 1.2em;
    color: rgba(255, 255, 255, 0.7);
    opacity: 0.8;
    line-height: 1;
}

.exit-lane.visible {
    opacity: 1;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000; 
    padding: 1rem; 
    overflow-y: auto;
}
.modal-content {
    background-color: white;
    padding: 1.5rem; 
    border-radius: 0.5rem;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 450px;
    min-width: 0;
    margin: auto;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}
#leaderboardModal .modal-content {
    max-width: 550px;
    min-width: 0;
    width: 100%;
    text-align: left;
    box-sizing: border-box;
}

.btn {
    padding: 0.65rem 1.25rem; 
    border-radius: 0.375rem; 
    font-weight: 600; 
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s; 
    margin: 0.25rem; 
    border: none; 
    display: inline-flex; 
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
}
.btn:disabled { 
    opacity: 0.6;
    cursor: not-allowed;
}
.btn:active:not(:disabled) { 
    transform: scale(0.98);
}
.btn:focus { 
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4); 
}


.btn-primary {
    background-color: #3B82F6; 
    color: white;
}
.btn-primary:hover:not(:disabled) {
    background-color: #2563EB; 
}
.btn-secondary {
    background-color: #6B7280; 
    color: white;
}
.btn-secondary:hover:not(:disabled) {
    background-color: #4B5563; 
}
.btn-danger {
    background-color: #EF4444; 
    color: white;
}
.btn-danger:hover:not(:disabled) {
    background-color: #DC2626; 
}
.btn-success {
    background-color: #10B981; 
    color: white;
}
.btn-success:hover:not(:disabled) {
    background-color: #059669; 
}
.btn-warning {
    background-color: #F59E0B; /* amber-500 */
    color: white;
}
.btn-warning:hover:not(:disabled) {
    background-color: #D97706; /* amber-600 */
}
.btn-neutral {
    background-color: #E5E7EB; /* gray-200 */
    color: #374151; /* gray-700 */
}
.btn-neutral:hover:not(:disabled) {
    background-color: #D1D5DB; /* gray-300 */
}

/* New size modifier */
.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}


.difficulty-button {
    background-color: #10B981; 
    color: white;
    margin: 0.5rem;
    padding: 0.8rem 1.3rem; 
    font-size: 1rem; 
    border-radius: 0.5rem; 
}
.difficulty-button:hover:not(:disabled) {
    background-color: #059669; 
}

.btn-special, .bangkok-difficulty { 
    background-color: #7C2D12; 
    color: white;
    font-weight: 700;
    border: 2px solid #9A3412; 
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-special:hover:not(:disabled), .bangkok-difficulty:hover:not(:disabled) {
    background-color: #9A3412; 
    transform: scale(1.03);
    transition: all 0.2s ease-in-out;
}

.bangkok-difficulty { 
    animation: pulse 2.5s infinite;
}


@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(154, 52, 18, 0.5), 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); 
    }
    70% {
        box-shadow: 0 0 0 12px rgba(154, 52, 18, 0), 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(154, 52, 18, 0), 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    }
}

/* Confetti styles */
.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    opacity: 0;
    animation: fall 3.5s ease-out forwards; 
}

@keyframes fall {
    0% { transform: translateY(-30px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* Leaderboard specific styles */
#leaderboardDisplay {
    flex: 1;
    min-height: 0;
    overflow: visible;
    width: 100%;
    box-sizing: border-box;
    padding-bottom: 0.5rem;
}

#leaderboardDisplay table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background-color: white;
    border-radius: 0.5rem;
    overflow: visible;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    min-width: 320px;
    table-layout: auto;
}

#leaderboardDisplay th, #leaderboardDisplay td {
    padding: 0.75rem 0.5rem;
    text-align: left;
    white-space: nowrap;
    min-width: 60px;
}
#leaderboardDisplay th.name, #leaderboardDisplay td.name {
    min-width: 100px;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#leaderboardDisplay th.time, #leaderboardDisplay td.time,
#leaderboardDisplay th.moves, #leaderboardDisplay td.moves {
    text-align: right;
    min-width: 60px;
}

#leaderboardDisplay .mb-6 {
    margin-bottom: 1.5rem !important;
}
#leaderboardModal .mt-6 {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #E5E7EB;
}

.leaderboard-header-optimal {
    display: block;
    margin-top: 0.2em;
    font-size: 0.95em;
}
.modal-content .material-icons {
    font-size: 1.2em;
    vertical-align: middle;
    margin-right: 0.2em;
}

@media (max-width: 480px) {
    #leaderboardDisplay table {
        font-size: 0.82rem;
    }
    #leaderboardDisplay th, #leaderboardDisplay td {
        padding: 0.4rem 0.2rem;
        min-width: 48px;
    }
    #leaderboardDisplay th.name, #leaderboardDisplay td.name {
        min-width: 70px;
        max-width: 110px;
    }
    .leaderboard-header-optimal {
        font-size: 0.85em;
    }
    .modal-content .material-icons {
        font-size: 1em;
    }
    #leaderboardModal .mt-6 {
        margin-top: 1rem;
        padding-top: 0.5rem;
    }
}

#leaderboardDisplay .overflow-x-auto {
    overflow-x: auto;
    overflow-y: visible;
    width: 100%;
    box-sizing: border-box;
}

@media (max-height: 700px) {
    .modal-content {
        padding: 1rem;
    }
    
    #leaderboardDisplay .mb-6 {
        margin-bottom: 1rem !important;
    }
    
    #leaderboardDisplay table {
        font-size: 0.85rem;
    }
    
    #leaderboardDisplay th,
    #leaderboardDisplay td {
        padding: 0.5rem 0.75rem;
    }
}

@media (max-height: 600px) {
    .modal-content {
        padding: 0.75rem;
    }
    
    #leaderboardDisplay .mb-6 {
        margin-bottom: 0.75rem !important;
    }
    
    #leaderboardDisplay table {
        font-size: 0.8rem;
    }
    
    #leaderboardDisplay th,
    #leaderboardDisplay td {
        padding: 0.4rem 0.6rem;
    }
}

#leaderboardDisplay th {
    background-color: #F3F4F6;
    font-weight: 600;
    white-space: nowrap;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid #E5E7EB;
    color: #4B5563;
}

#leaderboardDisplay td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #E5E7EB;
    color: #374151;
}

#leaderboardDisplay tr:last-child td {
    border-bottom: none;
}

#leaderboardDisplay tr:hover td {
    background-color: #F9FAFB;
}

#leaderboardDisplay .rank {
    width: 10%;
    text-align: center;
    font-weight: 600;
    color: #6B7280;
}

#leaderboardDisplay .name {
    width: 50%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

#leaderboardDisplay .time,
#leaderboardDisplay .moves {
    width: 20%;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

#leaderboardDisplay .time.best-score,
#leaderboardDisplay .moves.best-score {
    color: #059669; /* Tailwind green-600 */
    font-weight: 600;
}

.btn-small { 
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem; 
    font-weight: 500; 
}
.btn-sort-active {
    background-color: #3B82F6 !important; 
    color: white !important;
    pointer-events: none; 
}

#leaderboardModal .flex > .btn:not(.btn-sort-active) {
    background-color: #E5E7EB; 
    color: #374151; 
}
#leaderboardModal .flex > .btn:not(.btn-sort-active):hover:not(:disabled) {
    background-color: #D1D5DB; 
}

.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.2s ease;
}

.sortable:hover {
    background-color: #E5E7EB;
}

.sortable::after {
    content: '↕';
    font-size: 0.8em;
    margin-left: 4px;
    opacity: 0.5;
    display: inline-block;
    transition: transform 0.2s ease;
}

.sortable[data-sort-direction="asc"]::after {
    content: '↑';
    opacity: 1;
    color: #3B82F6;
}

.sortable[data-sort-direction="desc"]::after {
    content: '↓';
    opacity: 1;
    color: #3B82F6;
}

.sortable:hover::after {
    opacity: 0.8;
}

.modal-content {
    max-height: 90vh; 
    overflow-y: auto; 
}

.modal-content.bg-red-100 { 
    background-color: #FEE2E2; 
    border: 1px solid #F87171; 
}
.modal-content.bg-red-100 h2 {
    color: #B91C1C; 
}
.modal-content.bg-red-100 p {
    color: #991B1B; 
}
.modal-content.bg-red-100 .btn-danger { 
    background-color: #DC2626; 
    color: white;
}
.modal-content.bg-red-100 .btn-danger:hover:not(:disabled) {
    background-color: #B91C1C; 
}

.material-icons {
    font-size: 1.125rem;
    opacity: 0.8;
    vertical-align: middle;
}

#bestTime, #solvedCount {
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

#bestTime.updating, #solvedCount.updating {
    color: #3B82F6;
    animation: subtlePulse 0.3s ease-out;
}

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

@media (max-width: 640px) {
    .material-icons {
        font-size: 1rem;
    }
    #bestTime, #solvedCount {
        font-size: 0.8125rem;
    }
}

.stat-group {
    position: relative;
    cursor: help;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.stat-group:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.stat-group::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.stat-group::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.8);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    pointer-events: none;
}

.stat-group.show-tooltip::after,
.stat-group.show-tooltip::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}

.stat-icon, .stat-value {
    pointer-events: none;
}

@media (max-width: 640px) {
    .stat-group::after {
        font-size: 0.8125rem;
        padding: 6px 10px;
        max-width: 200px;
        white-space: normal;
        text-align: center;
    }
}

#leaderboardDisplay .mb-6 {
    margin-bottom: 0.75rem !important;
}
#leaderboardDisplay .p-4 {
    padding: 0.75rem 1rem !important;
}
/* #leaderboardDisplay .leaderboard-header-date {
    font-size: inherit !important;
    color: inherit !important;
    font-weight: inherit !important;
    margin: 0 !important;
    padding: 0 !important;
    display: none !important;
} */
/* #leaderboardDisplay .leaderboard-header-optimal {
    font-size: 0.78rem !important;
    color: #2563eb;
    font-weight: 400;
    margin: 0.1em 0 0 0;
    padding: 0;
    display: block;
    line-height: 1.2;
} */
#leaderboardDisplay .flex.items-center.space-x-3 > .material-icons {
    font-size: 1.1em;
}
#leaderboardDisplay .rounded-lg {
    border-radius: 0.6rem !important;
}
#leaderboardDisplay .border {
    border-width: 1px !important;
}
#leaderboardDisplay .shadow-sm {
    box-shadow: 0 1px 2px rgba(0,0,0,0.04) !important;
}
#leaderboardDisplay .flex.items-center.justify-between {
    gap: 0.5rem;
}

/* @media (max-width: 700px) {
    .modal-content, #leaderboardModal .modal-content {
        max-width: 95vw;
        width: 100vw;
        min-width: 0;
        padding: 1rem 0.5rem;
    }
}

@media (max-width: 480px) {
    .modal-content, #leaderboardModal .modal-content {
        max-width: 100vw;
        width: 100vw;
        padding: 0.5rem 0.2rem;
        border-radius: 0.25rem;
    }
} */

#leaderboardModal .modal-content h2 {
    text-align: center;
}
#leaderboardDate {
    text-align: center;
    display: block;
    width: 100%;
}

.loading-spinner.purple-spinner {
    width: 32px;
    height: 32px;
    border: 4px solid rgba(167, 139, 250, 0.3); /* purple-400 opacity 30% */
    border-top-color: #8B5CF6; /* purple-500 */
}

/* Battle Mode Tab Styles */
.battle-tab-button {
    transition: all 0.2s ease;
    background-color: transparent;
    color: #6B7280; /* gray-500 */
    border: 1px solid #D1D5DB; /* gray-300 */
    font-weight: 500;
    position: relative;
    z-index: 1;
}

.battle-tab-button:first-child {
    border-right: none;
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

.battle-tab-button:last-child {
    border-left: none;
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

.battle-tab-button.active {
    background-color: #8B5CF6; /* purple-500 */
    color: white;
    border-color: #7C3AED; /* purple-600 */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.battle-tab-button:not(.active):hover {
    background-color: #F9FAFB; /* gray-50 */
    color: #4B5563; /* gray-600 */
}

/* Add a container style for the tab group */
.battle-tab-group {
    display: flex;
    background-color: #F3F4F6; /* gray-100 */
    padding: 0.25rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Update the battle tab content styles */
#battleCreateTabContent,
#battleJoinTabContent {
    margin-top: 1rem;
}

#battleCreateTabContent button,
#battleJoinTabContent button {
    margin-top: 0.5rem;
}

/* Opponent Progress Styles */
#opponentProgressDisplay details[open] summary .material-icons { 
    transform: rotate(180deg); 
}

.opponent-progress-item {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    font-size: 0.8rem; 
    padding: 0.3rem 0.5rem;
    background-color: #f9fafb; 
    border-radius: 0.25rem; 
    margin-bottom: 0.2rem;
}

.opponent-activity-indicator {
    width: 8px; 
    height: 8px; 
    background-color: #9CA3AF; /* gray-400 */
    border-radius: 50%; 
    margin-left: 5px; 
    display: inline-block;
    transition: background-color 0.3s;
}

.opponent-activity-indicator.active {
    background-color: #34D399; /* emerald-400 */
    animation: pulseGreen 1.2s infinite ease-in-out;
}

@keyframes pulseGreen {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1); 
    }
    50% { 
        opacity: 0.6; 
        transform: scale(0.8); 
    }
}

/* Battle Results Modal Styles */
.ranking-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-radius: 0.375rem;
    border-width: 1px;
    font-weight: 500;
}
.ranking-item.rank-1 {
    background-color: #FEF9C3; /* yellow-100 */
    border-color: #FACC15; /* yellow-400 */
    color: #A16207; /* yellow-700 */
    box-shadow: 0 0 15px rgba(250, 204, 21, 0.5);
    transform: scale(1.02);
}
.ranking-item.rank-2 {
    background-color: #E5E7EB; /* gray-200 */
    border-color: #9CA3AF; /* gray-400 */
    color: #374151; /* gray-700 */
}
.ranking-item.rank-3 {
    background-color: #FDE68A; /* A warmer, bronze-like yellow */
    border-color: #D97706; /* amber-600 */
    color: #92400E; /* amber-800 */
}
.ranking-item .rank-dnf {
    color: #9CA3AF; /* gray-400 */
    font-style: italic;
}

/* Leaderboard Section Containers */
.leaderboard-section {
    background: #f8fafc;
    border-radius: 0.75rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    border: 1px solid #e5e7eb;
}

.leaderboard-header-date {
    font-size: 1.1em;
    color: #2563eb;
    font-weight: 600;
    margin-bottom: 0.2em;
    display: block;
}

.leaderboard-header-optimal {
    font-size: 0.98em;
    color: #059669;
    font-weight: 500;
    margin: 0.1em 0 0.5em 0;
    display: block;
    line-height: 1.2;
}

/* Badge styles for Fastest/Least Moves */
.badge {
    display: inline-block;
    padding: 0.15em 0.7em;
    font-size: 0.85em;
    font-weight: 600;
    border-radius: 999px;
    background: #e0e7ff;
    color: #3730a3;
    margin-left: 0.3em;
    margin-right: 0.1em;
    vertical-align: middle;
}
.badge-fastest {
    background: #dbeafe;
    color: #2563eb;
}
.badge-least-moves {
    background: #d1fae5;
    color: #059669;
}

/* --- Custom Radio Button Styles (App-wide) --- */
.radio-group {
  display: flex;
  flex-direction: row;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.radio-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  color: #4B5563; /* gray-700 */
  gap: 0.5rem;
  transition: color 0.2s;
}
.radio-label:hover,
.radio-label:focus-within {
  color: #8B5CF6; /* purple-500 */
}
input[type="radio"].custom-radio {
  appearance: none;
  width: 1.15em;
  height: 1.15em;
  border: 2px solid #C4B5FD; /* purple-300 */
  border-radius: 50%;
  background: #fff;
  margin: 0;
  display: inline-block;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  box-shadow: 0 1px 2px rgba(139, 92, 246, 0.05);
}
input[type="radio"].custom-radio:checked {
  border-color: #8B5CF6; /* purple-500 */
  background: radial-gradient(circle at center, #8B5CF6 55%, #fff 60%);
}
input[type="radio"].custom-radio:focus {
  border-color: #7C3AED; /* purple-600 */
  box-shadow: 0 0 0 2px #DDD6FE;
}

/* --- Card/Panel Style for Host Controls (Reusable) --- */
.card {
  background: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: 0.75rem;
  box-shadow: 0 1px 4px rgba(139,92,246,0.04);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

/* --- Improve section label for radio groups --- */
.radio-group-label {
  font-size: 1.05rem;
  font-weight: 600;
  color: #7C3AED;
  margin-bottom: 0.5rem;
  display: block;
}