/* ==========================================================================
   BrawlRPG :: theme.css  (v3 - "Nightfall")
   One shared design system for every page.

   v3 keeps every v2 class name working, but rebuilds the visual language:
   deeper surfaces, calmer chrome, clearer hierarchy, a real page header,
   consistent spacing scale and shared layout primitives so pages no longer
   need to hand-roll their own colours and card styles.

   Everything is token driven. Retint the whole game from :root.
   ========================================================================== */

:root {
  /* --- surfaces ---------------------------------------------------------- */
  --bg: #070a11;
  --bg-glow-a: rgb(255 178 74 / 7%);
  --bg-glow-b: rgb(88 140 255 / 6%);
  --bg-glow-c: rgb(82 214 125 / 4%);

  --surface: #101722;
  --surface-2: #141c29;
  --surface-3: #192232;
  --surface-4: #212c3f;
  --well: #060910;

  /* --- lines ------------------------------------------------------------- */
  --line: #1e2838;
  --line-2: #283447;
  --line-3: #37455d;

  /* --- text -------------------------------------------------------------- */
  --text: #eef2f9;
  --text-2: #c4cfe0;
  --dim: #93a1b8;
  --mute: #66738a;

  /* --- brand ------------------------------------------------------------- */
  --accent: #ffb44d;
  --accent-soft: #ffcf8b;
  --accent-deep: #c8871f;
  --accent-ink: #1b1205;

  /* --- semantic ---------------------------------------------------------- */
  --ok: #52d67d;
  --ok-soft: #8fe6a8;
  --warn: #ffd166;
  --bad: #f2665b;
  --bad-soft: #ff9f94;
  --info: #78c0ff;
  --violet: #cba4ff;

  /* --- shape ------------------------------------------------------------- */
  --r-xs: 5px;
  --r-sm: 7px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-pill: 999px;

  /* --- spacing ----------------------------------------------------------- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 22px;
  --sp-6: 30px;

  /* --- layout ------------------------------------------------------------ */
  --wrap: 1220px;
  --wrap-wide: 1420px;
  --wrap-narrow: 720px;
  --gap: 14px;

  /* --- depth ------------------------------------------------------------- */
  --sh-flat: inset 0 1px 0 rgb(255 255 255 / 4%);
  --sh-1: inset 0 1px 0 rgb(255 255 255 / 4%), 0 6px 18px rgb(0 0 0 / 30%);
  --sh-2: inset 0 1px 0 rgb(255 255 255 / 5%), 0 16px 40px rgb(0 0 0 / 42%);
  --sh-3: 0 26px 64px rgb(0 0 0 / 58%);
  --ring: 0 0 0 3px rgb(255 180 77 / 26%);

  /* --- type -------------------------------------------------------------- */
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI Semibold", "Segoe UI",
    system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas,
    "Roboto Mono", monospace;

  /* --- motion ------------------------------------------------------------ */
  --ease: cubic-bezier(.2, .7, .3, 1);
  --fast: 130ms var(--ease);
  --med: 220ms var(--ease);

  color-scheme: dark;
}

/* ==========================================================================
   Reset
   ========================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 760px at 10% -16%, var(--bg-glow-a), transparent 60%),
    radial-gradient(1000px 720px at 104% -12%, var(--bg-glow-b), transparent 56%),
    radial-gradient(820px 620px at 50% 120%, var(--bg-glow-c), transparent 58%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: rgb(255 180 77 / 15%);
  overscroll-behavior-y: none;
  text-rendering: optimizeLegibility;
}

@supports (padding: env(safe-area-inset-bottom)) {
  body { padding-bottom: env(safe-area-inset-bottom); }
}

img, svg { max-width: 100%; }
svg { display: inline-block; vertical-align: middle; }

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 650;
  letter-spacing: -0.012em;
  line-height: 1.18;
  margin: 0 0 .45em;
  color: var(--text);
}
h1 { font-size: clamp(24px, 3.4vw, 32px); }
h2 { font-size: clamp(19px, 2.2vw, 23px); }
h3 { font-size: 16px; }
h4 { font-size: 13px; }

p { margin: 0 0 .9em; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 2px;
  transition: color var(--fast);
}
a:hover { color: var(--accent-soft); text-decoration: underline; }

b, strong { font-weight: 700; color: var(--text); }
small { font-size: 11.5px; }

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--sp-4) 0;
}

code, pre, kbd, samp { font-family: var(--font-mono); font-size: .92em; }

::selection { background: rgb(255 180 77 / 28%); color: #fff; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Layout
   ========================================================================== */

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding: clamp(14px, 2vw, 24px) clamp(12px, 2.2vw, 26px) 48px;
}

