/* reverse-invasion.css — 反向入侵：设置卡 / 顶栏横幅 / 屏蔽层 / 聊天回执气泡（由 style.css 拆出） */

/* ===================== 反向入侵设置卡（Char 手机·设置·桌面背景下方） ===================== */
.phone-settings-reverse-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.phone-settings-reverse-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.phone-settings-reverse-title-wrap {
    flex: 1;
    min-width: 0;
}

.phone-settings-reverse-switch {
    flex-shrink: 0;
    position: relative;
    width: 42px;
    height: 24px;
    display: inline-block;
    cursor: pointer;
}

.phone-settings-reverse-switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    margin: 0;
    cursor: pointer;
    z-index: 2;
}

.phone-settings-reverse-switch-track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(120, 130, 140, 0.32);
    transition: background 0.18s ease;
}

.phone-settings-reverse-switch-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
    transition: transform 0.18s ease;
}

.phone-settings-reverse-switch input:checked + .phone-settings-reverse-switch-track {
    background: linear-gradient(135deg, #FF6B8A 0%, #FF9A6B 100%);
}

.phone-settings-reverse-switch input:checked + .phone-settings-reverse-switch-track::after {
    transform: translateX(18px);
}

.phone-settings-reverse-collapse-btn {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(120, 130, 140, 0.22);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    color: #555;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.phone-settings-reverse-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.9);
}

.phone-settings-reverse-collapse-arrow {
    transition: transform 0.18s ease;
    display: inline-block;
}

.phone-settings-reverse-collapse-arrow.is-open {
    transform: rotate(180deg);
}

.phone-settings-reverse-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 8px 4px 4px;
    border-top: 1px dashed rgba(120, 130, 140, 0.22);
}

.phone-settings-reverse-body[hidden] {
    display: none;
}

.phone-settings-reverse-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.phone-settings-reverse-label {
    font-size: 13px;
    color: #333;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.phone-settings-reverse-depth-actions {
    display: inline-flex;
    gap: 6px;
}

.phone-settings-reverse-depth-btn {
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(120, 130, 140, 0.24);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 11px;
    color: #555;
    cursor: pointer;
}

.phone-settings-reverse-depth-btn:hover {
    background: rgba(255, 255, 255, 0.95);
}

.phone-settings-reverse-interval {
    width: 110px;
    padding: 6px 10px;
    border: 1px solid rgba(120, 130, 140, 0.24);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    color: #222;
}

.phone-settings-reverse-hint {
    font-size: 11.5px;
    color: rgba(60, 60, 70, 0.62);
    line-height: 1.45;
}

.phone-settings-reverse-depth-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px 10px;
}

.phone-settings-reverse-depth-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(120, 130, 140, 0.18);
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    line-height: 1.35;
}

.phone-settings-reverse-depth-item input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: #FF6B8A;
}

.phone-settings-reverse-depth-name {
    color: #333;
    font-weight: 600;
    flex: 1;
}

.phone-settings-reverse-depth-sub {
    display: block;
    width: 100%;
    color: rgba(60, 60, 70, 0.55);
    font-size: 11px;
    font-weight: 400;
    margin-left: 22px;
    margin-top: 2px;
}

.phone-settings-reverse-depth-item:has(input:checked) {
    background: linear-gradient(135deg, rgba(255, 107, 138, 0.15) 0%, rgba(255, 154, 107, 0.12) 100%);
    border-color: rgba(255, 107, 138, 0.42);
}

/* ===================== 反向入侵 · 顶部状态条 + 透明输入屏蔽层 ===================== */

/* 透明屏蔽层：覆盖整屏，吃掉所有点击/触摸事件，但 User 仍能"看见"下方页面被 Char 操作 */
.reverse-invasion-block-layer {
    position: fixed;
    inset: 0;
    z-index: 1000040;
    background: transparent;
    pointer-events: auto;
    cursor: not-allowed;
}

html.reverse-invasion-active {
    /* 阻止键盘选区 / 文本选中，强化"被锁定"感 */
    user-select: none;
    -webkit-user-select: none;
}

html.reverse-invasion-active body {
    overflow: hidden;
}

/* 顶部状态条（2026-07 重做）
   —— 用户集中反馈两类问题，这里一次解决：
   ① iPhone(灵动岛/刘海机型) Safari 等场景下，横幅 top:12px 会顶进真机状态栏 / 灵动岛
      背后，按钮完全点不到。现在下移：56px 基础偏移 + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) 安全区
      （与项目 safe-area-compat.css 同一套方案；不支持 env() 的老内核回落到纯 56px，
      也已避开顶部框架）。
   ② 显示面积太小、只有一行半文字，看不清 Char 做了什么。改为纵向大卡片：
      标题行 + 当前动态(最多 6 行) + 最近操作轨迹 + 全宽"知道了"大按钮(≥44px 触控高度)。 */
