
        :root {
            --bg-color: #111315;
            --text-color: #ffffff;
            --muted-text: #8b8f93;
            --border-color: rgba(255, 255, 255, 0.2);
            --tile-border: rgba(255, 255, 255, 0.26);

            --correct: #538d4e;
            --present: #b59f3b;
            --absent: #3a3a3c;

            --key-bg: #818384;
            --key-text: #ffffff;

            --modal-bg: #ffffff;
            --modal-text: #202124;
            --modal-soft: #f0f0f0;
            --icon-bg: rgba(255, 255, 255, 0.06);
            --icon-hover: rgba(255, 255, 255, 0.12);
            --header-text: #f3f3f3;
        }

        body[data-theme="light"] {
            --bg-color: #f6f6f6;
            --text-color: #1a1a1a;
            --muted-text: #5f6368;
            --border-color: rgba(0, 0, 0, 0.15);
            --tile-border: rgba(0, 0, 0, 0.18);

            --correct: #538d4e;
            --present: #b59f3b;
            --absent: #86888a;

            --key-bg: #d3d6da;
            --key-text: #1a1a1a;

            --modal-bg: #ffffff;
            --modal-text: #202124;
            --modal-soft: #f3f3f3;
            --icon-bg: rgba(0, 0, 0, 0.04);
            --icon-hover: rgba(0, 0, 0, 0.08);
            --header-text: #202124;
        }

        /* In light theme ensure letters on colored tiles and keyboard keys are white */
        body[data-theme="light"] .tile[data-state="correct"],
        body[data-theme="light"] .tile[data-state="present"],
        body[data-theme="light"] .tile[data-state="absent"] {
            color: #ffffff;
        }

        body[data-theme="light"] .key[data-state="correct"],
        body[data-theme="light"] .key[data-state="present"],
        body[data-theme="light"] .key[data-state="absent"] {
            color: #ffffff;
        }

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

        body {
            background: var(--bg-color);
            color: var(--text-color);
            font-family: Arial, Helvetica, sans-serif;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        button {
            font-family: inherit;
        }

        /* =========================
           HEADER
           ========================= */

        header {
            height: 58px;
            width: 100%;
            border-bottom: 1px solid var(--border-color);

            display: flex;
            align-items: center;
            justify-content: center;

            position: relative;
            flex-shrink: 0;
        }

        header h1 {
            font-size: 30px;
            font-weight: 800;
            letter-spacing: 2px;
            color: var(--header-text);
            line-height: 1;
        }

        #day-counter {
            position: absolute;
            top: calc(100% + 6px);
            left: 50%;
            transform: translateX(-50%);

            color: var(--muted-text);
            font-size: 11px;
            font-weight: bold;
            letter-spacing: 1px;
            white-space: nowrap;
        }

        #rules-button,
        #result-open-button,
        #mode-toggle,
        #theme-toggle {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);

            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;

            background: var(--icon-bg);
            border: 1px solid var(--border-color);
            color: var(--header-text);

            font-size: 22px;
            font-weight: bold;
            line-height: 1;

            cursor: pointer;
            padding: 0;
            border-radius: 50%;
            -webkit-tap-highlight-color: transparent;
            touch-action: manipulation;
        }

        #rules-button {
            left: 14px;
        }

        #result-open-button {
            right: 94px;
            display: none;
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
            z-index: 2;
        }

        #result-open-button.visible {
            display: flex;
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
        }

        #mode-toggle {
            right: 54px;
            font-size: 18px;
        }

        #theme-toggle {
            right: 14px;
            font-size: 18px;
        }

        /* Theme icons */
        .icon {
            width: 20px;
            height: 20px;
            display: inline-block;
            vertical-align: middle;
        }

        .icon-moon { display: none; }

        body[data-theme="light"] .icon-sun { display: none; }
        body[data-theme="light"] .icon-moon { display: inline-block; }

        #rules-button:hover,
        #result-open-button:hover,
        #mode-toggle:hover,
        #theme-toggle:hover {
            background: var(--icon-hover);
        }

        /* =========================
           GAME
           ========================= */

        #game-container {
            flex: 1;

            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: flex-start;

            width: 100%;
            padding: 18px 10px 0;
            overflow-y: auto;
        }

        #board {
            display: grid;
            grid-template-rows: repeat(6, 1fr);
            gap: 6px;

            width: min(340px, 84vw);
            aspect-ratio: 5 / 6;
            margin-top: 6px;
        }

        .row {
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            gap: 6px;
        }

        .tile {
            border: 2px solid var(--tile-border);
            background: transparent;

            display: flex;
            justify-content: center;
            align-items: center;

            font-size: clamp(1.5rem, 6vw, 2.2rem);
            font-weight: bold;

            text-transform: uppercase;
            user-select: none;

            transition:
                    transform 0.1s ease,
                    background-color 0.25s ease,
                    border-color 0.25s ease;

            perspective: 1000px;
                -webkit-backface-visibility: hidden;
                backface-visibility: hidden;
                transform-style: preserve-3d;
        }

        .tile[data-state="active"] {
            border-color: #565758;
            animation: pop 0.1s ease-in-out;
        }

        .tile[data-state="correct"] {
            background-color: var(--correct);
            border-color: var(--correct);
        }

        .tile[data-state="present"] {
            background-color: var(--present);
            border-color: var(--present);
        }

        .tile[data-state="absent"] {
            background-color: var(--absent);
            border-color: var(--absent);
        }

        @keyframes pop {
            0% {
                transform: scale(1);
            }

            50% {
                transform: scale(1.08);
            }

            100% {
                transform: scale(1);
            }
        }

        .flip {
            animation: flip 0.5s ease forwards;
        }

        @keyframes flip {
            0% {
                transform: rotateX(0);
            }

            45% {
                transform: rotateX(90deg);
            }

            55% {
                transform: rotateX(90deg);
            }

            100% {
                transform: rotateX(0);
            }
        }

        /* =========================
           KEYBOARD
           ========================= */

        #keyboard {
            width: min(500px, 92vw);
            padding: 0 8px 10px;
            margin: 12px auto 0;

            display: flex;
            flex-direction: column;
            gap: 6px;

            flex-shrink: 0;
            align-self: center;
        }

        .kb-row {
            display: flex;
            justify-content: center;
            gap: 6px;

            width: 100%;
            touch-action: manipulation;
        }

        .key {
            height: 62px;
            min-width: 0;

            border: 0;
            border-radius: 5px;

            background: var(--key-bg);
            color: var(--key-text);

            font-size: 14px;
            font-weight: 700;

            cursor: pointer;
            user-select: none;

            flex: 1;

            display: flex;
            justify-content: center;
            align-items: center;

            transition:
                    background-color 0.15s ease,
                    transform 0.05s ease;
        }

        .key:hover {
            filter: brightness(1.08);
        }

        .key:active {
            transform: scale(0.95);
        }

        .key.large {
            flex: 1.5;
            font-size: 12px;
        }

        .key[data-state="correct"] {
            background: var(--correct);
        }

        .key[data-state="present"] {
            background: var(--present);
        }

        .key[data-state="absent"] {
            background: var(--absent);
        }

        .key:disabled {
            cursor: default;
        }

        #message-container {
            position: fixed;
            top: 78px;
            left: 50%;
            transform: translateX(-50%);

            z-index: 2000;

            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;

            pointer-events: none;
        }

        .message {
            background: #ffffff;
            color: #000000;

            padding: 11px 18px;
            border-radius: 4px;

            font-size: 14px;
            font-weight: bold;

            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.35);

            animation:
                    fadeIn 0.2s ease-in,
                    fadeOut 0.4s ease 1.6s forwards;
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(-10px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        @keyframes fadeOut {
            from {
                opacity: 1;
            }

            to {
                opacity: 0;
            }
        }

        .modal-overlay {
            position: fixed;
            inset: 0;

            background: rgba(0, 0, 0, 0.65);

            display: none;
            align-items: center;
            justify-content: center;

            z-index: 3000;

            padding: 20px;
        }

        .modal-overlay.visible {
            display: flex;
            animation: modalFadeIn 0.15s ease;
        }

        @keyframes modalFadeIn {
            from {
                opacity: 0;
            }

            to {
                opacity: 1;
            }
        }

        .modal {
            width: min(480px, 100%);
            max-height: 90vh;
            overflow-y: auto;

            background: var(--modal-bg);
            color: var(--modal-text);

            border-radius: 8px;

            box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);

            padding: 28px;

            position: relative;

            animation: modalSlideIn 0.2s ease;
        }

        @keyframes modalSlideIn {
            from {
                transform: translateY(10px) scale(0.98);
                opacity: 0;
            }

            to {
                transform: translateY(0) scale(1);
                opacity: 1;
            }
        }

        .modal h2 {
            text-align: center;
            font-size: 24px;
            margin-bottom: 20px;
        }

        .modal h3 {
            font-size: 16px;
            margin: 18px 0 8px;
        }

        .modal p {
            font-size: 14px;
            line-height: 1.55;
            margin-bottom: 10px;
        }

        .modal-close {
            position: absolute;
            right: 12px;
            top: 10px;

            width: 34px;
            height: 34px;

            border: none;
            background: transparent;

            font-size: 25px;
            color: #666;

            cursor: pointer;
            border-radius: 50%;
        }

        .modal-close:hover {
            background: #eeeeee;
        }

        .rule-example {
            display: flex;
            gap: 5px;
            margin: 12px 0;
        }

        .example-tile {
            width: 42px;
            height: 42px;

            border: 2px solid #d3d6da;

            display: flex;
            justify-content: center;
            align-items: center;

            font-weight: bold;
            font-size: 20px;
        }

        .example-tile.correct {
            background: var(--correct);
            border-color: var(--correct);
            color: white;
        }

        .example-tile.present {
            background: var(--present);
            border-color: var(--present);
            color: white;
        }

        .example-tile.absent {
            background: var(--absent);
            border-color: var(--absent);
            color: white;
        }

        #result-title {
            margin-bottom: 5px;
        }

        #result-subtitle {
            text-align: center;
            color: #666;
            margin-bottom: 22px;
        }

        #result-word {
            text-align: center;
            font-size: 25px;
            font-weight: bold;
            letter-spacing: 2px;
            margin-bottom: 22px;
        }

        #stats {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 10px;

            margin-bottom: 25px;
        }

        .stat {
            text-align: center;
        }

        .stat-value {
            display: block;
            font-size: 28px;
            font-weight: bold;
        }

        .stat-label {
            display: block;
            margin-top: 4px;
            font-size: 11px;
            color: #666;
        }

        .dictionary-links {
            display: flex;
            flex-direction: column;
            gap: 9px;
        }

        .dictionary-link {
            display: block;

            text-decoration: none;
            text-align: center;

            padding: 12px;

            border-radius: 5px;

            background: #f0f0f0;
            color: #202124;

            font-size: 14px;
            font-weight: bold;

            transition: background-color 0.15s ease;
        }

        .dictionary-link:hover {
            background: #dddddd;
        }

        .result-actions {
            display: flex;
            gap: 10px;
            margin-top: 15px;
        }

        .action-button {
            flex: 1;
            border: none;
            border-radius: 5px;
            padding: 12px;
            font-size: 14px;
            font-weight: bold;
            cursor: pointer;
            transition: background-color 0.15s ease;
        }

        #share-button {
            background: var(--modal-soft);
            color: var(--modal-text);
        }

        #share-button:hover {
            background: #dddddd;
        }

        #result-close {
            background: #202124;
            color: white;
        }

        #result-close:hover {
            background: #000000;
        }

        /* =========================
           MOBILE
           ========================= */

        @media (max-width: 500px) {
            header {
                height: 58px;
            }

            header h1 {
                font-size: 25px;
            }

            #rules-button,
            #theme-toggle {
                width: 32px;
                height: 32px;
                font-size: 18px;
            }

            #rules-button {
                left: 5px;
            }

            #theme-toggle {
                right: 5px;
            }

            #day-counter {
                top: calc(100% + 5px);
                font-size: 9px;
            }

            #game-container {
                padding: 4px;
            }

            #board {
                width: min(350px, 82vw);
            }

            #keyboard {
                padding-bottom: 7px;
                gap: 4px;
            }

            /* Mobile: pin keyboard near bottom and ensure main content doesn't get hidden */
            #keyboard {
                position: fixed;
                left: 50%;
                transform: translateX(-50%);
                bottom: 12px;
                width: min(500px, 94vw);
                padding: 8px;
                border-radius: 10px;
                box-shadow: 0 8px 24px rgba(0,0,0,0.45);
                z-index: 1200;
                background: transparent;
            }

            /* Reserve space so tiles stay above the keyboard */
            #game-container {
                padding-bottom: 200px;
                padding-top: 22px;
            }

            .key {
                height: clamp(50px, 12vw, 58px);
                font-size: 12px;
            }

            .key.large {
                font-size: 10px;
            }

            .kb-row {
                gap: 3px;
            }

            .key {
                height: clamp(50px, 12vw, 58px);
                font-size: 12px;
            }

            .key.large {
                font-size: 9px;
            }

            .modal {
                padding: 22px;
            }

            #stats {
                gap: 4px;
            }

            .stat-value {
                font-size: 23px;
            }

            .stat-label {
                font-size: 9px;
            }
        }
    