/* ================================================================
   1. GLOBAL & THEME VARIABLES
================================================================ 
*/
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
:root {
    --background: #f4f4f4;
    --header-footer: #fafafa;
    --text: #222222;
    --accent: #68a063;
    --surface-2: #e8e8e8;
    --surface-3: #ffffff;
    --grid-bg: #e8e8e8;
    --cell-bg: #ffffff;
    --found-bg: #ffeb3b;
    --border-soft: rgba(34, 34, 34, 0.12);
    --menu-shadow: 0 18px 38px rgba(34, 34, 34, 0.12);
    --marker-fill: rgba(255, 235, 59, 0.38);
    --marker-stroke: rgba(0, 0, 0, 0);
    --marker-preview-fill: rgba(255, 235, 59, 0.28);
    --marker-preview-stroke: rgba(0, 0, 0, 0);
    --marker-wrong-fill: rgba(248, 113, 113, 0.22);
    --board-size-vmin: 92vmin;
    --grid-logo-image: url('appvark_logo_light.png');
    --grid-logo-size: min(72%, 520px);
    --scrollbar-track: color-mix(in srgb, var(--accent) 14%, transparent);
    --scrollbar-thumb: color-mix(in srgb, var(--accent) 42%, transparent);
    --scrollbar-thumb-hover: color-mix(in srgb, var(--accent) 58%, transparent);
    --submenu-bg: rgba(34, 34, 34, 0.045);
}

html.dark-theme,
body.dark-theme {
    --background: #232323;
    --header-footer: #2c2c2c;
    --text: #eeeeee;
    --accent: #68a063;
    --surface-2: #363636;
    --surface-3: #444444;
    --grid-bg: #363636;
    --cell-bg: #444444;
    --found-bg: #ffeb3b;
    --border-soft: rgba(238, 238, 238, 0.16);
    --menu-shadow: 0 18px 38px rgba(0, 0, 0, 0.28);
    --marker-fill: rgba(255, 235, 59, 0.38);
    --marker-stroke: rgba(0, 0, 0, 0);
    --marker-preview-fill: rgba(255, 235, 59, 0.28);
    --marker-preview-stroke: rgba(0, 0, 0, 0);
    --marker-wrong-fill: rgba(248, 113, 113, 0.22);
    --scrollbar-track: color-mix(in srgb, var(--accent) 16%, rgba(255, 255, 255, 0.06));
    --scrollbar-thumb: color-mix(in srgb, var(--accent) 60%, rgba(255, 255, 255, 0.14));
    --scrollbar-thumb-hover: color-mix(in srgb, var(--accent) 76%, rgba(255, 255, 255, 0.18));
    --submenu-bg: rgba(238, 238, 238, 0.06);
    --grid-logo-image: url('appvark_logo_dark.png');
}

html[data-accent-theme="emerald"],
body[data-accent-theme="emerald"] {
    --accent: #68a063;
}

html[data-accent-theme="green"],
body[data-accent-theme="green"] {
    --accent: #4e8b49;
}

html[data-accent-theme="mint"],
body[data-accent-theme="mint"] {
    --accent: #ff8a2a;
}

html[data-accent-theme="tangerine"],
body[data-accent-theme="tangerine"] {
    --accent: #f26a21;
}

html[data-accent-theme="ocean"],
body[data-accent-theme="ocean"] {
    --accent: #2f7dff;
}

html[data-accent-theme="sky"],
body[data-accent-theme="sky"] {
    --accent: #7ea9da;
}

html[data-accent-theme="coral"],
body[data-accent-theme="coral"] {
    --accent: #d98a5a;
}

html[data-accent-theme="red"],
body[data-accent-theme="red"] {
    --accent: #c96f6f;
}

html[data-accent-theme="crimson"],
body[data-accent-theme="crimson"] {
    --accent: #b94747;
}

html[data-accent-theme="rose"],
body[data-accent-theme="rose"] {
    --accent: #d884a8;
}

html[data-accent-theme="pink"],
body[data-accent-theme="pink"] {
    --accent: #cf4ca6;
}

html[data-accent-theme="purple"],
body[data-accent-theme="purple"] {
    --accent: #8a4fff;
}

html[data-accent-theme="indigo"],
body[data-accent-theme="indigo"] {
    --accent: #8f79d6;
}

html[data-accent-theme="amber"],
body[data-accent-theme="amber"] {
    --accent: #e1a600;
}

html[data-accent-theme="yellow"],
body[data-accent-theme="yellow"] {
    --accent: #ccb75a;
}

html, body {
    height: 100%;
    background: var(--background);
    color: var(--text);
    overflow: hidden;
    touch-action: none;
}

.app-viewport-shell {
    position: fixed;
    inset: 0;
    background: var(--background);
    overflow: hidden;
}

/* Global themed scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid var(--scrollbar-track);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

.menu,
.menu-left-scroll,
.word-list-container {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.menu::-webkit-scrollbar,
.menu-left-scroll::-webkit-scrollbar,
.word-list-container::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.menu::-webkit-scrollbar-track,
.menu-left-scroll::-webkit-scrollbar-track,
.word-list-container::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

.menu::-webkit-scrollbar-thumb,
.menu-left-scroll::-webkit-scrollbar-thumb,
.word-list-container::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid var(--scrollbar-track);
}

.menu::-webkit-scrollbar-thumb:hover,
.menu-left-scroll::-webkit-scrollbar-thumb:hover,
.word-list-container::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* ================================================================
   2. SITE NAVIGATION & HEADER
================================================================ 
*/
.site-header {
    position: fixed;
    top: 0; left: 0; width: 100%;
    height: 60px;
    background: var(--header-footer); display: grid; grid-template-columns: 48px 1fr 48px;
    padding: 0 12px;
    align-items: center;
    border-bottom: 2px solid var(--accent); z-index: 10040;
    box-sizing: border-box;
}

.header-left, .header-right { display: flex; align-items: center; }
.header-left { justify-content: flex-start; position: relative; }
.header-right { justify-content: flex-end; position: relative; }
.header-center {
    text-align: center;
    color: var(--accent);
    font-weight: bold;
    font-size: 1.15rem;
    letter-spacing: 0.08em;
    line-height: 1;
    white-space: nowrap;
}

.menu-toggle {
    background: none; border: none; color: var(--accent);
    font-weight: bold; font-size: 1.2rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; padding: 0;
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    z-index: 2;
}

.menu-equals {
    width: 24px;
    height: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    pointer-events: none;
    position: relative;
}

