/* app/static/css/mobile.css
   Dedicated mobile/tablet layer.
   Desktop remains unchanged above 1024px.
*/

/* Baseline mobile safety */
*,
*::before,
*::after {
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .header .user-menu .dropdown a.logout {
        display: none !important;
    }
}

img,
video,
iframe,
svg,
canvas {
    max-width: 100%;
    height: auto;
}

.mobile-menu-toggle,
.mobile-nav-backdrop,
.mobile-chat-back {
    display: none;
}

/* Tablet adjustments */
@media (max-width: 1024px) {
    html,
    body {
        overflow-x: hidden;
    }

    .container {
        width: 100%;
        max-width: 960px;
        margin: 28px auto;
        padding: 20px 16px;
    }

    .header {
        padding: 0 20px;
    }

    .nav a,
    .username {
        padding: 0 18px;
    }

    .notifications-container {
        right: 12px;
        bottom: 12px;
        max-width: min(460px, calc(100vw - 24px));
    }

    .notification-card {
        width: 100%;
    }

    .profile-root > .profile-wrapper {
        margin-left: 0;
    }

    .console-card {
        position: static;
        min-width: 0;
    }
}

/* Mobile redesign */
@media (max-width: 768px) {
    :root {
        --mobile-header-h: 56px;
        --mobile-pad: 12px;
        --mobile-gap: 10px;
    }

    html,
    body {
        overflow-x: hidden;
    }

    body {
        padding-top: var(--mobile-header-h);
    }

    body.mobile-ui-nav-open {
        overflow: hidden;
        touch-action: none;
    }

    /* Header + one-hand navigation */
    .header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1900;
        height: var(--mobile-header-h);
        padding: 0 var(--mobile-pad);
        align-items: center;
        background: var(--bg-header);
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
    }

    .logo {
        font-size: 28px;
        padding: 0 2px;
        -webkit-text-stroke: 0.8px var(--accent);
    }

    .mobile-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        gap: 5px;
        width: 32px;
        min-width: 32px;
        height: 24px;
        margin-left: auto;
        border: 0;
        background: transparent;
        color: var(--text-main);
        cursor: pointer;
        z-index: 1910;
        padding: 0;
    }

    .mobile-menu-toggle:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }

    .mobile-menu-toggle-bar {
        width: 22px;
        height: 2px;
        border-radius: 2px;
        background: currentColor;
        transition: transform 0.2s ease, opacity 0.2s ease;
    }

    body.mobile-ui-nav-open .mobile-menu-toggle-bar:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    body.mobile-ui-nav-open .mobile-menu-toggle-bar:nth-child(2) {
        opacity: 0;
    }

    body.mobile-ui-nav-open .mobile-menu-toggle-bar:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    .mobile-nav-backdrop {
        position: fixed;
        inset: var(--mobile-header-h) 0 0 0;
        display: block;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
        z-index: 1880;
    }

    body.mobile-ui-nav-open .mobile-nav-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .nav {
        position: fixed;
        top: var(--mobile-header-h);
        right: 0;
        bottom: 0;
        width: min(340px, 88vw);
        max-width: 88vw;
        min-width: 280px;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        padding: 14px;
        overflow-y: auto;
        overflow-x: hidden;
        background: var(--bg-header);
        border-left: 1px solid var(--border-color);
        box-shadow: -12px 0 26px rgba(0, 0, 0, 0.35);
        transform: translateX(110%);
        transition: transform 0.22s ease;
        z-index: 1890;
    }

    body:not(.mobile-ui-nav-open) .nav {
        visibility: hidden;
        pointer-events: none;
    }

    body.mobile-ui-nav-open .nav {
        visibility: visible;
        pointer-events: auto;
        transform: translateX(0);
    }

    .header .nav > a,
    .header .nav > .nav-item > a,
    .header .nav > .nav-item > .username {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        padding: 10px 12px;
        border-radius: 10px;
        font-size: 16px;
        font-weight: 600;
    }

    .header .nav-item {
        width: 100%;
        display: block;
    }

    .header .nav-item.has-dropdown {
        --dropdown-eq-width: auto;
    }

    .header .nav-item.has-dropdown > a,
    .header .nav-item.has-dropdown > .username,
    .header .nav-item.has-dropdown > .dropdown {
        width: auto;
        min-width: 0;
    }

    .header .nav-item.has-dropdown .dropdown,
    .header .user-menu .dropdown {
        position: static;
        display: flex;
        flex-direction: column;
        gap: 4px;
        width: auto;
        min-width: 0;
        margin: 2px 0 6px;
        padding: 4px 0 4px 10px;
        background: transparent;
        border-left: 1px solid rgba(255, 255, 255, 0.1);
    }

    .header .nav-item.has-dropdown .dropdown a,
    .header .user-menu .dropdown a {
        min-height: 40px;
        padding: 8px 10px;
        font-size: 15px;
        border-radius: 8px;
        white-space: normal;
    }

    /* Core content spacing */
    .container {
        margin: 16px 10px;
        padding: 14px 12px;
        width: auto;
    }

    .games-wrapper,
    .achievements-shell,
    .settings-root,
    .admin-root {
        width: 100%;
        max-width: none;
    }

    .games-wrapper {
        padding: 0 10px;
    }

    .achievements-shell,
    .settings-root,
    .admin-root {
        padding-left: 10px;
        padding-right: 10px;
    }

    /* Touch-friendly controls */
    .btn,
    select.select,
    .select-display,
    .admin-input,
    .admin-select,
    .admin-textarea,
    .chat-input-editable {
        min-height: 44px;
    }

    .btn {
        padding: 10px 14px;
        font-size: 15px;
    }

    /* Settings */
    .settings-root {
        padding-top: 14px;
        padding-bottom: 24px;
    }

    .settings-layout {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .settings-nav {
        position: static;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .nav-link {
        min-height: 44px;
        text-align: center;
    }

    .setting-item,
    .session-row,
    .sessions-header,
    .settings-google-box {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-left: 0;
        width: 100%;
    }

    /* Admin: card-like rows for mobile */
    .admin-root {
        margin: 12px auto 24px;
        gap: 12px;
        padding-bottom: 24px;
    }

    .admin-header {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
        gap: 10px;
    }

    .admin-actions,
    .admin-user-select {
        width: 100%;
        min-width: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .admin-user-select-row {
        grid-template-columns: 40px minmax(0, 1fr);
    }

    .admin-card {
        padding: 12px;
    }

    .card-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .card-tools {
        width: 100%;
        flex-wrap: wrap;
    }

    .admin-table {
        width: 100%;
        min-width: 0;
        table-layout: auto;
        display: block;
    }

    .admin-table thead {
        display: none;
    }

    .admin-table,
    .admin-table tbody,
    .admin-table tr,
    .admin-table td {
        display: block;
        width: 100%;
    }

    .admin-table tr {
        margin-bottom: 10px;
        padding: 10px;
        border: 1px solid var(--border-color);
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.02);
    }

    .admin-table tr:last-child {
        margin-bottom: 0;
    }

    .admin-table td {
        border-bottom: 0;
        padding: 4px 0;
    }

    .admin-table td:first-child,
    .field-label {
        width: auto;
        color: var(--text-muted);
        font-size: 13px;
    }

    .modal-card {
        width: min(560px, 96vw);
        padding: 14px;
    }

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

    .modal-actions .btn {
        flex: 1 1 auto;
    }

    /* Games, achievements, chess pages */
    .games-main {
        padding: 20px 0 30px;
    }

    .games-header {
        margin-bottom: 20px;
    }

    .games-title {
        font-size: 30px;
    }

    .games-subtitle {
        font-size: 15px;
    }

    .game-card {
        grid-template-columns: 1fr;
        padding: 14px;
        gap: 12px;
    }

    .game-name {
        font-size: 22px;
    }

    .game-media {
        min-height: 170px;
    }

    .achievements-top {
        grid-template-columns: 1fr;
    }

    .achievement-card-head,
    .achievement-progress-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .achievement-progress,
    .achievement-progress-right {
        width: 100%;
        text-align: left;
    }

    .chess-hero {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .chess-grid,
    .match-layout,
    .match-pgn,
    .history-summary {
        grid-template-columns: 1fr;
    }

    .match-layout {
        gap: 12px;
    }

    .match-actions {
        flex-wrap: wrap;
    }

    .match-actions .btn {
        flex: 1 1 calc(50% - 6px);
        min-height: 44px;
    }

    .promotion-picker {
        width: min(calc(100% - 8px), 300px);
        grid-template-columns: repeat(4, minmax(52px, 1fr));
    }

    /* Profile console */
    .profile-root {
        padding-top: 16px;
    }

    .profile-root > .profile-wrapper {
        grid-template-columns: 1fr;
        padding: 0 10px;
        gap: 12px;
        margin-left: 0;
    }

    .left-column {
        width: 100%;
    }

    .console-card {
        position: static;
        width: 100%;
        min-width: 0;
    }

    .console-block {
        font-size: 15px;
        padding: 8px 6px;
    }

    .indent {
        margin-left: 18px;
    }

    /* Error page */
    .error-main {
        min-height: calc(100dvh - var(--mobile-header-h));
        padding: 10px;
    }

    .error-card {
        padding: 24px 12px;
    }

    .error-code {
        font-size: 54px;
    }

    .error-title {
        font-size: 28px;
    }

    .error-text {
        font-size: 17px;
    }

    /* Home widget page (inline styles override) */
    .widget-container {
        min-width: 0;
        width: 100%;
        padding: 16px 12px;
    }

    .widget-container h2 {
        font-size: 26px;
    }

    #countdown {
        font-size: 1.35em;
    }

    /* Verify page inline button */
    #verifyBtn {
        min-width: 0 !important;
        width: min(100%, 420px) !important;
        padding: 12px 16px !important;
        font-size: 16px !important;
    }

    /* Messenger mobile UX */
    .messenger-main {
        position: fixed;
        top: var(--mobile-header-h);
        left: 0;
        right: 0;
        bottom: 0;
        height: auto;
        padding: 0;
        margin: 0;
    }

    .messenger-wrapper {
        height: 100%;
        min-height: 0;
        display: flex;
    }

    .messenger-wrapper.no-selected-chat .chat-list {
        display: flex;
        width: 100%;
        max-height: none;
        border-bottom: 0;
    }

    .messenger-wrapper.no-selected-chat .chat-area {
        display: none;
    }

    .messenger-wrapper.has-selected-chat .chat-list {
        display: none;
    }

    .messenger-wrapper.has-selected-chat .chat-area {
        display: flex;
        width: 100%;
        height: 100%;
    }

    .chat-list {
        width: 100% !important;
        min-width: 0;
        max-width: none;
        border-right: 0;
    }

    .resize-handle,
    .no-chat {
        display: none;
    }

    .chat-list-header {
        height: auto;
        padding: 12px;
    }

    .new-chat-btn.btn {
        width: 100%;
        min-height: 44px;
    }

    .chat-item {
        min-height: 62px;
        padding: 10px 12px;
    }

    .chat-username {
        font-size: 16px;
    }

    .chat-last {
        font-size: 13px;
    }

    .chat-right {
        width: 50px;
        min-width: 50px;
        flex-basis: 50px;
    }

    .chat-header {
        position: sticky;
        top: 0;
        z-index: 22;
        min-height: 56px;
        padding: 10px 12px;
        background: var(--bg-sidebar);
    }

    .mobile-chat-back {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 28px;
        min-height: 44px;
        margin-right: 6px;
        border: 0;
        background: transparent;
        color: var(--text-main);
        text-decoration: none;
        font-size: 28px;
        line-height: 1;
        padding: 0;
    }

    .chat-header-user .chat-username-header {
        font-size: 17px;
    }

    .chat-status {
        font-size: 12px;
    }

    .messages {
        padding: 10px 10px 8px;
    }

    .group-body {
        max-width: 90%;
    }

    .msg,
    .msg.short {
        max-width: min(100%, calc(100vw - 80px));
        font-size: 14px;
    }

    .msg-text {
        font-size: 14px;
    }

    .chat-input-field {
        padding: 6px 8px;
    }

    .chat-input-inner {
        gap: 8px;
    }

    .chat-input-editable {
        min-height: 42px;
        max-height: 140px;
        padding: 9px 10px;
        font-size: 14px;
    }

    button.btn.send-btn {
        height: 44px;
        min-height: 44px;
        padding: 8px 12px;
        font-size: 14px;
    }

    /* Notifications */
    .notifications-container {
        right: 8px;
        left: 8px;
        bottom: 8px;
        max-width: none;
    }

    .notification-card {
        min-height: 66px;
        padding: 12px;
        gap: 10px;
    }

    .notification-avatar {
        width: 42px;
        height: 42px;
        flex-basis: 42px;
    }

    .notification-title {
        font-size: 15px;
    }

    .notification-text {
        font-size: 13px;
    }
}

