/* Height-constrained phone UI. Enabled by compact_landscape.js, independent of desktop breakpoints. */
.compact-settings-save, .compact-chat-grip, .compact-chat-close, .compact-chat-resize,
.compact-action-icon, .compact-room-more, .compact-room-more-toggle { display: none; }

body.compact-landscape :is(.overlay-modal, .settings-overlay, .seating-overlay) {
  inset: var(--compact-top) auto auto var(--compact-left);
  width: var(--compact-width); height: var(--compact-height);
  padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  overflow: hidden;
}
body.compact-landscape :is(.modal-card, .seating-modal, .settings-modal) {
  width: min(600px, 100%); min-width: 0; min-height: 0;
  max-height: calc(var(--compact-height) - 16px);
  display: flex; flex-direction: column; overflow: hidden; border-radius: 10px;
}
body.compact-landscape :is(.modal-head, .seating-head, .settings-modal .settings-head) {
  flex: 0 0 auto; min-height: 44px; padding: 0 8px 0 12px; gap: 8px;
}
body.compact-landscape :is(.modal-head, .seating-head, .settings-head) :is(strong, h2) {
  margin: 0; min-width: 0; font-size: 16px; line-height: 1.2; letter-spacing: normal;
}
body.compact-landscape :is(.modal-head, .seating-head, .settings-head) > div { min-width: 0; }
body.compact-landscape :is(.modal-head, .seating-head, .settings-head) small { display: none; }
body.compact-landscape .modal-close { flex: 0 0 44px; width: 44px; height: 44px; border: 0; font-size: 24px; }
body.compact-landscape :is(.modal-body, .sound-modal-body, .settings-content, .inventory-grid) {
  flex: 1 1 auto; min-height: 0; padding: 10px 12px; gap: 8px;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable;
}
body.compact-landscape .neurospy-rules-body { max-height: none; }
body.compact-landscape :is(.modal-body, .settings-content) :is(input, select, textarea) { font-size: 16px; }
body.compact-landscape :is(.modal-body, .settings-content) :is(input:not([type="checkbox"]):not([type="range"]):not([type="color"]), select) {
  min-height: 40px; padding: 6px 8px;
}
body.compact-landscape :is(.modal-body, .settings-content) label { gap: 4px; font-size: 12px; }
body.compact-landscape :is(.modal-body, .settings-content) button { min-height: 40px; padding: 7px 10px; font-size: 13px; }
body.compact-landscape .modal-head .compact-header-save,
body.compact-landscape .settings-head .compact-settings-save {
  display: block; flex: 0 0 auto; width: auto; min-width: 88px; min-height: 40px;
  margin-left: auto; padding: 6px 12px; color: white; background: var(--accent-color); font-size: 13px;
}
body.compact-landscape :is(.neurospy-settings-actions, .avatar-editor-actions) { display: none; }
body.compact-landscape :is(.compact-modal-card, .neurospy-password-card) { width: min(420px, 100%); }
body.compact-landscape :is(.neurospy-settings-card, .neurospy-bot-card, .neurospy-model-card, .settings-modal) {
  width: min(760px, 100%); height: min(480px, calc(var(--compact-height) - 16px));
}
body.compact-landscape .neurospy-settings-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
body.compact-landscape .neurospy-form-section { padding: 8px; gap: 8px; border-radius: 6px; }
body.compact-landscape .neurospy-form-section:first-child { grid-column: 1 / -1; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
body.compact-landscape .neurospy-form-section:first-child > label { grid-column: 1; }
body.compact-landscape .neurospy-form-section:first-child > .neurospy-player-limits { grid-column: 2; grid-row: 1 / span 2; align-self: start; }
body.compact-landscape .neurospy-form-section:first-child > h3 { display: none; }
body.compact-landscape .settings-tabs { flex: 0 0 40px; padding: 0 8px; }
body.compact-landscape .settings-tab { padding: 8px; font-size: 11px; letter-spacing: .04em; }
body.compact-landscape .settings-modal .settings-section { padding: 4px; }
body.compact-landscape .settings-modal .section-intro { margin: 0 0 8px; }
body.compact-landscape .section-intro > span,
body.compact-landscape .section-intro :is(h2, p) { display: none; }
body.compact-landscape .character-section-actions { margin-left: auto; }
body.compact-landscape .settings-modal .settings-section label { margin-bottom: 8px; }
body.compact-landscape .settings-modal .voice-settings { margin: 4px 0 8px; padding: 8px; }
body.compact-landscape #settingsPanel :is(#saveCharacter, #saveRoom) { display: none; }
body.compact-landscape .api-key-settings { padding: 10px; margin-bottom: 10px; }
body.compact-landscape .settings-modal .settings-section[data-panel="room"].active,
body.compact-landscape #createRoomModal .modal-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; }
body.compact-landscape .settings-section[data-panel="room"] > :is(label, fieldset),
body.compact-landscape #createRoomModal .modal-body > :is(label, fieldset, div) { grid-column: 1 / -1; }
body.compact-landscape .settings-section[data-panel="room"] > label:nth-of-type(-n+2),
body.compact-landscape #createRoomModal .modal-body > label:nth-of-type(-n+2) { grid-column: auto; }
body.compact-landscape .settings-section[data-panel="room"] > .section-intro { display: none; }

/* Avatar editor: no fixed footer; both the preview and the picker fit the body. */
body.compact-landscape #avatarEditorModal .avatar-editor-card {
  width: min(820px, 100%); height: min(380px, calc(var(--compact-height) - 16px));
  display: grid; grid-template-rows: 44px minmax(0, 1fr);
}
body.compact-landscape #avatarEditorModal .avatar-editor-mobile-save {
  display: block; width: auto; min-height: 40px; padding: 6px 12px;
  color: white; background: var(--accent-color); font-size: 13px;
}
body.compact-landscape #avatarEditorModal .avatar-editor-body {
  display: grid; grid-template-rows: 40px minmax(0, 1fr); gap: 6px; padding: 6px 8px; overflow: hidden;
}
body.compact-landscape #avatarEditorModal .avatar-editor-tabs { min-height: 0; padding: 1px; }
body.compact-landscape #avatarEditorModal .avatar-editor-tabs button { min-height: 36px; padding: 4px; font-size: 12px; }
body.compact-landscape #avatarEditorModal .avatar-editor-workspace {
  grid-template-columns: minmax(150px, .65fr) minmax(0, 2fr); margin: 0; min-height: 0; overflow: hidden; border-radius: 7px;
}
body.compact-landscape #avatarEditorModal .avatar-editor-preview-pane { min-height: 0; padding: 6px; overflow: hidden; border: 0; border-right: 1px solid var(--border-color); }
body.compact-landscape #avatarEditorModal .avatar-character-preview-pane,
body.compact-landscape #avatarEditorModal .avatar-background-preview-pane { min-height: 0; gap: 4px; }
body.compact-landscape #avatarEditorModal .avatar-editor-preview { width: min(132px, calc(var(--compact-height) - 144px)); }
body.compact-landscape #avatarEditorModal :is(.avatar-editor-preview-label, .avatar-character-preview-pane > small, .avatar-background-preview-pane > small) { display: none; }
body.compact-landscape #avatarEditorModal .avatar-editor-controls-pane { min-height: 0; overflow: auto; padding: 6px; }
body.compact-landscape #avatarEditorModal .avatar-editor-panel { gap: 6px; }
body.compact-landscape #avatarEditorModal .avatar-editor-control-card { padding: 8px; }
body.compact-landscape #avatarEditorModal .avatar-editor-section-head { margin-bottom: 4px; }
body.compact-landscape #avatarEditorModal .avatar-editor-hat-choices { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
body.compact-landscape #avatarEditorModal .avatar-editor-hat-choices .profile-hat-choice { height: 76px; min-height: 76px; padding: 3px; }
body.compact-landscape #avatarEditorModal .avatar-editor-hat-choices .profile-hat-choice img { max-height: 68px; }
body.compact-landscape #avatarEditorModal .avatar-cosmetic-description { min-height: 0; padding: 6px 8px; }
body.compact-landscape #avatarEditorModal .avatar-background-preview-pane .profile-background-preview { min-height: 110px; }
body.compact-landscape #avatarEditorModal .avatar-badge-choice { min-height: 68px; padding: 5px; }