.menu-equals span {
    display: block;
    width: 100%;
    height: 3px;
    border-radius: 999px;
    background: currentColor;
    transition: transform 0.22s ease, top 0.22s ease;
}

.menu-toggle.is-open .menu-equals {
    height: 20px;
}

.menu-toggle.is-open .menu-equals span {
    position: absolute;
    top: 50%;
    left: 0;
}

.menu-toggle.is-open .menu-equals span:first-child {
    transform: translateY(-50%) rotate(45deg);
}

.menu-toggle.is-open .menu-equals span:last-child {
    transform: translateY(-50%) rotate(-45deg);
}

.side-arrow { 
    transition: transform 0.3s ease; 
    display: inline-block;
    font-family: serif !important; 
    line-height: 1;
}

.menu {
    position: fixed;
    top: 60px;
    bottom: 35px;
    width: 320px;
    height: auto;
    max-height: none;
    background: var(--header-footer);
    transition: transform 0.3s ease;
    z-index: 10030;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

body.has-ad-preview .menu,
body.has-app-ad-slot .menu {
    bottom: 0;
}

.menu-left {
    left: 0;
    transform: translateX(-100%);
    border-right: 2px solid var(--accent);
}

.menu-left-layout {
    min-height: 100%;
    position: relative;
}

.menu-left-scroll {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: 136px;
}

.menu-left-scroll > ul {
    margin: 0;
}

.menu-left-actions {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr;
    box-shadow: 0 -10px 18px rgba(0, 0, 0, 0.16);
}

.menu-left-action {
    border: 0;
    border-top: 1px solid var(--border-soft);
    background: var(--header-footer);
    color: var(--text);
    padding: 15px 16px;
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.menu-left-actions .menu-left-action:last-child {
    padding-bottom: 15px;
}

.menu-left-action--secondary {
    border-top: 1px solid var(--border-soft);
    border-bottom: 1px solid var(--border-soft);
    color: var(--accent);
}

.menu-left-action:hover,
.menu-left-action:focus-visible {
    background: var(--grid-bg);
}

.menu-left.show {
    transform: translateX(0);
}

.menu-right {
    right: 0;
    left: auto;
    transform: translateX(100%);
    border-right: none;
    border-left: 2px solid var(--accent);
}

.menu-right.show {
    transform: translateX(0);
}

.menu ul { list-style: none; padding: 0; }
.menu li { padding: 15px; cursor: pointer; color: var(--text); border-bottom: 1px solid var(--border-soft); display: block; }
.menu ul li a { text-decoration: none; color: inherit; display: block; width: 100%; }
.user-menu-layout {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.user-menu-main {
    display: grid;
}

.menu-user-summary {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    cursor: default;
    padding: 18px 16px;
    border-bottom: 1px solid var(--border-soft);
}

.menu-user-summary--button {
    width: 100%;
    border: none;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.menu-user-summary--button:hover {
    background: var(--submenu-bg);
}

.menu-user-summary__text {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.menu-user-avatar,
.profile-avatar {
    position: relative;
    display: grid;
    place-items: center;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid var(--border-soft);
    background: var(--submenu-bg);
    color: var(--accent);
}

.menu-user-avatar {
    width: 48px;
    height: 48px;
}

.menu-user-avatar__image,
.profile-avatar__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.menu-user-avatar__icon,
.profile-avatar__icon {
    width: 60%;
    height: 60%;
    display: grid;
    place-items: center;
}

.menu-user-avatar__icon svg,
.profile-avatar__icon svg {
    width: 100%;
    height: 100%;
}

.is-hidden {
    display: none !important;
}

.menu-user-name {
    display: block;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-user-meta {
    display: block;
    font-size: 0.82rem;
    opacity: 0.75;
}

.menu-user-meta__admin-link {
    color: inherit;
    text-decoration: none;
    font-weight: 700;
}

.menu-user-meta__admin-link:hover {
    text-decoration: underline;
}

.menu-section {
    display: grid;
    gap: 2px;
    padding: 10px 0;
}

.menu-section-title {
    padding: 12px 16px 6px;
    font-size: 0.76rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.7;
}

.menu-action {
    width: 100%;
    padding: 14px 16px;
    border: none;
    background: transparent;
    color: inherit;
    text-align: left;
    font: inherit;
    font-weight: bold;
    cursor: pointer;
}

.menu-action[disabled] {
    opacity: 0.6;
    cursor: default;
}

.menu-action--nested {
    padding-left: 20px;
    font-weight: 600;
}

.menu-action--danger {
    color: #c62828;
}

.has-submenu > .submenu { display: none; background: var(--submenu-bg); padding-left: 15px; margin-top: 10px; }
.has-submenu.open > .submenu { display: block; }

.menu-left-scroll > ul > .has-submenu.open {
    color: var(--accent);
}

.menu-left-scroll > ul > .has-submenu.open > a,
.menu-left-scroll > ul > .has-submenu.open > .side-arrow {
    color: var(--accent);
}

.menu-left-scroll > ul > .has-submenu.open > .submenu,
.menu-left-scroll > ul > .has-submenu.open > .submenu li,
.menu-left-scroll > ul > .has-submenu.open > .submenu li a,
.menu-left-scroll > ul > .has-submenu.open > .submenu .side-arrow {
    color: var(--text);
}

.menu-left-scroll .has-submenu.is-current-category,
.menu-left-scroll > ul > .has-submenu.open > .submenu .has-submenu.is-current-category {
    color: var(--accent);
}

.menu-left-scroll .has-submenu.is-current-category > .side-arrow,
.menu-left-scroll > ul > .has-submenu.open > .submenu .has-submenu.is-current-category > .side-arrow {
    color: var(--accent);
}

.menu-action--submenu[aria-expanded="true"] {
    color: var(--accent);
}

.menu-action--submenu[aria-expanded="true"] .side-arrow {
    color: var(--accent);
}

.theme-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    padding: 10px 0 0;
    cursor: pointer;
}

.theme-switch__label {
    font-weight: 600;
}

.theme-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.theme-switch__slider {
    position: relative;
    width: 52px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 999px;
    background: rgba(127, 127, 127, 0.25);
    border: 1px solid var(--border-soft);
    transition: background 0.2s ease, border-color 0.2s ease;
}

.theme-switch__slider::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--header-footer);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
    transition: transform 0.2s ease, background 0.2s ease;
}

.theme-switch input:checked + .theme-switch__slider {
    background: var(--accent);
    border-color: var(--accent);
}

.theme-switch input:checked + .theme-switch__slider::after {
    transform: translateX(22px);
    background: var(--background);
}

.menu-section--settings {
    margin-top: auto;
    padding-bottom: 30px;
}

.menu-section--footer-action {
    margin-top: auto;
    padding-top: 0;
    padding-bottom: 24px;
}

.menu-section--footer-action .menu-action,
.menu-section--footer-action .menu-action--nested {
    color: inherit;
}

.menu-action--submenu {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.side-arrow--menu {
    font-size: 0.8rem;
}

.menu-settings-panel {
    display: none;
    gap: 2px;
    padding: 4px 16px 0;
    border-top: 1px solid var(--border-soft);
    background: var(--submenu-bg);
}

.menu-settings-panel.is-open {
    display: grid;
}

.menu-settings-panel--nested {
    margin: 6px 0 0;
    padding: 10px 0 10px;
    border-top: 1px solid var(--border-soft);
    border-bottom: 1px solid var(--border-soft);
    background: transparent;
}

.menu-settings-panel .menu-action--nested {
    padding: 12px 0;
}

.menu-settings-panel .theme-switch {
    padding: 12px 0;
}

.menu-accent-group {
    display: grid;
    gap: 8px;
}

.menu-accent-group.is-hidden {
    display: none;
}

.menu-accent-label {
    font-weight: 600;
    padding-top: 10px;
}

.accent-swatch {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    background: transparent;
    display: inline-grid;
    place-items: center;
    position: relative;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.accent-swatch:hover {
    transform: translateY(-1px);
    border-color: var(--accent);
}

.accent-swatch.is-active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 24%, transparent);
}

.accent-swatch.is-locked {
    opacity: 0.38;
    filter: grayscale(0.2);
    cursor: default;
}

.accent-swatch.is-locked::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background:
        linear-gradient(currentColor, currentColor) center / 10px 1.8px no-repeat,
        radial-gradient(circle at center, transparent 6px, currentColor 6px, currentColor 7.6px, transparent 7.6px);
    color: var(--text);
    pointer-events: none;
}

.accent-swatch.is-locked:hover {
    transform: none;
    border-color: var(--border-soft);
}

.accent-swatch__color {
    width: 22px;
    height: 22px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    display: grid;
    place-items: center;
}

.accent-swatch__color--default {
    background: color-mix(in srgb, var(--header-footer) 88%, var(--background) 12%);
    color: var(--text);
    border-color: var(--border-soft);
}

.accent-swatch__color--icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

.accent-swatch__color--emerald {
    background: #68a063;
}

.accent-swatch__color--green {
    background: #4e8b49;
}

.accent-swatch__color--mint {
    background: #ff8a2a;
}

.accent-swatch__color--tangerine {
    background: #f26a21;
}

.accent-swatch__color--ocean {
    background: #2f7dff;
}

.accent-swatch__color--sky {
    background: #7ea9da;
}

.accent-swatch__color--coral {
    background: #d98a5a;
}

.accent-swatch__color--red {
    background: #c96f6f;
}

.accent-swatch__color--crimson {
    background: #b94747;
}

.accent-swatch__color--rose {
    background: #d884a8;
}

.accent-swatch__color--pink {
    background: #cf4ca6;
}

.accent-swatch__color--purple {
    background: #8a4fff;
}

.accent-swatch__color--indigo {
    background: #8f79d6;
}

.accent-swatch__color--amber {
    background: #e1a600;
}

.accent-swatch__color--yellow {
    background: #ccb75a;
}

.menu-settings-panel--nested.is-open {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

@media (max-width: 640px) {
    .site-header {
        grid-template-columns: 44px 1fr 44px;
        padding: 0 8px;
    }

    .header-center {
        font-size: 1rem;
        letter-spacing: 0.05em;
    }

    .menu {
        width: 100vw;
    }

    .menu-toggle {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    .menu-equals {
        width: 26px;
        height: 18px;
    }

    .menu-equals span {
        height: 3px;
    }
}

/* ================================================================
   3. MAIN GAME AREA & GRID
================================================================ 
*/
main {
    position: fixed;
    top: 60px;
    bottom: 35px;
    left: 0; width: 100%;
    overflow: hidden;
}

body[data-app-platform="android"] main {
    bottom: 64px !important;
}

body[data-app-platform="android"][data-user-subscription-tier="pro"] main,
body[data-app-platform="android"][data-user-ads-removed="1"] main {
    bottom: 35px !important;
}

@media (orientation: landscape) {
    body[data-app-platform="android"]:not([data-user-subscription-tier="pro"]):not([data-user-ads-removed="1"]) main {
        bottom: 0 !important;
    }

    body[data-app-platform="android"]:not([data-user-subscription-tier="pro"]):not([data-user-ads-removed="1"]) .wordsearch-container {
        padding-bottom: 64px;
        box-sizing: border-box;
    }

    body.has-ad-preview:not([data-app-platform="android"]) main {
        bottom: 0 !important;
    }

    body.has-ad-preview:not([data-app-platform="android"]) .wordsearch-container {
        padding-bottom: 64px;
        box-sizing: border-box;
    }
}

.game-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    gap: 5px;
    padding: 0;
    box-sizing: border-box;
}

.wordsearch-container {
    flex-grow: 1; display: flex; justify-content: center; align-items: center; padding: 5px;
    position: relative;
}

.grid {
    display: grid; 
    grid-template-columns: repeat(13, 1fr);
    position: relative;
    width: var(--board-size-vmin); height: var(--board-size-vmin);
    max-width: 100%; max-height: 100%;
    border: 2px solid var(--accent); 
    background-color: var(--grid-bg);
    background-image: var(--grid-logo-image);
    background-repeat: no-repeat;
    background-position: center;
    background-size: var(--grid-logo-size);
    overflow: hidden;
}

.cell {
    background: transparent; color: var(--text);
    display: flex; justify-content: center; align-items: center;
    font-weight: bold; font-size: 2.2vh;
    position: relative;
    z-index: 1;
}

.cell-letter {
    display: inline-block;
    line-height: 1;
    will-change: transform;
    pointer-events: none;
}

.cell.highlighted,
.cell.found-cell { background: transparent; color: var(--text); }
.cell.wrong-selection { background: transparent; color: var(--text); }

.cell.highlighted .cell-letter,
.cell.found-cell .cell-letter,
.cell.wrong-selection .cell-letter {
    color: var(--text);
}

body:not(.dark-theme) .cell.highlighted .cell-letter,
body:not(.dark-theme) .cell.found-cell .cell-letter,
body:not(.dark-theme) .cell.wrong-selection .cell-letter {
    color: #363636 !important;
}

body.dark-theme .cell.highlighted .cell-letter,
body.dark-theme .cell.found-cell .cell-letter,
body.dark-theme .cell.wrong-selection .cell-letter {
    color: #ececf1 !important;
}

.cell-letter.found-dance {
    animation: found-letter-wave 0.55s ease;
    animation-delay: var(--wave-delay, 0ms);
}

.cell-letter.wrong-shake {
    animation: wrong-letter-shake 0.38s ease;
}

@keyframes found-letter-wave {
    0% { transform: translateY(0) scale(1); }
    30% { transform: translateY(-16%) scale(1.06); }
    55% { transform: translateY(4%) scale(0.99); }
    100% { transform: translateY(0) scale(1); }
}


@keyframes wrong-letter-shake {
    0% { transform: translateX(0) rotate(0deg); }
    18% { transform: translateX(-8%) rotate(-4deg); }
    36% { transform: translateX(7%) rotate(3deg); }
    54% { transform: translateX(-5%) rotate(-2deg); }
    72% { transform: translateX(4%) rotate(1.5deg); }
    100% { transform: translateX(0) rotate(0deg); }
}

.grid-marker-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
    z-index: 3;
}

.grid-float-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
    z-index: 4;
}

.found-word-float {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, -50%);
    color: var(--text);
    font-size: clamp(0.9rem, 1.5vw, 1.12rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.16);
    animation: foundWordFloat 820ms cubic-bezier(0.2, 0.72, 0.2, 1) forwards;
}