.reverse-invasion-banner {
    position: fixed;
    top: 56px; /* 老内核（不支持 env()/calc 嵌套）兜底 */
    top: calc(56px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)));
    left: 50%;
    /* 收起态不再用 -120% 甩出屏外（下移后甩不干净会露一截），改淡出+上移 */
    transform: translate(-50%, -16px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 1000060;
    width: min(480px, calc(100vw - 20px));
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease, visibility 0s linear 0.32s;
}

.reverse-invasion-banner.is-open {
    transform: translate(-50%, 0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease;
}

.reverse-invasion-banner-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(48, 18, 38, 0.96) 0%, rgba(38, 12, 38, 0.96) 100%);
    border: 1px solid rgba(255, 107, 138, 0.42);
    box-shadow: 0 10px 28px rgba(20, 0, 30, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    color: #fff;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.reverse-invasion-banner-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.reverse-invasion-banner-pulse {
    flex-shrink: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #FF6B8A;
    box-shadow: 0 0 0 0 rgba(255, 107, 138, 0.7);
    animation: reverse-invasion-pulse 1.8s ease-in-out infinite;
}

@keyframes reverse-invasion-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 107, 138, 0.55); transform: scale(1); }
    70%  { box-shadow: 0 0 0 12px rgba(255, 107, 138, 0); transform: scale(1.08); }
    100% { box-shadow: 0 0 0 0 rgba(255, 107, 138, 0); transform: scale(1); }
}

.reverse-invasion-banner-title {
    font-size: 13px;
    letter-spacing: 0.08em;
    font-weight: 800;
    color: #FFD0DC;
    text-transform: uppercase;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reverse-invasion-banner-status {
    font-size: 14.5px;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.55;
    word-break: break-word;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
}

/* 最近操作轨迹：把 Char 刚做过的几步留在屏上，User 能连续看清整个过程 */
.reverse-invasion-banner-log {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-top: 8px;
    border-top: 1px dashed rgba(255, 208, 220, 0.28);
}

.reverse-invasion-banner-log[hidden] {
    display: none;
}

.reverse-invasion-banner-log-item {
    font-size: 12px;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.55);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reverse-invasion-banner-log-item::before {
    content: '·';
    margin-right: 5px;
    color: rgba(255, 107, 138, 0.7);
}

/* "知道了"：全宽大按钮，≥44px 触控高度（iOS 人机指南最小触控目标），
   touch-action: manipulation 消除双击缩放判定带来的点击延迟 */
.reverse-invasion-banner-skip {
    width: 100%;
    min-height: 44px;
    background: linear-gradient(135deg, #FF6B8A 0%, #FF9A6B 100%);
    border: none;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 10px 16px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255, 107, 138, 0.35);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    transition: transform 0.12s ease, filter 0.12s ease, background 0.2s ease;
}

.reverse-invasion-banner-skip:active:not(:disabled) {
    transform: scale(0.97);
    filter: brightness(0.9);
}

/* 点击后的确认态：变绿 + "✓ 已知晓"，让用户明确感知点击已生效 */
.reverse-invasion-banner-skip.is-acked {
    background: linear-gradient(135deg, #38C98E 0%, #2BB3A3 100%);
    box-shadow: 0 4px 12px rgba(43, 179, 163, 0.35);
    cursor: default;
    opacity: 1;
}

/* 被无视态：Char 依角色性格拒不收手时，按钮转深灰红"✗ TA 无视了你的确认"，
   配合一次轻微横向抖动，传达"确认已送达但被对方无视"的挫败感 */
.reverse-invasion-banner-skip.is-defied {
    background: linear-gradient(135deg, rgba(90, 30, 46, 0.95) 0%, rgba(60, 20, 40, 0.95) 100%);
    border: 1px solid rgba(255, 107, 138, 0.5);
    color: #FFB3C4;
    box-shadow: 0 4px 12px rgba(20, 0, 10, 0.4);
    cursor: default;
    opacity: 1;
    animation: reverse-invasion-defy-shake 0.45s ease;
}

@keyframes reverse-invasion-defy-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(2px); }
}

.reverse-invasion-banner-skip:disabled:not(.is-acked):not(.is-defied) {
    opacity: 0.65;
    cursor: not-allowed;
}

@media (max-width: 480px) {
    .reverse-invasion-banner {
        top: 48px;
        top: calc(48px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)));
        width: calc(100vw - 16px);
    }
    .phone-settings-reverse-depth-grid {
        grid-template-columns: 1fr;
    }
    .reverse-invasion-banner-pulse {
        animation: none;
    }
}

