html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (max-width: 760px), (max-width: 1024px) and (max-height: 600px) and (pointer: coarse) {
  html { scroll-padding-top: calc(84px + env(safe-area-inset-top)); }
  body.paper-theme :is(main,section,article,form,fieldset,details) { min-width: 0; }
  body.paper-theme :is(img,video,canvas,iframe) { max-width: 100%; }
  body.paper-theme :is(input:not([type=radio]):not([type=checkbox]):not([type=range]):not([type=color]):not([type=file]),textarea,select) { font-size: 16px !important; }
  body.paper-theme :is(.account-head button,.avatar-crop-actions button,.trip-discussion-actions .paper-button,.trip-discussion-reply-actions .paper-button,.community-reply-form button,.theme-select-option,.account-truth-lie) { min-height: 44px; }
  body.paper-theme :is(.trip-discussion-body,.trip-discussion-reply p,.trip-detail-note,.community-person-intro,.community-photo-caption,.song-title,.song-artist,.account-field-note) { overflow-wrap: anywhere; }
  body.paper-theme :is(section[id],details[id],.account-inline) { scroll-margin-top: calc(84px + env(safe-area-inset-top)); }
  body.paper-theme .opening-header,
  body.paper-theme .opening-header.header-plain {
    height: calc(68px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(16px,env(safe-area-inset-right)) 0 max(16px,env(safe-area-inset-left));
    gap: 0;
  }
  body.paper-theme .opening-header .header-links { margin-left: auto; padding: 0; }
  body.paper-theme .opening-header .header-links a { font-size: 14px; letter-spacing: 0; }
  body.paper-theme .opening-header .menu-toggle { margin-left: 8px; }
  body.paper-theme .opening-header .language-toggle { margin-left: 4px; }
  body.paper-theme > .language-toggle { top: max(12px,env(safe-area-inset-top)); right: max(12px,env(safe-area-inset-right)); }
  body.paper-theme .site-menu { height: var(--mobile-height,100dvh); max-height: var(--mobile-height,100dvh); overflow-y: auto; overscroll-behavior: contain; }
  body.paper-theme .site-menu .menu-top { flex: none; height: calc(68px + env(safe-area-inset-top)); padding-inline: 20px; padding-top: env(safe-area-inset-top); }
  body.paper-theme .site-menu .menu-links { flex: 1 0 auto; padding-block: 12px; }
  body.paper-theme .site-menu .menu-links :is(a,button) { min-height: 48px; }
  body.paper-theme .site-menu .menu-footer { padding-bottom: 12px; }
  body.paper-theme dialog[open]:not(.site-menu):not(.assistant-viewport) {
    position: fixed;
    inset: calc(var(--mobile-top,0px) + var(--mobile-height,100dvh) / 2) auto auto 50%;
    translate: -50% -50%;
    margin: 0;
    max-width: calc(100% - 24px);
    max-height: calc(var(--mobile-height,100dvh) - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding-block: 20px;
  }
  body.paper-theme :is(.account-shell,.avatar-crop-shell) { padding-inline: 20px; }
  body.paper-theme .account-head { gap: 12px; }
  body.paper-theme .account-head h2 { min-width: 0; line-height: 1.5; }
  body.paper-theme .account-head button { flex: none; min-width: 44px; padding: 8px; }
  body.paper-theme .account-truth-heading { flex-wrap: wrap; gap: 8px; }
  body.paper-theme .account-avatar { flex: none; }
  body.paper-theme .site-footer { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  body.paper-theme :is(.trip-calendar,.trip-calendar-scroll,.personal-grid,.table-wrap) { max-width: 100%; min-width: 0; overscroll-behavior-x: contain; }
  body.paper-theme .trip-map-canvas { min-height: min(320px,70svh); }
  body.paper-theme .trip-map-caption { flex-wrap: wrap; }
  body.paper-theme .trip-planner-heading { align-items: flex-start; flex-wrap: wrap; }
  body.paper-theme :is(.trip-day-heading,.trip-calendar-heading,.trip-dialog-heading,.trip-discussion-meta) { flex-wrap: wrap; }
  body.paper-theme .trip-calendar-day-heading button { min-height: 44px; }
  body.paper-theme :is(.trip-place-extra,.trip-place-actions,.trip-event-actions,.trip-discussion-actions,.trip-discussion-reply-actions) { flex-wrap: wrap; }
  body.paper-theme .trip-place-extra .paper-button { white-space: normal; text-align: left; }
  body.paper-theme :is(.trip-discussion-reply-form,.avatar-crop-actions) { flex-wrap: wrap; }
  body.paper-theme .trip-discussion-reply-form input { flex: 1 1 160px; min-height: 44px; }
  body.paper-theme .trip-discussion-replies { margin-left: 0; padding-left: 12px; }
  body.paper-theme .community-main { padding-top: calc(100px + env(safe-area-inset-top)); }
  body.paper-theme .community-intro { align-items: flex-start; flex-wrap: wrap; }
  body.paper-theme .community-tabs { top: calc(68px + env(safe-area-inset-top)); overflow-x: auto; }
  body.paper-theme .community-tabs button { min-height: 48px; white-space: nowrap; }
  body.paper-theme .community-person-open { min-width: 0; max-width: 100%; }
  body.paper-theme .community-person-name { overflow-wrap: anywhere; }
  body.paper-theme .community-people:is([data-columns="3"],[data-columns="4"]) { gap: 8px; }
  body.paper-theme .community-people:is([data-columns="3"],[data-columns="4"]) .community-person-open { min-height: 140px; padding: 16px 6px; gap: 8px; }
  body.paper-theme .community-people:is([data-columns="3"],[data-columns="4"]) .community-person-name { font-size: 15px; line-height: 1.5; }
  body.paper-theme .community-people:is([data-columns="3"],[data-columns="4"]) :is(.community-person-relationship,.community-person-intro,.community-person-action) { display: none; }
  body.paper-theme .community-photo-viewer { padding: 10px; }
  body.paper-theme .community-viewer-stage { position: relative; display: grid; grid-template-columns: minmax(0,1fr); }
  body.paper-theme .community-viewer-stage button { position: absolute; top: 50%; z-index: 1; width: 44px; height: 44px; min-height: 44px; padding: 8px; translate: 0 -50%; background: rgb(var(--ui-surface-rgb) / .92); }
  body.paper-theme .community-viewer-stage button:first-child { left: 4px; }
  body.paper-theme .community-viewer-stage button:last-child { right: 4px; }
  body.paper-theme .community-viewer-footer { flex-wrap: wrap; }
  body.paper-theme .game-main { padding-top: calc(100px + env(safe-area-inset-top)); }
  body.paper-theme .drawing-tools { gap: 8px; }
  body.paper-theme .drawing-colors button { width: 44px; height: 44px; min-height: 44px; }
  body.paper-theme .drawing-preview-controls { flex-wrap: wrap; }
  body.paper-theme .drawing-prompt :is(input,select) { min-width: 0; max-width: 100%; }
  html[lang=en] body.paper-theme .game-hero h1 { font-size: clamp(48px,13vw,76px); line-height: 1.1; text-wrap: balance; }
  body.paper-theme .chat-page { height: var(--mobile-height,100dvh); }
  body.paper-theme .chat-layout { height: auto; flex: 1 1 0; min-height: 0; }
  body.paper-theme .chat-top { height: calc(62px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); grid-template-columns: minmax(0,1fr) auto auto; gap: 8px; }
  body.paper-theme .chat-top h1 { display: none; }
  body.paper-theme .chat-top a { font-size: 13px; }
  body.paper-theme .chat-top button { min-height: 44px; }
  body.paper-theme .chat-top .language-toggle { margin: 0; }
  body.paper-theme .chat-conversation { min-height: 0; }
  body.paper-theme .chat-messages { min-height: 0; overscroll-behavior: contain; }
  body.paper-theme .chat-composer { flex: none; padding-bottom: 8px; }
  body.paper-theme .chat-composer textarea { min-width: 0; }
  body.paper-theme .chat-composer button { width: 44px; height: 44px; min-height: 44px; padding: 10px; }
  body.paper-theme .chat-status { flex: none; padding-bottom: max(8px,env(safe-area-inset-bottom)); }
  body.paper-theme.admin-page .admin-topbar { display: grid; grid-template-columns: minmax(0,1fr) auto 44px; gap: 8px; padding: max(12px,env(safe-area-inset-top)) 16px 12px; }
  body.paper-theme.admin-page .admin-brand { min-width: 0; font-size: 23px; }
  body.paper-theme.admin-page .admin-back { margin: 0; max-width: 100px; }
  body.paper-theme.admin-page .language-toggle { margin: 0; }
  body.paper-theme.admin-page :is(.admin-shell,.admin-panel,.admin-editor,.admin-details,.table-wrap) { min-width: 0; }
  body.paper-theme.admin-page .admin-shell { padding-inline: 16px; padding-bottom: calc(48px + env(safe-area-inset-bottom)); }
  body.paper-theme.admin-page .table-wrap { overflow-x: auto; }
  body.paper-theme.admin-page .table-wrap table { min-width: 600px; }
  body.paper-theme.admin-page :is(.admin-editor-head,.party-admin-head,.live-admin-heading) { flex-wrap: wrap; gap: 12px; }
  body.paper-theme.admin-page .guest-table button { min-height: 44px; font-size: 12px; }
}
@media (max-width: 480px) {
  body.paper-theme :is(.account-profile-form .account-name-fields,.trip-form-grid,.trip-entry-fields,.map-form-fields,.google-place-fields) { grid-template-columns: minmax(0,1fr); }
  body.paper-theme .trip-entry-fields label:nth-child(3) { grid-column: auto; }
  body.paper-theme .guest-directory-title { flex-direction: column; }
  body.paper-theme .guest-layout-control { padding-top: 0; }
  body.paper-theme .community-people[data-columns="2"] .community-person-open { padding: 18px 12px; }
  body.paper-theme .community-people[data-columns="2"] .community-person-name { font-size: 20px; }
  body.paper-theme .song-card .song-form-actions { flex-wrap: wrap; }
  body.paper-theme :is(.song-selection,.song-search-line) { min-width: 0; }
  body.paper-theme .song-card .song-search-line button { padding-inline: 12px; }
  body.paper-theme .game-section-heading { align-items: flex-start; flex-wrap: wrap; }
  body.paper-theme .party-island .party-game-menu { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 1024px) and (max-height: 500px) and (pointer: coarse), (max-width: 760px) and (max-height: 500px) {
  body.paper-theme .opening-content { min-height: 100svh; height: auto; }
  body.paper-theme .assistant-viewport .assistant-widget-header { padding-block: 8px; }
}