@keyframes foundWordFloat {
    0% {
        opacity: 0;
        transform: translate(-50%, -40%) scale(0.82);
    }
    18% {
        opacity: 1;
        transform: translate(-50%, -52%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -138%) scale(1.03);
    }
}

.grid-marker {
    fill: var(--marker-fill);
    stroke: var(--marker-stroke);
    stroke-width: 0.85;
}

.grid-marker--preview {
    fill: var(--marker-preview-fill);
    stroke: var(--marker-preview-stroke);
    stroke-width: 0.8;
}

.grid-marker--wrong {
    fill: var(--marker-wrong-fill);
    stroke: none;
}

.grid-start-overlay {
    position: absolute;
    inset: 5px;
    display: none;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--background) 88%, transparent);
    backdrop-filter: blur(4px);
    z-index: 6;
    pointer-events: none;
}

.grid-start-overlay.is-visible {
    display: flex;
}

.grid-start-overlay.is-paused {
    display: flex;
}

.grid-start-overlay.is-paused .grid-start-overlay__content {
    display: none;
}

.grid-start-overlay__content {
    width: min(92%, 320px);
    padding: 20px 22px;
    border: 1px solid var(--border-soft);
    border-radius: 18px;
    background: color-mix(in srgb, var(--header-footer) 92%, var(--background) 8%);
    text-align: center;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.14);
    pointer-events: auto;
}