/* Keep the save action and close control outside the scrolling list. */
body.compact-landscape #contextSavesModal .modal-card { width: min(680px, 100%); }
body.compact-landscape #contextSavesModal .modal-body { display: flex; flex-direction: column; overflow: hidden; }
body.compact-landscape .context-saves-form { flex: 0 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; margin: 0; padding: 0 0 8px; }
body.compact-landscape .context-saves-form label { min-width: 0; }
body.compact-landscape #contextSaveSubmit { align-self: end; width: auto; max-width: 220px; min-height: 40px; }
body.compact-landscape #contextSaveStatus { grid-column: 1 / -1; margin: 0; font-size: 11px; }
body.compact-landscape .context-saves-list { flex: 1 1 auto; min-height: 0; max-height: none; gap: 6px; }
body.compact-landscape .context-save-item { min-height: 54px; padding: 6px 8px; gap: 8px; }
body.compact-landscape .context-save-item-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.compact-landscape .context-save-item-info small { font-size: 11px; }
body.compact-landscape .context-save-item-actions { gap: 4px; }
body.compact-landscape .context-save-item-actions button { width: auto; padding: 6px 10px; }

/* Settings that can use the width rather than stacking tall cards. */
body.compact-landscape .sound-modal { width: min(680px, 100%); }
body.compact-landscape .sound-modal-body { display: grid; grid-template-columns: minmax(180px, .8fr) minmax(0, 1.5fr); align-content: start; gap: 6px 10px; }
body.compact-landscape .sound-option { grid-column: 1; min-height: 44px; margin: 0; padding: 6px 10px; }
body.compact-landscape .sound-option strong { margin: 0; font-size: 13px; }
body.compact-landscape .sound-levels { grid-column: 2; grid-row: 1 / span 3; margin: 0; gap: 6px; }
body.compact-landscape .sound-slider { padding: 6px 8px; gap: 3px; }
body.compact-landscape .sound-slider input { min-height: 28px; margin: 0; }
body.compact-landscape :is(#seatingModal, #nsSeatingModal) .seating-modal { width: min(760px, 100%); }
body.compact-landscape :is(#seatingGrid, #nsSeatingGrid) { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; padding: 8px; gap: 8px; }
body.compact-landscape #seatingGrid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
body.compact-landscape #nsSeatingGrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
body.compact-landscape .seating-slot { height: 94px; aspect-ratio: auto; }
body.compact-landscape .seating-summary { padding: 5px; gap: 3px; }
body.compact-landscape .seating-summary :is(> img, .seating-human-avatar) { width: 44px; height: 44px; }
body.compact-landscape #nsSeatingGrid .neurospy-seat-avatar { flex-basis: 40px; width: 40px; height: 40px; }
body.compact-landscape .seating-summary span { font-size: 23px; }
body.compact-landscape .seating-picker { min-height: 40px; padding: 5px; font-size: 13px; }

/* A small persistent toolbar; secondary actions keep their original handlers. */
body.compact-landscape .game-actions,
body.compact-landscape[data-screen="neurospy-game"] .neurospy-game-actions { top: 6px; right: max(8px, env(safe-area-inset-right)); gap: 4px; z-index: 470; flex-wrap: nowrap; }
body.compact-landscape .game-actions > .game-action,
body.compact-landscape[data-screen="neurospy-game"] .neurospy-game-actions > .game-action { width: 44px; height: 44px; min-width: 44px; padding: 11px; border-radius: 7px; }
body.compact-landscape[data-screen="neurospy-game"] .neurospy-game-more-menu {
  width: min(320px, calc(var(--compact-width) - 16px));
  max-height: max(44px, calc(var(--compact-height) - 62px));
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 5px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
body.compact-landscape[data-screen="neurospy-game"] .neurospy-game-more-menu .game-action {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  gap: 6px;
  padding: 5px 7px;
  font-size: 12px;
  line-height: 1.15;
  text-align: left;
}
body.compact-landscape[data-screen="neurospy-game"] .neurospy-game-more-menu .game-action svg {
  width: 17px;
  height: 17px;
  flex-basis: 17px;
}
body.compact-landscape[data-screen="neurospy-game"] #nsGamePlayers {
  translate: 0 -8px;
}
body.compact-landscape[data-screen="neurospy-game"] #nsGamePlayerNames .character-name {
  font-size: clamp(8.5px, 1.45vw, 10px);
  padding: 2px 5px;
}
body.compact-landscape[data-screen="neurospy-game"] #nsGamePlayerNames .neurospy-game-role {
  font-size: clamp(8.5px, 1.6vw, 10px);
  padding: 2px 6px;
}
body.compact-landscape[data-screen="neurospy-game"] .neurospy-game-hud {
  top: max(6px, env(safe-area-inset-top));
  right: max(104px, calc(env(safe-area-inset-right) + 96px));
  left: max(6px, env(safe-area-inset-left));
  transform: none;
  pointer-events: none;
}
body.compact-landscape[data-screen="neurospy-game"] .neurospy-game-status-stack {
  width: 100%;
  display: grid;
  grid-template-columns: fit-content(42%) minmax(0, 1fr);
  align-items: start;
  gap: 5px 8px;
}
body.compact-landscape[data-screen="neurospy-game"] :is(.neurospy-game-phase, .neurospy-game-status-stack > section, .neurospy-host-menu) { pointer-events: auto; }
.neurospy-mobile-turn-counter { display: none; }
body.compact-landscape[data-screen="neurospy-game"] .neurospy-game-phase {
  display: grid;
  grid-template-areas: "turn location timer";
  grid-template-columns: auto minmax(0, auto) auto;
  width: auto;
  min-width: 0;
  min-height: 38px;
  gap: 6px;
  padding: 4px 7px;
}
body.compact-landscape[data-screen="neurospy-game"] .neurospy-game-phase > :is(strong, span) { display: none; }
body.compact-landscape[data-screen="neurospy-game"] #nsGameTurnCounter:not(.hidden) {
  display: block;
  grid-area: turn;
  align-self: center;
  color: #f2f3f8;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