/* Small phones */
@media (max-width: 480px) {
    :root {
        --mobile-header-h: 52px;
        --mobile-pad: 8px;
    }

    body {
        padding-top: var(--mobile-header-h);
    }

    .header {
        height: var(--mobile-header-h);
        padding: 0 var(--mobile-pad);
    }

    .logo {
        font-size: 24px;
    }

    .mobile-menu-toggle {
        width: 30px;
        min-width: 30px;
        height: 22px;
    }

    .mobile-menu-toggle-bar {
        width: 20px;
    }

    .mobile-nav-backdrop {
        inset: var(--mobile-header-h) 0 0 0;
    }

    .nav {
        top: var(--mobile-header-h);
        width: 100%;
        max-width: none;
        min-width: 0;
        border-left: 0;
        border-top: 1px solid var(--border-color);
        box-shadow: none;
    }

    .container {
        margin: 12px 8px;
        padding: 12px 10px;
    }

    .games-title {
        font-size: 24px;
    }

    .game-name {
        font-size: 20px;
    }

    .settings-nav {
        grid-template-columns: 1fr;
    }

    .admin-root {
        padding-left: 8px;
        padding-right: 8px;
    }

    .messenger-main {
        top: var(--mobile-header-h);
    }

    .chat-item {
        min-height: 56px;
        padding: 10px;
    }

    .avatar-sm {
        width: 34px;
        height: 34px;
    }

    .chat-right {
        width: 46px;
        min-width: 46px;
        flex-basis: 46px;
    }

    .chat-header {
        min-height: 52px;
        padding: 8px 10px;
    }

    .mobile-chat-back {
        font-size: 24px;
        min-height: 40px;
    }

    .messages {
        padding: 8px 8px 6px;
    }

    .msg,
    .msg.short,
    .msg-text {
        font-size: 13px;
    }

    .chat-input-editable {
        min-height: 38px;
        font-size: 14px;
        padding: 8px;
    }

    button.btn.send-btn {
        height: 40px;
        min-height: 40px;
        padding: 8px 10px;
        font-size: 13px;
    }

    .error-code {
        font-size: 44px;
    }

    .error-title {
        font-size: 24px;
    }

    .error-text {
        font-size: 15px;
    }
}

