/* ================================================================
   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: #222222;
    --surface-2: #e8e8e8;
    --surface-3: #ffffff;
    --grid-bg: #e8e8e8;
    --cell-bg: #ffffff;
    --board-size-vmin: 92vmin;
    --grid-logo-image: url('appvark_logo_light.png');
    --grid-logo-size: min(72%, 520px);
    --border-soft: rgba(34, 34, 34, 0.12);
    --menu-shadow: 0 18px 38px rgba(34, 34, 34, 0.12);
    --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: #eeeeee;
    --surface-2: #363636;
    --surface-3: #444444;
    --grid-bg: #363636;
    --cell-bg: #444444;
    --grid-logo-image: url('appvark_logo_dark.png');
    --border-soft: rgba(238, 238, 238, 0.16);
    --menu-shadow: 0 18px 38px rgba(0, 0, 0, 0.28);
    --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);
}

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;
}

* {
    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-action:hover,
.menu-left-action:focus-visible {
    background: var(--grid-bg);
}

.menu-left-actions .menu-left-action:last-child {
    padding-bottom: 15px;
}

.menu-left.show {
    transform: translateX(0);
}

.menu-right {
    right: 0;
    left: auto;
    transform: translateX(100%);
    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 {
    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);
    width: 48px;
    height: 48px;
}

.menu-user-avatar__icon {
    width: 60%;
    height: 60%;
    display: grid;
    place-items: center;
}

.menu-user-avatar__icon svg {
    width: 100%;
    height: 100%;
}

.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-section {
    display: grid;
    gap: 2px;
    padding: 10px 0;
}

.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--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;
}

.menu-left-scroll .submenu li a {
    white-space: nowrap;
}

.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 > .side-arrow {
    transform: rotate(90deg);
}

.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,
.menu-left-scroll .has-submenu.is-current-category,
.menu-left-scroll > ul > .has-submenu.open > .submenu .has-submenu.is-current,
.menu-left-scroll > ul > .has-submenu.open > .submenu .has-submenu.is-current-category {
    color: var(--accent);
}

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

.menu-left-scroll > ul > .has-submenu.open > .submenu li a.is-current,
.menu-left-scroll > ul > .has-submenu.open > .submenu li a[aria-current="page"] {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
}

.menu-section--settings {
    margin-top: auto;
    padding-bottom: 30px;
}

.menu-section--footer-action {
    margin-top: auto;
    padding-bottom: 24px;
}

.menu-action--submenu {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.menu-action--submenu[aria-expanded="true"] {
    color: var(--accent);
}

.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;
}

.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-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;
}

/* ================================================================
   3. MAIN SHELL AREA
================================================================ */
main {
    position: fixed;
    top: 60px;
    left: 0;
    width: 100%;
    bottom: 35px;
    overflow: hidden;
    background: var(--background);
}

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"]) .sudoku-board-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"]) .sudoku-board-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;
}

.sudoku-board-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px;
    position: relative;
}

.grid {
    display: grid;
    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);
    overflow: hidden;
}

.sudoku-grid {
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    background-color: var(--grid-bg);
    background-image: var(--grid-logo-image);
    background-repeat: no-repeat;
    background-position: center;
    background-size: var(--grid-logo-size);
}

.sudoku-grid.is-loading {
    opacity: 0.55;
    pointer-events: none;
}

.cell {
    background: transparent;
    color: var(--text);
    border-top: 0;
    border-left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    position: relative;
    border-right: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
    border-bottom: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
    font-size: clamp(1.1rem, 2.8vh, 2rem);
    appearance: none;
    -webkit-appearance: none;
    font-family: inherit;
    cursor: pointer;
    padding: 0;
}

.cell:nth-child(9n) {
    border-right: 0;
}

.cell:nth-child(3n):not(:nth-child(9n)) {
    border-right-color: var(--accent);
    border-right-width: 2px;
}

.cell:nth-child(n + 19):nth-child(-n + 27),
.cell:nth-child(n + 46):nth-child(-n + 54) {
    border-bottom-color: var(--accent);
    border-bottom-width: 2px;
}

.cell:nth-child(n + 73) {
    border-bottom: 0;
}

.sudoku-grid.jigsaw-grid .cell:nth-child(3n):not(:nth-child(9n)) {
    border-right-color: color-mix(in srgb, var(--accent) 18%, transparent);
    border-right-width: 1px;
}

.sudoku-grid.jigsaw-grid .cell:nth-child(n + 19):nth-child(-n + 27),
.sudoku-grid.jigsaw-grid .cell:nth-child(n + 46):nth-child(-n + 54) {
    border-bottom-color: color-mix(in srgb, var(--accent) 18%, transparent);
    border-bottom-width: 1px;
}