/* 矮屏（横屏手机等）：压缩动态区行数，防止卡片高过可视区 */
@media (max-height: 520px) {
    .reverse-invasion-banner-status {
        -webkit-line-clamp: 3;
    }
    .reverse-invasion-banner-log {
        display: none;
    }
}

/* ============================================================
   反向入侵·真实操作回执（可折叠卡片）
   --------------------------------------------------------------
   覆盖普通微信气泡的字数限制：完整记录 Char 在 User 手机上的
   每一步浏览、看到的内容、实际执行的动作。默认折叠，点击展开。
   ============================================================ */
.chat-message-bubble--reverse-invasion-receipt {
    background: transparent !important;
    padding: 0 !important;
    max-width: 100% !important;
    width: 100%;
    box-shadow: none !important;
}

.chat-message-bubble--reverse-invasion-receipt .rir-card {
    border-radius: 14px;
    background: linear-gradient(160deg, rgba(255, 246, 247, 0.95), rgba(243, 232, 255, 0.92));
    border: 1px solid rgba(255, 110, 130, 0.22);
    box-shadow: 0 6px 18px rgba(255, 110, 130, 0.12);
    overflow: hidden;
}

.chat-message-bubble--reverse-invasion-receipt .rir-head {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    background: transparent;
    border: 0;
    cursor: pointer;
    text-align: left;
    color: #4a2030;
    transition: background-color 0.18s ease;
}

.chat-message-bubble--reverse-invasion-receipt .rir-head:hover {
    background-color: rgba(255, 200, 210, 0.25);
}