.grid-start-overlay__eyebrow {
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.68;
    margin-bottom: 10px;
}

.grid-start-overlay__title {
    font-size: clamp(1.3rem, 2.2vw, 1.8rem);
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
}

.grid-start-overlay__copy {
    line-height: 1.5;
    opacity: 0.8;
    margin-bottom: 16px;
}

.grid-start-overlay__button {
    border: none;
    border-radius: 999px;
    padding: 12px 28px;
    background: var(--accent);
    color: var(--background);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.completion-modal__content {
    width: calc(100vw - 24px);
    max-width: 360px;
    padding: 24px 24px 22px;
    border: 1px solid var(--border-soft);
    border-radius: 18px;
    background: color-mix(in srgb, var(--header-footer) 92%, var(--background) 8%);
    text-align: center;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.14);
    box-sizing: border-box;
}

.completion-modal__eyebrow {
    margin: 0 0 10px;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.68;
}

.completion-modal__title {
    margin: 0 0 8px;
    padding: 0;
    border: 0;
    color: var(--accent);
    font-size: clamp(1.3rem, 2.2vw, 1.8rem);
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: none;
}

.completion-modal__copy {
    margin: 0 0 16px;
    line-height: 1.5;
    opacity: 0.8;
}

.completion-modal__summary {
    margin-top: 8px;
    padding: 14px 16px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: var(--submenu-bg);
    display: grid;
    gap: 8px;
    text-align: left;
}

.completion-modal__row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.94rem;
}

.completion-modal__label {
    opacity: 0.72;
}

.completion-modal__value {
    font-weight: 700;
    text-align: right;
    color: var(--accent);
}

.completion-modal__button {
    margin-top: 18px !important;
    min-width: 180px;
}

/* ================================================================
   4. STATS & WORD LIST MODULES
================================================================ 
*/
.stats-container, .word-list-container {
    flex-shrink: 0; 
    background: rgba(75,46,31,0.05);
    border: 2px solid var(--accent); 
    margin: 0 10px; 
    border-radius: 6px;
    padding: 10px;
}

.stats-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    text-align: center;
    align-items: stretch;
}

.word-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    text-align: center;
}

.category-header { text-align: center; width: 100%; border-bottom: 2px solid var(--accent); padding-bottom: 5px; margin-bottom: 8px; }
#sidebarCategory { font-weight: bold; color: var(--accent); text-transform: uppercase; display: block; letter-spacing: 2px; }
.category-header--desktop { display: none; }
#wordListCategory { font-weight: bold; color: var(--accent); text-transform: uppercase; display: block; letter-spacing: 2px; }

.stat-item, .word-list span { color: var(--accent); font-weight: bold; font-size: 0.95rem; }
.stat-item {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 46px;
}
.stat-label { display: block; font-size: 0.7rem; opacity: 0.8; text-transform: uppercase; }

.stats-action-button {
    width: 100%;
    grid-column: auto;
    margin-top: 0;
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    padding: 8px 10px;
    background: var(--header-footer);
    color: var(--accent);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.stats-action-button:hover {
    background: var(--submenu-bg);
}

.stats-action-button__label {
    line-height: 1;
}

.stats-action-button__meta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    line-height: 1;
}

.hint-ad-icon {
    width: 20px;
    height: 20px;
    display: inline-block;
    color: var(--accent);
}