.cell.jigsaw-region-right {
    border-right-color: var(--accent) !important;
    border-right-width: 2px !important;
}

.cell.jigsaw-region-bottom {
    border-bottom-color: var(--accent) !important;
    border-bottom-width: 2px !important;
}

.cell.given {
    color: var(--accent);
    background: transparent;
}

.cell.selected {
    background: color-mix(in srgb, #9ec5ff 34%, transparent);
    box-shadow: inset 0 0 0 2px color-mix(in srgb, #2f7dff 55%, transparent);
}

.cell.related {
    background: color-mix(in srgb, var(--accent) 9%, transparent);
}

.cell.matching {
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.cell.error {
    color: #c62828;
    background: color-mix(in srgb, #c62828 18%, transparent);
}

.cell.diagonal::before {
    content: "";
    position: absolute;
    inset: 14%;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
    pointer-events: none;
}

.cell.hyper-region::before {
    content: "";
    position: absolute;
    inset: 7%;
    border-radius: 6px;
    background: color-mix(in srgb, var(--accent) 7%, transparent);
    pointer-events: none;
}

.cell.anti-knight-cell::before {
    content: "";
    position: absolute;
    top: 5px;
    right: 5px;
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 34%, transparent);
    pointer-events: none;
}

.cell.anti-queen-cell::before {
    content: "";
    position: absolute;
    top: 5px;
    right: 5px;
    width: 7px;
    height: 7px;
    border: 1px solid color-mix(in srgb, var(--accent) 48%, transparent);
    transform: rotate(45deg);
    pointer-events: none;
}

.cell.anti-king-cell::before {
    content: "";
    position: absolute;
    top: 5px;
    right: 5px;
    width: 6px;
    height: 6px;
    border: 1px solid color-mix(in srgb, var(--accent) 42%, transparent);
    border-radius: 2px;
    pointer-events: none;
}

.cell.killer-cage-top {
    border-top: 1px dashed color-mix(in srgb, var(--accent) 58%, transparent);
}

.cell.killer-cage-right {
    border-right: 1px dashed color-mix(in srgb, var(--accent) 58%, transparent);
}

.cell.killer-cage-bottom {
    border-bottom: 1px dashed color-mix(in srgb, var(--accent) 58%, transparent);
}

.cell.killer-cage-left {
    border-left: 1px dashed color-mix(in srgb, var(--accent) 58%, transparent);
}

.cell[data-cage-sum]::after {
    content: attr(data-cage-sum);
    position: absolute;
    top: 2px;
    left: 3px;
    font-size: clamp(0.48rem, 1vw, 0.68rem);
    line-height: 1;
    font-weight: 700;
    color: color-mix(in srgb, var(--accent) 78%, var(--text) 22%);
    pointer-events: none;
}

.cell.selected {
    background: color-mix(in srgb, #9ec5ff 34%, transparent);
    box-shadow: inset 0 0 0 2px color-mix(in srgb, #2f7dff 55%, transparent);
}

.cell.hinted {
    animation: hintPulse 0.75s ease;
}

.cell-parity-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    width: clamp(0.8rem, 1.8vw, 1rem);
    height: clamp(0.8rem, 1.8vw, 1rem);
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-size: clamp(0.45rem, 0.95vw, 0.58rem);
    line-height: 1;
    font-weight: 700;
    background: color-mix(in srgb, var(--background) 90%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
    color: color-mix(in srgb, var(--accent) 72%, var(--text) 28%);
    pointer-events: none;
    z-index: 3;
}

.cell-edge-marker {
    position: absolute;
    z-index: 4;
    pointer-events: none;
}

.cell-edge-marker--right {
    top: 50%;
    right: 0;
    transform: translate(50%, -50%);
}

.cell-edge-marker--bottom {
    left: 50%;
    bottom: 0;
    transform: translate(-50%, 50%);
}

.cell-edge-marker--xv {
    min-width: clamp(0.82rem, 1.9vw, 1rem);
    height: clamp(0.82rem, 1.9vw, 1rem);
    padding: 0 1px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--background) 92%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    color: color-mix(in srgb, var(--accent) 82%, var(--text) 18%);
    font-size: clamp(0.45rem, 0.95vw, 0.58rem);
    font-weight: 700;
    line-height: 1;
}

.cell-edge-marker--consecutive {
    width: clamp(0.48rem, 1.3vw, 0.62rem);
    height: clamp(0.48rem, 1.3vw, 0.62rem);
    border-radius: 4px;
    background: color-mix(in srgb, var(--accent) 58%, var(--background) 42%);
    border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent);
}

.cell-edge-marker--kropki-white,
.cell-edge-marker--kropki-black {
    width: clamp(0.48rem, 1.25vw, 0.62rem);
    height: clamp(0.48rem, 1.25vw, 0.62rem);
    border-radius: 999px;
}

.cell-edge-marker--kropki-white {
    background: var(--background);
    border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}

.cell-edge-marker--kropki-black {
    background: color-mix(in srgb, var(--accent) 68%, var(--text) 32%);
    border: 1px solid color-mix(in srgb, var(--accent) 12%, transparent);
}

.sudoku-start-overlay {
    position: absolute;
    inset: 5px;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 4;
    background: color-mix(in srgb, var(--background) 32%, transparent);
    backdrop-filter: blur(2px);
}

.sudoku-start-overlay.is-visible {
    display: flex;
}

.sudoku-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%);
    box-shadow: var(--menu-shadow);
    text-align: center;
}

.sudoku-start-overlay__eyebrow {
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.68;
    margin-bottom: 10px;
}

.sudoku-start-overlay__title {
    font-size: clamp(1.3rem, 2.2vw, 1.8rem);
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
}

.sudoku-start-overlay__copy {
    line-height: 1.5;
    opacity: 0.8;
    margin-bottom: 16px;
}

.sudoku-start-overlay__button {
    border: none;
    border-radius: 999px;
    padding: 12px 28px;
    background: var(--accent);
    color: var(--background);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.cell-notes {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    place-items: center;
    font-size: clamp(0.45rem, 1.15vh, 0.72rem);
    line-height: 1;
    opacity: 0.78;
}

.cell-note {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
}

@keyframes hintPulse {
    0% { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
    50% { box-shadow: inset 0 0 0 4px color-mix(in srgb, var(--accent) 70%, transparent); }
    100% { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
}

.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,
#wordListCategory {
    font-weight: bold;
    color: var(--accent);
    text-transform: uppercase;
    display: block;
    letter-spacing: 2px;
}

.category-header--desktop {
    display: none;
}

.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__label {
    line-height: 1;
}

.stats-action-button__meta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    line-height: 1;
}

.stats-action-button:hover,
.sudoku-controls button:hover {
    background: var(--submenu-bg);
}

.sudoku-status {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 14px;
}

.sudoku-status__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-soft);
}