/* Mobile UX comfort pass */
@media (max-width: 768px) {
    :root {
        --mobile-header-h: 64px;
        --mobile-pad: 16px;
        --mobile-gap: 12px;
    }

    body {
        font-size: 16px;
        line-height: 1.6;
        padding-top: var(--mobile-header-h);
    }

    main,
    section,
    article,
    aside,
    nav,
    form {
        min-width: 0;
    }

    h1,
    .games-title,
    .achievements-title,
    .auth-title,
    .error-title {
        font-size: clamp(28px, 7.5vw, 32px);
        line-height: 1.2;
        letter-spacing: 0;
    }

    h2,
    .settings-title {
        font-size: clamp(24px, 6.4vw, 26px);
        line-height: 1.25;
    }

    h3,
    .section-head h3,
    .game-name,
    .achievement-card-head h3 {
        font-size: clamp(20px, 5.8vw, 22px);
        line-height: 1.3;
    }

    p,
    li,
    .games-subtitle,
    .game-desc,
    .achievements-subtitle,
    .achievement-desc,
    .error-text,
    .auth-field,
    .setting-item > span,
    .session-subline,
    .chat-last,
    .msg,
    .msg-text,
    .chat-input-editable {
        font-size: 16px;
        line-height: 1.6;
    }

    .header {
        height: var(--mobile-header-h);
        padding: 0 var(--mobile-pad);
    }

    .logo {
        font-size: 30px;
        padding: 0 6px;
    }

    .mobile-menu-toggle {
        width: 44px;
        min-width: 44px;
        height: 44px;
        gap: 6px;
        padding: 0;
        border-radius: 10px;
    }

    .mobile-menu-toggle:hover {
        background: rgba(255, 255, 255, 0.04);
    }

    .mobile-menu-toggle-bar {
        width: 24px;
        height: 2.5px;
    }

    body.mobile-ui-nav-open .mobile-menu-toggle-bar:nth-child(1) {
        transform: translateY(8.5px) rotate(45deg);
    }

    body.mobile-ui-nav-open .mobile-menu-toggle-bar:nth-child(3) {
        transform: translateY(-8.5px) rotate(-45deg);
    }

    .nav {
        width: min(360px, 92vw);
        max-width: 92vw;
        padding: 16px;
        gap: 8px;
    }

    .header .nav > a,
    .header .nav > .nav-item > a,
    .header .nav > .nav-item > .username {
        min-height: 48px;
        padding: 12px 14px;
        font-size: 17px;
        border-radius: 12px;
    }

    .header .nav-item.has-dropdown .dropdown,
    .header .user-menu .dropdown {
        gap: 6px;
        margin: 4px 0 10px;
        padding: 6px 0 6px 12px;
    }

    .header .nav-item.has-dropdown .dropdown a,
    .header .user-menu .dropdown a {
        min-height: 44px;
        padding: 10px 12px;
        font-size: 16px;
        border-radius: 10px;
    }

    .container {
        margin: 20px 16px 28px;
        padding: 20px 16px;
        border-radius: 12px;
    }

    .games-wrapper,
    .achievements-shell,
    .settings-root,
    .admin-root,
    .profile-root > .profile-wrapper {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .games-main,
    .achievements-main,
    .settings-main,
    .admin-main,
    .profile-root {
        padding-bottom: 28px;
    }

    .settings-layout,
    .admin-grid,
    .games-list,
    .achievements-list,
    .chess-main,
    .chess-side,
    .match-layout,
    .history-list {
        gap: 16px;
    }

    .settings-section,
    .admin-card,
    .game-card,
    .achievement-card,
    .chess-card,
    .match-panel,
    .modal-card {
        padding: 16px;
    }

    .section-head {
        margin-bottom: 10px;
    }

    .setting-item {
        gap: 12px;
        padding: 14px 0;
    }

    .session-row {
        padding: 14px 12px;
        gap: 12px;
    }

    .sessions-header {
        gap: 12px;
    }

    .settings-banner,
    .sessions-empty,
    .settings-google-meta,
    .settings-google-disabled {
        font-size: 15px;
    }

    .settings-banner {
        padding: 12px 14px;
        line-height: 1.5;
    }

    .btn,
    select.select,
    .select-display,
    .select-option,
    .admin-input,
    .admin-select,
    .admin-textarea,
    .chat-input-editable,
    .auth-field input,
    .container input,
    .icon-btn,
    .nav-link,
    .auth-eye,
    .mobile-chat-back,
    .mini-dialog-item,
    .replay-controls .btn,
    .match-invite-controls input,
    .match-pgn-field input {
        min-height: 44px;
        font-size: 16px;
    }

    .btn {
        padding: 12px 16px;
        font-weight: 600;
        line-height: 1.2;
    }

    .btn.small {
        min-height: 44px;
        padding: 10px 14px;
        font-size: 15px;
    }

    .auth-eye {
        width: 44px;
        min-width: 44px;
        height: 44px;
    }

    .auth-eye:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }

    .auth-eye-icon {
        width: 20px;
        height: 20px;
    }

    .auth-password-row {
        align-items: stretch;
    }

    .auth-link-button {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
        font-size: 16px;
        margin-top: 0;
        margin-bottom: 0;
    }

    .auth-alert,
    .auth-rule,
    .auth-switch,
    .auth-switch-inline,
    .auth-separator > span {
        font-size: 16px;
    }

    .auth-card {
        gap: 18px;
    }

    .auth-form {
        gap: 16px;
    }

    input,
    textarea,
    select,
    button {
        font-size: 16px;
    }

    .admin-textarea {
        min-height: 88px;
    }

    .admin-input,
    .admin-select,
    .admin-textarea {
        padding: 10px 12px;
    }

    .select-option {
        display: flex;
        align-items: center;
        padding: 10px 12px;
    }

    .select-wrap.user-select .select-search {
        font-size: 16px;
        min-height: 44px;
    }

    .icon-btn {
        width: 44px;
        height: 44px;
    }

    .admin-user-select-row {
        grid-template-columns: 44px minmax(0, 1fr);
    }

    .field-label,
    .admin-table td:first-child {
        font-size: 14px;
        font-weight: 600;
    }

    .admin-table td {
        padding: 8px 0;
    }

    .admin-table tr {
        padding: 12px;
    }

    .note,
    .badge,
    .admin-lock,
    .field-error,
    .changes-empty,
    .unsaved-note,
    .mini-header,
    .mini-empty {
        font-size: 14px;
    }

    .select-display-main,
    .select-option.user-option .option-title,
    .admin-changes .changes-list,
    .changes-item,
    .mini-dialog-title,
    .mini-message-text {
        font-size: 16px;
    }

    .select-option.user-option .option-sub,
    .mini-dialog-preview,
    .mini-message-header {
        font-size: 14px;
    }

    .modal-card h3 {
        font-size: 20px;
    }

    .modal-card p {
        font-size: 16px;
        line-height: 1.6;
    }

    .games-header {
        margin-bottom: 24px;
        gap: 14px;
    }

    .games-subtitle {
        font-size: 16px;
        max-width: none;
    }

    .game-card {
        padding: 16px;
        gap: 16px;
    }

    .game-desc {
        font-size: 16px;
    }

    .game-media {
        min-height: 190px;
    }

    .game-players {
        font-size: 14px;
        padding: 8px 12px;
    }

    .achievements-subtitle,
    .xp-line,
    .xp-meta,
    .achievement-level,
    .achievement-xp,
    .achievement-progress-right {
        font-size: 15px;
    }

    .achievement-card-head,
    .achievement-progress-row {
        gap: 10px;
    }

    .achievement-desc {
        font-size: 16px;
        line-height: 1.6;
    }

    .achievements-section {
        margin-top: 24px;
    }

    .achievements-section h2 {
        font-size: 24px;
        margin-bottom: 12px;
    }

    .chess-card-title {
        font-size: 20px;
    }

    .chess-card-subtitle,
    .chess-note,
    .chess-empty,
    .live-meta,
    .profile-hint,
    .profile-guest,
    .opponent-meta,
    .match-time-details,
    .match-invite-label,
    .match-moves-head,
    .move-index,
    .match-pgn-label,
    .replay-date {
        font-size: 14px;
    }

    .chess-field,
    .live-players,
    .leaderboard-name,
    .history-type-name,
    .match-time,
    .move-cell,
    .replay-title {
        font-size: 16px;
    }

    .segmented button,
    .time-preset,
    .match-actions .btn,
    .match-pgn .btn,
    .match-invite-controls .btn {
        min-height: 44px;
        font-size: 16px;
        padding: 10px 12px;
    }

    .segmented {
        padding: 4px;
    }

    .segmented-indicator {
        top: 4px;
        bottom: 4px;
        left: 4px;
        width: calc((100% - 8px) / var(--seg-count, 3));
    }

    .vstepper {
        width: 64px;
        grid-template-rows: 44px 44px 44px;
    }

    .vstepper button {
        font-size: 20px;
    }

    .vstepper input {
        font-size: 16px;
    }

    .profile-stat,
    .leaderboard-stats,
    .stat-label,
    .history-result {
        font-size: 14px;
    }

    .stat-value,
    .match-status {
        font-size: 18px;
    }

    .match-invite-controls {
        gap: 10px;
    }

    .match-moves-wrap {
        min-height: 320px;
    }

    .move-row {
        padding: 10px;
        gap: 8px;
    }

    .promotion-picker button {
        min-height: 52px;
    }

    .promotion-picker button img {
        width: 44px;
        height: 44px;
    }

    .profile-root {
        padding-top: 20px;
    }

    .profile-root > .profile-wrapper {
        gap: 16px;
    }

    .avatar-box {
        width: min(240px, 70vw);
        height: min(240px, 70vw);
    }

    .console-block {
        font-size: 16px;
        line-height: 1.6;
        padding: 10px 8px;
    }

    .indent {
        margin-left: 24px;
    }

    .error-main {
        padding: 16px;
    }

    .error-card {
        padding: 28px 16px;
    }

    .error-text {
        font-size: 18px;
        line-height: 1.6;
    }

    .error-actions {
        gap: 12px;
        flex-wrap: wrap;
    }

    .error-actions .btn {
        flex: 1 1 180px;
    }

    .widget-container {
        padding: 20px 16px !important;
        border-radius: 16px;
    }

    .widget-container h2 {
        font-size: 28px !important;
        line-height: 1.2;
    }

    #countdown {
        font-size: 1.45em !important;
        line-height: 1.4;
        min-height: 2.8em;
    }

    #verifyBtn {
        min-height: 48px !important;
        font-size: 18px !important;
        padding: 12px 16px !important;
    }

    .verify-btn {
        min-height: 48px;
    }

    .messenger-main {
        top: var(--mobile-header-h);
    }

    .chat-list-header {
        padding: 16px;
    }

    .chat-item {
        min-height: 72px;
        padding: 12px 14px;
        gap: 12px;
    }

    .avatar-sm {
        width: 40px;
        height: 40px;
    }

    .chat-username {
        font-size: 17px;
        line-height: 1.35;
    }

    .chat-last,
    .chat-time {
        font-size: 15px;
        line-height: 1.4;
    }

    .chat-right {
        width: 64px;
        min-width: 64px;
        flex-basis: 64px;
    }

    .chat-header {
        min-height: 60px;
        padding: 10px 12px;
        gap: 10px;
    }

    .mobile-chat-back {
        min-width: 44px;
        height: 44px;
        margin-right: 4px;
        font-size: 30px;
        border-radius: 10px;
    }

    .chat-header-user {
        min-height: 44px;
        padding: 6px 8px;
        border-radius: 10px;
    }

    .chat-header-user .chat-username-header {
        font-size: 18px;
        line-height: 1.3;
    }

    .chat-status {
        font-size: 14px;
        line-height: 1.4;
    }

    .messages {
        padding: 12px 12px 10px;
        gap: 12px;
    }

    .group-body {
        max-width: 92%;
    }

    .msg,
    .msg.short,
    .msg-text {
        font-size: 16px;
        line-height: 1.5;
    }

    .msg {
        padding: 10px 12px 24px;
    }

    .msg-time,
    .msg.short .msg-time {
        font-size: 13px;
    }

    .chat-input-field {
        padding: 8px 10px;
    }

    .chat-input-inner {
        gap: 10px;
    }

    .chat-input-editable {
        min-height: 46px;
        max-height: 180px;
        padding: 10px 12px;
        font-size: 16px;
        line-height: 1.45;
    }

    button.btn.send-btn {
        height: 46px;
        min-height: 46px;
        padding: 10px 14px;
        font-size: 16px;
    }

    .chat-input-editable:empty:before {
        font-size: 16px;
    }

    .day-separator,
    .unread-separator {
        font-size: 14px;
    }

    .notifications-container {
        right: 10px;
        left: 10px;
        bottom: 10px;
    }

    .notification-card {
        min-height: 72px;
        padding: 12px;
        gap: 12px;
    }

    .notification-title {
        font-size: 16px;
    }

    .notification-text {
        font-size: 14px;
        line-height: 1.45;
    }

    .notification-avatar {
        width: 44px;
        height: 44px;
        flex-basis: 44px;
    }

    #cookieBanner {
        left: 12px !important;
        right: 12px !important;
        transform: none !important;
        bottom: 12px !important;
        width: auto !important;
        max-width: none !important;
        padding: 14px 14px !important;
        border-radius: 12px !important;
        font-size: 16px !important;
        line-height: 1.5 !important;
    }

    #cookieBanner button {
        width: 100% !important;
        min-height: 44px !important;
        margin-left: 0 !important;
        margin-top: 10px !important;
        padding: 10px 14px !important;
        border-radius: 10px !important;
        font-size: 16px !important;
    }

    a:focus-visible,
    button:focus-visible,
    input:focus-visible,
    select:focus-visible,
    textarea:focus-visible,
    [tabindex]:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }
}