.hint-ad-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.hint-daily-icons {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.hint-daily-icon {
    width: 10px;
    height: 14px;
    display: inline-block;
    color: color-mix(in srgb, var(--accent) 24%, var(--text) 76%);
}

.hint-daily-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.hint-daily-icon.is-available {
    color: var(--accent);
}

.word-list span.found { text-decoration: line-through; opacity: 0.5; color: var(--text); }

/* ================================================================
   5. UI COMPONENTS (MODAL & FOOTER)
================================================================ 
*/
.site-footer {
    position: fixed; bottom: 0; left: 0; width: 100%; height: 35px;
    background: var(--header-footer); border-top: 1px solid var(--accent);
    display: flex; justify-content: space-between; align-items: center;
    padding:
        0
        18px
        0
        15px;
    font-size: 0.75rem; font-weight: bold; z-index: 10000;
    box-sizing: border-box;
}

.footer-left,
.footer-right {
    display: block;
}

.footer-right a {
    color: inherit;
    text-decoration: none;
}

@supports (-webkit-touch-callout: none) {
    body:not([data-app-platform="android"]) .footer-right {
        transform: translateX(-3px);
    }
}

.desktop-ad-preview-bar {
    display: none;
    pointer-events: none;
}

.mobile-ad-preview-bar {
    display: none;
    pointer-events: none;
    
}

.adsense-footer-ad {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.adsense-side-ad {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    pointer-events: auto;
}

.desktop-side-ad {
    display: none;
}

body.has-ad-preview .site-footer,
body.has-app-ad-slot .site-footer {
    display: none !important;
}

body[data-app-platform="android"][data-user-subscription-tier="pro"] .site-footer,
body[data-app-platform="android"][data-user-ads-removed="1"] .site-footer {
    display: flex !important;
}

.android-install-sheet {
    position: fixed;
    inset: 0;
    z-index: 1000002;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.38);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease;
}

.android-install-sheet[hidden] {
    display: none !important;
}

.android-install-sheet.is-open {
    opacity: 1;
    pointer-events: auto;
}

.android-install-sheet__backdrop {
    position: absolute;
    inset: 0;
}

.android-install-sheet__panel {
    position: relative;
    width: min(100%, 440px);
    padding: 24px;
    border: 2px solid var(--accent);
    border-radius: 24px;
    background: var(--header-footer);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
    transform: translateY(18px);
    transition: transform 0.24s ease;
    text-align: left;
}

.android-install-sheet.is-open .android-install-sheet__panel {
    transform: translateY(0);
}

.android-install-sheet__header {
    display: grid;
    gap: 8px;
}

.android-install-sheet__eyebrow {
    margin: 0;
    color: var(--accent);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.android-install-sheet__header h2 {
    margin: 0;
    color: var(--text);
    font-size: clamp(1.2rem, 2.8vw, 1.55rem);
    line-height: 1.12;
}

.android-install-sheet__copy {
    margin: 0;
    color: color-mix(in srgb, var(--text) 82%, transparent);
    font-size: 0.94rem;
    line-height: 1.5;
}

.android-install-sheet__actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 22px;
}

.android-install-sheet__actions button {
    width: 100%;
    min-height: 48px;
    margin-top: 0;
    border-radius: 999px;
    font-weight: 700;
    white-space: nowrap;
}

.android-install-sheet__install {
    border: none;
    background: var(--accent);
    color: var(--header-footer);
    box-shadow: none;
}

.android-install-sheet__dismiss {
    border: 1px solid var(--border-soft) !important;
    background: var(--background) !important;
    color: var(--text) !important;
    box-shadow: none !important;
}

.android-install-sheet__never {
    border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
    background: transparent;
    color: var(--accent);
    box-shadow: none;
}

.apple-install-sheet {
    position: fixed;
    inset: 0;
    z-index: 1000001;
    display: grid;
    align-items: end;
    padding: 0;
    background: rgba(0, 0, 0, 0.32);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease;
}

.apple-install-sheet[hidden] {
    display: none !important;
}

.apple-install-sheet.is-open {
    opacity: 1;
    pointer-events: auto;
}

.apple-install-sheet__backdrop {
    position: absolute;
    inset: 0;
}

.apple-install-sheet__panel {
    position: relative;
    width: min(100%, 620px);
    margin: 0 auto;
    padding: 20px 18px 16px;
    border: 2px solid var(--accent);
    border-bottom: none;
    border-radius: 26px 26px 0 0;
    background: var(--header-footer);
    box-shadow: 0 -18px 42px rgba(0, 0, 0, 0.28);
    transform: translateY(108%);
    transition: transform 0.28s ease;
    overflow: hidden;
}

.apple-install-sheet.is-open .apple-install-sheet__panel {
    transform: translateY(0);
}

.apple-install-sheet__header {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
    text-align: left;
}

.apple-install-sheet__eyebrow {
    margin: 0;
    color: var(--accent);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.apple-install-sheet__header h2 {
    margin: 0;
    color: var(--text);
    font-size: clamp(1.15rem, 2.8vw, 1.5rem);
    line-height: 1.1;
}

.apple-install-sheet__copy {
    margin: 0;
    color: color-mix(in srgb, var(--text) 82%, transparent);
    font-size: 0.92rem;
    line-height: 1.45;
}

.apple-install-sheet__carousel {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    scrollbar-width: none;
}

.apple-install-sheet__carousel::-webkit-scrollbar {
    display: none;
}

.apple-install-sheet__card {
    flex: 0 0 100%;
    scroll-snap-align: start;
    display: grid;
    gap: 12px;
    padding: 12px 4px 4px;
    border: none;
    border-radius: 0;
    background: transparent;
    text-align: left;
}

.apple-install-sheet__step {
    color: var(--accent);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.apple-install-sheet__card-title {
    margin: 0;
    color: var(--text);
    font-size: 1.08rem;
    line-height: 1.15;
}

.apple-install-sheet__card-copy {
    margin: 0;
    color: color-mix(in srgb, var(--text) 82%, transparent);
    font-size: 0.9rem;
    line-height: 1.45;
}

.apple-install-sheet__image-shell {
    display: flex;
    justify-content: center;
    padding: 8px 0 0;
    border: none;
    border-radius: 0;
    background: transparent;
}

.apple-install-sheet__image {
    display: block;
    width: min(100%, 260px);
    max-height: min(42vh, 420px);
    height: auto;
    object-fit: contain;
    object-position: center top;
    border-radius: 14px;
    border: 1px solid var(--border-soft);
    background: var(--surface-3);
}

.apple-install-sheet__dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 16px 0 14px;
}

.apple-install-sheet__dot {
    width: 10px;
    height: 10px;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text) 16%, transparent);
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease;
}

