@layer interaction {
  :root { --dock-height: 0px; --nav-measured: 0px; --hud-height: 84px; --keyboard-inset: 0px; --visible-height: 100dvh; }
  html { scroll-padding-top: calc(var(--hud-height) + var(--topbar-height) + 16px); }
  .welcome-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; position: relative; z-index: 1; }
  .welcome-actions button { min-height: 48px; }
  .game-summary { position: sticky; }
  .summary-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-health { min-height: 28px; }
  .hud-details { position: relative; }
  .hud-details > summary { align-items: center; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); cursor: pointer; display: flex; font-size: 12px; justify-content: center; min-height: 44px; padding: 6px 10px; }
  .hud-details-content { background: var(--surface-elevated); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow-panel); display: grid; font-size: 13px; gap: 12px; padding: 16px; position: absolute; right: 0; top: calc(100% + 8px); width: min(300px, calc(100vw - 36px)); z-index: 45; }
  .hud-details-content .summary-stat { border: 0; min-height: 24px; padding: 0; }
  .hud-details-content .summary-stat > strong, .hud-details-content .summary-stat > span { font-size: 13px; }
  .hud-details-content p { margin: 0; color: var(--muted); }
  .summary-action { font-size: 12px; min-height: 44px; }
  .adventure-alert { background: #f28b8b16; border: 1px solid #f28b8b66; border-radius: 9px; color: var(--danger); font-size: 14px; line-height: 1.7; padding: 8px 12px; }
  .scene-details { margin-top: 10px; }
  .scene-details > summary, .context-details > summary { align-items: center; color: var(--muted); cursor: pointer; display: flex; font-size: 13px; gap: 8px; justify-content: space-between; min-height: 44px; padding: 8px 0; }
  .scene-details > summary::after, .context-details > summary::after { content: "＋"; }
  .scene-details[open] > summary::after, .context-details[open] > summary::after { content: "－"; }
  .scene-copy { font-size: 16px; line-height: 1.8; }
  .scene-details .scene-status { margin-bottom: 12px; }
  .scene-details .scene-hero { margin-top: 0; }
  .context-details { min-width: 0; }
  #context-summary { color: var(--faint); font-size: 12px; margin-left: auto; }
  .context-details .adventure-context { grid-template-columns: minmax(0, 1fr); }
  .party-empty { color: var(--muted); font-size: 13px; line-height: 1.7; margin: 0; }
  .context-details:not(.has-companions) .party-panel { background: transparent; border: 0; padding: 8px 0; }
  .context-details:not(.has-companions) .party-panel .section-heading { display: none; }
  .context-details:not(.has-companions) .party-list { margin: 0; }
  .latest-turn { scroll-margin-top: 12px; overflow-anchor: none; }
  .latest-turn:focus { outline: 2px solid var(--focus); outline-offset: 3px; }
  .narration, .previous-turn p { font-size: 17px; line-height: 1.85; white-space: pre-wrap; }
  .previous-turns { display: grid; gap: 8px; margin-top: 12px; }
  .previous-turn { border-bottom: 1px solid var(--border); color: var(--muted); }
  .previous-turn > summary { cursor: pointer; font-size: 13px; line-height: 1.6; min-height: 44px; padding: 10px 0; overflow-wrap: anywhere; }
  .previous-turn p { font-size: 16px; margin-top: 4px; }
  #earlier-records { min-height: 44px; }
  .action-dock { margin-top: 18px; }
  .action-area { align-items: center; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding-top: 12px; position: relative; }
  #quick-actions, #feedback-suggestions { display: contents; }
  .more-actions { position: relative; }
  .more-action-list { max-height: min(50dvh, 380px); overflow-y: auto; }
  .more-actions .quick-action { white-space: normal; }
  .action-dock .command-box { margin-top: 10px; padding: 10px; }
  .action-dock .command-row { align-items: end; grid-template-columns: minmax(0, 1fr) auto; }
  .action-dock textarea { font-size: 16px; height: 44px; min-height: 44px; max-height: 120px; resize: none; padding: 9px 11px; }
  .action-dock .command-submit { min-height: 44px; min-width: 76px; width: auto; }
  .command-feedback { background: var(--accent-soft); border-radius: 10px; padding: 12px; }
  .command-feedback p { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 6px 0; }
  .new-response { background: var(--accent); border: 1px solid #fff4; border-radius: 999px; bottom: calc(var(--nav-measured) + var(--dock-height) + var(--keyboard-inset) + 12px); box-shadow: var(--shadow-panel); color: #20180c; font-size: 14px; font-weight: 650; left: 50%; min-height: 44px; padding: 9px 18px; position: fixed; transform: translateX(-50%); white-space: nowrap; z-index: 35; }
  .save-options { align-self: start; position: relative; }
  .save-options > summary { align-items: center; border: 1px solid var(--border); border-radius: 9px; color: var(--muted); cursor: pointer; display: flex; font-size: 12px; justify-content: center; min-height: 44px; min-width: 48px; padding: 6px; }
  .save-options .save-delete { position: absolute; right: 0; top: 100%; min-height: 44px; min-width: 80px; background: var(--surface-elevated); z-index: 1; }
  .save-card strong { white-space: normal; overflow-wrap: anywhere; }
  .save-card small, .save-location, .save-experience { color: var(--muted); display: block; font-size: 12px; line-height: 1.65; margin-top: 5px; }
  .new-game-form small { font-size: 12px; }
  .quest-offer-summary { color: var(--text); font-size: 14px; line-height: 1.8; margin-bottom: 6px; }
  .quest-offer-reward { color: var(--accent); font-size: 13px; line-height: 1.6; }
  .character-hero-art { background: transparent; border: 0; border-radius: 12px; padding: 0; }
  .portrait-dialog { background: var(--surface-elevated); border: 1px solid var(--border-strong); border-radius: 18px; color: var(--text); max-height: calc(100dvh - 24px); max-width: calc(100vw - 24px); overflow-y: auto; padding: 18px; text-align: center; }
  .portrait-dialog::backdrop { background: #080e19bd; }
  .portrait-dialog h2 { font-size: 20px; margin-top: 0; }
  #portrait-large .avatar-hero { width: min(250px, 65vw); }
  .portrait-dialog button { margin-top: 14px; min-height: 44px; }
  .npc-details > summary, .mechanical-details > summary, .item-details > summary { min-height: 44px; padding-block: 12px; }
  .mini-button, .topbar-button, .view-more-item { font-size: 12px; }
  .npc-card small, .npc-card-relation, .party-card-meta, .party-card > small, .item-meta, .settings-description { font-size: 12px; }
  .turn-progress small { font-size: 12px; }
  @media (max-width: 720px) {
    :root { --bottom-nav-height: 60px; }
    html { scroll-padding-top: calc(var(--hud-height) + 12px); scroll-padding-bottom: calc(var(--dock-height) + var(--nav-measured) + 16px); }
    .tabs-active .topbar { position: relative; min-height: 48px; padding-block: 4px; }
    .tabs-active .game-summary { top: 0; margin-bottom: 8px; padding: 4px 9px; border-radius: 12px; z-index: 30; }
    .summary-heading { min-height: 44px; gap: 4px; }
    .summary-title-row { display: none; }
    .game-summary .summary-identity { flex: 1; }
    .game-summary #game-subtitle { color: var(--text); font-size: 13px; line-height: 1.4; margin: 0; max-width: 44vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .summary-controls { gap: 4px; }
    .summary-state { border: 0; padding: 3px; background: transparent; }
    .summary-state strong { font-size: 12px; }
    .summary-action { font-size: 12px; min-height: 44px; padding: 6px; }
    .summary-action > span:first-child { display: none; }
    .hud-details > summary { min-height: 44px; padding: 6px; }
    .summary-stats { margin-top: 0; padding-top: 3px; }
    .summary-health { min-height: 21px; padding: 0 4px; gap: 3px; }
    .summary-health .stat-label { font-size: 12px; }
    .game-summary .turn-progress-mini { position: absolute; left: 8px; right: 8px; top: calc(100% + 3px); max-width: none; text-align: center; font-size: 12px; }
    .workspace { margin-top: 8px; padding-bottom: 16px; }
    .tabs-active .app-shell { padding-bottom: calc(var(--nav-measured) + 18px); }
    .tabs-active.adventure-active .app-shell { padding-bottom: calc(var(--dock-height) + var(--nav-measured) + 24px); }
    .adventure-panel { padding: 12px; }
    .view-heading h2 { font-size: 23px; }
    .view-heading { padding-bottom: 8px; }
    .scene-details { margin-top: 0; }
    .scene-details > summary { min-height: 44px; }
    .scene-details .scene-hero { height: 88px; }
    .scene-details .scene-copy { margin: 10px 0; font-size: 15px; line-height: 1.75; }
    .scene-details .scene-status { display: none; }
    .scene-details #scene-exits { display: flex; }
    .scene-details #scene-exits .quick-action { font-size: 12px; padding: 6px 8px; }
    .adventure-layout { margin-top: 0; gap: 10px; }
    .combat-enemies { display: flex; flex-direction: column; }
    .combat-enemies .combat-boss { order: -1; }
    .latest-turn { margin-top: 8px; padding: 12px; }
    .latest-turn-heading h3 { font-size: 16px; }
    .context-details { border-top: 1px solid var(--border); }
    .context-details > summary { min-height: 48px; }
    .context-details .adventure-context { display: grid; gap: 10px; }
    .context-details .npc-card { flex-direction: row; }
    .action-dock { background: #111d2cf5; border-top: 1px solid var(--border-strong); bottom: calc(var(--nav-measured) + var(--keyboard-inset)); box-shadow: 0 -10px 24px #0003; left: 0; margin: 0; padding: 6px 10px; position: fixed; right: 0; z-index: 21; backdrop-filter: blur(16px); }
    .action-dock .action-area { border: 0; flex-wrap: nowrap; gap: 5px; padding: 0; }
    .action-dock .action-area > div > .quick-action { flex: 1 1 0; font-size: 12px; min-width: 0; min-height: 44px; overflow: hidden; padding: 6px; text-overflow: ellipsis; white-space: nowrap; }
    .action-dock .more-actions { flex: 0 0 auto; position: static; }
    .action-dock .more-actions > summary { font-size: 12px; min-height: 44px; padding: 6px; }
    .action-dock .more-actions > summary::after { content: "更多"; }
    .action-dock .more-actions > summary { font-size: 0; }
    .action-dock .more-actions > summary::after { font-size: 12px; }
    .action-dock .more-action-list { background: var(--surface-elevated); bottom: calc(100% + 8px); box-shadow: var(--shadow-panel); display: flex; flex-wrap: wrap; left: 8px; margin: 0; max-height: calc(var(--visible-height) * .45); position: absolute; right: 8px; }
    .action-dock .more-action-list .quick-action { font-size: 13px; flex: 1 1 130px; }
    .action-dock .action-group { flex: 1 1 100%; }
    .action-dock .command-box { background: transparent; border: 0; box-shadow: none; margin: 6px 0 0; padding: 0; }
    .action-dock .command-row { gap: 6px; }
    .action-dock .command-submit { min-width: 58px; padding-inline: 10px; }
    .command-submit span { display: none; }
    .command-hint { display: none; }
    .turn-progress { min-height: 0; margin-top: 5px; padding: 5px 8px; }
    .turn-progress small { display: none; }
    .view-navigation { padding-block: 3px max(3px, env(safe-area-inset-bottom)); }
    .view-navigation .view-tab { min-height: 52px; }
    .view-navigation .view-tab span:not([aria-hidden="true"]) { font-size: 12px; }
    .keyboard-open .view-navigation { display: none; }
    .keyboard-open .game-summary { position: sticky; }
    .keyboard-open .action-dock { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
    .keyboard-open .action-area { display: none; }
    .keyboard-open textarea { max-height: min(120px, calc(var(--visible-height) * .25)); }
    .character-hero { display: block; position: relative; padding: 12px; text-align: left; }
    .character-hero-art { position: absolute; top: 12px; left: 12px; }
    .character-hero-art .avatar-hero { width: 80px; }
    .character-hero-info > .eyebrow, .character-hero-info h3, .character-hero-info > p { margin-left: 94px; }
    .character-hero-info h3 { font-size: 25px; margin-top: 8px; }
    .character-hero-info > p { font-size: 12px; min-height: 44px; }
    .character-vitals { margin-top: 14px; }
    .character-hero-info .attribute-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
    .attribute-chip { min-width: 0; }
    .attribute-chip small { font-size: 12px; }
    .character-hero-loadout { font-size: 13px; }
    .growth-note { font-size: 11px; }
    .npc-card-actions { align-items: start; }
    .welcome-view { min-height: 0; padding: 32px 20px; }
    .welcome-view h1 { line-height: 1.15; }
    .welcome-art { opacity: .4; }
    .welcome-actions { margin-top: 20px; }
    .welcome-actions button { flex: 1 1 auto; }
    .feature-row { margin-top: 24px; }
  }
  @media (max-width: 360px) {
    .game-summary #game-subtitle { max-width: 37vw; font-size: 12px; }
    .summary-controls { gap: 2px; }
    .character-hero-info .attribute-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  }
  @media (max-height: 500px) and (max-width: 720px) {
    .action-dock .action-area { display: none; }
    .summary-heading { display: none; }
    .summary-health { min-height: 24px; }
  }
}