.wrap.wide { max-width: var(--wrap-wide); }
.wrap.narrow { max-width: var(--wrap-narrow); }

.hidden { display: none !important; }

/* Shared page header: title on the left, actions on the right. */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin: 2px 0 var(--sp-4);
}

.page-head .titles { min-width: 0; }

.page-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.page-eyebrow::before {
  content: "";
  width: 16px;
  height: 2px;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent), transparent);
}

.page-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(24px, 3.2vw, 31px);
  font-weight: 680;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text);
}

.page-sub {
  margin: 5px 0 0;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.5;
  max-width: 62ch;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

/* Stack: vertical rhythm for panels and sections. */
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.stack.tight { gap: var(--sp-2); }
.stack.loose { gap: var(--sp-5); }

/* Auto-fitting card grid. Set --min on the element to change the track. */
.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--min, 260px), 1fr));
  gap: var(--gap);
  align-items: start;
}
.grid-auto.fill { grid-template-columns: repeat(auto-fill, minmax(var(--min, 260px), 1fr)); }

/* Two-pane layout used by most game screens. Collapses on tablets. */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}
.split.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.split.side-left { grid-template-columns: minmax(0, 1fr) minmax(0, 1.55fr); }

@media (max-width: 980px) {
  .split, .split.even, .split.side-left { grid-template-columns: minmax(0, 1fr); }
}

.section-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: var(--sp-5) 0 var(--sp-3);
  color: var(--dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line-2), transparent);
}

/* Banner slots in the toolbar must not paint as empty bars. */
#tb-bar .tb-warn:empty,
#tb-bar .tb-godly:empty,
#tb-bar .tb-crewraid:empty { display: none !important; }

/* ==========================================================================
   Surfaces
   ========================================================================== */

.box,
.panel,
.card {
  background:
    linear-gradient(180deg, rgb(255 255 255 / 2.4%), transparent 160px),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
  position: relative;
  transition: border-color var(--med), box-shadow var(--med), transform var(--med);
}

/* Only interactive panels lift. */
a.card:hover,
.card.link:hover { border-color: var(--line-3); box-shadow: var(--sh-2); }

.box + .box,
.panel + .panel,
.card + .card { margin-top: var(--gap); }

/* Inside a stack the gap owns the spacing. */
.stack > .box,
.stack > .panel,
.stack > .card { margin-top: 0; }

.head,
.phead,
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  position: relative;
  padding: 12px 16px;
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  border-bottom: 1px solid var(--line-2);
  box-shadow: inset 2px 0 0 rgb(255 180 77 / 70%), var(--sh-flat);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 680;
  letter-spacing: .085em;
  text-transform: uppercase;
}

/* Amber hairline that fades out along the header. */
.head::after,
.phead::after,
.card-head::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 1px;
  width: 58%;
  background: linear-gradient(90deg, rgb(255 180 77 / 80%), transparent);
  opacity: .45;
  pointer-events: none;
}

.head small,
.phead small,
.card-head small { color: var(--dim); font-weight: 500; letter-spacing: .01em; text-transform: none; }
.head .muted,
.phead .muted { text-transform: none; letter-spacing: 0; }
.head .btn,
.phead .btn,
.head .mini,
.phead .mini { text-transform: none; letter-spacing: .01em; }

.body,
.pbody,
.card-body { padding: 16px; }

.body.tight, .pbody.tight, .card-body.tight { padding: 10px 12px; }
.body.flush, .pbody.flush, .card-body.flush { padding: 0; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn,
.mini,
button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45em;
  padding: 9px 15px;
  border: 1px solid var(--line-3);
  border-radius: var(--r-md);
  background: linear-gradient(180deg, var(--surface-4), var(--surface-3));
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: .01em;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 6%), 0 2px 6px rgb(0 0 0 / 25%);
  transition: border-color var(--fast), background-color var(--fast),
    color var(--fast), transform 90ms var(--ease), box-shadow var(--fast);
}

.btn:hover:not(:disabled),
.mini:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.btn:active:not(:disabled),
.mini:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 1px 3px rgb(0 0 0 / 35%);
}

/* Disabled controls read as inert surfaces, not washed-out brand colour. */
.btn:disabled,
.mini:disabled,
.btn.primary:disabled,
.mini.primary:disabled,
.btn.danger:disabled,
.mini.danger:disabled,
.btn.red:disabled {
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  border-color: var(--line-2);
  color: var(--mute);
  box-shadow: none;
  filter: none;
  opacity: 1;
  cursor: not-allowed;
}
.btn:disabled:hover,
.mini:disabled:hover { border-color: var(--line-2); color: var(--mute); }

