#answer-focus-preview { display: none; }
/* 海报使用稳定布局高度；手机答题输入时使用独立的键盘可视区域布局。 */
:root { --app-layout-height: 100svh; --app-visible-height: 100dvh; }
#viewport-height-probe {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  height: 100dvh;
  visibility: hidden;
  pointer-events: none;
}
@media (max-width: 900px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body.viewing-home:has(#view-home:not(.invite-mode)),
  body.viewing-ended:has(.comic-result-page[data-result-size="single"]) { background: #fffaf9 url('/images/lobby/button-v6/background-optimized.webp') center top / cover no-repeat; }
  body:is(.viewing-home,.viewing-lobby,.viewing-game,.viewing-ended) {
    min-height: var(--app-layout-height); margin: 0; padding: 0; overflow-x: hidden;
    background: #fffaf9 url('/images/lobby/button-v6/background-optimized.webp') center top / cover no-repeat;
  }
  body:is(.viewing-home,.viewing-lobby,.viewing-game,.viewing-ended) #app {
    display: grid; place-items: start center; width: 100%; max-width: none;
    height: var(--app-layout-height); min-height: 0; padding: 0; margin: 0; overflow: clip;
  }
  body.viewing-home:has(#view-home:not(.invite-mode)) #app { height: var(--app-layout-height); min-height: 0; overflow: clip; }
  #view-home:not(.invite-mode) { width: min(100%,480px); }
  html:not(.keyboard-open) body.viewing-home:has(#view-home.home-art-scroll:not(.invite-mode)) #app {
    height: auto;
    min-height: var(--app-layout-height);
    overflow: visible;
  }
  body.viewing-lobby #view-lobby {
    display: grid; place-items: start center; width: 100%; height: var(--app-layout-height);
    padding: 0; margin: 0; overflow: visible;
  }
  body.viewing-lobby #view-lobby .comic-lobby-page { width: min(100%,480px); min-height: 0; }
  body.viewing-game #app { height: var(--app-layout-height); }
  body.viewing-game #view-game { width: 100%; height: var(--app-layout-height); margin: 0; }
  body.viewing-ended #view-ended {
    width: 100%; height: var(--app-layout-height); margin: 0; padding: 0;
    display: grid; place-items: start center;
  }
  body.viewing-ended #view-ended:has(.comic-result-page[data-result-size="single"]) { place-items: start center; overflow-y: auto; }
  body.viewing-ended #view-ended:has(.comic-result-page[data-result-count]) { overflow-y:auto; }
  body.viewing-ended #view-ended .comic-result-page[data-result-count] { width:min(100%,480px); height:auto; padding:0; }
  #view-ended .comic-result-page { width: min(100%,480px); height: var(--app-layout-height); min-height: 0; margin: 0; }
  #view-ended .comic-result-page[data-result-size="single"] { width: min(100%,480px); height: auto; min-height: 0; }
  #view-ended .comic-result-page:not([data-result-size="single"]) { padding: 8px 12px max(12px,env(safe-area-inset-bottom)); gap: 6px; }
  #view-ended .comic-result-page:not([data-result-size="single"]) .comic-result-hero { flex-basis: clamp(84px,calc(var(--app-layout-height) * .17),125px); background-position: center; background-size: auto 100%; }
  #view-ended .comic-result-page:not([data-result-size="single"]) .comic-final-scores { display: grid; grid-template-rows: minmax(0,1fr); width: 100%; }
  #view-ended .comic-result-page[data-result-size="crowd"] .comic-final-scores { grid-template-rows: minmax(0,1fr) minmax(0,1fr); }
  #view-ended .comic-result-page:not([data-result-size="single"]) .comic-podium { min-height: 0; height: 100%; padding: 30px 3px 8px; }
  #view-ended .comic-result-page:not([data-result-size="single"]) .podium-celebration { display: none; }
  #view-ended .comic-result-page:not([data-result-size="single"]) .podium-person { width: clamp(54px,calc(var(--app-layout-height) * .13),100px); height: auto; aspect-ratio: 1; flex-shrink: 0; }
  #view-ended .comic-result-page:not([data-result-size="single"]) .podium-block { height: clamp(95px,calc(var(--app-layout-height) * .23),195px); }
  #view-ended .comic-result-page:not([data-result-size="single"]) .podium-1 .podium-block { height: clamp(120px,calc(var(--app-layout-height) * .28),245px); }
  #view-ended .comic-result-page[data-result-size="crowd"] .podium-person { width: clamp(48px,calc(var(--app-layout-height) * .095),72px); }
  #view-ended .comic-result-page[data-result-size="crowd"] .podium-block { height: clamp(82px,calc(var(--app-layout-height) * .15),106px); }
  #view-ended .comic-result-page[data-result-size="crowd"] .podium-1 .podium-block { height: clamp(100px,calc(var(--app-layout-height) * .19),138px); }
  #view-ended .comic-result-page:not([data-result-size="single"]) .final-rest { min-height: 0; overflow-y: auto; padding: 4px 2px; gap: 4px; }
  #view-ended .comic-result-page:not([data-result-size="single"]) .final-rank-row { flex: 1 0 34px; min-height: 34px; padding: 2px 6px; }
  #view-ended .comic-result-page:not([data-result-size="single"]) .final-rank-row .player-avatar { width: 30px; height: 30px; }
  #view-ended .comic-result-page:not([data-result-size="single"]) .result-actions .btn { min-height: 48px; }
  #view-home.invite-mode { width: min(100%,480px); min-height: var(--app-layout-height); margin: 0; padding: 8px 14px 14px; }
  #view-home.invite-mode .home-accessible-title { flex-basis: clamp(70px,calc(var(--app-layout-height) * .13),110px); height: auto; background-position: center; background-size: auto 100%; }
  #view-home.invite-mode .home-form-card { gap: 4px; }
  #view-home.invite-mode .invite-summary { padding: 4px; gap: 2px; }
  #view-home.invite-mode .invite-card-head strong { font-size: clamp(18px,5vw,23px); }
  #view-home.invite-mode .invite-room-strip { min-height: 48px; }
  #view-home.invite-mode .invite-friends-art { min-height: clamp(54px,calc(var(--app-layout-height) * .10),90px); background-size: auto 90%; }
  #view-home.invite-mode .avatar-setup { flex: 0 0 auto; min-height: 92px; padding-top: 24px; }
  #view-home.invite-mode .home-avatar { width: 60px; height: 60px; min-height: 60px; flex-basis: 60px; }
  #view-home.invite-mode .avatar-upload-btn { min-height: 40px; }
  #view-home.invite-mode #nickname { min-height: 44px; }
  #view-home.invite-mode .field-error:empty, #view-home.invite-mode #home-error:empty { display: none; }
  #view-home.invite-mode #invite-join-panel { gap: 6px; }
  #view-home.invite-mode #invite-join-panel p { padding: 5px; font-size: 11px; }
  #view-home.invite-mode #invite-join-panel .btn { min-height: 48px; }
  .modal:not(#create-room-modal) { max-height: var(--app-visible-height); top: var(--app-visible-top,0px); bottom: auto; height: var(--app-visible-height); overflow-y: auto; padding: 16px; }
  .modal:not(#create-room-modal) > .modal-card { max-height: calc(var(--app-visible-height) - 32px); overflow-y: auto; flex-shrink: 0; }
  /* 键盘只缩小内部可滚动窗口。没有额外的页面尾部占位，滑到底就是实际内容底部。 */
  html.keyboard-open,
  html.game-keyboard-settling { overflow: hidden !important; overscroll-behavior: none; }
  html.keyboard-open:not(.game-keyboard-open):not(.ios-game-viewport) body:is(.viewing-home,.viewing-lobby,.viewing-game,.viewing-ended) {
    position: fixed; inset: 0; width: 100%; height: var(--app-visible-height); min-height: 0; overflow: hidden !important;
  }
  html.keyboard-open:not(.game-keyboard-open):not(.ios-game-viewport) body:is(.viewing-home,.viewing-lobby,.viewing-game,.viewing-ended) #app,
  html.keyboard-open body.viewing-home:has(#view-home:not(.invite-mode)) #app {
    position: fixed; inset: var(--app-visible-top,0px) 0 auto; width: 100%;
    height: var(--app-visible-height); min-height: 0; overflow-x: hidden; overflow-y: auto;
    overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  html.keyboard-open #app::-webkit-scrollbar { display: none; }
  html.keyboard-open #view-home:not(.invite-mode) #nickname-error { top: calc(54.58237% + 5px); }
  /* 极短横屏保持可读尺寸并允许纵向浏览；键盘不会改变这项布局判断。 */
  html.landscape-viewport body:is(.viewing-home,.viewing-lobby,.viewing-game,.viewing-ended) { overflow-y: auto; }
  html.landscape-viewport:not(.keyboard-open) body:is(.viewing-home,.viewing-lobby,.viewing-game,.viewing-ended) #app { height: auto; min-height: var(--app-layout-height); overflow: visible; }
  html.landscape-viewport:not(.keyboard-open) body.viewing-home:has(#view-home:not(.invite-mode)) #app { height: auto; min-height: var(--app-layout-height); overflow: visible; }
  html.landscape-viewport body.viewing-lobby #view-lobby { height: auto; }
  html.landscape-viewport body.viewing-game #view-game { height: max(540px,var(--app-layout-height)); }
  html.landscape-viewport body.viewing-ended #view-ended { height: auto; }
  html.landscape-viewport #view-ended .comic-result-page:not([data-result-size="single"]) { height: max(620px,var(--app-layout-height)); }
}

/* 保留纵向滚动与滑块，阻止网页横向滚动和支持该属性的浏览器横向回弹。 */
@media (max-width:900px) {
  html { overscroll-behavior-x: none; overflow-x: clip; }
  body { overscroll-behavior-x: none; overflow-x: clip; }
  body.viewing-game #view-game #answer-input { font-size: 16px; -webkit-text-size-adjust: 100%; }
}

/* 横向手势交给页面控制，弹窗在自身纵向滚动。 */
@media (max-width:900px) {
  #app, .modal:not(#create-room-modal), #create-room-modal { overscroll-behavior-x:none; }
  .modal:not(#create-room-modal) { touch-action:pan-y; }
}

/* 答题输入专用：整页停在键盘上方，题图和输入区共同使用实际可视高度。 */
@media (max-width:900px) {
  html.game-keyboard-open body.viewing-game #app,
  html.game-keyboard-settling body.viewing-game #app {
    position: absolute;
    inset: var(--app-visible-page-top,0px) 0 auto;
    width: 100%;
    height: var(--app-visible-height);
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }
  /* 容器位于实际可见视口，文档不要在其底边之后继续保留键盘收起时的高度。 */
  html.game-keyboard-open body.viewing-game,
  html.game-keyboard-settling body.viewing-game {
    position: static;
    height: var(--app-visible-page-bottom);
    min-height: 0;
    overflow: hidden;
  }
  html.game-keyboard-open body.viewing-game #view-game {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: var(--app-visible-height);
    min-height: 0;
    padding: 0;
    gap: 0;
    overflow: hidden;
  }
  html.game-keyboard-settling body.viewing-game #view-game { height: var(--app-visible-height); }
  /* iOS 锁住文档滚动。答题容器的两条边使用同一个视觉视口的文档坐标。 */
  html.ios-game-viewport {
    height: 100%;
    overflow: hidden !important;
    overscroll-behavior: none;
  }
  html.ios-game-viewport body.viewing-game {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    overflow: clip;
    overscroll-behavior: none;
  }
  /* 键盘打开时额外容纳实测可见底边，关闭后文档立即随布局视口恢复。 */
  html.ios-game-viewport.keyboard-open body.viewing-game {
    height: max(100%, var(--app-visible-page-bottom, 100%));
  }
  html.ios-game-viewport body.viewing-game #app {
    position: absolute;
    inset: var(--app-visible-page-top,0px) 0 auto;
    contain: layout;
    overflow-anchor: none;
    width: 100%;
    height: var(--app-visible-height);
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    overflow: clip;
  }
  html.ios-game-viewport body.viewing-game #view-game {
    height: var(--app-visible-height);
    overflow: clip;
  }
  html.ios-game-viewport:not(.keyboard-open) body.viewing-game #app {
    grid-template-rows: minmax(0, 1fr);
  }
  html.ios-game-viewport:not(.keyboard-open) body.viewing-game #app,
  html.ios-game-viewport:not(.keyboard-open) body.viewing-game #view-game {
    max-height: 100%;
  }
  html.ios-game-viewport #view-game .answer-input-row { position: relative; }
  /* 原生控件临时移位时保留原槽的视觉内容。绝对定位不参与网格尺寸计算。 */
  html.ios-game-viewport #answer-input.ios-answer-focus-guard + #answer-focus-preview {
    display: block;
    position: absolute;
    grid-area: 1 / 1 / -1 / 2;
    inset: 0;
    box-sizing: border-box;
    margin: 0;
    padding: 8px;
    border: 1.5px solid var(--comic-pink);
    border-radius: 9px;
    box-shadow: 0 0 0 2px rgb(245 44 131 / 18%);
    color: #9ca3af;
    background: white;
    font: inherit;
    font-size: 16px;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    overflow: hidden;
    pointer-events: none;
    user-select: none;
  }
  html.ios-game-viewport #answer-input.ios-answer-focus-guard + #answer-focus-preview.has-draft { color: var(--comic-ink); }
  html.ios-game-viewport #view-game #answer-input.ios-answer-focus-guard {
    transform: translateY(var(--ios-answer-focus-shift, 0px));
    caret-color: transparent;
    opacity: 0;
    transition: none;
  }
  #view-game .topnav {
    flex: 0 0 36px;
    width: 100%;
    min-height: 36px;
    height: 36px;
    max-height: 36px;
    padding: 0 2%;
    gap: 4px;
  }
  #view-game .room-code-tag { gap: 3px; font-size: 12px; }
  #view-game .room-code-label { display: inline-flex; }
  #view-game .game-feedback-link { gap: 2px; font-size: 12px; }
  #view-game .game-feedback-link > span { display: inline; }
  #view-game .topnav-divider { height: 16px; flex: 0 0 1px; }
  #view-game .home-room-btn { width: 26px; height: 27px; margin-right: 2px; }
  #view-game .home-room-btn::before { inset: 0; width: 27px; height: 27px; }
  #view-game .copy-room-btn,
  #view-game .game-code-visibility { width: 21px; height: 24px; }
  #view-game .game-feedback-link svg { width: 21px; height: 23px; }
  #view-game .game-top-actions { gap: 5px; }
  #view-game .question-progress { font-size: 12px; }

  html.game-keyboard-open #view-game .game-layout {
    display: grid;
    flex: 0 0 var(--game-content-height);
    height: var(--game-content-height);
    min-height: 0;
    grid-template-rows: minmax(0,1fr) var(--game-bottom-height);
    grid-template-areas: "stage stage" "players answers";
    gap: var(--game-bottom-gap,2px);
    background: #0b1931;
    overflow: hidden;
  }
  html.game-keyboard-open #view-game .game-main { display: contents; }
  html.game-keyboard-open #view-game .game-sidebar { grid-area: players; min-height: 0; max-height: 100%; display: flex; overflow: hidden; }
  html.game-keyboard-open #view-game .game-sidebar > button { display: none; }
  html.game-keyboard-open #view-game .score-board {
    flex: 1 1 auto;
    min-height: 0;
    margin-left: 0;
    padding: 4px;
    border: 1px solid #0b1931;
    border-radius: 10px;
    background-image: none;
    overflow: hidden;
  }
  html.game-keyboard-open #view-game .player-panel-title,
  html.game-keyboard-open #view-game .answer-panel-title { display: none; }
  html.game-keyboard-open #view-game #score-list {
    position: static;
    inset: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 2px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  html.game-keyboard-open #view-game #score-list .score-row {
    display: grid;
    flex: 0 0 auto;
    grid-template-columns: 30px minmax(0,1fr);
    align-items: center;
    gap: 4px;
    min-width: 0;
    min-height: 38px;
    margin: 0;
    padding: 3px 1px;
    text-align: left;
  }
  html.game-keyboard-open #view-game .player-portrait { flex: none; width: 30px; height: 30px; }
  html.game-keyboard-open #view-game .score-row .player-avatar { width: 30px !important; height: 30px !important; min-width: 30px; }
  html.game-keyboard-open #view-game .player-meta { min-width: 0; width: 100%; }
  html.game-keyboard-open #view-game .score-row .player-name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    max-height: 2.4em;
    font-size: 11px;
    line-height: 1.2;
  }
  html.game-keyboard-open #view-game .score-row .pts { font-size: 12px; line-height: 1.2; }
  html.game-keyboard-open #view-game .score-row.me::before { inset: 0; border-width: 1px; border-radius: 6px; }

  html.game-keyboard-open #view-game .question-stage {
    grid-area: stage;
    display: grid;
    grid-template-rows: minmax(0,1fr) auto auto auto !important;
    gap: 4px;
    min-height: 0;
    padding: 8px 6px 6px;
    border-radius: 0;
    overflow: hidden;
  }
  html.game-keyboard-open #view-game .question-stage > .img-wrapper {
    position: relative;
    inset: auto !important;
    display: flex;
    grid-row: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    margin: 0;
    align-self: stretch;
    align-items: flex-start !important;
    overflow: auto;
    overscroll-behavior: contain;
  }
  html.game-keyboard-open #view-game .answer-board {
    position: static;
    inset: auto;
    grid-row: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 0;
    height: auto;
    margin: 0;
    padding: 0;
  }
  html.game-keyboard-open #view-game .answer-cell-area {
    position: static !important;
    inset: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: auto;
    min-height: 0;
    gap: 3px;
  }
  html.game-keyboard-open #view-game .answer-cells {
    display: flex;
    flex: 0 1 auto;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    width: auto;
    max-width: 100%;
    min-width: 0;
    height: auto;
    gap: 3px;
  }
  html.game-keyboard-open #view-game .answer-cell { flex: 0 0 var(--answer-cell-size,24px); }
  html.game-keyboard-open #view-game .answer-inline-label { font-size: 12px; margin: 0; }
  html.game-keyboard-open #view-game .answer-cell-area .answer-short-tag { margin: 0; min-height: 22px; font-size: 11px; }
  html.game-keyboard-open #view-game .answer-original { margin: 0; max-height: 2.6em; overflow-y: auto; font-size: 12px; }
  html.game-keyboard-open #view-game .answer-stage-status {
    position: static;
    inset: auto;
    grid-row: 3;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: 2.6em;
    margin: 0;
    padding: 2px 3px;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.3;
  }
  html.game-keyboard-open #view-game .answer-stage-status:empty { display: none; }
  html.game-keyboard-open #view-game .stage-timer-row {
    position: static;
    inset: auto;
    grid-row: 4;
    display: grid;
    grid-template-columns: auto minmax(0,1fr) auto;
    align-items: center;
    width: calc(100% - 8px);
    min-height: 28px;
    height: 28px;
    margin: 0 4px;
    gap: 4px;
  }
  html.game-keyboard-open #view-game .timer-meta,
  html.game-keyboard-open #view-game .stage-skip-button { font-size: 11px; }
  html.game-keyboard-open #view-game .stage-skip-button { width: auto; min-width: 0; min-height: 27px; padding: 3px 4px; }

  html.game-keyboard-open #view-game .answer-panel {
    grid-area: answers;
    position: relative;
    display: block;
    height: 100%;
    min-height: 0;
    padding: 0;
    gap: 4px;
    border: 1px solid #0b1931;
    border-radius: 10px;
    background-image: none;
    overflow: hidden;
  }
  html.game-keyboard-open #view-game .answer-log {
    position: absolute;
    inset: 4px 4px 52px;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    padding: 0;
    overflow: auto;
    overscroll-behavior: contain;
  }
  html.game-keyboard-open #view-game .answer-item { grid-template-columns: 28px minmax(0,1fr); gap: 4px; }
  html.game-keyboard-open #view-game .answer-item .answer-avatar { width: 28px !important; height: 28px !important; }
  html.game-keyboard-open #view-game .answer-item .answer-name { font-size: 11px; }
  html.game-keyboard-open #view-game .answer-item .answer-text { font-size: 12px; }
  html.game-keyboard-open #view-game #answer-area {
    position: absolute;
    inset: auto 4px 4px;
    width: auto;
    height: 44px;
    min-height: 0;
    margin: 0;
  }
  html.game-keyboard-open #view-game #answer-area .answer-input-row {
    display: grid;
    grid-template-columns: minmax(0,1fr) auto auto;
    grid-template-rows: 44px;
    align-items: stretch;
    width: 100%;
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    gap: 4px;
  }
  html.game-keyboard-open #view-game .answer-actions { display: contents; }
  html.game-keyboard-open #view-game #answer-area #answer-input {
    box-sizing: border-box;
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    margin: 0;
    padding: 8px;
    font-size: 16px;
    line-height: 1.4;
    resize: none;
  }
  html.game-keyboard-open #view-game #answer-area #btn-chat,
  html.game-keyboard-open #view-game #answer-area #btn-submit {
    grid-row: 1;
    width: auto;
    min-width: 0;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0 7px;
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
  }
  html.game-keyboard-open #view-game #answer-area #btn-chat { grid-column: 2; }
  html.game-keyboard-open #view-game #answer-area #btn-submit { grid-column: 3; }
  html.game-keyboard-open #view-game .submit-plane { display: none; }

  /* 极短视口优先保留题图和输入，完整记录待键盘收起后查看。 */
  html.game-keyboard-short #view-game .game-layout { grid-template-rows: minmax(0,1fr) var(--game-bottom-height,44px); }
  html.game-keyboard-short #view-game .answer-panel { grid-template-rows: 44px; align-content: end; padding: 0; }
  html.game-keyboard-short #view-game .answer-log { display: none; }
  html.game-keyboard-short #view-game .question-stage { padding: 7px 6px 4px; gap: 2px; }
  html.game-keyboard-short #view-game .answer-cell-area { flex-wrap: nowrap; }
  html.game-keyboard-short #view-game .answer-cells { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; }
  html.game-keyboard-short #view-game .answer-stage-status { max-height: 1.3em; white-space: nowrap; text-overflow: ellipsis; }
}