.apple-install-sheet__dot.is-active {
    background: var(--accent);
    transform: scale(1.18);
}

.apple-install-sheet__actions {
    display: flex;
    align-items: center;
    justify-content: stretch;
    gap: 12px;
}

.apple-install-sheet__actions button {
    margin-top: 0;
    white-space: nowrap;
    min-height: 48px;
    border-radius: 999px;
    font-weight: 700;
}

.apple-install-sheet__actions .secondary-button {
    flex: 1 1 50%;
    border: none !important;
    background: var(--accent) !important;
    color: var(--header-footer) !important;
    box-shadow: none !important;
}

.apple-install-sheet__never {
    flex: 1 1 50%;
    background: var(--background) !important;
    color: var(--accent) !important;
    border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent) !important;
    box-shadow: none !important;
}

.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85); display: none; 
    justify-content: center; align-items: center; z-index: 999999; backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--header-footer); border: 4px solid var(--accent); color: var(--text);
    padding: 40px; border-radius: 20px; text-align: center; width: 90%; max-width: 450px;
    box-sizing: border-box;
    max-width: calc(100vw - 24px);
}
.modal-content h2 {
    color: var(--accent);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent);
    text-transform: uppercase;
    letter-spacing: 2px;
}
/* --- MODAL BUTTON STYLING --- */
.modal-content button {
    margin-top: 20px;
    padding: 12px 25px;
    background-color: var(--accent);
    color: var(--background);
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s ease, filter 0.2s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    white-space: nowrap;
}

.modal-content button:hover {
    filter: brightness(1.1);
}

.modal-content button:active {
    transform: scale(0.96);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.modal-content.completion-modal__content {
    width: calc(100vw - 24px);
    max-width: 360px;
    padding: 24px 24px 22px;
    box-sizing: border-box;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 12px 25px;
    background: var(--accent);
    color: var(--background);
    border: none;
    border-radius: 8px;
    font: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.1s ease, filter 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: scale(0.96);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.auth-modal__content {
    position: relative;
    max-width: 460px;
    padding: 28px;
    padding-top: 34px;
    text-align: left;
    max-height: calc(100vh - 24px);
    overflow-x: hidden;
    overflow-y: auto;
}

.auth-modal__header {
    display: block;
    margin-bottom: 18px;
}

.auth-modal__header h2 {
    margin: 0 0 8px;
    border-bottom: none;
    padding-bottom: 0;
    letter-spacing: 0.04em;
}

.auth-modal__copy {
    margin: 0;
    line-height: 1.5;
    opacity: 0.8;
}

.auth-close {
    position: absolute;
    top: 8px;
    right: 12px;
    margin: 0;
    padding: 0;
    width: 36px;
    height: 36px;
    background: transparent;
    color: var(--text);
    border: none;
    border-radius: 999px;
    box-shadow: none;
    font-size: 1.8rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.75;
    z-index: 2;
}

.auth-close:hover {
    background: var(--submenu-bg);
    opacity: 1;
}

.auth-status {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--submenu-bg);
    border: 1px solid var(--border-soft);
}

.auth-status.is-error {
    background: rgba(220, 38, 38, 0.12);
    border-color: rgba(220, 38, 38, 0.28);
}

.auth-status.is-success {
    background: rgba(255, 235, 59, 0.18);
    border-color: rgba(255, 235, 59, 0.34);
}

.pro-upgrade-modal__content {
    position: relative;
    max-width: 460px;
    padding: 28px;
    padding-top: 34px;
    text-align: left;
}

.pro-upgrade-summary {
    margin-top: 8px;
}

.pro-upgrade-summary .resume-saved-game__value {
    text-align: right;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 22px;
}

.modal-actions--row {
    flex-wrap: nowrap;
}

.modal-actions--stack {
    flex-direction: column;
    align-items: stretch;
}

.modal-actions .secondary-button,
.modal-actions button:not(.secondary-button) {
    margin-top: 0;
}

.secondary-button {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border-soft);
}

.secondary-button:hover {
    filter: none;
    background: var(--submenu-bg);
}

@media (max-width: 520px) {
    .modal-actions--row {
        flex-wrap: wrap;
    }

    .modal-actions--row button {
        width: 100%;
    }

    .logout-confirm__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .logout-confirm__actions button {
        width: 100%;
    }

    #cancelDeletionModal .logout-confirm__actions {
        flex-direction: column;
        align-items: stretch;
    }

    #cancelDeletionModal .logout-confirm__actions button {
        width: 100%;
        flex: 1 1 auto;
    }
}

.auth-provider-stack {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}

.google-signin-slot {
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.google-signin-slot > div {
    max-width: 100%;
}

.auth-provider-note {
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--submenu-bg);
    border: 1px dashed var(--border-soft);
    line-height: 1.5;
    font-size: 0.92rem;
}

.auth-provider-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    width: 100%;
    padding: 0 18px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    color: #1f1f1f;
    font-weight: 700;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.auth-provider-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.12);
}

.auth-divider {
    position: relative;
    text-align: center;
    margin: 4px 0 16px;
}

.auth-divider::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    border-top: 1px solid var(--border-soft);
}

.auth-divider span {
    position: relative;
    display: inline-block;
    padding: 0 12px;
    background: var(--header-footer);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.7;
}

.auth-form {
    display: none;
    gap: 14px;
}

.auth-form.is-active {
    display: grid;
}

.auth-field {
    display: grid;
    gap: 8px;
    font-weight: 600;
}

.auth-field input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border-soft);
    background: var(--cell-bg);
    color: var(--text);
    font: inherit;
    font-size: 16px;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    box-shadow: none;
}

.auth-form input,
.auth-form select,
.auth-form textarea,
.profile-form input,
.profile-form select,
.profile-form textarea {
    box-sizing: border-box;
    max-width: 100%;
}

.auth-field input:focus,
.auth-field input:active,
.profile-form select:focus,
.profile-form select:active {
    outline: none;
    box-shadow: none;
    border-color: var(--border-soft);
}

.auth-note {
    margin: -2px 0 0;
    font-size: 0.9rem;
    opacity: 0.78;
}

