/* 游戏手札：正面好友卡带、背面游戏卡带、收藏印章与横线纸笔记。 */
.game-handbook-page,
.game-handbook-note-page {
    --gh-mist: #9bafbd;
    --gh-ivory: #f3f0e8;
    --gh-cloud: #d7dee3;
    --gh-charcoal: #292e35;
    --gh-navy: #233a56;
    --gh-moon: #e6e7ea;
    --gh-ink: var(--gh-navy);
    --gh-muted: var(--gh-navy);
    --gh-accent: var(--gh-navy);
    --gh-line: var(--gh-mist);
    --gh-surface: var(--gh-cloud);
    --gh-surface-raised: var(--gh-moon);
    --gh-paper: var(--gh-ivory);
    --gh-paper-ink: var(--gh-navy);
    --gh-paper-muted: var(--gh-navy);
    --gh-focus: var(--gh-navy);
    --gh-destructive: var(--gh-navy);
    --gh-shadow: rgb(35 58 86 / 0.16);
    --gh-bevel-light: rgb(230 231 234 / 0.65);
    --gh-bevel-dark: rgb(35 58 86 / 0.3);
    --gh-rule: rgb(35 58 86 / 0.15);
    display: none;
    position: absolute;
    inset: 0;
    z-index: 13;
    flex-direction: column;
    overflow: hidden;
    background: var(--gh-surface);
    color: var(--gh-ink);
    isolation: isolate;
}
.game-handbook-page *,
.game-handbook-note-page * { box-sizing: border-box; }
.game-handbook-page.show,
.game-handbook-note-page.show { display: flex; }
.game-handbook-head {
    flex: 0 0 auto;
    min-height: 62px;
    padding: 9px 12px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    align-items: center;
    gap: 8px;
    background: var(--gh-surface);
}
.game-handbook-head h2 {
    margin: 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    font-size: 16px;
    line-height: 1.4;
    font-weight: 750;
    color: var(--gh-ink);
}
.game-handbook-back,
.game-handbook-delete {
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--gh-ink);
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.game-handbook-back { font-size: 32px; line-height: 1; }
.game-handbook-delete { font-size: 12px; font-weight: 650; color: var(--gh-destructive); text-decoration: underline; text-underline-offset: 3px; }
.game-handbook-page button:focus-visible,
.game-handbook-note-page button:focus-visible {
    outline: 3px solid var(--gh-focus);
    outline-offset: 3px;
}
.game-handbook-page button:disabled,
.game-handbook-note-page button:disabled { opacity: 0.5; cursor: default; }
.game-handbook-body,
.game-handbook-note-detail {
    flex: 1;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--gh-line) transparent;
}
.game-handbook-body {
    width: 100%;
    padding: 24px 20px calc(30px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
}
.game-handbook-body > * { max-width: 660px; margin-left: auto; margin-right: auto; }
.game-handbook-empty {
    padding: 16px 0;
    margin-top: 0;
    margin-bottom: 16px;
    color: var(--gh-muted);
    font-size: 13px;
    line-height: 1.8;
    overflow-wrap: anywhere;
}
.game-handbook-empty { grid-column: 1 / -1; width: 100%; padding: 28px 20px; border: 1px dashed var(--gh-line); text-align: center; }
.game-handbook-note-list { display: grid; gap: 12px; }
.game-handbook-note-row {
    width: 100%;
    min-height: 66px;
    display: grid;
    align-items: center;
    gap: 12px;
    color: var(--gh-ink);
    font-family: inherit;
    text-align: left;
}
.game-handbook-note-row {
    padding: 12px 14px;
    border: 1px solid var(--gh-line);
    border-radius: 8px;
    background: var(--gh-surface-raised);
    cursor: pointer;
}
.game-handbook-note-row { grid-template-columns: minmax(0, 1fr) auto; }
/* 好友列表：正面卡带的顶盖、满幅头像封面、底部姓名与篇数。 */
.game-handbook-friend-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px 12px;
    align-content: start;
}
.game-handbook-friend-row {
    --gh-shell: var(--gh-mist);
    --gh-shell-ink: var(--gh-navy);
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    min-height: 0;
    aspect-ratio: 7 / 10;
    padding: 10% 7% 14%;
    border: 1px solid var(--gh-bevel-dark);
    border-radius: 13% / 9%;
    background: var(--gh-shell);
    color: var(--gh-shell-ink);
    box-shadow: inset 1px 1px 0 var(--gh-bevel-light), inset -2px -2px 0 var(--gh-bevel-dark), 0 3px 5px var(--gh-shadow);
    font-family: inherit;
    text-align: center;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 160ms ease;
}
.game-handbook-friend-row:nth-child(3n + 2) { --gh-shell: var(--gh-navy); --gh-shell-ink: var(--gh-moon); }
.game-handbook-friend-row:nth-child(3n) { --gh-shell: var(--gh-moon); }
.game-handbook-friend-row::before {
    content: "";
    position: absolute;
    top: 3%;
    left: 35%;
    width: 30%;
    height: 3%;
    border-radius: 2px;
    background: var(--gh-bevel-dark);
    box-shadow: 0 1px 0 var(--gh-bevel-light);
}
.game-handbook-friend-row::after {
    content: "";
    position: absolute;
    bottom: 4%;
    left: 42%;
    width: 16%;
    height: 5%;
    background: var(--gh-bevel-dark);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.game-handbook-friend-cap {
    flex: 0 0 18%;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5%;
    border: 1px solid var(--gh-bevel-dark);
    border-bottom: 0;
    border-radius: 5px 5px 0 0;
    font-size: clamp(6px, 1.55vw, 9px);
    font-weight: 750;
    letter-spacing: 0.05em;
    white-space: nowrap;
}
.game-handbook-cartridge-mark { display: flex; align-items: center; gap: 2px; height: 12px; }
.game-handbook-cartridge-mark i { display: block; width: 4px; height: 9px; border: 1px solid currentColor; border-radius: 2px; }
.game-handbook-cartridge-mark i:last-child { height: 6px; }
.game-handbook-friend-main {
    position: relative;
    display: block;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    padding: 0;
    border-left: 1px solid var(--gh-bevel-dark);
    border-right: 1px solid var(--gh-bevel-dark);
    background: var(--gh-paper);
    color: var(--gh-paper-ink);
}
.game-handbook-avatar {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 0;
    border-radius: 0;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: var(--gh-cloud);
    color: var(--gh-navy);
    font-weight: 750;
    font-size: clamp(24px, 7vw, 42px);
}
.game-handbook-avatar img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; object-position: center; }
.game-handbook-note-row > span { min-width: 0; }
.game-handbook-friend-serial strong {
    display: block;
    flex-shrink: 0;
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: clamp(10px, 2.9vw, 15px);
    font-weight: 750;
    line-height: 1.3;
}
.game-handbook-friend-serial {
    display: flex;
    flex: 0 0 auto;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 4px 3px;
    border-radius: 0 0 5px 5px;
    background: var(--gh-charcoal);
    color: var(--gh-moon);
    font-size: clamp(9px, 2.35vw, 12px);
    line-height: 1.3;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.game-handbook-friend-serial small { display: block; font-size: clamp(9px, 2.2vw, 11px); line-height: 1.3; white-space: nowrap; }
.game-handbook-note-row strong {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--gh-ink);
    font-size: 15px;
    line-height: 1.5;
    font-weight: 750;
}
.game-handbook-note-row small {
    display: block;
    margin-top: 3px;
    color: var(--gh-muted);
    font-size: 12px;
    line-height: 1.5;
}
/* 游戏卡带：触点朝上，五道独立凹槽和侧边缺口来自背面结构。 */
.game-handbook-cartridge-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 18px;
    align-content: start;
}
.game-handbook-cartridge {
    position: relative;
    display: block;
    width: 100%;
    min-width: 0;
    aspect-ratio: 7 / 10;
    padding: 0;
    border: 1px solid var(--gh-bevel-dark);
    border-radius: 12% / 8%;
    background: var(--gh-mist);
    box-shadow: inset 2px 2px 0 var(--gh-bevel-light), inset -3px -3px 0 var(--gh-bevel-dark);
    clip-path: polygon(0 7%, 8% 0, 100% 0, 100% 19%, 94% 19%, 94% 29%, 100% 29%, 100% 100%, 0 100%);
    color: var(--gh-paper-ink);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 160ms ease;
}
.game-handbook-cartridge::before {
    content: "";
    position: absolute;
    inset: 4% 6% 5%;
    border: 1px solid var(--gh-bevel-dark);
    border-radius: 8% / 5%;
    box-shadow: 1px 1px 0 var(--gh-bevel-light);
    pointer-events: none;
}
.game-handbook-cartridge-contacts {
    position: absolute;
    top: 3%;
    left: 12%;
    right: 12%;
    height: 43%;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 7%;
    pointer-events: none;
}
.game-handbook-cartridge-contacts i {
    position: relative;
    display: block;
    overflow: hidden;
    border: 1px solid var(--gh-bevel-dark);
    border-radius: 0 0 4px 4px;
    background: var(--gh-charcoal);
    box-shadow: -1px 0 0 var(--gh-bevel-light), 1px 1px 0 var(--gh-bevel-light);
}
.game-handbook-cartridge-contacts i::before,
.game-handbook-cartridge-contacts i::after {
    content: "";
    position: absolute;
    top: 12%;
    bottom: 12%;
    width: 35%;
    background: var(--gh-cloud);
}
.game-handbook-cartridge-contacts i::before { left: 9%; }
.game-handbook-cartridge-contacts i::after { right: 9%; top: 22%; }
.game-handbook-cartridge-contacts i:nth-child(even)::before { top: 24%; bottom: 20%; }
.game-handbook-cartridge-contacts i:nth-child(odd)::after { bottom: 30%; }
.game-handbook-cartridge-contacts i:nth-child(3)::before { top: 8%; }
.game-handbook-cartridge-contacts i:nth-child(4)::after { top: 12%; }
.game-handbook-cartridge:focus-visible {
    /* Clip-path clips outer outlines; keep the keyboard ring inside the shell. */
    outline-offset: -6px;
}
.game-handbook-cartridge-label {
    position: absolute;
    left: 10%;
    right: 10%;
    top: 49%;
    bottom: 12%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    padding: 6%;
    border: 1px solid var(--gh-bevel-dark);
    border-radius: 4px;
    background: var(--gh-paper);
    color: var(--gh-paper-ink);
    pointer-events: none;
}
.game-handbook-cartridge-label small {
    flex-shrink: 0;
    color: var(--gh-paper-muted);
    font-size: clamp(8px, 2vw, 11px);
    line-height: 1.25;
    font-weight: 650;
    letter-spacing: 0.16em;
}
.game-handbook-cartridge-label strong {
    flex-shrink: 0;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    width: 100%;
    font-size: clamp(12px, 3.7vw, 22px);
    font-weight: 800;
    line-height: 1.22;
    overflow-wrap: anywhere;
}
.game-handbook-cartridge-label > span { flex-shrink: 0; font-size: clamp(9px, 2.4vw, 12px); line-height: 1.4; font-weight: 600; color: var(--gh-paper-muted); }
.game-handbook-cartridge-foot {
    position: absolute;
    left: 6%;
    right: 6%;
    bottom: 6%;
    text-align: center;
    color: var(--gh-navy);
    font-size: clamp(7px, 1.6vw, 9px);
    line-height: 1.3;
    font-weight: 700;
    letter-spacing: 0.12em;
    pointer-events: none;
}
.game-handbook-stamp-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 12px;
    row-gap: 24px;
    padding: 4px 0 10px;
}
.game-handbook-stamp-cell {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--gh-ink);
    font-family: inherit;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}
