        :root {
            /* --- GRID MATH --- */
            --hex-width: 90px; 
            --hex-height: calc(var(--hex-width) * 1.1547); 
            --gap: 4px; 
            --row-overlap: calc(var(--hex-height) * -0.25);
            --layout-min-width: 640px;
            --layout-max-width: 1200px;
            
            /* --- THEME VARIABLES (Light Defaults) --- */
            --bg-color: #ffffff;
            --text-color: #343a40;
            --header-border: #f1f1f1;
            
            --hex-bg: #f8f9fa;
            --hex-text: #343a40;
            --hex-hover: #e9ecef;
            --hex-active: #ffd43b; /* Honey Yellow */
            --hex-active-text: #000;
            --hex-border: #dee2e6;
            
            --tag-bg: #eee;
            --tag-text: #333;
            
            --btn-shadow: rgba(0,0,0,0.1);
        }

        /* --- DARK MODE OVERRIDES (Default via HTML attr) --- */
        [data-theme="dark"] {
            --bg-color: #121212;
            --text-color: #e0e0e0;
            --header-border: #333;
            
            --hex-bg: #2c2c2c;
            --hex-text: #e0e0e0;
            --hex-hover: #3a3a3a;
            --hex-active: #ffd43b;
            --hex-active-text: #000;
            --hex-border: #444;
            
            --tag-bg: #333;
            --tag-text: #fff;
            
            --btn-shadow: rgba(0,0,0,0.5);
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: var(--bg-color);
            color: var(--text-color);
            display: flex;
            flex-direction: column;
            align-items: center;
            margin: 0;
            min-height: 100vh;
            transition: background-color 0.3s, color 0.3s;
        }

        /* --- UI ELEMENTS --- */
        header {
            width: 100%;
            max-width: var(--layout-max-width);
            min-width: var(--layout-min-width);
            box-sizing: border-box;
            padding: 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 2px solid var(--header-border);
            margin-bottom: 20px;
        }

        .site-footer {
            width: 100%;
            max-width: var(--layout-max-width);
            min-width: var(--layout-min-width);
            box-sizing: border-box;
            padding: 20px;
            margin-top: 24px;
            border-top: 2px solid var(--header-border);
            text-align: center;
            font-size: 1rem;
            letter-spacing: 0.4px;
        }

        .site-footer a {
            color: var(--hex-active);
        }

        .header-left {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        h1 { margin: 0; font-size: 1.5rem; letter-spacing: 1px; }
        
        .score-box {
            background: #ffd43b;
            color: #000;
            padding: 5px 15px;
            border-radius: 20px;
            font-weight: bold;
            box-shadow: 0 2px 5px var(--btn-shadow);
        }

        /* Theme Toggle */
        .theme-toggle {
            background: none;
            border: 1px solid var(--text-color);
            color: var(--text-color);
            padding: 5px 10px;
            border-radius: 15px;
            cursor: pointer;
            font-size: 0.8rem;
            box-shadow: none;
        }

        /* --- GAME CONTAINER --- */
        .game-area {
            display: flex;
            flex-direction: column;
            align-items: stretch;
            width: 100%;
            min-width: 600px;
            box-sizing: border-box;
            padding: 0 20px;
        }

        /* Current Word Display */
        .word-display {
            height: 60px;
            font-size: 2.5rem;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 4px;
            color: var(--text-color);
            display: flex;
            align-items: center;
            justify-content: center;
            margin-top: 8px;
            margin-bottom: 8px;
        }

        /* --- THE HEX GRID --- */
        .hex-grid {
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 20px;
            user-select: none;
            touch-action: none; 
        }

        .hex-row {
            display: flex;
            justify-content: center;
            margin-top: calc(var(--row-overlap) + var(--gap));
        }

        .hex-row:first-child {
            margin-top: 0;
        }

        .hex {
            width: var(--hex-width);
            height: var(--hex-height);
            background-color: var(--hex-bg);
            color: var(--hex-text);
            margin: 0 calc(var(--gap) / 2);
            
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 2rem;
            font-weight: 700;
            text-transform: uppercase;
            cursor: pointer;
            transition: none;
            
            clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
            filter: drop-shadow(0px 2px 2px rgba(0,0,0,0.2));
            overflow: hidden;
        }

        .hex:hover {
            background-color: var(--hex-hover);
            z-index: 10;
        }

        .hex.selected {
            background-color: var(--hex-active);
            color: var(--hex-active-text);
            filter: drop-shadow(0px 3px 3px rgba(0,0,0,0.3));
        }
        
        .hex.last-active {
            background-color: #fcc419; 
            z-index: 11;
        }

        .trace-overlay {
            position: absolute;
            inset: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 2;
        }

        .trace-line {
            stroke: #111;
            stroke-width: 12;
            stroke-linecap: round;
            stroke-linejoin: round;
            fill: none;
        }

        /* --- CONTROLS --- */
        .controls {
            margin-top: 30px;
            display: flex;
            gap: 15px;
        }

        button.control-btn {
            border: none;
            padding: 12px 24px;
            border-radius: 50px;
            font-size: 1rem;
            font-weight: bold;
            cursor: pointer;
            box-shadow: 0 2px 5px var(--btn-shadow);
            transition: transform 0.1s;
        }
        button.control-btn:active { transform: scale(0.95); }

        .btn-clear { background: var(--hex-bg); color: var(--text-color); }
        .btn-shuffle { background: #339af0; color: white; }
        .btn-submit { background: var(--text-color); color: var(--bg-color); }

        .progress-section {
            width: 100%;
            margin-top: 24px;
        }

        #progress-bars {
            width: 100%;
            min-width: calc(var(--layout-min-width) - 40px);
            max-width: calc(var(--layout-max-width) - 40px);
            margin: 0 auto;
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .progress-item {
            padding: 4px 0;
        }

        .progress-label,
        .progress-count {
            font-size: 0.82rem;
            color: var(--text-color);
            opacity: 0.85;
        }

        .progress-track {
            height: 10px;
            background: var(--hex-bg);
            border-radius: 999px;
            overflow: hidden;
            border: 1px solid var(--hex-border);
        }

        .progress-fill {
            height: 100%;
            background: linear-gradient(90deg, #74c0fc 0%, #ffd43b 100%);
            width: 0%;
            transition: width 0.25s ease;
        }

        .progress-fill.gain {
            animation: bar-gain 0.35s ease-out;
        }

        @keyframes bar-gain {
            0% { filter: brightness(1); }
            35% { filter: brightness(1.35); }
            100% { filter: brightness(1); }
        }

        .progress-summary {
            list-style: none;
            display: grid;
            grid-template-columns: 12px 52px 1fr 35px;
            align-items: center;
            gap: 8px;
            cursor: pointer;
        }

        .progress-summary::-webkit-details-marker {
            display: none;
        }

        .progress-arrow {
            font-size: 0.85rem;
            opacity: 0.8;
            transition: transform 0.15s ease;
            transform: rotate(0deg);
            width: 12px;
            text-align: center;
        }

        .progress-item[open] .progress-arrow {
            transform: rotate(90deg);
        }

        .found-tags {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            align-items: center;
            gap: 8px;
            margin-top: 6px;
        }
        .tag {
            background: var(--tag-bg);
            color: var(--tag-text);
            padding: 5px 10px;
            border-radius: 4px;
            font-size: 0.9rem;
        }

        .progress-empty {
            font-size: 0.82rem;
            opacity: 0.7;
        }
        
        /* Status message for API feedback */
        #api-status {
            height: 20px;
            margin-top: 10px;
            font-size: 0.85rem;
            color: #ff6b6b;
            text-align: center;
        }

        #api-status.success {
            color: #2f9e44;
        }

        #api-status.neutral {
            color: var(--text-color);
        }
