@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
    --red: #8c3dc1;
    --red-dark: #54297e;
    --bg: #0a0a0a;
    --text-color: #ffffff;
    --text-muted: #9ca3af;
    --glass: rgba(31, 41, 55, 0.35);
    --glass-border: rgba(140, 61, 193, 0.2);
    --blur: blur(12px);
    --page-bg: radial-gradient(ellipse at bottom, #1a1a1a 0%, var(--bg) 70%);
    --glass-hover: rgba(55, 65, 81, 0.6);
    --border-hover: rgba(140, 61, 193, 0.5);
    --island-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
    --island-border: rgba(255, 255, 255, 0.04);
    --island-shadow: 0 10px 30px rgba(3, 7, 18, 0.6);
    --island-shadow-hover: 0 18px 48px rgba(0, 0, 0, 0.65);
    --grid-size: 50px;
    --bg-overscan: 64px;
    --sphere-blend: screen;
    --particle-color: white;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --app-height: 100vh;
    --bg-height: 100vh;
    --tile-size: 52px;
    --tile-gap: 6px;
    --wordle-absent: #9aa3b2;
    --wordle-present: #dfbc3f;
    --wordle-correct: #72bf6a;
    --wordle-ink: #ffffff;
    --modal-bg: rgba(12, 12, 14, 0.96);
    --modal-text: #f8fafc;
    --modal-body: #e5e7eb;
    --modal-muted: #a7b0c0;
    --modal-border: rgba(255, 255, 255, 0.12);
    --modal-soft: rgba(255, 255, 255, 0.08);
}

:root.light-theme {
    --bg: #f2f4f7;
    --page-bg: radial-gradient(circle at top, #ffffff 0%, #f2f4f7 60%, #e2e8f0 100%);
    --text-color: #0f172a;
    --text-muted: #64748b;
    --glass: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(255, 255, 255, 0.8);
    --glass-hover: rgba(255, 255, 255, 0.5);
    --border-hover: rgba(140, 61, 193, 0.6);
    --sphere-blend: normal;
    --island-bg: linear-gradient(135deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.1));
    --island-border: rgba(255, 255, 255, 0.9);
    --island-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.1), 0 0 20px rgba(255, 255, 255, 0.5) inset;
    --island-shadow-hover: 0 18px 48px rgba(0, 0, 0, 0.08), 0 0 30px rgba(255, 255, 255, 0.6) inset;
    --particle-color: #8c3dc1;
    --modal-bg: rgba(255, 255, 255, 0.96);
    --modal-text: #1d1d22;
    --modal-body: #28282e;
    --modal-muted: #64748b;
    --modal-border: rgba(15, 23, 42, 0.12);
    --modal-soft: rgba(148, 163, 184, 0.16);
}