.sudoku-status__item span {
    font-size: 0.78rem;
    font-weight: bold;
    opacity: 0.75;
}

.sudoku-status__item strong {
    color: var(--accent);
    font-size: 0.95rem;
}

.sudoku-tools {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

.sudoku-tools button {
    min-width: 0;
    min-height: 58px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--header-footer);
    color: color-mix(in srgb, var(--text) 42%, transparent);
    font: inherit;
    cursor: pointer;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 4px;
}

.sudoku-tools button.is-notes-active {
    color: var(--accent);
}

.sudoku-tools button svg {
    width: 24px;
    height: 24px;
    display: block;
}

.sudoku-tools button span {
    display: block;
    font-size: 1.3rem;
    font-weight: bold;
    line-height: 1;
}

.sudoku-tools button:hover {
    background: var(--submenu-bg);
}

.sudoku-controls button.is-active {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent);
}

.sudoku-tools button.is-disabled {
    color: color-mix(in srgb, var(--text) 42%, transparent);
    pointer-events: none;
}

.sudoku-controls button.is-disabled {
    opacity: 0.42;
    pointer-events: none;
}

.sudoku-controls button.is-complete {
    opacity: 0.34;
}

.sudoku-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sudoku-controls button {
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--header-footer);
    color: var(--accent);
    font: inherit;
    font-size: 1.35rem;
    font-weight: bold;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.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;
}

.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.has-app-ad-slot[data-app-platform="android"] .app-viewport-shell {
    background: var(--background);
}

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;
    inset: 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;
}

.modal-content button {
    margin-top: 20px;
    padding: 12px 25px;
    background-color: var(--accent);
    color: var(--background);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.2s ease;
}

.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);
}

.completion-modal__content {
    width: min(92%, 360px);
    padding: 24px 24px 22px;
    border: 1px solid var(--border-soft);
    border-radius: 18px;
    box-shadow: var(--menu-shadow);
}

.completion-modal__eyebrow {
    margin: 0 0 10px;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 700;
}

.completion-modal__title {
    margin: 0 0 8px;
    padding: 0;
    border: 0;
    color: var(--accent);
    font-size: 1.45rem;
    line-height: 1.1;
}

.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: 9px;
}

.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);
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 22px;
}

.modal-actions--row {
    flex-wrap: nowrap;
}

.modal-actions .secondary-button,
.modal-actions button:not(.secondary-button) {
    margin-top: 0;
}

.secondary-button {
    background: transparent !important;
    color: var(--text) !important;
    border: 1px solid var(--border-soft) !important;
}

.secondary-button:hover {
    filter: none;
    background: var(--submenu-bg) !important;
}