.auth-secondary-button {
    width: 100%;
    display: block;
    box-sizing: border-box;
    max-width: 100%;
    border: none;
    background: transparent;
    color: var(--accent);
    font: inherit;
    font-weight: 700;
    text-align: center;
    padding: 0;
    cursor: pointer;
    white-space: normal;
}

@media (max-width: 520px) {
    .modal-content {
        width: calc(100vw - 24px);
        padding: 24px 18px;
    }

    .auth-modal__content {
        padding: 24px 18px;
        padding-top: 30px;
    }
}

.auth-secondary-button:hover {
    text-decoration: underline;
}

.auth-submit {
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
}

.player-status-modal__content {
    position: relative;
    max-width: 760px;
    max-height: min(82vh, 760px);
    padding: 28px;
    padding-top: 34px;
    overflow-y: auto;
    text-align: left;
}

.player-status__header {
    display: block;
    margin-bottom: 18px;
}

.player-status__header h2 {
    margin: 0 0 8px;
    border-bottom: none;
    padding-bottom: 0;
    letter-spacing: 0.04em;
}

.player-status__copy {
    margin: 0;
    line-height: 1.5;
    opacity: 0.8;
}

.player-status__body {
    display: grid;
    gap: 18px;
}

.player-status__loading {
    padding: 24px 0;
    opacity: 0.75;
}

.logout-confirm-modal__content {
    position: relative;
    max-width: 440px;
    padding: 28px;
    padding-top: 34px;
    text-align: left;
}

.logout-confirm__header {
    display: block;
    margin-bottom: 20px;
}

.logout-confirm__header h2 {
    margin: 0 0 8px;
    border-bottom: none;
    padding-bottom: 0;
    letter-spacing: 0.04em;
}

.logout-confirm__copy {
    margin: 0;
    line-height: 1.5;
    opacity: 0.82;
}

.logout-confirm__actions {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.logout-confirm__actions button {
    width: auto;
    flex: 0 0 auto;
}

.logout-confirm__actions--stacked {
    flex-direction: column;
    align-items: stretch;
}

.logout-confirm__actions--stacked button {
    width: 100%;
    flex: 1 1 auto;
}

#cancelDeletionModal .logout-confirm__actions {
    flex-direction: row;
    align-items: center;
}

#cancelDeletionModal .logout-confirm__actions button {
    width: auto;
    flex: 0 0 auto;
}

.logout-confirm__cancel,
.logout-confirm__confirm {
    margin-top: 0 !important;
}

.logout-confirm__cancel {
    background: transparent !important;
    color: var(--text) !important;
    border: 1px solid var(--border-soft) !important;
    box-shadow: none !important;
}

.announcement-modal__content {
    max-width: 460px;
}

.announcement-modal__summary {
    display: grid;
    gap: 12px;
}

.announcement-modal__message-title {
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.35;
}

.announcement-modal__text {
    margin: 0;
    color: var(--text);
    line-height: 1.55;
}

.announcement-modal__actions {
    justify-content: center;
}

.announcement-modal__link {
    color: var(--accent);
    font-weight: 700;
    text-decoration: underline;
    display: inline-flex;
    align-items: center;
    justify-self: end;
    padding: 4px 0;
}

.announcement-modal__link:hover {
    filter: brightness(1.05);
}

.resume-saved-game-modal__content {
    position: relative;
    max-width: 460px;
    padding: 28px;
    padding-top: 34px;
    text-align: left;
}

.resume-saved-game__header {
    display: block;
    margin-bottom: 18px;
}

.resume-saved-game__header h2 {
    margin: 0 0 8px;
    border-bottom: none;
    padding-bottom: 0;
    letter-spacing: 0.04em;
}

.resume-saved-game__copy {
    margin: 0;
    line-height: 1.5;
    opacity: 0.82;
}

.resume-saved-game__summary {
    margin-top: 8px;
    padding: 14px 16px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: var(--submenu-bg);
    display: grid;
    gap: 8px;
}

.resume-saved-game__row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.94rem;
}

.resume-saved-game__label {
    opacity: 0.72;
}

.resume-saved-game__value {
    font-weight: 700;
    text-align: right;
}

.resume-saved-game__actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.profile-modal__content {
    position: relative;
    max-width: 460px;
    padding: 28px;
    padding-top: 34px;
    text-align: left;
}

.profile-modal__header {
    display: block;
    margin-bottom: 18px;
}

.profile-modal__header h2 {
    margin: 0 0 8px;
    border-bottom: none;
    padding-bottom: 0;
    letter-spacing: 0.04em;
}

.profile-modal__copy {
    margin: 0;
    line-height: 1.5;
    opacity: 0.82;
}

.profile-form {
    display: grid;
    gap: 14px;
}

.account-settings-modal__content {
    position: relative;
    max-width: 480px;
    padding: 28px;
    padding-top: 34px;
    text-align: left;
}

.profile-avatar-editor {
    display: grid;
    justify-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.profile-avatar {
    width: 88px;
    height: 88px;
}

.profile-avatar-editor__field {
    width: 100%;
}

.profile-form select {
    width: 100%;
    margin-top: 6px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border-soft);
    background: var(--background);
    color: var(--text);
    font: inherit;
    font-size: 16px;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    box-shadow: none;
}

.auth-field--readonly input {
    opacity: 0.72;
    cursor: default;
}

.player-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.player-card {
    padding: 14px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: var(--submenu-bg);
}

.player-card__label {
    display: block;
    font-size: 0.76rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.7;
    margin-bottom: 8px;
}

.player-card__value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
}

.player-panel {
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    overflow: hidden;
}

.player-panel__title {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.8;
}

.player-list {
    display: grid;
}

.player-list__row {
    display: grid;
    grid-template-columns: 1.3fr 1fr 1fr 1fr;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-soft);
    align-items: center;
}

.player-list__row:last-child {
    border-bottom: none;
}

.player-list__row span {
    min-width: 0;
}

.player-list__head {
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.7;
}

.player-list__empty {
    padding: 18px 16px;
    opacity: 0.75;
}

@media (max-width: 680px) {
    .player-status-modal__content {
        width: 94%;
        padding: 22px;
        padding-top: 30px;
    }

    .player-list__row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

}
/* ================================================================
   6. RESPONSIVE QUERIES
================================================================ 
*/