/* Telegram injects these variables for light, dark, and custom client themes. */
body.telegram-mini-app {
    --bg: var(--tg-theme-bg-color, #0a0a0a);
    --page-bg: var(--tg-theme-bg-color, #0a0a0a);
    --text-color: var(--tg-theme-text-color, #ffffff);
    --text-muted: var(--tg-theme-hint-color, #9ca3af);
    --red: var(--tg-theme-button-color, #8c3dc1);
    --red-dark: var(--tg-theme-button-color, #54297e);
    --glass: var(--tg-theme-secondary-bg-color, rgba(31, 41, 55, 0.35));
    --glass-hover: var(--tg-theme-section-bg-color, rgba(55, 65, 81, 0.6));
    --glass-border: var(--tg-theme-section-separator-color, rgba(140, 61, 193, 0.2));
    --island-bg: var(--tg-theme-secondary-bg-color, rgba(31, 41, 55, 0.35));
    --island-border: var(--tg-theme-section-separator-color, rgba(140, 61, 193, 0.2));
    --modal-bg: var(--tg-theme-bg-color, rgba(12, 12, 14, 0.96));
    --modal-text: var(--tg-theme-text-color, #f8fafc);
    --modal-body: var(--tg-theme-text-color, #e5e7eb);
    --modal-muted: var(--tg-theme-hint-color, #a7b0c0);
    --modal-border: var(--tg-theme-section-separator-color, rgba(255, 255, 255, 0.12));
    --modal-soft: var(--tg-theme-secondary-bg-color, rgba(255, 255, 255, 0.08));
}

body.telegram-mini-app .gradient-background,
body.telegram-mini-app #siteHeaderMount,
body.telegram-mini-app .unwordle-footer,
body.telegram-mini-app .custom-cursor {
    display: none;
}

body.telegram-mini-app .content-wrapper {
    padding-top: max(0.75rem, var(--safe-top));
    padding-bottom: max(0.75rem, var(--safe-bottom));
}

body.telegram-mini-app .unwordle-card {
    background: var(--tg-theme-secondary-bg-color, var(--island-bg));
    border-color: var(--tg-theme-section-separator-color, var(--island-border));
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

body.telegram-mini-app .game-action--primary,
body.telegram-mini-app .daily-timer__pause {
    color: var(--tg-theme-button-text-color, #ffffff);
    background: var(--tg-theme-button-color, var(--red));
    border-color: var(--tg-theme-button-color, var(--red));
}

body.telegram-mini-app .keyboard-key:not([data-state]) {
    color: var(--tg-theme-text-color, #07111f);
    background: var(--tg-theme-secondary-bg-color, rgba(226, 232, 240, 0.84));
    border-color: var(--tg-theme-section-separator-color, rgba(255, 255, 255, 0.28));
    box-shadow: none;
}

/* Telegram iOS has a shorter usable viewport than the visual sheet suggests. */
body.telegram-mini-app .unwordle-modal {
    place-items: start center;
    padding-top: calc(var(--safe-top) + 0.75rem);
    padding-bottom: calc(var(--safe-bottom) + 0.75rem);
}

body.telegram-mini-app .unwordle-modal__panel {
    max-height: calc(var(--app-height) - var(--safe-top) - var(--safe-bottom) - 1.5rem);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

@supports (-webkit-touch-callout: none) {
    :root {
        --bg-overscan: 120px;
    }
}

@supports (height: 100svh) {
    :root {
        --app-height: 100svh;
    }
}

@supports (height: 100lvh) {
    :root {
        --bg-height: 100lvh;
    }
}

@supports (height: 100dvh) {
    :root {
        --app-height: 100dvh;
    }
}

* {
    box-sizing: border-box;
}

html {
    min-height: var(--app-height);
    background: var(--page-bg);
    background-color: var(--bg);
    overscroll-behavior-y: none;
    touch-action: pan-x pan-y;
}

body {
    min-height: var(--app-height);
    margin: 0;
    overflow-x: hidden;
    touch-action: pan-x pan-y;
    color: var(--text-color);
    background: var(--page-bg);
    background-color: var(--bg);
    font-family: 'Inter', sans-serif;
    transition: color 0.3s ease, background-color 0.3s ease;
}

body.site-page-unwordle .custom-cursor,
body.site-page-unwordle .custom-cursor.cursor-hover,
body.site-page-unwordle .custom-cursor.cursor-click {
    width: 20px !important;
    height: 20px !important;
    background-color: rgba(255, 255, 255, 0.56) !important;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.5) !important;
}

:root.light-theme body.site-page-unwordle .custom-cursor,
:root.light-theme body.site-page-unwordle .custom-cursor.cursor-hover,
:root.light-theme body.site-page-unwordle .custom-cursor.cursor-click {
    background-color: rgba(15, 23, 42, 0.32) !important;
    box-shadow: 0 0 12px rgba(15, 23, 42, 0.14) !important;
}

button,
input {
    font: inherit;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

button {
    color: inherit;
}

.gradient-background {
    position: fixed;
    top: calc(-1 * var(--bg-overscan));
    left: 0;
    width: 100%;
    height: calc(var(--bg-height) + (var(--bg-overscan) * 2));
    min-height: 110vh;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
    background-color: var(--bg);
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
}

.gradient-sphere {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    mix-blend-mode: var(--sphere-blend);
    transition: mix-blend-mode 0.3s ease;
    will-change: transform;
    contain: strict;
}

.sphere-1 {
    width: 50vw;
    height: 50vw;
    background: linear-gradient(45deg, rgba(255, 0, 128, 0.9), rgba(255, 60, 172, 0.7), rgba(255, 102, 0, 0.5));
    top: -15%;
    left: -15%;
    animation: float-1 6s ease-in-out infinite;
}

.sphere-2 {
    width: 55vw;
    height: 55vw;
    background: linear-gradient(220deg, rgba(72, 0, 255, 0.9), rgba(140, 61, 193, 0.7), rgba(0, 200, 255, 0.5));
    bottom: -25%;
    right: -15%;
    animation: float-2 8s ease-in-out infinite;
}

.sphere-3 {
    width: 40vw;
    height: 40vw;
    background: linear-gradient(120deg, rgba(133, 89, 255, 0.8), rgba(98, 216, 249, 0.6), rgba(0, 255, 200, 0.4));
    top: 50%;
    left: 15%;
    animation: float-3 7s ease-in-out infinite;
}

.sphere-4 {
    width: 35vw;
    height: 35vw;
    background: linear-gradient(300deg, rgba(255, 0, 200, 0.7), rgba(140, 61, 193, 0.6), rgba(72, 0, 255, 0.4));
    top: 10%;
    right: 20%;
    animation: float-4 9s ease-in-out infinite;
}

.glow {
    position: absolute;
    width: 40vw;
    height: 40vh;
    background: radial-gradient(circle, rgba(72, 0, 255, 0.15), transparent 70%);
    top: 50%;
    left: 50%;
    z-index: 2;
    filter: blur(15px);
    transform: translate(-50%, -50%);
    animation: pulse 8s infinite alternate;
    contain: strict;
}

.grid-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    opacity: 0.64;
    mix-blend-mode: overlay;
    background-size: var(--grid-size) var(--grid-size);
    background-position: center center;
    background-image:
        linear-gradient(to right, #d7e5fa 1px, transparent 1px),
        linear-gradient(to bottom, #d7e5fa 1px, transparent 1px);
    contain: strict;
}

@keyframes float-1 {
    0%, 100% { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 0.8; }
    25% { transform: translate(15%, 5%) scale(1.15) rotate(90deg); opacity: 1; }
    50% { transform: translate(10%, 15%) scale(1.1) rotate(180deg); opacity: 0.9; }
    75% { transform: translate(-5%, 10%) scale(1.2) rotate(270deg); opacity: 1; }
}

@keyframes float-2 {
    0%, 100% { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 0.9; }
    33% { transform: translate(-15%, -10%) scale(1.2) rotate(-120deg); opacity: 1; }
    66% { transform: translate(5%, -15%) scale(1.1) rotate(-240deg); opacity: 0.85; }
}

@keyframes float-3 {
    0%, 100% { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 0.7; }
    20% { transform: translate(-10%, -5%) scale(1.15) rotate(72deg); opacity: 0.9; }
    40% { transform: translate(5%, -10%) scale(1.1) rotate(144deg); opacity: 0.8; }
    60% { transform: translate(10%, 5%) scale(1.2) rotate(216deg); opacity: 1; }
    80% { transform: translate(-5%, 10%) scale(1.05) rotate(288deg); opacity: 0.85; }
}

@keyframes float-4 {
    0%, 100% { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 0.7; }
    25% { transform: translate(-10%, 10%) scale(1.1) rotate(-90deg); opacity: 0.9; }
    50% { transform: translate(-5%, -10%) scale(1.15) rotate(-180deg); opacity: 1; }
    75% { transform: translate(10%, -5%) scale(1.05) rotate(-270deg); opacity: 0.8; }
}

@keyframes pulse {
    0% { opacity: 0.3; transform: translate(-50%, -50%) scale(0.9); }
    100% { opacity: 0.7; transform: translate(-50%, -50%) scale(1.1); }
}

.content-wrapper {
    position: relative;
    z-index: 10;
    min-height: var(--app-height);
    padding: calc(5.5rem + var(--safe-top)) max(1rem, var(--safe-left)) calc(1.25rem + var(--safe-bottom));
}

.unwordle-shell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.unwordle-card {
    width: min(100%, 620px);
    margin: 0 auto;
    padding: 14px;
    color: var(--text-color);
    background: var(--island-bg);
    border: 1px solid var(--island-border);
    border-radius: 16px;
    box-shadow: var(--island-shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.unwordle-topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

:root.light-theme .unwordle-topbar {
    border-bottom-color: rgba(15, 23, 42, 0.1);
}

.unwordle-heading {
    text-align: center;
}

.unwordle-heading h1 {
    margin: 0;
    color: var(--text-color);
    font-size: 1.18rem;
    line-height: 1;
    font-weight: 800;
    letter-spacing: 0;
    white-space: nowrap;
}

.unwordle-icon-group {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.unwordle-icon-group--right {
    justify-content: flex-end;
}

.unwordle-icon-button {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.unwordle-icon-button:hover {
    transform: translateY(-1px);
    background: var(--glass-hover);
    border-color: var(--border-hover);
}

:root.light-theme .unwordle-icon-button {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(15, 23, 42, 0.12);
}

.mode-tabs,
.difficulty-tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
}

.mode-tabs {
    margin-top: 0.85rem;
}

.difficulty-tabs {
    margin-top: 0.28rem;
}

.mode-tab,
.difficulty-tab {
    min-height: 34px;
    padding: 0 0.45rem;
    color: var(--text-color);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 0.98rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.difficulty-tab {
    font-size: 0.88rem;
}

.difficulty-tabs[hidden] {
    display: none;
}

.tab-separator {
    color: var(--text-muted);
    font-weight: 800;
    line-height: 1;
    opacity: 0.7;
    user-select: none;
}

.mode-tab.is-active,
.difficulty-tab.is-active {
    color: var(--text-color);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    font-weight: 800;
}

.mode-tab:hover,
.difficulty-tab:hover {
    background: var(--glass-hover);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.game-status {
    min-height: 1.35rem;
    margin-top: 0.75rem;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
}

.game-status a {
    color: var(--red);
    font-weight: 800;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
}

.game-status a:hover {
    color: var(--text-color);
}

.game-grid {
    width: max-content;
    max-width: 100%;
    display: grid;
    gap: var(--tile-gap);
    margin: 0.4rem auto 0;
}

.game-row-wrap {
    display: grid;
    grid-template-columns: auto 20px;
    align-items: center;
    gap: 8px;
}

.game-row {
    display: grid;
    grid-template-columns: repeat(5, var(--tile-size));
    gap: var(--tile-gap);
}

.game-row.is-invalid {
    animation: row-shake 0.28s ease;
}

.row-check {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: var(--wordle-correct);
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 900;
    opacity: 0;
    transform: scale(0.72);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.game-row-wrap.is-accepted .row-check {
    opacity: 1;
    transform: scale(1);
}

.unwordle-tile {
    width: var(--tile-size);
    height: var(--tile-size);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--wordle-ink);
    border: 2px solid transparent;
    border-radius: 6px;
    font-size: 1.58rem;
    font-weight: 900;
    line-height: 1;
    text-transform: uppercase;
    user-select: none;
    transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

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

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

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

.unwordle-card.is-poop-mode .unwordle-tile {
    background: rgba(148, 163, 184, 0.48);
    border-color: rgba(255, 255, 255, 0.18);
}

.unwordle-card.is-poop-mode .unwordle-tile[data-state="poop-correct"] {
    background: #8a5a2b;
    border-color: rgba(226, 180, 112, 0.62);
}

.unwordle-card.is-poop-mode .game-row-wrap--target .unwordle-tile {
    background: #8a5a2b;
    border-color: rgba(226, 180, 112, 0.62);
}

/* Keep the controls steady as the word ladder grows; only its rows scroll. */
.unwordle-card.is-poop-mode {
    height: calc(var(--app-height) - 7.5rem - var(--safe-top) - var(--safe-bottom));
    display: flex;
    flex-direction: column;
}

.unwordle-card.is-poop-mode .game-grid {
    min-height: 0;
    flex: 1 1 auto;
    align-content: start;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.unwordle-card.is-poop-mode .game-grid::-webkit-scrollbar {
    display: none;
}

body.telegram-mini-app .unwordle-card.is-poop-mode {
    height: calc(var(--app-height) - 1.5rem - var(--safe-top) - var(--safe-bottom));
}

.unwordle-tile.is-active {
    border-color: #111827;
    border-style: dashed;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.28), 0 0 18px rgba(140, 61, 193, 0.36);
    transform: translateY(-1px);
}

.unwordle-tile.is-filled {
    filter: saturate(1.06);
}

.unwordle-tile.is-hidden-letter {
    color: transparent;
}

:root.light-theme .unwordle-tile.is-active {
    border-color: #0f172a;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.78), 0 8px 22px rgba(15, 23, 42, 0.14);
}

.game-actions {
    display: flex;
    justify-content: center;
    gap: 0.55rem;
    margin-top: 0.9rem;
}

.game-action {
    min-height: 38px;
    padding: 0 0.95rem;
    color: var(--text-color);
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 7px;
    font-size: 0.88rem;
    font-weight: 800;
    cursor: pointer;
    backdrop-filter: var(--blur);
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.game-action--primary {
    color: #ffffff;
    background: rgba(140, 61, 193, 0.58);
    border-color: rgba(167, 139, 250, 0.48);
}

.game-action:hover {
    transform: translateY(-2px);
    background: var(--glass-hover);
    border-color: var(--border-hover);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

.game-action[hidden] {
    display: none;
}

.daily-timer {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 42px;
    padding: 0.35rem 0.45rem 0.35rem 0.8rem;
    color: var(--text-color);
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    backdrop-filter: var(--blur);
}

.daily-timer.is-solved {
    padding-right: 0.8rem;
}

.daily-timer[hidden] {
    display: none;
}

.daily-timer__label {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.daily-timer strong {
    min-width: 4.2rem;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.daily-timer.is-solved strong {
    min-width: 7.2rem;
}

.daily-timer__pause {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0 0.72rem;
    color: #ffffff;
    background: rgba(140, 61, 193, 0.58);
    border: 1px solid rgba(167, 139, 250, 0.48);
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
}

.daily-timer__pause[hidden],
.daily-timer.is-solved .daily-timer__pause {
    display: none;
}

:root.light-theme .mode-tab:hover,
:root.light-theme .difficulty-tab:hover,
:root.light-theme .game-action,
:root.light-theme .daily-timer {
    color: #0f172a;
    background: rgba(255, 255, 255, 0.82);
    border-color: rgba(15, 23, 42, 0.16);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

:root.light-theme .mode-tab.is-active,
:root.light-theme .difficulty-tab.is-active {
    background: rgba(140, 61, 193, 0.1);
    border-color: rgba(140, 61, 193, 0.22);
}

:root.light-theme .game-action--primary,
:root.light-theme .daily-timer__pause {
    color: #ffffff;
    background: linear-gradient(135deg, var(--red), var(--red-dark));
    border-color: rgba(140, 61, 193, 0.45);
}

.next-puzzle {
    min-height: 1.2rem;
    margin: 0.65rem auto 0;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-align: center;
}

.next-puzzle[hidden] {
    display: none;
}

.ukrainian-keyboard {
    width: min(100%, 590px);
    display: grid;
    gap: 6px;
    margin: 0.75rem auto 0;
    user-select: none;
    -webkit-user-select: none;
}

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

.keyboard-key {
    min-width: 0;
    height: 52px;
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #07111f;
    background: rgba(226, 232, 240, 0.84);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 6px;
    font-size: 0.94rem;
    font-weight: 900;
    line-height: 1;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    transition: transform 0.15s ease, background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.keyboard-key:hover {
    transform: translateY(-1px);
}

.keyboard-key--wide {
    flex-basis: 1.45rem;
}

:root.light-theme .keyboard-key:not([data-state]) {
    color: #0f172a;
    background: rgba(255, 255, 255, 0.88);
    border-color: rgba(15, 23, 42, 0.14);
    box-shadow: 0 5px 16px rgba(15, 23, 42, 0.12);
}

:root.light-theme .keyboard-key:not([data-state]):hover {
    background: #ffffff;
    border-color: rgba(140, 61, 193, 0.28);
}

.keyboard-key[data-state="absent"] {
    color: #ffffff;
    background: var(--wordle-absent);
}

.keyboard-key[data-state="present"] {
    color: #ffffff;
    background: var(--wordle-present);
}

.keyboard-key[data-state="correct"] {
    color: #ffffff;
    background: var(--wordle-correct);
}

/* Site-level light-theme preferences must not override Telegram's own theme. */
:root.light-theme body.telegram-mini-app .mode-tab:hover,
:root.light-theme body.telegram-mini-app .difficulty-tab:hover,
:root.light-theme body.telegram-mini-app .game-action,
:root.light-theme body.telegram-mini-app .daily-timer {
    color: var(--tg-theme-text-color, var(--text-color));
    background: var(--tg-theme-secondary-bg-color, var(--glass));
    border-color: var(--tg-theme-section-separator-color, var(--glass-border));
    box-shadow: none;
}

:root.light-theme body.telegram-mini-app .mode-tab.is-active,
:root.light-theme body.telegram-mini-app .difficulty-tab.is-active {
    background: var(--tg-theme-section-bg-color, var(--glass-hover));
    border-color: var(--tg-theme-section-separator-color, var(--glass-border));
}

:root.light-theme body.telegram-mini-app .game-action--primary,
:root.light-theme body.telegram-mini-app .daily-timer__pause {
    color: var(--tg-theme-button-text-color, #ffffff);
    background: var(--tg-theme-button-color, var(--red));
    border-color: var(--tg-theme-button-color, var(--red));
}

:root.light-theme body.telegram-mini-app .keyboard-key:not([data-state]) {
    color: var(--tg-theme-text-color, var(--text-color));
    background: var(--tg-theme-secondary-bg-color, var(--glass));
    border-color: var(--tg-theme-section-separator-color, var(--glass-border));
    box-shadow: none;
}

.unwordle-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 700;
}

.unwordle-footer a {
    color: var(--text-color);
    text-decoration: none;
}

.unwordle-footer a:hover {
    color: var(--red);
}

.unwordle-modal {
    position: fixed;
    inset: 0;
    z-index: 190;
    display: grid;
    place-items: center;
    padding: max(1rem, var(--safe-top)) max(1rem, var(--safe-right)) max(1rem, var(--safe-bottom)) max(1rem, var(--safe-left));
}

.unwordle-modal[hidden] {
    display: none;
}

.unwordle-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.52);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

:root.light-theme .unwordle-modal__backdrop {
    background: rgba(15, 23, 42, 0.2);
}

.unwordle-modal__panel {
    position: relative;
    width: min(100%, 458px);
    max-height: min(88vh, 720px);
    overflow: auto;
    color: var(--modal-text);
    background: var(--modal-bg);
    border: 1px solid var(--modal-border);
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
    padding: 1rem 0.9rem 1.1rem;
    outline: none;
}

:root.light-theme .unwordle-modal__panel {
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.2);
}

.unwordle-modal__close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    border-radius: 999px;
    color: var(--modal-text);
    font-size: 1.1rem;
    cursor: pointer;
}

.unwordle-modal__close:hover {
    background: var(--modal-soft);
}

.help-content h2,
.unwordle-modal__panel--leaderboard h2,
.unwordle-modal__panel--name h2 {
    margin: 0 2.2rem 1rem;
    color: var(--modal-text);
    font-size: 1.55rem;
    line-height: 1.15;
    font-weight: 900;
    text-align: center;
}

.help-content p,
.leaderboard-note {
    margin: 0 0 1.25rem;
    color: var(--modal-body);
    font-size: 1.02rem;
    line-height: 1.38;
}

.help-content em {
    display: block;
    margin: 1rem 0 0;
    padding: 0 0 0 1rem;
    color: var(--modal-muted);
    border-left: 7px solid rgba(148, 160, 179, 0.38);
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.45;
}

.help-example {
    display: grid;
    gap: 5px;
    justify-content: center;
    margin: 0.8rem auto 1.1rem;
}

.help-example-row-wrap {
    display: grid;
    grid-template-columns: auto 20px;
    align-items: center;
    gap: 8px;
}

.help-example-row {
    display: grid;
    grid-template-columns: repeat(5, 66px);
    gap: 5px;
}

.help-example-row-wrap.is-invalid .help-example-row {
    animation: help-row-shake-loop 2.8s ease-in-out infinite;
}

.help-example-row-wrap.is-typing .help-tile {
    color: transparent;
    animation: help-type-letter 4.2s linear infinite;
}

.help-example-row-wrap.is-typing .help-tile:nth-child(1) {
    animation-delay: 0.1s;
}

.help-example-row-wrap.is-typing .help-tile:nth-child(2) {
    animation-delay: 0.34s;
}

.help-example-row-wrap.is-typing .help-tile:nth-child(3) {
    animation-delay: 0.58s;
}

.help-example-row-wrap.is-typing .help-tile:nth-child(4) {
    animation-delay: 0.82s;
}

.help-example-row-wrap.is-typing .help-tile:nth-child(5) {
    animation-delay: 1.06s;
}

.help-row-check {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: var(--wordle-correct);
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 900;
    opacity: 0;
    transform: scale(0.72);
}

.help-example-row-wrap.is-accepted .help-row-check {
    opacity: 1;
    transform: scale(1);
}

.help-example-row-wrap.is-typing .help-row-check {
    animation: help-check-loop 4.2s ease-in-out infinite;
}

.help-tile {
    position: relative;
    width: 66px;
    height: 66px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    border-radius: 2px;
    font-size: 1.9rem;
    font-weight: 900;
    line-height: 1;
    text-transform: uppercase;
}

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

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

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

.color-rule {
    display: grid;
    grid-template-columns: 40px 1fr;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
    color: var(--modal-body);
    font-size: 1rem;
    line-height: 1.38;
}

.color-swatch {
    width: 40px;
    height: 40px;
}

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

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

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

.help-label {
    margin: 1rem 0 0.5rem;
    color: var(--modal-body);
    font-weight: 700;
}

.help-centered {
    text-align: center;
}

.help-content .help-error-reason {
    max-width: 360px;
    margin: -0.35rem auto 0.75rem;
    padding: 0.58rem 0.72rem;
    color: var(--modal-text);
    background: rgba(232, 121, 111, 0.16);
    border: 1px solid rgba(232, 121, 111, 0.42);
    border-radius: 8px;
    font-size: 0.94rem;
    font-weight: 800;
    text-align: center;
}

.modal-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    margin-top: 1.25rem;
    color: var(--modal-text);
    font-size: 1rem;
}

.modal-link {
    padding: 0;
    color: var(--modal-text);
    background: transparent;
    border: 0;
    font-size: 1rem;
    font-weight: 800;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.modal-link--muted {
    color: var(--modal-muted);
    font-weight: 500;
    text-decoration: none;
}

.leaderboard-note {
    margin-top: -0.4rem;
    color: var(--modal-muted);
    font-size: 0.9rem;
    text-align: center;
}

.leaderboard-list {
    display: grid;
    gap: 0.5rem;
}

.leaderboard-row {
    display: grid;
    grid-template-columns: 2rem minmax(0, 1fr) 4.2rem 3.15rem;
    align-items: center;
    gap: 0.75rem;
    padding: 0.72rem 0.8rem;
    background: var(--modal-soft);
    border: 1px solid var(--modal-border);
    border-radius: 8px;
}

.leaderboard-row--unlimited {
    grid-template-columns: 2rem minmax(0, 1fr) auto;
    padding-block: 0.52rem;
}

.leaderboard-row--poop {
    grid-template-columns: 2rem minmax(0, 1fr) 4.8rem;
}

.leaderboard-rank {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: var(--red);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 900;
}

.leaderboard-rank--medal {
    color: inherit;
    background: transparent;
    border-radius: 0;
    font-size: 1.55rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.22));
}

.leaderboard-avatar {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--modal-border);
    border: 1px solid var(--modal-border);
    border-radius: 999px;
}

.leaderboard-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.leaderboard-main {
    display: grid;
    gap: 0.12rem;
    min-width: 0;
}

.leaderboard-main strong {
    color: var(--modal-text);
    font-size: 0.98rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-main span,
.leaderboard-style span,
.leaderboard-time span {
    color: var(--modal-muted);
    font-size: 0.76rem;
    font-weight: 700;
}

.difficulty-counts {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem;
    color: var(--modal-muted);
}

.difficulty-count {
    display: inline-flex;
    align-items: center;
    gap: 0.24rem;
    font-variant-numeric: tabular-nums;
}

.difficulty-count i {
    width: 0.9rem;
    color: var(--modal-body);
    font-size: 0.78rem;
    text-align: center;
}

.difficulty-count strong {
    color: var(--modal-text);
    font-size: 0.82rem;
    font-weight: 900;
}

.leaderboard-difficulty {
    min-width: 7rem;
    display: inline-flex;
    justify-content: flex-end;
}

.leaderboard-difficulty .difficulty-counts {
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 0.48rem;
}

.leaderboard-style,
.leaderboard-time {
    display: grid;
    gap: 0.12rem;
    align-content: center;
    text-align: right;
}

.leaderboard-attempts {
    display: grid;
    gap: 0.12rem;
    align-content: center;
    text-align: right;
}

.leaderboard-attempts strong {
    color: var(--modal-text);
    font-size: 1rem;
    line-height: 1;
}

.leaderboard-attempts span {
    color: var(--modal-muted);
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1.05;
    white-space: nowrap;
}

.leaderboard-style {
    min-width: 4.2rem;
    text-align: left;
}

.leaderboard-style strong,
.leaderboard-time strong {
    color: var(--modal-text);
    font-size: 1rem;
    line-height: 1;
}

.leaderboard-style strong,
.leaderboard-style span {
    justify-self: start;
}

.leaderboard-time strong {
    justify-self: end;
    text-align: right;
}

.leaderboard-style span,
.leaderboard-time span {
    line-height: 1.05;
    white-space: nowrap;
}

.leaderboard-empty {
    margin: 1.25rem 0 0;
    padding: 1rem;
    color: var(--modal-muted);
    background: var(--modal-soft);
    border: 1px solid var(--modal-border);
    border-radius: 8px;
    text-align: center;
    line-height: 1.4;
}

.leaderboard-section-title {
    margin: 1rem 0 0.55rem;
    color: var(--modal-muted);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.stats-list {
    display: grid;
    gap: 0.65rem;
}

.stats-row {
    display: grid;
    grid-template-columns: 1.3rem 1fr auto;
    align-items: center;
    gap: 0.65rem;
    color: var(--modal-body);
    font-size: 0.98rem;
}

.stats-row i {
    width: 1.3rem;
    color: var(--modal-body);
    text-align: center;
}

.stats-row strong {
    font-weight: 500;
}

.stats-row span {
    font-variant-numeric: tabular-nums;
}

.name-form {
    display: grid;
    gap: 0.75rem;
    margin-top: 1rem;
}

.name-form input {
    width: 100%;
    min-height: 46px;
    padding: 0 0.9rem;
    color: var(--modal-text);
    background: var(--modal-soft);
    border: 1px solid var(--modal-border);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    outline: none;
}

.name-form input:focus {
    border-color: rgba(140, 61, 193, 0.65);
    box-shadow: 0 0 0 3px rgba(140, 61, 193, 0.16);
}

@keyframes row-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    50% { transform: translateX(6px); }
    75% { transform: translateX(-4px); }
}

@keyframes help-row-shake-loop {
    0%, 18%, 100% { transform: translateX(0); }
    4% { transform: translateX(-6px); }
    8% { transform: translateX(6px); }
    12% { transform: translateX(-4px); }
    16% { transform: translateX(0); }
}

@keyframes help-type-letter {
    0%, 9% {
        color: transparent;
        transform: scale(1);
    }
    12%, 72% {
        color: #ffffff;
        transform: scale(1.04);
    }
    78%, 100% {
        color: transparent;
        transform: scale(1);
    }
}

@keyframes help-check-loop {
    0%, 42% {
        opacity: 0;
        transform: scale(0.72);
    }
    48%, 72% {
        opacity: 1;
        transform: scale(1);
    }
    78%, 100% {
        opacity: 0;
        transform: scale(0.72);
    }
}

@media (max-width: 768px) {
    :root {
        --grid-size: 35px;
    }

    .sphere-1 {
        width: 70vw;
        height: 70vw;
        filter: blur(30px);
    }

    .sphere-2 {
        width: 75vw;
        height: 75vw;
        filter: blur(30px);
    }

    .sphere-3 {
        width: 55vw;
        height: 55vw;
        filter: blur(25px);
    }

    .sphere-4 {
        width: 50vw;
        height: 50vw;
        filter: blur(25px);
    }
}

@media (max-width: 520px) {
    :root {
        --tile-size: 48px;
        --tile-gap: 5px;
    }

    .content-wrapper {
        padding-inline: max(0.7rem, var(--safe-left));
    }

    .unwordle-card {
        padding: 10px;
        border-radius: 14px;
    }

    .unwordle-icon-group {
        gap: 0.32rem;
    }

    .unwordle-icon-button {
        width: 28px;
        height: 28px;
        font-size: 0.82rem;
    }

    .unwordle-heading h1 {
        font-size: 1rem;
    }

    .mode-tab {
        min-height: 32px;
        font-size: 0.88rem;
    }

    .difficulty-tab {
        min-height: 30px;
    }

    .keyboard-row {
        gap: 4px;
    }

    .keyboard-key {
        height: 46px;
        border-radius: 5px;
        font-size: 0.8rem;
    }

    .unwordle-card.is-poop-mode .game-grid {
        min-height: 0;
    }

    .leaderboard-row {
        grid-template-columns: 1.75rem minmax(0, 1fr) 3.65rem 2.85rem;
        gap: 0.5rem;
        padding-inline: 0.58rem;
    }

    .leaderboard-row--unlimited {
        grid-template-columns: 1.75rem minmax(0, 1fr) auto;
    }

    .leaderboard-row--poop {
        grid-template-columns: 1.75rem minmax(0, 1fr) 4.25rem;
    }

    .leaderboard-rank {
        width: 1.75rem;
        height: 1.75rem;
    }

    .leaderboard-avatar {
        width: 1.75rem;
        height: 1.75rem;
    }

    .leaderboard-style {
        min-width: 3.65rem;
    }

    .leaderboard-style span,
    .leaderboard-time span {
        font-size: 0.68rem;
    }

    body.telegram-mini-app .unwordle-modal__panel {
        padding: 0.85rem 0.7rem 0.95rem;
    }

    body.telegram-mini-app .help-content h2 {
        margin: 0 2rem 0.8rem;
        font-size: 1.32rem;
    }

    body.telegram-mini-app .help-content p,
    body.telegram-mini-app .help-content em {
        font-size: 0.96rem;
    }

    body.telegram-mini-app .help-example-row-wrap {
        grid-template-columns: minmax(0, 1fr) 18px;
        gap: 5px;
    }

    body.telegram-mini-app .help-example-row {
        width: min(100%, 310px);
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 4px;
    }

    body.telegram-mini-app .help-tile {
        width: auto;
        height: auto;
        aspect-ratio: 1;
        font-size: clamp(1.08rem, 6vw, 1.42rem);
    }
}

@media (max-width: 380px) {
    :root {
        --tile-size: 42px;
    }

    .unwordle-icon-button {
        width: 26px;
        height: 26px;
    }

    .game-action {
        padding-inline: 0.72rem;
    }

    .game-row-wrap {
        grid-template-columns: auto 18px;
        gap: 5px;
    }

    .row-check {
        width: 18px;
        height: 18px;
        font-size: 0.62rem;
    }

    .help-example-row-wrap {
        grid-template-columns: auto 18px;
        gap: 5px;
    }

    .help-row-check {
        width: 18px;
        height: 18px;
        font-size: 0.62rem;
    }

    .help-example-row {
        grid-template-columns: repeat(5, 42px);
    }

    .help-tile {
        width: 42px;
        height: 42px;
        font-size: 1.28rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.001ms !important;
    }

    .help-example-row-wrap.is-typing .help-tile {
        color: #ffffff;
    }

    .help-example-row-wrap.is-typing .help-row-check {
        opacity: 1;
        transform: scale(1);
    }
}