@media (max-width: 900px) {
  html.game-keyboard-compact #view-game .question-stage { padding: 7px 6px 4px; gap: 2px; }
  html.game-keyboard-compact #view-game .stage-timer-row { height: 24px; min-height: 24px; gap: 3px; }
  html.game-keyboard-compact #view-game .timer-clock { width: 23px; height: 24px; }
  html.game-keyboard-compact #view-game .stage-skip-button { height: 24px; min-height: 24px; padding: 1px 4px; }
  html.game-keyboard-compact #view-game .answer-cell-area,
  html.game-keyboard-compact #view-game .answer-cells { gap: 2px; }
  html.game-keyboard-compact #view-game .answer-cell {
    flex-basis: min(var(--answer-cell-size,24px),24px);
    width: min(var(--answer-cell-size,24px),24px);
    height: 24px;
    min-height: 24px;
    max-height: 24px;
  }
  html.game-keyboard-open #view-game .game-sidebar,
  html.game-keyboard-open #view-game .score-board { height: 100%; }
  html.game-image-stable #view-game .image-canvas { max-width: none; max-height: none; flex: 0 0 auto; }
  html.game-keyboard-open #view-game .image-canvas { margin: auto; }
  html.game-keyboard-open #view-game .img-wrapper { overflow: auto; overscroll-behavior: contain; touch-action: pan-y; }
}