.chat-message-bubble--reverse-invasion-receipt .rir-head-badge {
    flex: 0 0 auto;
    padding: 2px 8px;
    border-radius: 999px;
    background: linear-gradient(90deg, #ff6b81, #c071ff);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1.6;
    box-shadow: 0 2px 4px rgba(255, 107, 129, 0.32);
}

.chat-message-bubble--reverse-invasion-receipt .rir-head-text {
    flex: 1 1 auto;
    min-width: 0;
}

.chat-message-bubble--reverse-invasion-receipt .rir-head-title {
    font-size: 14px;
    font-weight: 600;
    color: #2d1023;
    line-height: 1.35;
}

.chat-message-bubble--reverse-invasion-receipt .rir-head-summary {
    margin-top: 4px;
    font-size: 12.5px;
    line-height: 1.45;
    color: #5b3142;
    /* 折叠时摘要最多两行，避免标题区过高 */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    word-break: break-word;
}

.chat-message-bubble--reverse-invasion-receipt .rir-head-ts {
    margin-top: 4px;
    font-size: 11px;
    color: #8c5f70;
    opacity: 0.85;
}

.chat-message-bubble--reverse-invasion-receipt .rir-head-arrow {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    color: #ad2d4d;
    font-size: 12px;
    transition: transform 0.22s ease;
}

.chat-message-bubble--reverse-invasion-receipt .rir-card:not([data-collapsed="1"]) .rir-head-arrow {
    transform: rotate(180deg);
}

.chat-message-bubble--reverse-invasion-receipt .rir-card:not([data-collapsed="1"]) .rir-head-summary {
    -webkit-line-clamp: unset;
    display: block;
}

.chat-message-bubble--reverse-invasion-receipt .rir-body {
    padding: 4px 14px 14px;
    border-top: 1px dashed rgba(255, 110, 130, 0.25);
    background: rgba(255, 252, 253, 0.65);
    color: #3a1c2c;
    font-size: 13px;
    line-height: 1.55;
}

.chat-message-bubble--reverse-invasion-receipt .rir-body[hidden] {
    display: none;
}

.chat-message-bubble--reverse-invasion-receipt .rir-section {
    margin-top: 10px;
}

.chat-message-bubble--reverse-invasion-receipt .rir-section:first-child {
    margin-top: 8px;
}

.chat-message-bubble--reverse-invasion-receipt .rir-section-title {
    font-size: 12px;
    font-weight: 600;
    color: #ad2d4d;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.chat-message-bubble--reverse-invasion-receipt .rir-line {
    margin: 2px 0;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-message-bubble--reverse-invasion-receipt .rir-open {
    margin-bottom: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(255, 110, 130, 0.14);
}

.chat-message-bubble--reverse-invasion-receipt .rir-open-name {
    font-weight: 600;
    color: #6b1c3c;
    font-size: 12.5px;
    margin-bottom: 4px;
}

.chat-message-bubble--reverse-invasion-receipt .rir-open-narration {
    color: #4a2030;
    font-size: 12.5px;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-message-bubble--reverse-invasion-receipt .rir-open-actions {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-message-bubble--reverse-invasion-receipt .rir-action {
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(255, 235, 240, 0.85);
    border-left: 3px solid #ff6b81;
    font-size: 12.5px;
    line-height: 1.45;
}

.chat-message-bubble--reverse-invasion-receipt .rir-action-kind {
    display: inline-block;
    margin-right: 6px;
    padding: 1px 6px;
    border-radius: 6px;
    background: #ff6b81;
    color: #fff;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    vertical-align: 1px;
}

.chat-message-bubble--reverse-invasion-receipt .rir-action-content {
    margin-top: 3px;
    color: #4a2030;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-message-bubble--reverse-invasion-receipt .rir-evidence {
    margin-bottom: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(247, 237, 255, 0.78);
    border: 1px solid rgba(192, 113, 255, 0.18);
}

.chat-message-bubble--reverse-invasion-receipt .rir-evidence-app {
    font-weight: 600;
    color: #58208c;
    font-size: 12.5px;
    margin-bottom: 4px;
}

.chat-message-bubble--reverse-invasion-receipt .rir-section-fallback {
    background: rgba(255, 255, 255, 0.78);
    padding: 8px 10px;
    border-radius: 10px;
    color: #3a1c2c;
}

/* ============================================================
   反向入侵 · 触发瞬间「夺屏」特效（2026-10 重做：雪花屏 → 故障撕裂）
   --------------------------------------------------------------
   用户反馈旧版雪花屏刺眼、过场太长、噪点上的字看不清，改为参考视频式的故障效果：
   - 暗底（近黑 + 极淡的底部红晕），横向切片错位 / 红青色块 / RGB 分离重影 / HUD 角标；
     大幅撕裂只在击入、击出的 0.3~0.5s 出现，阅读期间画面静止，只偶发一次轻微故障；
     不抖整屏、不白闪、没有大面积亮色闪烁。
   - 主文字：瀞ノグリッチ明朝 H3；氛围字：怨霊 onryou（均为 woff2 子集，见
     tools/reverse-invasion-glitch-font-subset.py）。字体就位前回落到系统宋体 / 衬线体。
     @font-face 声明 100~900 的字重区间：粗体请求直接用原字形，不叠浏览器伪粗体。
   - 撕裂帧由 JS 写内联 clip-path / transform（约 16fps，只在击入 / 击出 / 微故障时运行）；
     clip-path 不可用的老内核只是没有切片，文字照常可读。
   - .is-night：纯黑静默版；.is-reduced 与 prefers-reduced-motion：只淡入淡出。
   - 抖动 / 位移只作用在特效层内部元素，绝不 transform body/html（iOS Safari fixed 定位老坑）。
   ============================================================ */
@font-face {
    font-family: "LoveMiRIGlitchMincho";
    src: url("assets/reverse-invasion/fonts/ri-glitch-mincho-v1.woff2?v=1") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "LoveMiRIOnryou";
    src: url("assets/reverse-invasion/fonts/ri-onryou-ui-v1.woff2?v=1") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

.reverse-invasion-glitch {
    --rig-bg: #05070d;
    --rig-cyan: #19e3ff;
    --rig-red: #ff2e4d;
    --rig-ink: #eef7ff;
    --rig-font-main: "LoveMiRIGlitchMincho", "Noto Serif SC", "Source Han Serif SC", "Source Han Serif", "Songti SC", "STSong", "SimSun", serif;
    --rig-font-aux: "LoveMiRIOnryou", "LoveMiRIGlitchMincho", "Noto Serif SC", "Songti SC", "STSong", serif;
    position: fixed;
    inset: 0;
    z-index: 1000080; /* 高于状态条(1000060)与输入屏蔽层(1000040)，夺屏期间盖住一切 */
    overflow: hidden;
    contain: layout paint;
    background: var(--rig-bg);
    color: var(--rig-ink);
    pointer-events: auto;
    cursor: not-allowed;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.reverse-invasion-glitch.is-skip-armed {
    cursor: pointer;
}

.rig-backdrop,
.rig-blocks,
.rig-stage,
.rig-cracks,
.rig-impact,
.rig-scanlines {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* 底色：近黑 + 极淡的底部红晕 / 顶部深蓝（参考视频开场的地平线余晖），整体亮度很低 */
.rig-backdrop {
    background:
        radial-gradient(120% 55% at 50% 118%, rgba(255, 46, 77, 0.2), transparent 62%),
        radial-gradient(90% 55% at 50% -10%, rgba(25, 70, 130, 0.22), transparent 70%),
        var(--rig-bg);
}

/* 极淡扫描线：只给"屏幕"质感，不压字 */
.rig-scanlines {
    background: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.022) 0 1px, transparent 1px 3px);
}

/* 怨霊 onryou 巨型水印：「入侵」/「察觉」压在最底层，只留极淡的暗红笔触 */
.rig-watermark {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -54%) rotate(-6deg);
    font-family: var(--rig-font-aux);
    font-size: 150px; /* 老内核不支持 clamp() 时的兜底 */
    font-size: clamp(130px, 46vw, 360px);
    line-height: 1;
    letter-spacing: -0.04em;
    white-space: nowrap;
    color: rgba(255, 46, 77, 0.075);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.24s ease;
}

.reverse-invasion-glitch.is-striking .rig-watermark {
    color: rgba(255, 46, 77, 0.12);
    transform: translate(-48%, -54%) rotate(-6deg);
}

/* 撕裂色块：JS 在击入 / 击出 / 微故障时随机摆放，平时隐藏 */
.rig-block {
    position: absolute;
    display: block;
    visibility: hidden;
}

/* ---------- HUD：四角括线 + 两侧红色导轨 + onryou 小字读数（参考视频中段的蓝色 HUD） ---------- */
.rig-hud {
    position: absolute;
    left: 14px;
    right: 14px;
    top: 14px;
    top: calc(14px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)));
    bottom: 14px;
    bottom: calc(14px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.rig-hud-corner {
    position: absolute;
    width: 18px;
    height: 18px;
    border: 0 solid rgba(25, 227, 255, 0.5);
}

.rig-hud-corner.is-tl { left: 0; top: 0; border-left-width: 1.5px; border-top-width: 1.5px; }
.rig-hud-corner.is-tr { right: 0; top: 0; border-right-width: 1.5px; border-top-width: 1.5px; }
.rig-hud-corner.is-bl { left: 0; bottom: 0; border-left-width: 1.5px; border-bottom-width: 1.5px; }
.rig-hud-corner.is-br { right: 0; bottom: 0; border-right-width: 1.5px; border-bottom-width: 1.5px; }

.rig-hud-rail {
    position: absolute;
    top: 41%;
    width: 2px;
    height: 18%;
    background: linear-gradient(180deg, transparent, rgba(255, 46, 77, 0.55) 20%, rgba(255, 46, 77, 0.55) 80%, transparent);
}

.rig-hud-rail.is-l { left: 6px; }
.rig-hud-rail.is-r { right: 6px; }

.rig-hud-label {
    position: absolute;
    font-family: var(--rig-font-aux);
    font-size: 12px;
    line-height: 1;
    letter-spacing: 0.24em;
    white-space: nowrap;
    color: rgba(150, 222, 255, 0.6);
}

.rig-hud-label.is-tl { left: 26px; top: 3px; }
.rig-hud-label.is-tr { right: 26px; top: 3px; color: rgba(255, 120, 136, 0.72); }
.rig-hud-label.is-bl { left: 26px; bottom: 3px; }
.rig-hud-label.is-br { right: 26px; bottom: 3px; }

/* ---------- 文字卡：第一击（Char 名 + 入侵宣告 + onryou 副标）/ 第二击（模型台词 + 署名） ---------- */
.rig-card {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 72px 28px 84px;
    padding-top: calc(72px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)));
    padding-bottom: calc(84px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
    text-align: center;
    visibility: hidden;
}

.reverse-invasion-glitch[data-card="intro"] .rig-card-intro,
.reverse-invasion-glitch[data-card="burst"] .rig-card-burst {
    visibility: visible;
}

/* 故障字：正字在文档流里撑开尺寸；重影 / 切片副本绝对定位逐字叠在正字上（宿主不能有内边距） */
.rig-gt {
    position: relative;
    z-index: 0;
    display: block;
    max-width: 100%;
    font-family: var(--rig-font-main);
    font-weight: 700;
    overflow-wrap: break-word;
    word-break: break-word;
}

.rig-gt-base {
    position: relative;
    z-index: 2;
    display: block;
    opacity: 0;
    transition: opacity 0.16s ease;
}

.rig-gt-ghost,
.rig-gt-slice {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    display: block;
    pointer-events: none;
}

.rig-gt-ghost {
    z-index: 1;
    opacity: 0;
    text-shadow: none;
    transition: opacity 0.16s ease;
}

/* 重影静止偏移按字号（em）缩放：大字约 1.5~2.4px，小字不到 1px，不会把正字糊成双影 */
.rig-gt-ghost.is-c { color: var(--rig-cyan); transform: translate3d(-0.045em, 0, 0); }
.rig-gt-ghost.is-r { color: var(--rig-red); transform: translate3d(0.045em, 0, 0); }

/* 切片副本：带底色，盖住原位那一条字，再把错位后的同一条字露出来——横向撕裂的观感 */
.rig-gt-slice {
    z-index: 3;
    visibility: hidden;
    background: var(--rig-bg);
    box-shadow: 0 0 0 80px var(--rig-bg);
}

.rig-sub,
.rig-sign {
    opacity: 0;
    transition: opacity 0.24s ease;
}

.reverse-invasion-glitch.is-text-in .rig-gt-base,
.reverse-invasion-glitch.is-text-in .rig-sub,
.reverse-invasion-glitch.is-text-in .rig-sign,
.reverse-invasion-glitch.is-text-in .rig-watermark,
.reverse-invasion-glitch.is-text-in .rig-hud {
    opacity: 1;
}

.reverse-invasion-glitch.is-text-in .rig-gt-ghost {
    opacity: 0.5;
}

/* 长台词字号小、行数多：重影再淡一档，阅读优先 */
.reverse-invasion-glitch.is-text-in .rig-line.is-long .rig-gt-ghost,
.reverse-invasion-glitch.is-text-in .rig-line.is-xlong .rig-gt-ghost {
    opacity: 0.34;
}

.rig-name {
    font-size: 36px;
    font-size: clamp(30px, 10vw, 54px);
    line-height: 1.18;
    letter-spacing: 0.08em;
    color: var(--rig-ink);
    text-shadow: 0 0 1px rgba(0, 0, 0, 0.9), 0 0 22px rgba(25, 227, 255, 0.3);
}

.rig-message {
    font-size: 20px;
    font-size: clamp(17px, 5.2vw, 26px);
    line-height: 1.4;
    letter-spacing: 0.16em;
    text-wrap: balance;
    color: rgba(238, 247, 255, 0.94);
    text-shadow: 0 0 1px rgba(0, 0, 0, 0.9), 0 2px 10px rgba(0, 0, 0, 0.8);
}

/* onryou 副标：「信号已被劫持」+ 呼吸的三点（等第一次 API 时让 User 知道还在进行） */
.rig-sub {
    display: inline-flex;
    align-items: baseline;
    margin-top: 6px;
    font-family: var(--rig-font-aux);
    font-size: 16px;
    font-size: clamp(14px, 4.2vw, 19px);
    line-height: 1.3;
    letter-spacing: 0.32em;
    color: rgba(255, 98, 116, 0.92);
}

.rig-dots i {
    font-style: normal;
    letter-spacing: 0;
    opacity: 0.2;
    animation: rig-dot 1.2s steps(1, end) infinite;
}

.rig-dots i:nth-child(2) { animation-delay: 0.2s; }
.rig-dots i:nth-child(3) { animation-delay: 0.4s; }

@keyframes rig-dot {
    0%, 100% { opacity: 0.2; }
    40%, 70% { opacity: 0.95; }
}

/* 第二击：模型台词。颜色由模型 textColor 决定（过暗时 JS 已提亮），贴身暗描边保证可读 */
.rig-line {
    width: 100%;
    max-width: 560px;
    font-size: 24px;
    font-size: clamp(21px, 6.2vw, 34px);
    line-height: 1.56;
    letter-spacing: 0.05em;
    /* 均衡断行：避免末行只剩「嗎？」两三个字（不支持的内核按普通断行） */
    text-wrap: balance;
    color: var(--rig-color, #ff3355);
    text-shadow:
        0 0 1px rgba(0, 0, 0, 0.95),
        0 2px 12px rgba(0, 0, 0, 0.85),
        0 0 18px var(--rig-glow, rgba(255, 51, 85, 0.38));
}

.rig-line.is-long {
    font-size: 20px;
    font-size: clamp(18px, 5.3vw, 28px);
    line-height: 1.52;
}

.rig-line.is-xlong {
    font-size: 17px;
    font-size: clamp(16px, 4.6vw, 24px);
    line-height: 1.5;
}

/* 外语台词的中文翻译：另起一行、字号收小、中性浅色，和原文分开读 */
.rig-line-tr {
    display: block;
    margin: 0.35em 0 0.6em;
    font-size: 0.62em;
    line-height: 1.55;
    letter-spacing: 0.08em;
    color: rgba(232, 240, 250, 0.84);
}

.rig-line-tr:last-child {
    margin-bottom: 0;
}

.rig-gt-ghost .rig-line-tr {
    color: inherit;
}

.rig-sign {
    font-family: var(--rig-font-main);
    font-size: 13px;
    line-height: 1.4;
    letter-spacing: 0.32em;
    color: rgba(232, 240, 250, 0.58);
}

/* 台词完整亮出后才出现的 onryou 轻触提示 */
.rig-skip {
    position: absolute;
    left: 50%;
    bottom: 9%;
    bottom: calc(9% + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
    transform: translateX(-50%);
    font-family: var(--rig-font-aux);
    font-size: 13px;
    line-height: 1;
    letter-spacing: 0.36em;
    white-space: nowrap;
    color: rgba(232, 240, 250, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.reverse-invasion-glitch.is-skip-armed .rig-skip {
    opacity: 1;
}

/* ---------- 裂屏（模型 crackScreen=true）：裂纹 + LCD 坏点色线 + 暗红冲击，不再白闪 ---------- */
.rig-cracks svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transform: scale(0.8);
}

.reverse-invasion-glitch.is-cracked .rig-cracks svg {
    animation: rig-crack-in 0.3s cubic-bezier(0.16, 1.2, 0.4, 1) forwards;
}

@keyframes rig-crack-in {
    0%   { opacity: 0;   transform: scale(0.8); }
    50%  { opacity: 1;   transform: scale(1.03); }
    100% { opacity: 0.9; transform: scale(1); }
}

.rig-impact {
    opacity: 0;
    background: radial-gradient(circle at 50% 46%, rgba(255, 46, 77, 0.3), rgba(120, 0, 24, 0.12) 38%, transparent 70%);
}

.reverse-invasion-glitch.is-cracked .rig-impact {
    animation: rig-impact 0.5s ease-out forwards;
}

@keyframes rig-impact {
    0%   { opacity: 1; }
    100% { opacity: 0; }
}

/* ---------- 击出：画面跳帧收束成一条线后消失，露出底下早已就位的状态条 ---------- */
.reverse-invasion-glitch.is-leaving {
    animation: rig-collapse 0.34s steps(6, end) forwards;
}

@keyframes rig-collapse {
    0%   { -webkit-clip-path: inset(0 0 0 0); clip-path: inset(0 0 0 0); opacity: 1; }
    55%  { -webkit-clip-path: inset(46% 0 46% 0); clip-path: inset(46% 0 46% 0); opacity: 1; }
    85%  { -webkit-clip-path: inset(49.5% 22% 49.5% 22%); clip-path: inset(49.5% 22% 49.5% 22%); opacity: 0.85; }
    100% { -webkit-clip-path: inset(50% 50% 50% 50%); clip-path: inset(50% 50% 50% 50%); opacity: 0; }
}

@keyframes rig-fade-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* ============================================================
   夜间模式（判定见 JS _isNightInvasionMode，创建瞬间定格 .is-night）
   整屏死黑：没有色块 / HUD / 水印 / 副标 / 扫描线 / 裂屏，撕裂只落在字上且幅度极小；
   死寂里只浮现文字，DOM 与动画都比日间更少。
   ============================================================ */
.reverse-invasion-glitch.is-night {
    --rig-bg: #000;
}

.reverse-invasion-glitch.is-night .rig-backdrop {
    background: #000;
}

.reverse-invasion-glitch.is-night .rig-watermark,
.reverse-invasion-glitch.is-night .rig-blocks,
.reverse-invasion-glitch.is-night .rig-hud,
.reverse-invasion-glitch.is-night .rig-scanlines,
.reverse-invasion-glitch.is-night .rig-sub,
.reverse-invasion-glitch.is-night .rig-cracks,
.reverse-invasion-glitch.is-night .rig-impact {
    display: none;
}

.reverse-invasion-glitch.is-night .rig-name {
    font-size: 30px;
    font-size: clamp(26px, 8.4vw, 44px);
    color: rgba(226, 232, 244, 0.74);
    text-shadow: 0 0 1px #000;
}

.reverse-invasion-glitch.is-night .rig-message {
    color: rgba(226, 232, 244, 0.52);
    text-shadow: 0 0 1px #000;
}

.reverse-invasion-glitch.is-night.is-text-in .rig-gt-ghost {
    opacity: 0.26;
}

.reverse-invasion-glitch.is-night .rig-sign {
    color: rgba(226, 232, 244, 0.38);
}

.reverse-invasion-glitch.is-night .rig-skip {
    color: rgba(226, 232, 244, 0.3);
}

.reverse-invasion-glitch.is-night.is-leaving {
    animation: rig-fade-out 0.34s ease forwards;
}

/* ============================================================
   减弱动态效果：JS 侧（.is-reduced）完全不跑撕裂帧；CSS 再兜一层，
   保证即便 JS 没判定到，也不会出现切片 / 色块 / 跳帧收束，只淡入淡出。
   ============================================================ */
.reverse-invasion-glitch.is-reduced .rig-gt-slice,
.reverse-invasion-glitch.is-reduced .rig-blocks {
    display: none;
}

.reverse-invasion-glitch.is-reduced .rig-dots i {
    animation: none;
    opacity: 0.7;
}

.reverse-invasion-glitch.is-reduced.is-leaving {
    animation: rig-fade-out 0.3s ease forwards;
}

.reverse-invasion-glitch.is-reduced.is-cracked .rig-cracks svg {
    animation: none;
    opacity: 0.85;
    transform: none;
}

.reverse-invasion-glitch.is-reduced.is-cracked .rig-impact {
    animation: none;
}

@media (prefers-reduced-motion: reduce) {
    .reverse-invasion-glitch .rig-gt-slice,
    .reverse-invasion-glitch .rig-blocks {
        display: none;
    }
    .reverse-invasion-glitch .rig-dots i {
        animation: none;
        opacity: 0.7;
    }
    .reverse-invasion-glitch.is-leaving {
        animation: rig-fade-out 0.3s ease forwards;
    }
    .reverse-invasion-glitch.is-cracked .rig-cracks svg {
        animation: none;
        opacity: 0.85;
        transform: none;
    }
    .reverse-invasion-glitch.is-cracked .rig-impact {
        animation: none;
    }
}

/* 矮屏（横屏手机）：字号与留白收一档，避免溢出 */
@media (max-height: 520px) {
    .rig-card {
        gap: 8px;
        padding-top: 40px;
        padding-top: calc(40px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)));
        padding-bottom: 44px;
        padding-bottom: calc(44px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
    }
    .rig-name {
        font-size: 28px;
        font-size: clamp(24px, 6vw, 36px);
    }
    .rig-message {
        font-size: 17px;
        font-size: clamp(15px, 3.6vw, 20px);
    }
    .rig-line {
        font-size: 19px;
        font-size: clamp(17px, 4vw, 24px);
        line-height: 1.45;
    }
    .rig-line.is-long,
    .rig-line.is-xlong {
        font-size: 16px;
        font-size: clamp(15px, 3.4vw, 20px);
    }
    .rig-watermark {
        font-size: 120px;
        font-size: clamp(110px, 30vw, 240px);
    }
    .rig-skip {
        bottom: 6%;
        bottom: calc(6% + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
    }
}

/* ============================================================
   反向入侵 · 定时突袭前的授权弹窗（2026-08 新增）
   --------------------------------------------------------------
   Char 设置了「日常突袭」时，动手前必须先弹窗询问：
   「XX 申请入侵你的手机，是否给予权限？」
   授权 → 正常进入反向入侵；拒绝 / 超时未响应 → 取消本次入侵。
   ============================================================ */
.reverse-invasion-permit {
    position: fixed;
    inset: 0;
    z-index: 1000070;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    padding-top: calc(24px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)));
    padding-bottom: calc(24px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
    background: rgba(8, 4, 14, 0.58);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.reverse-invasion-permit.is-open {
    opacity: 1;
}

.reverse-invasion-permit-card {
    width: min(380px, 100%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 18px 16px;
    border-radius: 20px;
    background: linear-gradient(150deg, rgba(46, 18, 40, 0.97) 0%, rgba(30, 10, 34, 0.97) 100%);
    border: 1px solid rgba(255, 107, 138, 0.45);
    box-shadow: 0 14px 36px rgba(16, 0, 26, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    color: #fff;
    transform: scale(0.94);
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.reverse-invasion-permit.is-open .reverse-invasion-permit-card {
    transform: scale(1);
}

.reverse-invasion-permit-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.reverse-invasion-permit-pulse {
    flex-shrink: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #FF6B8A;
    box-shadow: 0 0 0 0 rgba(255, 107, 138, 0.7);
    animation: reverse-invasion-pulse 1.8s ease-in-out infinite;
}

.reverse-invasion-permit-title {
    flex: 1;
    min-width: 0;
    font-size: 16px;
    font-weight: 800;
    color: #FFD0DC;
    line-height: 1.4;
    word-break: break-word;
}

.reverse-invasion-permit-desc {
    font-size: 14px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
    word-break: break-word;
}

.reverse-invasion-permit-hint {
    font-size: 11.5px;
    color: rgba(255, 208, 220, 0.55);
    line-height: 1.5;
}

.reverse-invasion-permit-actions {
    display: flex;
    gap: 10px;
    margin-top: 2px;
}

.reverse-invasion-permit-btn {
    flex: 1;
    min-height: 46px; /* ≥44px 触控高度 */
    border-radius: 999px;
    border: none;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    transition: transform 0.12s ease, filter 0.12s ease;
}

.reverse-invasion-permit-btn:active {
    transform: scale(0.97);
    filter: brightness(0.9);
}

.reverse-invasion-permit-btn.is-deny {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.28);
    color: rgba(255, 255, 255, 0.88);
}

.reverse-invasion-permit-btn.is-allow {
    background: linear-gradient(135deg, #FF6B8A 0%, #FF9A6B 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(255, 107, 138, 0.35);
}

@media (max-width: 480px) {
    .reverse-invasion-permit {
        padding: 16px;
        padding-top: calc(16px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)));
        padding-bottom: calc(16px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
    }
    .reverse-invasion-permit-pulse {
        animation: none;
    }
}