/* --- MOBILE PORTRAIT (REDUCED FONT & GAP) --- */
@media (max-width: 1024px) and (orientation: portrait) {
    body[data-app-platform="android"][data-user-subscription-tier="pro"] .game-layout,
    body[data-app-platform="android"][data-user-ads-removed="1"] .game-layout {
        padding-bottom: 5px;
    }

    .game-layout {
        padding-top: 5px;
        display: grid;
        grid-template-rows: auto auto auto;
        align-content: space-evenly;
        justify-items: stretch;
    }

    body.has-app-ad-slot[data-app-platform="android"] main {
        bottom: 55px;
    }

    body.has-app-ad-slot[data-app-platform="android"] .site-footer {
        display: none !important;
    }

    body.has-app-ad-slot[data-app-platform="android"] .mobile-ad-preview-bar {
        position: fixed;
        left: 50%;
        right: auto;
        bottom: 0;
        display: block;
        height: 50px;
        width: min(320px, calc(100vw - 20px));
        z-index: 9990;
        pointer-events: none;
        transform: translateX(-50%);
    }

    .stats-container {
        padding: 8px;
        margin: 0 10px;
    }

    .wordsearch-container {
        padding: 5px;
    }

    .stats-list {
        gap: 6px;
    }

    .stat-item,
    .stats-action-button {
        min-height: 42px;
    }

    .stat-item {
        font-size: 0.9rem;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    .stats-action-button {
        font-size: 0.82rem;
        padding: 8px 6px;
    }

    .word-list-container { 
        width: min(var(--board-size-vmin), calc(100% - 20px));
        max-height: 20vh; 
        padding: 6px;      /* Reduced box padding */
        margin: 0 auto 5px !important; 
    }
    
    .word-list { 
        gap: 5px;         /* Reduced gap between words */
    }

    .word-list span { 
        font-size: 0.85rem; /* Reduced font size to prevent scroll */
    }

    .category-header { margin-bottom: 4px; padding-bottom: 4px; }
    .category-header--desktop { display: none; }
}
/* --- MOBILE LANDSCAPE (SIDEBAR STYLE) --- */
@media (max-width: 1024px) and (orientation: landscape) {
    .game-layout { flex-direction: row; justify-content: space-between; align-items: stretch; }

    .stats-container { 
        width: 130px; height: 100%; margin: 0; order: 1;
        border-radius: 0; border-top: none; border-bottom: none; border-left: none;
        display: flex; flex-direction: column;
    }

    .wordsearch-container { flex: 1; order: 2; padding: 5px; }
    .grid { width: 75vmin; height: 75vmin; }

    .word-list-container { 
        width: 140px; height: 100%; margin: 0; order: 3;
        border-radius: 0; border-top: none; border-bottom: none; border-right: none;
        overflow-y: auto;
    }
    .category-header--desktop { display: block; }
    .stats-container .category-header { display: none; }

    .stats-list, .word-list { grid-template-columns: 1fr; gap: 5px; }
    .word-list span { display: block; padding: 2px 0; font-size: 0.80rem; }
    .stat-item { margin-bottom: 12px; }
}

/* Web/PWA portrait tablet grid trim: keep app/webview sizing untouched and reduce browser board size by 100px. */
@media (min-width: 600px) and (max-width: 1024px) and (orientation: portrait) {
    body:not([data-app-platform="android"]) .grid {
        width: calc(var(--board-size-vmin) - 80px);
        height: calc(var(--board-size-vmin) - 90px);
    }
}

@media (max-width: 1024px) {
    body.has-ad-preview:not([data-app-platform="android"]) main {
        bottom: 55px;
    }

    body.has-ad-preview:not([data-app-platform="android"]) .site-footer {
        display: none !important;
    }

    body.has-ad-preview:not([data-app-platform="android"]) .desktop-ad-preview-bar {
        display: none;
    }

    body.has-ad-preview:not([data-app-platform="android"]) .mobile-ad-preview-bar {
        position: fixed;
        left: 50%;
        right: auto;
        bottom: 0;
        display: block;
        height: 50px;
        width: min(320px, calc(100vw - 20px));
        z-index: 9990;
        pointer-events: none;
        transform: translateX(-50%);
    }
}

/* --- DESKTOP --- */
@media (min-width: 1025px) {
    .game-layout {
        gap: 5px;
        padding: 0;
    }

    .menu-left {
        width: 266px;
    }

    body.has-ad-preview main {
        bottom: 0;
    }

    body.has-ad-preview .site-footer {
        display: none !important;
    }

    body.has-ad-preview .mobile-ad-preview-bar {
        display: none;
    }

    body.has-ad-preview .desktop-ad-preview-bar {
        display: none;
    }

    body.has-ad-preview .desktop-side-ad {
        display: flex;
        width: 160px;
        height: 100%;
        background: transparent;
        flex: 0 0 160px;
        justify-content: center;
        align-items: flex-start;
        padding-top: 12px;
    }

    .game-layout { flex-direction: row; }
    .stats-container { width: 200px; height: 100%; order: 1; margin: 0; border-radius: 0; border-top: none; border-bottom: none; border-left: none;}
    .desktop-side-ad--left { order: 2; }
    .wordsearch-container { flex: 1; order: 3;}
    .desktop-side-ad--right { order: 4; }
    .word-list-container { width: 200px; height: 100%; order: 5; margin: 0; border-radius: 0; border-top: none; border-bottom: none; border-right: none; overflow-y: auto; }
    .category-header--desktop { display: block; }
    .stats-container .category-header { display: none; }
    .stats-list, .word-list { grid-template-columns: 1fr; padding: 15px; }
    .grid { width: 80vmin; height: 80vmin; }
}

@media (max-width: 520px) {
    .apple-install-sheet {
        padding: 0;
    }

    .apple-install-sheet__panel {
        width: 100%;
        border-left: none;
        border-right: none;
        border-radius: 22px 22px 0 0;
        padding: 18px 14px 16px;
    }

    .apple-install-sheet__image {
        width: min(100%, 232px);
        max-height: min(38vh, 360px);
    }

    .apple-install-sheet__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .apple-install-sheet__actions button {
        width: 100%;
    }

    .android-install-sheet {
        padding: 0;
        align-items: end;
    }

    .android-install-sheet__panel {
        width: 100%;
        border-left: none;
        border-right: none;
        border-bottom: none;
        border-radius: 22px 22px 0 0;
        padding: 20px 14px 16px;
    }
}
@media (max-width: 640px) {
    #cancelDeletionModal .logout-confirm__actions {
        display: flex;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px;
    }

    #cancelDeletionModal .logout-confirm__actions button {
        width: 100% !important;
        flex: 1 1 auto !important;
    }
}
