/* 《昭瑜古镇·序章》手机版公共适配层 */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

button,
input,
textarea,
select {
    font-family: inherit;
}

@media (max-width: 768px), (pointer: coarse) and (max-width: 1024px) {
    :root {
        --mobile-taskbar-height: 62px;
        --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
    }

    body {
        width: 100%;
        min-width: 0;
        min-height: 100dvh;
        overscroll-behavior: none;
        touch-action: manipulation;
    }

    .desktop {
        height: 100dvh;
        min-height: 100dvh;
        padding-bottom: calc(var(--mobile-taskbar-height) + var(--mobile-safe-bottom));
        background-position: 58% center;
    }

    .desktop-icons {
        top: max(22px, env(safe-area-inset-top, 0px));
        left: 18px;
        right: 18px;
        display: grid;
        grid-template-columns: repeat(2, minmax(88px, 112px));
        gap: 16px 10px;
        align-content: start;
    }

    .desktop-icon {
        width: 100%;
        min-height: 98px;
        justify-content: center;
        gap: 7px;
        padding: 10px 7px;
        border: 1px solid rgba(255, 255, 255, 0.14);
        border-radius: 12px;
        background: rgba(22, 31, 40, 0.24);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    .desktop-icon:active {
        background: rgba(255, 255, 255, 0.25);
    }

    .desktop-icon .icon-img {
        width: 48px;
        height: 48px;
    }

    .desktop-icon .icon-label {
        max-width: 100%;
        font-size: 12px;
        word-break: normal;
    }

    .taskbar {
        height: calc(var(--mobile-taskbar-height) + var(--mobile-safe-bottom));
        padding: 0 8px var(--mobile-safe-bottom);
        background: rgba(23, 29, 36, 0.94);
    }

    .taskbar-icons {
        width: 100%;
        height: var(--mobile-taskbar-height);
        justify-content: space-around;
        gap: 2px;
    }

    .start-btn,
    .taskbar-icon {
        width: 19%;
        height: 52px;
        border-radius: 10px;
    }

    .start-btn {
        margin-right: 0;
    }

    .start-btn svg,
    .taskbar-icon img {
        width: 28px;
        height: 28px;
    }

    .taskbar-icon.active::after {
        bottom: 2px;
        width: 24px;
    }

    .search-box-taskbar,
    .system-tray .tray-icon {
        display: none;
    }

    .system-tray {
        position: fixed;
        top: max(8px, env(safe-area-inset-top, 0px));
        right: 10px;
        z-index: 20;
        pointer-events: none;
    }

    .tray-time {
        padding: 5px 8px;
        border-radius: 9px;
        background: rgba(15, 23, 32, 0.5);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    .tray-time .time {
        font-size: 13px;
    }

    .tray-time .date {
        display: none;
    }

    .window,
    .webpage-window {
        position: fixed !important;
        inset: env(safe-area-inset-top, 0px) 0 calc(var(--mobile-taskbar-height) + var(--mobile-safe-bottom)) 0 !important;
        width: auto !important;
        height: auto !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
        box-shadow: none;
    }

    .window.show {
        animation: mobileWindowOpen 0.18s ease-out;
    }

    @keyframes mobileWindowOpen {
        from {
            opacity: 0;
            transform: translateX(12px);
        }
        to {
            opacity: 1;
            transform: translateX(0);
        }
    }

    .window-titlebar {
        height: 48px;
        min-height: 48px;
        padding: 0 0 0 14px;
        cursor: default;
        border-bottom-color: #dfe3e8;
    }

    .window-title {
        min-width: 0;
        max-width: calc(100vw - 62px);
        overflow: hidden;
        font-size: 14px;
        font-weight: 600;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .window-title img {
        width: 20px;
        height: 20px;
    }

    .window-controls .window-btn:not(.close) {
        display: none;
    }

    .window-btn.close {
        width: 52px;
        height: 48px;
        color: #555;
        font-size: 18px;
    }

    .window-btn.close:active {
        color: #fff;
        background: #d92b3a;
    }

    .window-content {
        min-width: 0;
        padding: 14px;
    }

    .wechat-content {
        padding: 0;
    }

    .wechat-sidebar {
        display: none;
    }

    .wechat-main {
        min-width: 0;
        flex-direction: column !important;
    }

    .wechat-chat-list {
        display: flex;
        width: 100%;
        height: 76px;
        min-height: 76px;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: 0;
        border-bottom: 1px solid #dedede;
        scrollbar-width: none;
    }

    .wechat-chat-list::-webkit-scrollbar {
        display: none;
    }

    .chat-item {
        width: 116px;
        min-width: 116px;
        height: 76px;
        padding: 10px 8px;
        border-bottom: 0;
        border-right: 1px solid #eeeeee;
    }

    .chat-item.active {
        background: #e8f5e9;
        box-shadow: inset 0 -3px #07c160;
    }

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

    .chat-info {
        overflow: hidden;
    }

    .chat-name {
        overflow: hidden;
        font-size: 12px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .chat-msg {
        display: none;
    }

    .wechat-chat-detail {
        min-height: 0;
    }

    .chat-detail-header {
        height: 40px;
        min-height: 40px;
        padding: 0 12px;
    }

    .chat-detail-messages {
        min-height: 0;
        padding: 12px 10px 18px;
        gap: 11px;
        -webkit-overflow-scrolling: touch;
    }

    .message {
        max-width: 92%;
    }

    .message-bubble {
        padding: 9px 11px;
        font-size: 14px;
        word-break: break-word;
    }

    .message-avatar {
        width: 30px;
        height: 30px;
    }

    .file-message .message-bubble {
        min-width: min(220px, calc(100vw - 82px));
    }

    .chat-detail-input {
        height: 66px;
        min-height: 66px;
        padding: 8px 10px;
    }

    .chat-input-area {
        font-size: 16px;
    }

    .reply-options {
        left: 8px;
        right: 8px;
        bottom: 62px;
        max-height: min(48vh, 330px);
        overflow-y: auto;
        padding: 10px;
        border-radius: 10px;
    }

    .reply-option {
        min-height: 46px;
        padding: 11px 12px;
        font-size: 14px;
    }

    .browser-toolbar {
        height: 44px;
        min-height: 44px;
        padding: 0 6px;
        gap: 3px;
    }

    .browser-nav-btn {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
        font-size: 18px;
    }

    .browser-toolbar .browser-nav-btn:nth-child(2) {
        display: none;
    }

    .browser-address-bar {
        min-width: 0;
        height: 32px;
        padding: 0 10px;
        overflow: hidden;
        font-size: 11px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .browser-page,
    .browser-frame {
        min-height: 0;
    }

    .calendar-content {
        overflow-y: auto;
    }

    .calendar-header {
        padding: 14px 16px 10px;
    }

    .calendar-nav-btn,
    .calendar-today-btn {
        height: 40px;
    }

    .calendar-nav-btn {
        width: 40px;
    }

    .calendar-days,
    .calendar-weekdays {
        padding-inline: 8px;
    }

    .hospital-body {
        min-height: 0;
        flex-direction: column;
        overflow-y: auto;
    }

    .hospital-sidebar {
        display: flex;
        width: 100%;
        min-height: 52px;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 6px;
    }

    .hospital-menu-item {
        min-width: max-content;
        padding: 9px 12px;
    }

    .hospital-main {
        padding: 12px;
    }

    .hospital-stats {
        gap: 8px;
    }

    .wechat-desktop-notification,
    .ending-desktop-notification {
        top: max(10px, env(safe-area-inset-top, 0px));
        right: 10px;
        bottom: auto;
        left: 10px;
        width: auto;
        min-height: 70px;
        padding: 12px 14px;
        border-radius: 14px;
    }

    .context-menu {
        display: none !important;
    }

    .game-intro-overlay {
        align-items: stretch;
        padding: max(10px, env(safe-area-inset-top, 0px)) 10px max(10px, env(safe-area-inset-bottom, 0px));
    }

    .game-intro-panel {
        width: 100%;
        max-height: 100%;
        border-radius: 12px;
    }

    .game-intro-header {
        padding: 20px 16px 16px;
    }

    .game-intro-kicker {
        font-size: 11px;
    }

    .game-intro-title {
        font-size: 22px;
    }

    .game-intro-content {
        padding: 18px 18px 8px;
        -webkit-overflow-scrolling: touch;
    }

    .game-intro-section {
        margin-bottom: 20px;
    }

    .game-intro-footer {
        padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px));
    }

    .game-intro-start {
        width: 100%;
        min-height: 48px;
    }

    /* 入口页 */
    .page .topbar,
    .page .footer {
        padding-right: 16px;
        padding-left: 16px;
    }

    .page .stage {
        padding-right: 16px;
        padding-left: 16px;
    }

    .page .launch-panel {
        width: 100%;
    }

    .storage-note {
        line-height: 1.7;
    }

    /* 嵌入网页的统一触屏修正 */
    .zhaoyu-mobile-frame,
    .zhaoyu-mobile-frame body {
        width: 100%;
        min-width: 0 !important;
        max-width: 100%;
        min-height: 100%;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .zhaoyu-mobile-frame img,
    .zhaoyu-mobile-frame video,
    .zhaoyu-mobile-frame canvas {
        max-width: 100% !important;
        height: auto;
    }

    .zhaoyu-mobile-frame input,
    .zhaoyu-mobile-frame textarea,
    .zhaoyu-mobile-frame select {
        max-width: 100%;
        font-size: 16px !important;
    }

    .zhaoyu-mobile-frame button,
    .zhaoyu-mobile-frame [role="button"],
    .zhaoyu-mobile-frame .btn,
    .zhaoyu-mobile-frame .tab-item,
    .zhaoyu-mobile-frame .query-link {
        min-height: 42px;
        touch-action: manipulation;
    }

    .zhaoyu-mobile-frame table {
        display: block;
        width: 100% !important;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .zhaoyu-mobile-frame pre,
    .zhaoyu-mobile-frame code,
    .zhaoyu-mobile-frame td,
    .zhaoyu-mobile-frame th {
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .zhaoyu-mobile-frame .container,
    .zhaoyu-mobile-frame .main-container,
    .zhaoyu-mobile-frame .main-content,
    .zhaoyu-mobile-frame .content,
    .zhaoyu-mobile-frame .content-area,
    .zhaoyu-mobile-frame .page-container,
    .zhaoyu-mobile-frame .report-container,
    .zhaoyu-mobile-frame .article-container,
    .zhaoyu-mobile-frame .post-container,
    .zhaoyu-mobile-frame .profile-container,
    .zhaoyu-mobile-frame .diary-container,
    .zhaoyu-mobile-frame .content-wrapper {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    .zhaoyu-mobile-frame .modal,
    .zhaoyu-mobile-frame .modal-content,
    .zhaoyu-mobile-frame .login-modal-content,
    .zhaoyu-mobile-frame .dialog,
    .zhaoyu-mobile-frame .dialog-content {
        width: calc(100vw - 24px) !important;
        max-width: calc(100vw - 24px) !important;
        max-height: calc(100dvh - 24px) !important;
        overflow-y: auto;
    }

    /* 网页1论坛原稿没有手机规则，单独补齐。 */
    .zhaoyu-mobile-frame .top-nav {
        padding: 0 12px;
    }

    .zhaoyu-mobile-frame .top-nav-inner {
        height: 54px;
    }

    .zhaoyu-mobile-frame .top-nav .nav-menu,
    .zhaoyu-mobile-frame .top-nav .nav-right {
        display: none;
    }

    .zhaoyu-mobile-frame .container {
        margin: 10px auto;
        padding-right: 10px;
        padding-left: 10px;
    }

    .zhaoyu-mobile-frame .post-header {
        padding: 16px 14px 12px;
    }

    .zhaoyu-mobile-frame .post-title {
        font-size: 20px;
    }

    .zhaoyu-mobile-frame .post-body,
    .zhaoyu-mobile-frame .reply-item {
        display: block;
        padding: 15px 14px;
    }

    .zhaoyu-mobile-frame .user-info,
    .zhaoyu-mobile-frame .reply-user {
        display: flex;
        width: auto;
        align-items: center;
        gap: 10px;
        margin-bottom: 12px;
        text-align: left;
    }

    .zhaoyu-mobile-frame .avatar,
    .zhaoyu-mobile-frame .reply-avatar {
        width: 42px;
        height: 42px;
        margin: 0;
    }

    .zhaoyu-mobile-frame .post-content,
    .zhaoyu-mobile-frame .reply-content-wrap {
        padding-left: 0;
        border-left: 0;
    }

    .zhaoyu-mobile-frame .post-image img {
        width: 100%;
    }

    .zhaoyu-mobile-frame .reply-box {
        padding: 14px;
    }

    .zhaoyu-mobile-frame .clue-journal {
        max-height: 220px;
        padding: 12px;
    }

    .zhaoyu-mobile-frame .clue-link {
        min-height: 48px;
    }
}

@media (max-width: 420px) {
    .desktop-icons {
        grid-template-columns: repeat(2, minmax(82px, 104px));
    }

    .chat-item {
        width: 104px;
        min-width: 104px;
    }

    .message {
        max-width: 96%;
    }

    .browser-nav-btn {
        width: 34px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .window.show,
    .wechat-desktop-notification.show,
    .ending-desktop-notification.show {
        animation: none !important;
    }
}