button.game-handbook-stamp-cell { cursor: pointer; }
.game-handbook-slot-number {
    color: var(--gh-muted);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 12px;
    line-height: 1.4;
    letter-spacing: 0.18em;
    font-style: italic;
}
.game-handbook-stamp-square {
    display: grid;
    place-items: center;
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 1px solid var(--gh-line);
    background: var(--gh-surface-raised);
    transition: border-color 160ms ease, background-color 160ms ease;
}
.game-handbook-stamp-seal {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 76%;
    aspect-ratio: 1 / 1;
    padding: 9%;
    border: 2px solid var(--gh-accent);
    border-radius: 50%;
    outline: 1px solid var(--gh-accent);
    outline-offset: -6px;
    transform: rotate(-11deg);
    color: var(--gh-accent);
    opacity: 1;
}
.game-handbook-stamp-cell:nth-child(3n + 2) .game-handbook-stamp-seal { transform: rotate(8deg); }
.game-handbook-stamp-cell:nth-child(3n) .game-handbook-stamp-seal { transform: rotate(-4deg); }
.game-handbook-stamp-seal img {
    display: block;
    width: 80%;
    height: 66%;
    object-fit: contain;
    filter: none;
    mix-blend-mode: multiply;
    pointer-events: none;
}
.game-handbook-stamp-seal > span {
    margin-top: 2px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 8px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: 0.08em;
    white-space: nowrap;
}
.game-handbook-stamp-cell time,
.game-handbook-stamp-cell > small {
    display: block;
    color: var(--gh-muted);
    font-size: 11px;
    line-height: 1.6;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.game-handbook-stamp-cell.is-empty .game-handbook-stamp-square { background: transparent; border-style: dashed; opacity: 0.65; }
.game-handbook-stamp-cell.is-empty > small { font-size: 10px; letter-spacing: 0.04em; }
/* 纸张保持柔和米白；外层跟随深色主题时，正文仍使用深色墨水。 */
.game-handbook-note-detail {
    padding: 18px 14px calc(26px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
}
.game-handbook-paper {
    max-width: 660px;
    min-height: 100%;
    margin: 0 auto;
    padding: 24px 22px 22px;
    border-top: 3px solid var(--gh-mist);
    background: var(--gh-paper);
    color: var(--gh-paper-ink);
    box-shadow: 0 2px 8px var(--gh-shadow);
}
.game-handbook-paper > header { margin: 0 0 24px; }
.game-handbook-paper-kicker {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px 14px;
    padding: 7px 10px;
    background: var(--gh-moon);
    color: var(--gh-paper-muted);
    font-size: 11px;
    font-weight: 650;
    line-height: 1.7;
    letter-spacing: 0.04em;
    overflow-wrap: anywhere;
}
.game-handbook-paper h1 {
    margin: 22px 0 14px;
    color: var(--gh-paper-ink);
    font-size: 24px;
    line-height: 1.45;
    font-weight: 750;
    overflow-wrap: anywhere;
}
.game-handbook-note-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    color: var(--gh-paper-muted);
    font-size: 11px;
    line-height: 1.8;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.game-handbook-note-meta time { white-space: nowrap; }
.game-handbook-note-content {
    position: relative;
    min-height: 320px;
    padding: 0 0 0 15px;
    border: 0;
    border-left: 1px dashed var(--gh-mist);
    background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 31px, var(--gh-rule) 31px, var(--gh-rule) 32px);
    background-position: 0 0;
    color: var(--gh-paper-ink);
    font-size: 16px;
    font-weight: 400;
    line-height: 32px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: normal;
    tab-size: 2;
}
.game-handbook-paper-footer {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 10px;
    min-height: 108px;
    margin-top: 32px;
    padding: 18px;
    border: 1px solid var(--gh-cloud);
    background-image: radial-gradient(var(--gh-mist) 0.65px, transparent 0.7px);
    background-size: 12px 12px;
    color: var(--gh-paper-muted);
    font-size: 12px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}
.game-handbook-paper-footer img {
    width: 34px;
    height: 34px;
    object-fit: contain;
    opacity: 0.62;
    filter: none;
    mix-blend-mode: multiply;
}
.game-handbook-paper-footer > span { max-width: 100%; text-align: right; }
.game-handbook-paper-footer small { display: block; margin-top: 4px; font-size: 10px; line-height: 1.8; }
.game-handbook-back:active,
.game-handbook-delete:active,
.game-handbook-note-row:active { background: var(--gh-surface); }
.game-handbook-friend-row:active,
.game-handbook-cartridge:active { transform: translateY(2px); }
button.game-handbook-stamp-cell:active .game-handbook-stamp-square { border-color: var(--gh-accent); background: var(--gh-surface); }
@media (hover: hover) {
    .game-handbook-back:hover,
    .game-handbook-delete:hover,
    .game-handbook-note-row:hover { background: var(--gh-surface); }
    .game-handbook-friend-row:hover,
    .game-handbook-cartridge:hover { transform: translateY(-2px); }
    button.game-handbook-stamp-cell:hover .game-handbook-stamp-square { border-color: var(--gh-accent); }
}
/* 手札打开期间宿主状态栏与页面同色，整屏一个底色、无分界线。 */
#wechat-discover-page:has(.game-handbook-page.show) > .status-bar {
    background: #d7dee3 !important;
    border-bottom-color: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
html[data-appearance="dark"] .game-handbook-page,
html[data-appearance="dark"] .game-handbook-note-page {
    --gh-ink: var(--gh-moon);
    --gh-muted: var(--gh-cloud);
    --gh-accent: var(--gh-mist);
    --gh-line: var(--gh-mist);
    --gh-surface: var(--gh-charcoal);
    --gh-surface-raised: var(--gh-navy);
    --gh-focus: var(--gh-moon);
    --gh-destructive: var(--gh-moon);
}
html[data-appearance="dark"] #wechat-discover-page:has(.game-handbook-page.show) > .status-bar {
    background: #292e35 !important;
}
html[data-appearance="dark"] .game-handbook-stamp-seal img {
    filter: invert(1);
    mix-blend-mode: screen;
}
html[data-appearance="dark"] .game-handbook-cartridge:focus-visible { outline-color: var(--gh-navy); }
@media (max-width: 359px) {
    .game-handbook-body { padding-left: 14px; padding-right: 14px; }
    .game-handbook-friend-list { column-gap: 8px; row-gap: 18px; }
    .game-handbook-cartridge-list { column-gap: 12px; row-gap: 18px; }
    .game-handbook-stamp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
    .game-handbook-paper { padding-left: 16px; padding-right: 16px; }
    .game-handbook-paper h1 { font-size: 21px; }
}
@media (min-width: 600px) {
    .game-handbook-cartridge-list { gap: 28px 24px; }
    .game-handbook-stamp-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px 20px; }
    .game-handbook-paper { padding: 32px 36px; }
}
@media (prefers-reduced-motion: reduce) {
    .game-handbook-friend-row,
    .game-handbook-cartridge,
    .game-handbook-stamp-square { transition: none; }
    .game-handbook-friend-row:hover,
    .game-handbook-friend-row:active,
    .game-handbook-cartridge:hover,
    .game-handbook-cartridge:active { transform: none; }
}