body.compact-landscape[data-screen="neurospy-game"] .neurospy-game-phase > time { grid-area: timer; min-width: 22px; }
body.compact-landscape[data-screen="neurospy-game"] .neurospy-game-phase .neurospy-game-location {
  grid-area: location;
  width: auto;
  min-width: 0;
  max-width: min(170px, 25vw);
}
body.compact-landscape[data-screen="neurospy-game"] .neurospy-game-phase .neurospy-game-location.expanded {
  max-width: min(320px, 40vw);
  max-height: min(68px, 25dvh);
  overflow-y: auto;
}
body.compact-landscape[data-screen="neurospy-game"] .neurospy-game-status-stack > section {
  grid-column: 2;
  width: min(360px, 100%);
  max-width: 100%;
  max-height: min(56dvh, max(68px, calc(var(--compact-height) - 62px)));
  overflow-y: auto;
  overscroll-behavior: contain;
}
body.compact-landscape[data-screen="neurospy-game"] #nsPreparationPanel {
  position: fixed;
  top: calc(var(--compact-top, 0px) + var(--compact-height, 100dvh) / 2);
  left: calc(var(--compact-left, 0px) + var(--compact-width, 100vw) / 2);
  transform: translate(-50%, -50%);
  width: min(520px, calc(var(--compact-width, 100vw) - 24px));
  max-height: calc(var(--compact-height, 100dvh) - 16px);
  pointer-events: none;
}
body.compact-landscape #nsPreparationPanel button { pointer-events: auto; }
body.compact-landscape .neurospy-game-status-stack:has(#nsPreparationPanel:not(.hidden)) .neurospy-game-phase { visibility: hidden; }
body.compact-landscape[data-screen="neurospy-game"] #nsPreparationPick {
  position: fixed;
  top: max(52px, calc(env(safe-area-inset-top) + 48px));
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 24px);
}
body.compact-landscape[data-screen="neurospy-game"] #nsCourtPanel { padding: 5px 8px; }
body.compact-landscape[data-screen="neurospy-game"] #nsCourtPanel > strong { font-size: 13px; }
body.compact-landscape[data-screen="neurospy-game"] #nsCourtPanel > p { font-size: 11px; }
body.compact-landscape[data-screen="neurospy-game"] #nsCourtPanel:is(.is-defense, .is-last-word) > p { display: none; }
body.compact-landscape[data-screen="neurospy-game"] .neurospy-accusation-confirm { padding: 8px 10px; }
body.compact-landscape[data-screen="neurospy-game"] .neurospy-accusation-full { display: none; }
body.compact-landscape[data-screen="neurospy-game"] .neurospy-accusation-short { display: inline; }
body.compact-landscape[data-screen="neurospy-game"] .neurospy-court-vote-actions {
  position: sticky;
  bottom: 0;
  background: #20252e;
  border-radius: 6px;
}
body.compact-landscape[data-screen="neurospy-game"] .neurospy-victory-panel {
  top: max(54px, calc(env(safe-area-inset-top) + 48px));
  width: min(420px, calc(var(--compact-width) - 16px));
  max-height: max(70px, calc(var(--compact-height) - 68px));
  padding: 10px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
body.compact-landscape[data-screen="neurospy-game"] .neurospy-victory-panel > strong { font-size: 20px; }
body.compact-landscape[data-screen="neurospy-game"] .neurospy-victory-panel > p { font-size: 13px; }
body.compact-landscape .game-actions .spectators-button { width: auto; min-width: 48px; padding: 6px; font-size: 14px; }
body.compact-landscape .game-actions .room-seat-action { width: auto; min-width: 90px; padding: 6px; font-size: 12px; }
body.compact-landscape .compact-room-more-toggle { display: grid; }
body.compact-landscape .compact-room-more.is-open {
  display: grid; position: absolute; top: 50px; right: 0; grid-template-columns: repeat(2, minmax(130px, 1fr));
  max-height: calc(var(--compact-height) - 66px); overflow-y: auto;
  padding: 6px; gap: 4px; color: var(--text-main); background: var(--bg-modal); border: 1px solid var(--border-color); border-radius: 8px;
}
body.compact-landscape .compact-room-more .game-action { width: auto; min-height: 44px; display: flex; gap: 8px; padding: 7px; box-shadow: none; background: var(--bg-input); color: var(--text-main); font-size: 12px; }
body.compact-landscape .compact-room-more .game-action::after { content: attr(title); }
body.compact-landscape .compact-room-more .hidden { display: none; }
body.compact-landscape .compact-room-more svg { flex: 0 0 18px; width: 18px; height: 18px; }
body.compact-landscape:has([role="dialog"][aria-modal="true"]:not(.hidden)) :is(.neurospy-reaction-dock, .game-actions, .neurospy-game-actions, .neurospy-game-chat-toggle) { visibility: hidden; pointer-events: none; }
body.compact-landscape .neurospy-reaction-dock { right: max(8px, env(safe-area-inset-right)); bottom: max(8px, env(safe-area-inset-bottom)); gap: 6px; z-index: 185; }
body.compact-landscape .neurospy-reaction-toggle { width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 9px; border-radius: 9px; }
body.compact-landscape .neurospy-reaction-panel { width: min(520px, calc(var(--compact-width) - 24px)); max-height: calc(var(--compact-height) - 68px); padding: 6px; }
body.compact-landscape[data-screen="neurospy-game"] #nsReactionPanel {
  position: absolute;
  right: calc(100% + 6px);
  bottom: 0;
  width: min(520px, calc(var(--compact-width) - 50px - max(8px, env(safe-area-inset-right)) - max(8px, env(safe-area-inset-left))));
  max-height: calc(var(--compact-height) - max(8px, env(safe-area-inset-bottom)) - max(6px, env(safe-area-inset-top)));
}
body.compact-landscape .neurospy-reaction-panel > header { min-height: 36px; padding: 0 4px 4px; }
body.compact-landscape .neurospy-reaction-panel > header button { width: 40px; height: 40px; }
body.compact-landscape .neurospy-reaction-section { margin-top: 5px; }
body.compact-landscape .neurospy-reaction-grid { grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); gap: 4px; }
body.compact-landscape .neurospy-reaction-grid button { height: 44px; font-size: 18px; }
body.compact-landscape[data-screen="neurospy-game"] :is(.neurospy-side-reaction span, .neurospy-player-reaction) { font-size: 17px; }
body.compact-landscape[data-screen="room"]:has(.workspace:not(.log-hidden)) .room-reaction-dock {
  bottom: var(--room-reaction-bottom, max(8px, env(safe-area-inset-bottom)));
}
body.compact-landscape[data-screen="room"]:has(.workspace:not(.log-hidden)) .room-reaction-dock .neurospy-reaction-panel {
  max-height: calc(var(--compact-height) - var(--room-reaction-bottom, 8px) - 60px);
}