.btn.primary,
.mini.primary {
  background: linear-gradient(180deg, var(--accent-soft), var(--accent));
  border-color: #ffc978;
  color: var(--accent-ink);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 45%), 0 4px 14px rgb(255 180 77 / 20%);
}
.btn.primary:hover:not(:disabled),
.mini.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffe0b5, var(--accent-soft));
  color: var(--accent-ink);
}

.btn.danger,
.mini.danger {
  background: linear-gradient(180deg, #332024, #281a1e);
  border-color: #5d3236;
  color: var(--bad-soft);
}
.btn.danger:hover:not(:disabled),
.mini.danger:hover:not(:disabled) { border-color: var(--bad); color: #ffd9d4; }

.btn.ghost,
.mini.ghost {
  background: transparent;
  border-color: var(--line-2);
  color: var(--dim);
  box-shadow: none;
}
.btn.ghost:hover:not(:disabled),
.mini.ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.mini { padding: 6px 11px; font-size: 11.5px; border-radius: var(--r-sm); }
.btn.sm { padding: 6px 11px; font-size: 12px; border-radius: var(--r-sm); }
.btn.lg { padding: 12px 20px; font-size: 14.5px; border-radius: var(--r-md); }
.btn.block { display: flex; width: 100%; }

/* Big number/stat call-to-action used on dashboards. */
.btn.tile {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 15px;
  text-align: left;
  white-space: normal;
}
.btn.tile span { color: var(--dim); font-size: 10.5px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; }
.btn.tile b { font-size: 17px; font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Forms
   ========================================================================== */

input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]),
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--well);
  color: var(--text);
  font-family: inherit;
  font-size: 16px; /* stops Android WebView from zooming the page on focus */
  line-height: 1.35;
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 35%);
  transition: border-color var(--fast), box-shadow var(--fast), background-color var(--fast);
  appearance: none;
}

textarea { min-height: 88px; resize: vertical; }

select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--dim) 50%),
    linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

input::placeholder, textarea::placeholder { color: var(--mute); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 35%), var(--ring);
}

input:disabled, select:disabled, textarea:disabled {
  opacity: .55;
  cursor: default;
}

label {
  display: block;
  margin-top: 14px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--dim);
}
label:first-child { margin-top: 0; }

input[type=checkbox], input[type=radio] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  vertical-align: -3px;
}

/* Inline "input + button" row used by shoutbox, bank, invites. */
.field-row { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.field-row > input,
.field-row > select { flex: 1 1 180px; width: auto; min-width: 0; }

/* ==========================================================================
   Tables
   ========================================================================== */

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th {
  padding: 9px 11px;
  text-align: left;
  background: var(--surface-3);
  color: var(--dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}

td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color var(--fast); }
tbody tr:hover td { background: rgb(255 255 255 / 2.6%); }

/* Numbers line up in stat tables. */
td b, td .num, .num { font-variant-numeric: tabular-nums; }

/* Wrap wide tables so they scroll inside their panel instead of the page. */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   Text helpers
   ========================================================================== */

.muted { color: var(--dim); }
.dim { color: var(--dim); }
.tiny { font-size: 11px; }

.empty {
  color: var(--mute);
  font-style: normal;
  text-align: center;
  padding: 26px 12px;
  font-size: 12.5px;
  letter-spacing: .02em;
}

.hint, .note {
  color: var(--dim);
  font-size: 12px;
  line-height: 1.55;
}

.msg {
  min-height: 20px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--ok-soft);
  transition: color var(--fast);
}
.msg.ok { color: var(--ok-soft); }
.msg.err, .msg.error { color: var(--bad-soft); }
.msg.warn { color: var(--warn); }

/* Small status pill: <span class="tag ok">Ready</span> */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-2);
  background: var(--surface-3);
  color: var(--dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
}
.tag.ok { color: var(--ok-soft); border-color: rgb(82 214 125 / 35%); background: rgb(82 214 125 / 10%); }
.tag.warn { color: var(--warn); border-color: rgb(255 209 102 / 35%); background: rgb(255 209 102 / 10%); }
.tag.bad { color: var(--bad-soft); border-color: rgb(242 102 91 / 40%); background: rgb(242 102 91 / 12%); }
.tag.accent { color: var(--accent); border-color: rgb(255 180 77 / 40%); background: rgb(255 180 77 / 12%); }