@media (max-width: 480px) {
    :root {
        --mobile-header-h: 60px;
        --mobile-pad: 12px;
    }

    .header {
        height: var(--mobile-header-h);
    }

    .logo {
        font-size: 26px;
    }

    .mobile-menu-toggle {
        width: 44px;
        min-width: 44px;
        height: 44px;
    }

    .nav {
        width: 100%;
        max-width: none;
        padding: 14px 12px 18px;
    }

    .container {
        margin: 16px 12px 24px;
        padding: 16px 14px;
    }

    .games-wrapper,
    .achievements-shell,
    .settings-root,
    .admin-root,
    .profile-root > .profile-wrapper {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .settings-nav {
        grid-template-columns: 1fr;
    }

    .games-title {
        font-size: 28px;
    }

    .game-name {
        font-size: 21px;
    }

    .error-code {
        font-size: 48px;
    }

    .error-title {
        font-size: 30px;
    }

    .error-text {
        font-size: 16px;
    }

    .chat-item {
        min-height: 68px;
        padding: 12px;
    }

    .chat-right {
        width: 58px;
        min-width: 58px;
        flex-basis: 58px;
    }

    .chat-header {
        min-height: 58px;
        padding: 10px;
    }

    .mobile-chat-back {
        font-size: 28px;
    }

    .messages {
        padding: 10px 10px 8px;
    }

    .msg,
    .msg.short,
    .msg-text {
        font-size: 16px;
    }

    .chat-input-editable {
        min-height: 44px;
        padding: 10px;
        font-size: 16px;
    }

    button.btn.send-btn {
        height: 44px;
        min-height: 44px;
        padding: 10px 12px;
        font-size: 16px;
    }

    .notification-card {
        padding: 12px 10px;
    }

    .vstepper {
        width: 58px;
    }

    .match-timer {
        width: 108px;
        min-width: 108px;
        font-size: 20px;
    }

    .match-timer.show-ms {
        width: 126px;
        min-width: 126px;
    }
}
