      :root {
            --board-bg: #121213;
            --cell-bg: #3A3A3C;
            --text-color: #FFFFFF;
            --subtle-text-color: #d7dadc;
            --border-color: #2d2d2f;
            --panel-bg: #222;
            --modal-bg: #272729;
            --highlight-green: #538d4e;
            --highlight-yellow: #b59f3b;
            --highlight-blue: #4a90e2;
            --font-family: 'Roboto Mono', monospace;
            --cb-green: #f5793a; /* Orange for colorblind mode */
            --cb-yellow: #85c0f9; /* Light Blue for colorblind mode */
            --cb-blue: #009e73;  /* Teal for colorblind mode */
        }

        body.light-mode {
            --board-bg: #ffffff;
            --cell-bg: #e0e0e0;
            --text-color: #121213;
            --subtle-text-color: #555555;
            --border-color: #cccccc;
            --panel-bg: #f0f0f0;
            --modal-bg: #f5f5f5;
        }

        body.colorblind-mode {
            --highlight-green: var(--cb-green);
            --highlight-yellow: var(--cb-yellow);
            --highlight-blue: var(--cb-blue);
        }

        * {
            box-sizing: border-box;
        }

        body {
            background-color: var(--board-bg);
            color: var(--text-color);
            font-family: var(--font-family);
            margin: 0;
            padding: 15px;
            text-align: center;
            transition: background-color 0.3s, color 0.3s;
        }

        #game-container {
            width: 100%;
            max-width: 500px;
            margin: 0 auto;
            display: flex;
            flex-direction: column;
            align-items: center;
            position: relative;
        }

		header {
			width: 100%;
			text-align: center;
		}
		
		.header-top-row {
			display: flex;
			justify-content: space-between; /* Pushes title left, buttons right */
			align-items: center;            /* Vertically aligns them */
			padding-bottom: 10px;           /* Space above the subtitle */
			border-bottom: 1px solid var(--cell-bg); /* Moves the line here */
		}
        
		header h1 {
			font-size: 2.2rem;
			margin: 0;
			padding: 0;
			white-space: nowrap;

		}

		header p {
			color: var(--subtle-text-color);
			font-size: 0.9rem;
			margin-top: 10px;
		}
		#puzzle-date {
			margin-top: 5px; /* Moves it closer to the line above */
			letter-spacing: 1px; /* Adds a little space between letters */
			margin-bottom: 5px;
		}

		#settings-bar {
			display: flex;
			gap: 15px;
		}
        
        #colorblind-toggle, #show-tutorial-btn, #theme-toggle {
             background-color: transparent;
            border: 1px solid var(--cell-bg);
            border-radius: 50%;
            width: 36px;
            height: 36px;
            padding: 0;
            display: inline-flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            transition: background-color 0.2s;
        }
        #colorblind-toggle.active {
            background-color: var(--highlight-blue);
            border-color: var(--highlight-blue);
        }
        #colorblind-toggle.active svg {
            stroke: var(--board-bg);
        }
        #colorblind-toggle svg, #show-tutorial-btn svg, #theme-toggle svg {
            width: 20px;
            height: 20px;
            stroke: var(--highlight-blue);
        }
        #hint-btn svg {
            width: 20px;
            height: 20px;
            stroke: var(--highlight-yellow);
        }
        #hint-btn.active {
            background-color: var(--highlight-yellow);
        }
        #hint-btn.active svg {
            stroke: var(--board-bg);
        }

        #info-panel {
            display: flex;
            justify-content: space-around;
            align-items: center;
            margin: 20px 0;
            padding: 10px;
            background-color: var(--panel-bg);
            border-radius: 8px;
            flex-wrap: wrap;
            gap: 15px;
            width: 100%;
            max-width: 500px;
        }

        #info-panel > div {
            flex: 1 1 60px;
            text-align: center;
        }

        #info-panel span {
            font-size: 0.8rem;
            color: var(--subtle-text-color);
            display: block;
        }
        
        #info-panel p {
            font-size: 1.5rem;
            font-weight: bold;
            margin: 5px 0 0 0;
        }

        #letter-queue {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 8px;
            margin-top: 5px;
        }

        .letter-display {
            width: 40px;
            height: 40px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 1.8rem;
            font-weight: bold;
            border-radius: 4px;
            background-color: var(--highlight-yellow);
            color: #FFFFFF;
        }
        
        body.light-mode .letter-display {
            color: #121213;
        }

        .letter-display.small {
            width: 30px;
            height: 30px;
            font-size: 1.4rem;
            background-color: #555;
            opacity: 0.8;
        }

        .letter-display.smaller {
            width: 25px;
            height: 25px;
            font-size: 1.1rem;
            background-color: #444;
            opacity: 0.6;
        }

        #hint-display-area {
            background-color: var(--panel-bg);
            padding: 10px;
            border-radius: 8px;
            margin: 10px auto 0 auto;
            width: 100%;
            max-width: 300px;
            font-size: 0.9rem;
        }
        #hint-display-area p {
            margin: 4px 0;
            color: var(--subtle-text-color);
        }
        
        #matrix-container {
            max-width: 420px;
            width: 100%;
            margin: 5px auto 5px auto;
        }

        #matrix-container, .comparison-grid {
            position: relative;
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            gap: 5px;
        }

        .matrix-cell {
            width: 100%;
            aspect-ratio: 1 / 1;
            background-color: var(--cell-bg);
            border: 2px solid var(--border-color);
            border-radius: 4px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: clamp(1rem, 6vw, 2rem);
            font-weight: bold;
            text-transform: uppercase;
            cursor: pointer;
            transition: all 0.2s ease;
            position: relative;
            z-index: 1;
        }
        
        .matrix-cell.selected {
            border-color: var(--highlight-blue);
            box-shadow: 0 0 10px var(--highlight-blue);
        }

        .matrix-cell.pop {
            animation: pop 0.3s ease-out;
        }

        @keyframes pop {
            0% { transform: scale(1); }
            50% { transform: scale(1.2); }
            100% { transform: scale(1); }
        }

        .comparison-grid .matrix-cell {
            font-size: clamp(0.5rem, 4vw, 1.2rem);
            cursor: default;
        }

        .matrix-cell.filled {
            border-color: #565758;
            cursor: not-allowed;
        }
        .highlight-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 2;
        }

        .word-outline {
            fill: none;
            stroke-width: 3px;
            filter: drop-shadow(0 0 4px rgba(0,0,0,0.7)); /* Better shadow for SVG */
        }
        
        /* The animation class we'll add with JavaScript */
        .word-outline.animated {
            animation: draw-outline 0.6s ease-out forwards;
        }

        .word-outline-5 { 
            stroke: var(--highlight-green); 
            border-color: var(--highlight-green); 
            z-index: 3; 
        }
        .word-outline-4 { 
            stroke: var(--highlight-yellow); 
            border-color: var(--highlight-yellow); 
            z-index: 2; 
        }
        .word-outline-3 { 
            stroke: var(--highlight-blue); 
            border-color: var(--highlight-blue); 
            z-index: 1; 
        }

        /* Keyframe animation for the drawing effect */
        @keyframes draw-outline {
            to {
                stroke-dashoffset: 0;
            }
        }

        .buttons {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            justify-content: center;
            width: 100%;
            max-width: 420px;
        }
        #main-controls {
             margin: 30px 0;
        }
        #top-controls {
            margin-bottom: 10px;
        }
        
        #help-info-container p,#swap-info-container p {
            font-size: 1.3rem;
            color: var(--subtle-text-color);
            margin: 0 0 10px 0;
            font-weight: bold;
        }

        #swap-btn {
            background-color: var(--highlight-blue);
        }

        .matrix-cell.swap-selected {
            transform: scale(1.1);
            border-color: var(--highlight-green);
            box-shadow: 0 0 10px var(--highlight-green);
        }
        
        .swap-flyer {
            position: absolute;
            z-index: 10;
            transition: top 0.4s ease-in-out, left 0.4s ease-in-out;
        }

        button {
            background-color: var(--highlight-green);
            color: var(--text-color);
            border: none;
            padding: 10px 15px;
            font-family: var(--font-family);
            font-size: 0.9rem;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.2s;
        }
        
        .icon-btn {
            width: 48px;
            height: 48px;
            padding: 0;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .icon-btn svg {
            width: 24px;
            height: 24px;
            stroke: var(--text-color);
        }

        button:hover:not(:disabled) {
            opacity: 0.9;
        }
        
        button:disabled,
        .tab-btn.active:disabled,
        .tab-btn:disabled {
            background-color: #555;
            cursor: not-allowed;
            opacity: 0.6;
            border: 0px;
        }

        #check-score-btn {
            background-color: var(--highlight-yellow);
        }
        
        #leaderboard {
            margin-top: 20px;
            padding-top: 15px;
            border-top: 1px solid var(--cell-bg);
            width: 100%;
        }
        
        #leaderboard h2 {
            font-size: 1rem;
            color: var(--subtle-text-color);
            margin-top: 0;
            margin-bottom: 15px;
            text-transform: uppercase;
            letter-spacing: 0.1em;
        }
        
        .stats {
            display: flex;
            justify-content: space-around;
        }
        
        .stats p {
            font-size: 1.5rem;
            font-weight: bold;
            margin: 5px 0 0 0;
        }

        #rank-stats {
            margin-top: 15px;
            padding: 10px 0;
            font-size: 0.9rem;
            color: var(--subtle-text-color);
        }

        #rank-list {
            list-style: none;
            padding: 0;
            margin: 0;
        }

        .rank-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 6px 10px;
            border-radius: 4px;
            margin-bottom: 5px;
            background-color: var(--board-bg);
        }

        .rank-name {
            font-weight: bold;
            flex: 2;
            text-align: left;
        }
        .rank-score {
            flex: 2;
            font-size: 0.8rem;
            color: var(--subtle-text-color);
        }
        .rank-count {
            flex: 1;
            font-weight: bold;
            font-size: 1.1rem;
            text-align: right;
        }

        .rank-good { color: var(--highlight-blue); }
        .rank-master { color: var(--highlight-yellow); }
        .rank-legend { color: var(--highlight-yellow); filter: brightness(1.4); }
        .rank-perfect { color: var(--highlight-green); filter: brightness(1.4); text-shadow: 0 0 5px var(--highlight-green); }

		#rank-display {
			font-size: 1.5rem;
			font-weight: bold;
			color: var(--highlight-yellow);
			margin-bottom: 15px; /* Space above the grid */
			animation: pop-in 0.5s ease-out forwards;
		}

		/* Keyframe animation for the appearance */
		@keyframes pop-in {
			0% {
				opacity: 0;
				transform: scale(0.8);
			}
			100% {
				opacity: 1;
				transform: scale(1);
			}
}

        .hidden {
            display: none !important;
        }

        /* --- CORRECTED MODAL STYLES --- */
        #modal-overlay, 
        #archive-modal-overlay, 
        #tutorial-modal-overlay, 
        #confirm-modal-overlay, 
        #archive-info-modal-overlay, 
        #score-confirm-modal-overlay,
        #restart-confirm-modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.8);
            display: flex;
            justify-content: center;
            align-items: flex-start; /* Default alignment is top for scrolling */
            z-index: 1000;
            padding: 20px 10px;
            box-sizing: border-box;
            overflow-y: auto;
        }
        
        /* This override centers ONLY the modals that need it */
        #confirm-modal-overlay, 
        #archive-info-modal-overlay {
            align-items: center; 
        }

        .modal-content {
            background: var(--modal-bg);
            padding: 20px;
            border-radius: 10px;
            width: 100%;
            max-width: 500px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.3);
            text-align: center;
            position: relative;
        }
        
        #modal-words-container {
            display: flex;
            justify-content: space-between;
            gap: 10px;
            margin-top: 15px;
        }

        .word-column {
            flex: 1;
            text-align: center;
            margin-bottom: 15px;
        }

        .word-column h4 {
            margin-top: 0;
            border-bottom: 1px solid var(--cell-bg);
            padding-bottom: 5px;
        }

        .word-list {
            list-style: none;
            padding: 0;
            margin: 0;
            max-height: 120px;
            overflow-y: auto;
        }

        .word-list li {
            padding: 4px;
            margin: 3px 0;
            border-radius: 3px;
            text-transform: uppercase;
            font-weight: bold;
        }
        
        .word-5 { color: var(--highlight-green); }
        .word-4 { color: var(--highlight-yellow); }
        .word-3 { color: var(--highlight-blue); }

        .modal-buttons {
            display: flex;
            gap: 10px;
            justify-content: center;
            margin-top: 20px;
        }
        
        .modal-tabs {
            display: flex;
            justify-content: center;
            gap: 10px;
            margin-bottom: 15px;
        }

        .tab-btn {
            background-color: var(--highlight-green);
            padding: 8px 16px;
            border: 1px solid var(--cell-bg);
            color: var(--text-color);
            transition: all 0.2s ease;
        }

        .tab-btn:not(.active):not(:disabled):hover {
            color: var(--text-color);
        }

        .tab-btn.active {
            background-color: var(--highlight-blue);
            border-color: var(--highlight-blue);
            color: var(--text-color);
            border: 3px solid white ;
        }
        body.light-mode .tab-btn.active {
             color: #FFFFFF;
        }

        #archive-comparison {
            margin-top: 15px;
        }

        .comparison-column {
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        
        .comparison-column .comparison-grid {
            width: 100%;
            max-width: 350px;
            margin-bottom: 15px;
        }

        #archive-controls {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 10px;
            margin-bottom: 20px;
        }

        #archive-date-picker {
            background-color: var(--cell-bg);
            color: var(--text-color);
            border: 1px solid #555;
            border-radius: 5px;
            padding: 8px;
            font-family: var(--font-family);
        }
        
        #share-btn {
            background-color: var(--highlight-blue);
        }

        button.focused-btn {
            outline: 2px solid var(--highlight-blue);
            outline-offset: 2px;
        }

        /* --- Tutorial Modal Styles --- */
        #tutorial-modal-content h2 {
            margin-top: 0;
        }
        #tutorial-modal-content p {
            line-height: 1.6;
            color: var(--subtle-text-color);
        }
        .tutorial-grid-container {
            position: relative;
            width: 100%;
            max-width: 250px;
            margin: 20px auto;
        }
        #tutorial-grid { /* Changed from .tutorial-grid */
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            gap: 4px;
        }
        .tutorial-legend {
            margin-top: 20px;
            padding-top: 15px;
        }
        .legend-item {
            display: flex;
            align-items: center;    
            justify-content: center;
            gap: 15px;
            margin-bottom: 15px;
        }
        .legend-item span {
            align-items: center;
            white-space: normal;
            width: auto;
            text-align: left;
            flex-grow: 1;
        }
        .legend-box {
            width: 80px;
            flex-shrink: 0;
            height: 30px;
            border-radius: 5px;
            border-width: 3px;
            border-style: solid;
        }

        .tutorial-help-section {
            margin: 20px 0;
            padding: 15px;
            background-color: var(--board-bg);
            border-radius: 8px;
        }
        .tutorial-help-section h4 {
            margin-top: 0;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            color: var(--highlight-yellow);
        }
        .help-visuals {
            display: flex;
            justify-content: space-around;
            gap: 15px;
            margin-top: 15px;
        }
        .help-item {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px;
        }
        .help-item svg {
            width: 32px;
            height: 32px;
            stroke: var(--text-color);
        }
        .help-item p {
            font-size: 0.8rem;
            line-height: 1.4;
            margin: 0;
        }


        .modal-close-x {
            position: absolute;
            top: 10px;
            right: 15px;
            background: none;
            border: none;
            color: var(--text-color);
            font-size: 2rem;
            line-height: 1;
            cursor: pointer;
            opacity: 0.7;
            padding: 0;
        }
        .modal-close-x:hover {
            opacity: 1;
        }

        #countdown-container {
            margin-top: 20px;
            padding-top: 15px;
            border-top: 1px solid var(--cell-bg);
        }

        #countdown-timer {
            font-size: 1.5rem;
            font-weight: bold;
            color: var(--highlight-yellow);
        }
		.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #222;
    color: #fff;
    padding: 20px 30px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;

    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;

    /* Start hidden and transition smoothly */
    transform: translateY(100%);
    transition: transform 0.5s ease-in-out;
}

/* This class is added by JavaScript to show the banner */
.cookie-banner.active {
    transform: translateY(0);
}

.cookie-banner-text {
    margin: 0;
    font-size: 14px;
    flex-grow: 1; /* Allows text to take available space */
}

.cookie-banner-text a {
    color: #4e9af1;
    text-decoration: underline;
}

.cookie-banner-text a:hover {
    color: #72b3ff;
}

.cookie-banner-button {
    background-color: #4e9af1;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap; /* Prevents button text from wrapping */
    transition: background-color 0.2s;
}

.cookie-banner-button:hover {
    background-color: #3b7bbf;
}

/* Responsive styles for smaller screens */
@media (max-width: 768px) {
    .cookie-banner {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }
    
    .cookie-banner-button {
        width: 100%;
        margin-top: 15px;
    }
}

        @media (max-width: 600px) {
            header h1 {
                font-size: 1.8rem;
            }

            .stats {
                flex-direction: column;
                gap: 15px;
                align-items: center;
            }

            #modal-words-container {
                flex-direction: column;
            }

            .word-list {
                max-height: 80px;
            }
        }