/* =====================================================================
   Tablets, touch and the fullscreen DM screen. Applies to every theme;
   load last.
   ===================================================================== */

/* Notched / rounded-corner screens (iPad, home-screen app) */
.chrome { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); padding-top: env(safe-area-inset-top); }
.grid { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); padding-bottom: max(40px, calc(env(safe-area-inset-bottom) + 24px)); }

/* Things that only exist in fullscreen mode */
.fs-only { display: none !important; }

/* ---------- Tablet portrait and small laptops: two columns ----------
   Layouts are drawn on 12 columns. Here a panel half-width or narrower
   takes one of two columns, anything wider takes the whole row. */
@media (min-width: 701px) and (max-width: 1024px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid > .panel { grid-column: span 1 !important; }
  .grid > .panel[data-w="7"], .grid > .panel[data-w="8"], .grid > .panel[data-w="9"],
  .grid > .panel[data-w="10"], .grid > .panel[data-w="11"], .grid > .panel[data-w="12"] { grid-column: span 2 !important; }
  .grid > .panel.maxed { grid-column: auto !important; }
  .topbar { gap: 8px !important; }
  .search-btn { flex: 0 0 auto !important; width: 40px; min-width: 0 !important; padding: 0 !important; justify-content: center; }
  .quick-roll { flex: 1 1 120px; min-width: 0; }
  .quick-roll input { width: 100% !important; }
  .topbar > .spacer { display: none; }
  .campaign select { max-width: 170px !important; }
  .brand .wordmark { display: none; }
}
@media (max-width: 700px) {
  .grid > .panel.maxed { grid-column: auto !important; }
  .brand .wordmark { display: none; }
}

/* ---------- Touch screens ---------- */
@media (pointer: coarse) {
  html { -webkit-tap-highlight-color: transparent; }
  button, a, select, label, .chip, .roll, .panel-head { touch-action: manipulation; }
  /* bigger targets (Apple's minimum is 44pt; 40 keeps dense panels usable) */
  .icon-btn { min-width: 40px; height: 40px; }
  .icon-btn.xs { min-width: 32px; height: 32px; }
  .btn { min-height: 40px; }
  .btn.sm { min-height: 36px; }
  .btn.xs { min-height: 30px; }
  .seg button { padding: 8px 13px; }
  .chip { padding: 5px 11px; }
  .pop-item { padding: 11px 12px; }
  .pal-item { min-height: 44px; }
  .tab { padding: 11px 14px; }
  input[type="checkbox"] { width: 18px; height: 18px; }
  input[type="range"] { min-height: 28px; }
  /* iOS zooms the page into any text field under 16px; keep them at 16 */
  .input, .input.sm, .input.xs, select, textarea, .pal-in input { font-size: 16px !important; }
  /* nothing hides behind hover on a touch screen */
  .panel-ctl { opacity: 1 !important; }
  .panel-head { min-height: 48px; }
  /* crowded headers scroll sideways instead of cutting buttons off */
  .panel-tools { overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
  .panel-tools::-webkit-scrollbar { display: none; }
  .resize { width: 34px; height: 34px; touch-action: none; }
  .resize::after { width: 11px; height: 11px; right: 6px; bottom: 6px; }
  .search-btn kbd, .slot kbd { display: none; }
  .sigil-tab { min-height: 44px; }
}

/* ---------- Fullscreen DM screen ---------- */
html.screen-mode .topbar { display: none; }
html.screen-mode .fs-only { display: inline-flex !important; }
/* (.chrome already keeps clear of the status bar; adding it again here left a gap at the top) */
html.screen-mode .layout-rail { padding-top: 6px; padding-bottom: 6px; }
/* The page stays put and only the panels scroll, like an app. (On iPad, scrolling the whole page
   used to pull Safari out of fullscreen and slide the bar around.) */
html.screen-mode, html.screen-mode body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html.screen-mode body { position: fixed; inset: 0; display: flex; flex-direction: column; }
html.screen-mode .chrome { flex: none; position: relative; }
html.screen-mode .grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; align-content: start; }
html.screen-mode .sigil-tab:not(.active) .sigil-name { display: none; }
html.screen-mode .sigil-tab:not(.active) { padding-right: 5px; }
html.screen-mode #add-panel { display: none; }
html.screen-mode .grid { padding-top: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
html.screen-mode .drawer { top: var(--chrome, 56px); }
.fs-ctl { align-items: center; gap: 4px; }
.fs-ctl .fs-roll input { width: 170px; }
.fs-exit { gap: 6px; }
@media (max-width: 1024px) { .fs-ctl .fs-roll { display: none; } }

/* Grimoire / classic: give the compact rail a little breathing room */
html.screen-mode:not(.modern) .layout-rail { padding-top: 8px; }

/* Settings: theme picker groups */
.theme-group { display: flex; align-items: center; gap: 12px; margin: 6px 0; flex-wrap: wrap; }
.theme-group > span { min-width: 58px; }

/* Invite players (DM) */
.invite { display: grid; gap: 12px; }
.invite h3 { margin: 6px 0 0; font-size: 1rem; }
.invite-code { display: grid; place-items: center; padding: 16px; border-radius: 12px; background: var(--bg-2); border: 1px dashed var(--line-2); }
.invite-code span { font: 700 30px/1 var(--mono); letter-spacing: .14em; color: var(--accent); user-select: all; }
.invite-actions { justify-content: center; }
.invite-members { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.invite-members li { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.invite-members .av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
