html, body {
            margin: 0;
            padding: 0;
            height: 100%;
            width: 100vw;
            overflow: hidden;
            font-family: system-ui;
        }
        #map {
            position: fixed;
            top: 0; left: 0;
            width: 100vw; 
            height: calc(100vh - 100px); /* Adjusted for bottom ad */
            z-index: 1;
        }
        .overlay {
            position: fixed;
            z-index: 10;
            pointer-events: none;
        }
        .face-thumbnail {
            position: fixed;
            top: 16px; right: 16px;
            width: 64px; height: 64px;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.15);
            background: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            z-index: 20;
            pointer-events: auto;
        }
        .face-thumbnail img {
            width: 100%; height: 100%; object-fit: cover; border-radius: 8px;
        }
        .face-modal-bg {
            position: fixed;
            top: 0; left: 0; width: 100vw; height: 100vh;
            background: rgba(0,0,0,0.5);
            z-index: 30;
            display: none;
            align-items: center;
            justify-content: center;
        }
        .face-modal {
            background: #fff;
            border-radius: 16px;
            padding: 24px 16px 16px 16px;
            box-shadow: 0 4px 32px rgba(0,0,0,0.25);
            max-width: 90vw;
            max-height: 80vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            position: relative;
        }
        .face-modal img {
            width: 180px; height: 180px; object-fit: cover; border-radius: 12px;
        }
        .face-modal-close {
            position: absolute;
            top: 8px; right: 12px;
            background: none; border: none; font-size: 2rem; cursor: pointer;
        }
        .face-modal-expanded {
            position: fixed;
            top: 14px;
            right: 14px;

            background: #fff;
            border-radius: 16px;
            padding: 20px 20px 16px 20px;
            box-shadow: 0 4px 32px rgba(0,0,0,0.25);
            z-index: 1002;
            display: flex;
            flex-direction: column;
            align-items: center;
        
            width: 560px; 
            max-width: calc(100vw - 68px); /* 14px gutter plus 20px padding on each side */

            aspect-ratio: 4 / 2.99 ;
            max-height: min(420px, 40vh);
        }
        .face-modal-close {
            position: absolute;
            top: 8px;
            right: 12px;
            background: none;
            border: none;
            font-size: 2rem;
            cursor: pointer;
            color: #333;
        }
        .face-modal-header {
            text-align: center;
            margin-bottom: 4px;
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 2px;
            flex-shrink: 0; /* Prevent header from shrinking */
        }
        #face-modal-title {
            margin: 0;
            font-size: 1.1em;
            line-height: 1.1;
        }
        #face-modal-subtitle {
            margin: 0;
            font-size: 1em;
            line-height: 1.1;
            font-weight: normal;
        }
        #face-modal-round {
            font-size: 0.95em;
            margin-bottom: 2px;
            margin-top: 0;
        }
        
        /* === MODIFIED CSS FOR DYNAMIC IMAGES === */
        .face-modal-images {
            display: flex;
            flex-direction: column; /* Stack rows vertically */
            gap: 16px;               /* Space between rows */
            padding: 8px;
            justify-content: flex-start; /* Align rows to the top */
            align-items: center;
            width: 100%;
            overflow-y: auto;        /* Enable vertical scrolling */
            overflow-x: hidden;
            flex: 1;                 /* Fill available vertical space */
            min-height: 0;           /* Crucial for flex scrolling */
        }

        /* New class for dynamically created image rows */
        .face-modal-image-row {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 16px; /* Space between images in a row */
            width: 100%;
            flex-shrink: 0;
        }

        .face-modal-images img {
            border-radius: 12px;
            object-fit: contain; /* Preserves aspect ratio */
            background: #f3f3f3;
            box-shadow: 0 2px 8px rgba(0,0,0,0.10);
            /* Sizing is now handled by JS, these are safe defaults */
            max-width: 100%;
            height: auto;
        }
        /* === END OF MODIFIED CSS === */

        .face-thumbnail {
            z-index: 1001;
        }
        .game-buttons {
            position: fixed;
            left: 50%;
            bottom: 24px;
            transform: translateX(-50%);
            pointer-events: auto;
            z-index: 9000;
            margin-bottom: 100px;
        }
        #confirm-guess, #next-round {
            background-color: #538d4e;
            color: white;
            font-size: 20px;
            font-weight: bold;
            padding: 16px 24px;
            border-radius: 12px;
            border: none;
            box-shadow: 0 2px 8px rgba(0,0,0,0.12);
            cursor: pointer;
        }
        #confirm-guess:disabled {
            background-color: #a0a0a0;
            cursor: not-allowed;
            opacity: 0.6;
        }
        .round-modal-bg {
            position: fixed;
            left: 0; right: 0;
            bottom: 100px;
            top: 30vh;
            z-index: 40;
            display: none;
            flex-direction: column;
            pointer-events: none;
        }
        .round-modal {
            background: #fff;
            border-radius: 24px 24px 0 0;
            box-shadow: 0 -4px 32px rgba(0,0,0,0.18);
            height: 100%;
            width: 100vw;
            max-width: 600px;
            margin: 0 auto;
            display: flex;
            flex-direction: column;
            position: relative;
            z-index: 41;
            pointer-events: auto;
        }
        .round-modal-header {
            border-bottom: 1px solid #eee;
            text-align: center;
            flex-shrink: 0;
        }
        .round-modal-score {
            font-size: 1.2rem;
            margin-bottom: 8px;
        }
        .round-modal-content {
            flex: 1;
            overflow-y: auto;
            padding: 0px 24px;
            margin-bottom: 95px;
        }
        .round-modal-footer {
            position: absolute;
            left: 0; right: 0; bottom: 0;
            background: #fff;
            border-radius: 0 0 24px 24px;
            box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
            padding: 16px 0 24px 0;
            display: flex;
            justify-content: center;
            flex-shrink: 0;
            height: 55px;
            border-top: 1px solid #eee;
        }
        .round-modal-footer button {
            background-color: #538d4e;
            color: white;
            font-size: 20px;
            font-weight: bold;
            padding: 16px 32px;
            border-radius: 12px;
            border: none;
            box-shadow: 0 2px 8px rgba(0,0,0,0.12);
            cursor: pointer;
        }
        @media (max-width: 450px) {
            #face-modal-subtitle {
                font-size: 0.8em;
            }
            #face-modal-round {
                font-size: 0.8em;
            }
        }
        @media (max-width: 300px) {
            .face-modal-expanded {
                min-height: 230px;
            }
        }
        .round-modal-bg {
            z-index: 1000;
        }
        #round-modal-name {
            text-align: center;
        }
        button {
            cursor: pointer;
        }
        .button {
            display: inline-block;
            background-color: #538d4e; /* Wordle green */
            color: white;
            font-size: 18px;
            font-weight: bold;
            text-transform: uppercase;
            padding: 12px 24px;
            border-radius: 8px;
            margin: 10px;
            transition: background 0.2s ease-in-out;
        }
        button a {
            text-decoration: none;
            color: inherit;
        }
        #round-modal-final-results {
            text-align: center;
            border-bottom: 1px solid #eee;
        }
        #results-date {
            font-size: 16px;
            font-weight: bold;
            color: #666;
            margin-bottom: 10px;
        }
        .button:hover {
            background-color: #3a6d34;
        }
        .button:disabled {
            background-color: #a0a0a0;
            cursor: not-allowed;
            opacity: 0.6;
        }
        #twitter-share, #donate {
            background: none;
            border: none;
            padding: 0;
            margin: 10px;
            display: inline-block;
            vertical-align: middle;
        }
        #twitter-share img {
            width: 48px;
            height: 48px;
            border-radius: 8px;
        }
        #donate img {
            width:150px;
            height:49px;
        }
        canvas {
            display: block;
            width: 100% !important;
            height: 100% !important;
            min-height: 250px;
        }
        #round-modal-handle {
            height: 20px;
            cursor: ns-resize;
            text-align: center;
            user-select: none;
            flex-shrink: 0;
        }
        .round-modal-ad {
            display: flex;
            justify-content: center;
            align-items: center;
            margin-bottom: 12px;
            height: 60px;
            background: #f3f3f3;
            flex-shrink: 0;
            overflow: hidden;
        }
        .bottom-ad {
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 100px;
            background-color: #f3f3f3;
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 1000;
            overflow: hidden; /* Prevent overflow from covering round button */
        }
        #support-ethnoguessr {
            color: #444;
            font-size: 16px;
            font-weight: 500;
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 100px;
            background-color: #f3f3f3;
            display: flex;
            justify-content: center;
            text-align: center;
            z-index: 999;
        }
        #support-text {
            margin: auto;
        }
        @media (max-height: 700px) {
            .bottom-ad {
                height: 50px;
            }
            .round-modal-ad {
                height: 50px;
            }
            #support-ethnoguessr {
                height: 50px;
            }
            #map {
                height: calc(100vh - 50px);
            }
            .game-buttons {
                margin-bottom: 50px;
            }
            .round-modal-bg {
                bottom: 50px;
            }
        }

        /* NEW: Settings and Dark Mode Styles */
        .settings-button {
            position: absolute;
            top: 8px;
            left: 12px;
            background: none;
            border: none;
            font-size: 1.8rem;
            cursor: pointer;
            color: #888;
            z-index: 1;
        }

        .settings-options {
            width: 100%;
            margin-top: 16px;
            padding-top: 12px;
            border-top: 1px solid #eee;
            align-self: center; /* Override parent's align-items: flex-end */
        }

        .setting-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 4px 8px;
            font-size: 0.9em;
        }

        .setting-item label {
            margin-right: 16px;
        }

        /* Toggle Switch Styles */
        .switch {
          position: relative;
          display: inline-block;
          width: 50px;
          height: 28px;
          flex-shrink: 0;
        }

        .switch input { 
          opacity: 0;
          width: 0;
          height: 0;
        }

        .slider {
          position: absolute;
          cursor: pointer;
          top: 0;
          left: 0;
          right: 0;
          bottom: 0;
          background-color: #ccc;
          transition: .4s;
        }

        .slider:before {
          position: absolute;
          content: "";
          height: 20px;
          width: 20px;
          left: 4px;
          bottom: 4px;
          background-color: white;
          transition: .4s;
        }

        input:checked + .slider {
          background-color: #538d4e;
        }

        input:checked + .slider:before {
          transform: translateX(22px);
        }

        .slider.round {
          border-radius: 28px;
        }

        .slider.round:before {
          border-radius: 50%;
        }

        /* Dark Mode Theme */
        body.dark-mode {
            background-color: #121212;
            color: #e0e0e0;
        }

        body.dark-mode .face-modal-expanded,
        body.dark-mode .round-modal,
        body.dark-mode .round-modal-footer {
            background: #1e1e1e;
            color: #e0e0e0;
            /* box-shadow: none; Often looks better to remove shadows on dark bg */
            box-shadow: 0 2px 8px rgba(255,255,255,0.15);
        }

        body.dark-mode .face-modal-images img {
            background: #333;
        }

        body.dark-mode .round-modal-header,
        body.dark-mode #round-modal-final-results,
        body.dark-mode .settings-options {
            border-color: #383838;
        }

        body.dark-mode #results-date,
        body.dark-mode .settings-button,
        body.dark-mode .face-modal-close {
            color: #aaa;
        }

        body.dark-mode #support-ethnoguessr,
        body.dark-mode .bottom-ad,
        body.dark-mode .round-modal-ad {
            background-color: #3e3e3e;
        }

        body.dark-mode #support-text {
            color: #aaa;
        }

        .lightbox-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.7);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 9999;
        }

        .lightbox-overlay img {
            max-width: 90%;
            max-height: 90%;
            box-shadow: 0 0 20px black;
        }

        @media (min-width: 1200px) {
            .round-modal-bg {
                align-items: flex-end;
                padding-right: 14px; 
                box-sizing: border-box;
            }

            .round-modal {
                margin: 0;
                width: clamp(400px, calc(50vw - 100px), 600px);
            }

            .round-modal-footer {
                display: none;
            }
            .round-modal-content {
                margin-bottom: 0px;
            }
        }

    /* Hbd_S2S_BottomAd_ROS */
        @media only screen and (min-width: 0px) and (min-height: 0px) {
            div[id^="bsa-zone_1753174270638-6_123456"] {
                min-width: 300px;
                min-height: 50px;
            }
        }
        @media only screen and (min-width: 770px) and (min-height: 0px) {
            div[id^="bsa-zone_1753174270638-6_123456"] {
                min-width: 320px;
                min-height: 50px;
            }
        }
        
    /* Hbd_S2S_ModalAd_ROS */
        @media only screen and (min-width: 0px) and (min-height: 0px) {
            div[id^="bsa-zone_1753174565273-3_123456"] {
                min-width: 300px;
                min-height: 50px;
            }
        }
        @media only screen and (min-width: 880px) and (min-height: 0px) {
            div[id^="bsa-zone_1753174565273-3_123456"] {
                min-width: 320px;
                min-height: 50px;
            }
        }