/* Key/value stat row used across character sheets. */
.kv { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv > span { color: var(--dim); font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; }
.kv > b { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ==========================================================================
   Stat grids (character sheet)
   ========================================================================== */

.statgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  background: var(--surface-2);
  padding: 8px 11px;
}
.stat span { color: var(--dim); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.stat b { color: var(--text); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat b.good { color: var(--ok-soft); }
.stat b.warn { color: var(--bad-soft); }
.stat b.money { color: var(--warn); }

/* ==========================================================================
   Progress bars
   ========================================================================== */

.bar {
  height: 8px;
  background: var(--well);
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 45%);
}
.bar span,
.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(180deg, #63e08d, #35b45f);
  transition: width var(--med);
}

.bar.lg { height: 13px; }
.bar.sm { height: 5px; }
.bar.xp span, .bar.xp i { background: linear-gradient(180deg, var(--accent-soft), var(--accent)); }
.bar.hp span, .bar.hp i { background: linear-gradient(180deg, #6ee39a, #38b465); }
.bar.mana span, .bar.mana i { background: linear-gradient(180deg, #8ccbff, #4a9ae8); }
.bar.enemy span, .bar.enemy i { background: linear-gradient(180deg, #ff9a8f, #d9463c); }

/* Label above a bar. */
.barline { margin-top: 13px; }
.barline .lab {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--dim);
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.barline .lab b { color: var(--text); letter-spacing: 0; text-transform: none; font-size: 12px; font-variant-numeric: tabular-nums; }
.barmeta { display: flex; justify-content: space-between; color: var(--mute); font-size: 11px; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Lists
   ========================================================================== */

.list { display: flex; flex-direction: column; }
.list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  border-bottom: 1px solid var(--line);
  transition: background-color var(--fast);
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: rgb(255 255 255 / 2.2%); }
.list-row .grow { flex: 1; min-width: 0; }

/* Collapsible help text keeps long rules off the phone's first screen. */
.help { margin: 0 0 6px; }
.help > summary { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; color: var(--accent);
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; list-style: none; }
.help > summary::-webkit-details-marker { display: none; }
.help > summary::before { content: "+"; display: inline-grid; place-items: center; width: 17px; height: 17px;
  border: 1px solid var(--line-3); border-radius: var(--r-xs); font-size: 12px; line-height: 1; color: var(--dim); }
.help[open] > summary::before { content: "\2212"; color: var(--accent); border-color: var(--accent); }
.help > summary:hover { color: var(--accent-soft); }
.help[open] > summary { margin-bottom: 9px; }
.help p, .help ul { color: var(--dim); font-size: 12.5px; line-height: 1.65; margin: 0 0 8px; }
.help p:last-child { margin-bottom: 0; }
/* ==========================================================================
   Focus, scrollbars, motion
   ========================================================================== */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

* { scrollbar-width: thin; scrollbar-color: var(--line-3) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--well); }
::-webkit-scrollbar-thumb {
  background: var(--line-3);
  border-radius: var(--r-pill);
  border: 2px solid var(--well);
}
::-webkit-scrollbar-thumb:hover { background: #4d5f7f; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 900px) {
  :root { --gap: 12px; }
}

@media (max-width: 799px) {
  /* The APK wraps the site in a WebView with no browser chrome. Never let a
     wide table or a long name push controls off the glass. */
  html, body { overflow-x: hidden; }
  .wrap, .box, .panel, .card, .body, .pbody, .card-body,
  .split > *, .grid-auto > * { min-width: 0; max-width: 100%; }
  table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  img, svg, video, canvas { max-width: 100%; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-actions .btn, .page-actions .qbtn { flex: 1 1 auto; }
  td, .page-sub, .list-row .grow { overflow-wrap: anywhere; }
}

@media (max-width: 620px) {
  body { font-size: 14px; }
  .wrap { padding: 12px 10px 36px; }
  .head, .phead, .card-head { padding: 10px 13px; font-size: 11.5px; }
  .body, .pbody, .card-body { padding: 12px; }
  .btn { padding: 10px 14px; }
  .page-head { align-items: flex-start; }
  .page-title { font-size: 24px; }
  .page-actions { width: 100%; }
  table { font-size: 12.5px; }
  th, td { padding: 8px 9px; }
  .statgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-auto { grid-template-columns: minmax(0, 1fr); }
}

/* Slightly larger hit targets on touch screens. */
@media (pointer: coarse) {
  .btn, .mini { min-height: 38px; }
}