/* Both chat modes use a touch-dragged/resized rectangle, initially the left half. */
body.compact-landscape #logPanel,
body.compact-landscape[data-screen="neurospy-game"] #nsGameChatPanel {
  position: fixed;
  inset: auto !important; left: var(--compact-chat-left) !important; top: var(--compact-chat-top) !important;
  width: var(--compact-chat-width) !important; height: var(--compact-chat-height) !important;
  min-width: 0; min-height: 0; max-width: none; max-height: none; resize: none;
  border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; transform: none !important;
}
body.compact-landscape #logPanel { z-index: 180; display: flex; flex-direction: column; }
body.compact-landscape #logPanel.mobile-hidden { display: none; }
body.compact-landscape #logPanel .panel-head { display: grid; flex: 0 0 auto; grid-template-columns: 32px minmax(0, 1fr) 36px 36px; gap: 2px; padding: 2px 4px; min-height: 0; cursor: default; }
body.compact-landscape #logPanel .history-heading { display: contents; }
body.compact-landscape #logPanel .history-heading > strong { display: none; }
body.compact-landscape #logPanel .history-tabs { grid-column: 2; grid-row: 1; gap: 3px; margin: 0; align-self: center; }
body.compact-landscape #logPanel .history-tab { padding: 7px 5px; min-height: 36px; font-size: 11px; white-space: nowrap; }
body.compact-landscape #logPanel .panel-actions { grid-column: 3; grid-row: 1; display: flex; }
body.compact-landscape #logPanel .private-recipient { grid-column: 1 / -1; grid-row: 2; margin: 0; gap: 4px; }
body.compact-landscape #logPanel .private-recipient select { height: 32px; min-height: 32px; padding: 3px 6px; font-size: 13px; }
body.compact-landscape #logPanel .compact-chat-grip { grid-column: 1; grid-row: 1; display: grid; place-items: center; height: 40px; touch-action: none; cursor: move; }
body.compact-landscape #logPanel .compact-chat-close { grid-column: 4; grid-row: 1; }
body.compact-landscape :is(.compact-chat-close, #clearMessages:not(.hidden)) { display: grid; width: 36px; height: 40px; min-height: 0; padding: 8px; background: transparent; color: var(--text-muted); border: 0; }
body.compact-landscape :is(.compact-chat-close, .compact-chat-grip, .compact-chat-resize, .compact-action-icon) svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
body.compact-landscape .compact-chat-grip svg { stroke-width: 3; }
body.compact-landscape .compact-action-icon { display: grid; place-items: center; }
body.compact-landscape .compact-action-label { display: none; }
body.compact-landscape #logPanel .room-chat-history { flex: 1 1 auto; min-height: 0; }
body.compact-landscape #logPanel .messages { padding: 5px 7px; font-size: 13px; }
body.compact-landscape #composer { flex: 0 0 auto; display: grid; grid-template-columns: 36px minmax(0, 1fr) 40px 40px; gap: 4px; padding: 5px 7px 7px; }
body.compact-landscape #composer :is(.prompt-row, .composer-actions) { display: contents; }
body.compact-landscape #composer #target { display: none; }
body.compact-landscape #composer :is(#roomChatReplyPreview, #imagePreview) { grid-column: 1 / -1; }
body.compact-landscape #composer #attachImage { grid-column: 1; width: 36px; min-height: 44px; padding: 7px; }
body.compact-landscape #composer #prompt { grid-column: 2; height: 44px; min-height: 44px; max-height: 88px; padding: 9px 7px; font-size: 16px; }
body.compact-landscape #composer #send { grid-column: 3; }
body.compact-landscape #composer #continueDialogue { grid-column: 4; }
body.compact-landscape #composer :is(#send, #continueDialogue) { min-width: 0; min-height: 44px; width: 40px; padding: 7px; }
body.compact-landscape #send .send-label { display: none; }
body.compact-landscape #composer :is(#stopReply, #retryRequest) { grid-column: 1 / -1; padding: 5px; font-size: 12px; }
body.compact-landscape .compact-chat-resize { display: grid; position: absolute; z-index: 3; bottom: 0; right: 0; width: 26px; height: 24px; padding: 2px; border: 0; background: var(--bg-modal); color: var(--text-muted); border-radius: 7px 0 7px 0; touch-action: none; cursor: nwse-resize; }
body.compact-landscape #composer { padding-bottom: 19px; }
body.compact-landscape[data-screen="neurospy-game"] #nsGameChatPanel {
  display: grid;
  z-index: 180;
  grid-template: 44px minmax(0, 1fr) / 44px minmax(0, 1fr) 44px;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: none;
}
body.compact-landscape[data-screen="neurospy-game"] #nsGameChatPanel:not(.mobile-open) { display: none; }
body.compact-landscape #nsGameChatDragHandle { display: contents; }
body.compact-landscape #nsGameChatDragHandle .neurospy-game-chat-drag-dots {
  display: grid;
  grid-area: 1 / 1;
  width: 44px;
  height: 44px;
  place-items: center;
  color: var(--text-muted);
  background: transparent;
  touch-action: none;
  cursor: move;
}
body.compact-landscape #nsGameChatDragHandle .neurospy-game-chat-drag-dots::before {
  content: "";
  position: static;
  width: 10px;
  height: 16px;
  border-radius: 0;
  background: radial-gradient(circle, currentColor 1px, transparent 1.6px) 0 0 / 5px 5px;
}
body.compact-landscape #nsGameChatDragHandle .neurospy-game-chat-drag-dots::after { display: none; }
body.compact-landscape #nsGameChatDragHandle .neurospy-game-chat-title { display: block; grid-area: 1 / 2; align-self: center; font-size: 13px; }
body.compact-landscape #nsGameChatPanel:has(#nsChatTabs:not(.hidden)) .neurospy-game-chat-title { display: none; }
body.compact-landscape #nsGameChatClose { display: grid; grid-area: 1 / 3; width: 44px; height: 44px; padding: 0; place-items: center; background: transparent; border: 0; }
body.compact-landscape #nsChatTabs { grid-area: 1 / 2; min-width: 0; padding: 0; border: 0; }
body.compact-landscape #nsChatTabs button { min-height: 44px; padding: 5px; font-size: 12px; }
body.compact-landscape .ns-chat-full-label { display: none; }
body.compact-landscape .ns-chat-short-label { display: inline; }
body.compact-landscape :is(#nsPublicChatPanel, #nsPrivateChatPanel) { grid-area: 2 / 1 / 3 / -1; border-top: 1px solid var(--border-color); }
body.compact-landscape #nsPublicChatPanel { min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto; }
body.compact-landscape #nsGameTurnStatus { min-height: 0; padding: 3px 8px; font-size: 11px; }
body.compact-landscape :is(#nsGameChatForm, #nsPrivateForm) { padding: 5px 7px; gap: 4px; }
body.compact-landscape #nsGameChatForm { grid-template-columns: minmax(0, 1fr) auto; grid-auto-flow: row dense; }
body.compact-landscape #nsGameChatForm > :not(textarea):not(#nsGameTurnControls) { grid-column: 1 / -1; }
body.compact-landscape :is(#nsGameChatInput, #nsPrivateInput) {
  min-height: 44px !important;
  height: 44px !important;
  max-height: 44px !important;
  padding: 8px;
  font-size: 16px;
  resize: none;
}
body.compact-landscape #nsPrivateHeading:not(.is-host),
body.compact-landscape #nsPrivateHeading.is-host:has(#nsPrivateBack:not(.hidden)) #nsPrivateHint { display: none; }
body.compact-landscape #nsPrivateHeading { padding: 3px 7px; }
body.compact-landscape #nsPrivateForm { grid-template-columns: minmax(0, 1fr) 44px; }
body.compact-landscape #nsPrivateStatus { grid-column: 1 / -1; }
body.compact-landscape #nsPrivateSubmit { display: grid; place-items: center; min-height: 44px; padding: 0; }
body.compact-landscape #nsPrivateSubmit .neurospy-action-label { display: none; }
body.compact-landscape #nsPrivateSubmit .neurospy-action-icon { display: block; }
body.compact-landscape[data-screen="neurospy-game"] #nsGameChatPanel.compact-keyboard-open {
  grid-template-rows: 36px minmax(0, 1fr);
}
body.compact-landscape #nsGameChatPanel.compact-keyboard-open :is(#nsGameChatClose, .neurospy-game-chat-drag-dots, #nsChatTabs button) {
  min-height: 36px;
  height: 36px;
}
body.compact-landscape #nsGameChatPanel.compact-keyboard-open :is(#nsPrivateHeading, #nsGameTurnStatus, #nsGameChatCounter, .compact-chat-resize) { display: none; }
body.compact-landscape #nsGameTurnControls { grid-column: 2; display: flex; flex-wrap: wrap; gap: 4px; }
body.compact-landscape #nsGameTurnControls :is(#nsGameChatSubmit, #nsTransferTurn) { flex: 0 0 44px; min-height: 40px; padding: 6px; }
body.compact-landscape #nsGameTurnControls .neurospy-action-label { display: none; }
body.compact-landscape #nsGameTurnControls .neurospy-action-icon { display: block; }
body.compact-landscape[data-screen="neurospy-game"] #nsGameChatToggle { position: relative; display: grid; place-items: center; width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 10px; }
body.compact-landscape[data-screen="neurospy-game"] #nsGameChatToggleLabel { display: none; }

/* Never let stale desktop size constraints push a small dialog past the viewport. */
body.compact-landscape .hidden { display: none; }