.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;
    color: var(--accent);
}

.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: 9px;
}

.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;
    color: var(--accent);
}

.resume-saved-game__actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.resume-saved-game__actions button {
    margin-top: 0;
}

.sudoku-help-modal__content {
    max-width: 520px;
}

.sudoku-help-summary {
    margin-bottom: 16px;
}

.sudoku-help-rules {
    display: grid;
    gap: 10px;
    margin-top: 8px;
}

.sudoku-help-rule {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 12px 14px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: var(--submenu-bg);
}

.sudoku-help-rule__index {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    color: var(--accent);
    font-weight: 700;
    line-height: 1;
}

.sudoku-help-rule__text {
    line-height: 1.45;
}

@supports (-webkit-touch-callout: none) {
    body:not([data-app-platform="android"]) .footer-right {
        transform: translateX(-3px);
    }
}

@media (max-width: 640px) {
    .modal-actions--row {
        flex-wrap: wrap;
    }

    .modal-actions--row button {
        width: 100%;
    }

    .resume-saved-game__actions {
        flex-wrap: wrap;
    }

    .resume-saved-game__actions button {
        width: 100%;
    }

    .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;
    }

    .menu-equals span {
        height: 3px;
    }
}

@media (max-width: 1024px) and (orientation: portrait) {
    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%);
    }

    .game-layout {
        padding-top: 5px;
        display: grid;
        grid-template-rows: auto auto auto;
        gap: 0;
        align-content: space-evenly;
        justify-items: stretch;
        overflow: hidden;
    }

    .stats-container {
        padding: 8px;
        margin: 0 10px;
    }

    .sudoku-board-container {
        padding: 5px;
        min-height: 0;
    }

    .grid {
        width: min(calc(100vw - 20px), calc(100dvh - 250px));
        height: min(calc(100vw - 20px), calc(100dvh - 250px));
    }

    .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(calc(100% - 20px), 100%);
        max-height: 20vh;
        height: auto;
        padding: 6px;
        margin: 0 auto 5px !important;
        overflow-y: auto;
        overflow-x: hidden;
        display: grid;
        align-content: start;
    }

    .word-list {
        gap: 5px;
    }

    .sudoku-controls,
    .sudoku-tools,
    .sudoku-status {
        width: 100%;
    }

    .sudoku-status {
        grid-template-columns: 1fr;
        gap: 5px;
        margin-bottom: 5px;
    }

    .sudoku-status__item {
        display: flex;
        justify-content: space-between;
        gap: 8px;
        padding: 4px 0;
        border: 0;
        border-bottom: 1px solid var(--border-soft);
        border-radius: 0;
        background: transparent;
    }

    .sudoku-status__item span {
        font-size: 0.65rem;
    }

    .sudoku-status__item strong {
        font-size: 0.75rem;
    }

    .sudoku-tools {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 0;
        margin-bottom: 5px;
        padding: 0 0 5px;
        border-bottom: 2px solid var(--accent);
    }

    .sudoku-tools button {
        aspect-ratio: auto;
        height: 30px;
        min-height: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        padding: 0;
    }

    .sudoku-tools button svg {
        width: 22px;
        height: 22px;
    }

    .sudoku-tools button span {
        font-size: 1.25rem;
    }

    .sudoku-controls {
        grid-template-columns: repeat(9, minmax(0, 1fr));
        gap: 6px;
    }

    .sudoku-controls button {
        aspect-ratio: 1;
        height: auto;
        min-height: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        font-size: clamp(1.55rem, 7.2vw, 2.15rem);
        font-weight: 400;
        line-height: 1;
        padding: 0;
    }

    .category-header {
        margin-bottom: 4px;
        padding-bottom: 4px;
    }
}

@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;
    }

    .sudoku-board-container {
        flex: 1;
        order: 2;
        padding: 5px;
    }

    .grid {
        width: 75vmin;
        height: 75vmin;
    }

    .word-list-container {
        width: 180px;
        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 {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .stat-item {
        margin-bottom: 12px;
    }
}

@media (min-width: 1025px) {
    .game-layout {
        flex-direction: row;
        gap: 5px;
        padding: 0;
    }

    .stats-container {
        width: 200px;
        height: 100%;
        order: 1;
        margin: 0;
        border-radius: 0;
        border-top: none;
        border-bottom: none;
        border-left: none;
    }

    .sudoku-board-container {
        flex: 1;
        order: 2;
    }

    .word-list-container {
        width: 260px;
        height: 100%;
        order: 3;
        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 {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .grid {
        width: min(72vmin, calc(100vw - 480px));
        height: min(72vmin, calc(100vw - 480px));
    }
}


/* Account and auth menu styles ported from cut reference. */
.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;
}

.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) {
    .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;
    }

    .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;
    }

}