/* 极紧凑模式把答案提示和计时合在一行，为较高的 4:3 题图保留原有高度。 */
.stage-skip-label-short { display: none; }
@media (max-width:900px) {
  html.game-keyboard-minimal #view-game .question-stage {
    grid-template-columns: minmax(0,1fr) auto;
    grid-template-rows: minmax(0,1fr) 22px auto !important;
    padding: 6px 6px 3px;
    gap: 1px;
  }
  html.game-keyboard-minimal #view-game .question-stage > .img-wrapper { grid-column: 1 / -1; }
  html.game-keyboard-minimal #view-game .answer-board { grid-column: 1; grid-row: 2; height: 22px; overflow: hidden; }
  html.game-keyboard-minimal #view-game .answer-cell-area { flex-wrap: nowrap; height: 22px; gap: 1px; }
  html.game-keyboard-minimal #view-game .answer-cells { flex-wrap: nowrap; gap: 1px; overflow: hidden; }
  html.game-keyboard-minimal #view-game .answer-cell { flex: 0 1 20px; width: 20px; min-width: 6px; height: 22px; min-height: 22px; max-height: 22px; }
  html.game-keyboard-minimal #view-game .answer-inline-label { flex: 0 0 auto; font-size: 11px; }
  html.game-keyboard-minimal #view-game .answer-stage-status { grid-column: 1 / -1; grid-row: 3; padding: 0; }
  html.game-keyboard-minimal #view-game .stage-timer-row { grid-column: 2; grid-row: 2; grid-template-columns: auto auto; width: 100%; margin: 0; height: 22px; min-height: 22px; gap: 2px; }
  html.game-keyboard-minimal #view-game .timer-bar { display: none; }
  html.game-keyboard-minimal #view-game .timer-clock { width: 16px; height: 20px; }
  html.game-keyboard-minimal #view-game .timer-meta { font-size: 11px; gap: 1px; }
  html.game-keyboard-minimal #view-game .stage-skip-button { height: 22px; min-height: 22px; padding: 0 3px; font-size: 11px; }
  html.game-keyboard-minimal #view-game .stage-skip-label { display: none; }
  html.game-keyboard-minimal #view-game .stage-skip-label-short { display: inline; }
  html.game-keyboard-minimal #view-game #answer-area,
  html.game-keyboard-minimal #view-game #answer-area .answer-input-row,
  html.game-keyboard-minimal #view-game #answer-area #answer-input,
  html.game-keyboard-minimal #view-game #answer-area #btn-chat,
  html.game-keyboard-minimal #view-game #answer-area #btn-submit { height: 40px; min-height: 40px; max-height: 40px; }
  html.game-keyboard-minimal #view-game #answer-area .answer-input-row { grid-template-rows: 40px; }
}

/* 时钟贴图与中西文数字共用中心线，避免基线和贴图留白造成上下错位。 */
@media (max-width:900px) {
  #view-game .timer-meta { align-items: center; line-height: 1; }
  #view-game #timer-text { display: inline-flex; align-items: center; line-height: 1; }
  #view-game .timer-count, #view-game .timer-unit { display: inline-block; line-height: 1; }
  #view-game .timer-clock { display: block; flex-shrink: 0; align-self: center; transform: translateY(-1px); }
}
