/* Single stylesheet for the web page and the Android WebView. No external fonts or assets.
   The chrome stays neutral; colour is reserved for data. WebView can be old on minSdk 23, so
   this avoids color-mix(), :has() and container queries. */

/* ---------- tokens ---------- */
:root {
  color-scheme: dark;
  --bg: #0c0d0f;
  --surface: #141518;
  --surface-2: #1b1d21;
  --surface-3: #25272c;
  --line: rgba(255,255,255,.075);
  --line-strong: rgba(255,255,255,.15);
  --text: #f1f2f4;
  --text-2: #a9acb4;
  --text-3: #868a93;
  --invert: #f1f2f4;
  --on-invert: #101114;
  --paid: #e9b44c;
  --organic: #7b9ff6;
  --good: #4cc99b;
  --bad: #f0736d;
  --warn: #e9b44c;
  --good-soft: rgba(76,201,155,.14);
  --bad-soft: rgba(240,115,109,.14);
  --warn-soft: rgba(233,180,76,.13);
  --neutral-soft: rgba(255,255,255,.08);
  --shadow-card: none;
  --shadow-float: 0 18px 60px rgba(0,0,0,.55);
  --scrim: rgba(5,6,8,.62);
  --glass: rgba(12,13,15,.82);
  --focus: rgba(241,242,244,.55);

  --font-ui: "PingFang SC","HarmonyOS Sans SC","MiSans","Microsoft YaHei UI","Microsoft YaHei","Noto Sans SC",system-ui,sans-serif;
  --font-num: "DIN Alternate","Bahnschrift","Roboto","Segoe UI","PingFang SC","Microsoft YaHei UI",sans-serif;

  --gap: 14px;
  --pad: 20px;
  --row-y: 12px;
  --cell-x: 14px;
  --kpi-size: 28px;
  --chart-h: 300px;
  --side-w: 216px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #f4f3ef;
  --surface-3: #e9e7e1;
  --line: rgba(24,24,16,.09);
  --line-strong: rgba(24,24,16,.18);
  --text: #16171a;
  --text-2: #53565d;
  --text-3: #6d7077;
  --invert: #16171a;
  --on-invert: #ffffff;
  --paid: #b7791f;
  --organic: #3f63d8;
  --good: #0c8460;
  --bad: #cf3f3b;
  --warn: #99630f;
  --good-soft: rgba(12,132,96,.1);
  --bad-soft: rgba(207,63,59,.09);
  --warn-soft: rgba(183,121,31,.12);
  --neutral-soft: rgba(24,24,16,.06);
  --shadow-card: 0 1px 2px rgba(24,24,16,.04);
  --shadow-float: 0 18px 50px rgba(24,24,16,.17);
  --scrim: rgba(30,30,24,.32);
  --glass: rgba(245,244,240,.84);
  --focus: rgba(22,23,26,.5);
}
:root[data-density="comfortable"] { --gap: 18px; --pad: 26px; --row-y: 15px; --cell-x: 16px; --kpi-size: 32px; --chart-h: 340px; }
:root[data-density="compact"] { --gap: 10px; --pad: 14px; --row-y: 8px; --cell-x: 11px; --kpi-size: 24px; --chart-h: 250px; }
:root[data-nav="rail"] { --side-w: 64px; }
:root[data-nav="top"] { --side-w: 0px; }

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font-ui); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
h1, h2, h3, h4, p, ol { margin: 0; padding: 0; }
ol { list-style: none; }
button, input, select { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
svg { flex-shrink: 0; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.warn { color: var(--warn); }
.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border: 2px solid transparent; border-radius: 9px; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); border: 2px solid transparent; background-clip: padding-box; }

/* ---------- controls ---------- */
.field {
  height: 34px; padding: 0 10px; min-width: 0;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 9px; font-size: 13px;
  font-family: var(--font-num);
  transition: border-color .15s;
}
.field:hover { border-color: var(--text-3); }
.field:focus { outline: none; border-color: var(--text-2); }
.field::placeholder { color: var(--text-3); font-family: var(--font-ui); }
select.field {
  -webkit-appearance: none; appearance: none; font-family: var(--font-ui); padding-right: 28px; text-overflow: ellipsis;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.field-game { width: 168px; }
input[type="search"].field { font-family: var(--font-ui); -webkit-appearance: none; appearance: none; }
input[type="date"].field { cursor: pointer; }
input[type="date"].field::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .6; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px; white-space: nowrap;
  background: transparent; color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 9px; font-size: 13px; font-weight: 500;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover:not(:disabled) { background: var(--neutral-soft); }
.btn.primary { background: var(--invert); color: var(--on-invert); border-color: transparent; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--invert); opacity: .86; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px; padding: 0;
  background: transparent; color: var(--text-2); border: 0; border-radius: 9px;
  transition: background .15s, color .15s;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--neutral-soft); color: var(--text); }

:root[data-shell="android"] .export-btn { display: none; }

.link-btn { padding: 0; background: none; border: 0; color: var(--text-2); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--text); }

.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--neutral-soft); border-radius: 9px; }
.seg button { height: 30px; padding: 0 11px; white-space: nowrap; background: transparent; color: var(--text-2); border: 0; border-radius: 7px; font-size: 13px; transition: color .15s, background .15s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface-3); color: var(--text); font-weight: 600; }
:root[data-theme="light"] .seg button.on { background: var(--surface); box-shadow: 0 1px 2px rgba(24,24,16,.12); }

/* ---------- brand ---------- */
.logo { display: inline-flex; align-items: flex-end; gap: 2px; width: 28px; height: 28px; padding: 6px; flex-shrink: 0; background: var(--invert); border-radius: 8px; }
.logo i { display: block; flex: 1; background: var(--on-invert); border-radius: 1px; }
.logo i:nth-child(1) { height: 40%; }
.logo i:nth-child(2) { height: 68%; }
.logo i:nth-child(3) { height: 100%; }
.logo-lg { width: 44px; height: 44px; padding: 10px; gap: 3px; border-radius: 12px; }

/* ---------- login ---------- */
.login-wrap { position: relative; min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; overflow: hidden; }
.login-bars {
  position: absolute; inset: auto 0 0 0; height: 46vh; opacity: .55;
  background: repeating-linear-gradient(90deg, var(--neutral-soft) 0 34px, transparent 34px 46px);
  -webkit-mask-image: linear-gradient(100deg, transparent 8%, #000 100%), linear-gradient(to top, #000, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to top left, #000 8%, transparent 62%);
}
.login-card { position: relative; width: 100%; max-width: 320px; display: flex; flex-direction: column; align-items: center; }
.login-card h1 { margin: 18px 0 26px; font-size: 20px; font-weight: 600; letter-spacing: .02em; }
.login-card input { width: 100%; height: 44px; padding: 0 14px; background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: 11px; font-size: 15px; }
.login-card input:focus { outline: none; border-color: var(--text-2); }
.login-card input::placeholder { color: var(--text-3); }
.login-card .btn { width: 100%; height: 44px; margin-top: 10px; border-radius: 11px; font-size: 15px; }
.err { min-height: 20px; margin-top: 12px; color: var(--bad); font-size: 13px; }

/* ---------- shell ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 25; width: var(--side-w); display: flex; flex-direction: column; padding: 18px 12px; background: var(--bg); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; color: var(--text); text-decoration: none; font-size: 15px; font-weight: 600; white-space: nowrap; }
.tabs { display: flex; flex-direction: column; gap: 2px; margin-top: 26px; }
.tab { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 10px; white-space: nowrap; background: transparent; color: var(--text-2); border: 0; border-radius: 9px; font-size: 14px; text-align: left; transition: background .15s, color .15s; }
.tab svg { width: 18px; height: 18px; }
.tab:hover { color: var(--text); background: var(--neutral-soft); }
.tab.active { color: var(--text); background: var(--neutral-soft); font-weight: 600; }

:root[data-nav="rail"] .brand-name, :root[data-nav="rail"] .tab span { display: none; }
:root[data-nav="rail"] .sidebar { padding: 18px 10px; align-items: center; }
:root[data-nav="rail"] .brand { padding: 0; }
:root[data-nav="rail"] .tab { justify-content: center; width: 44px; height: 42px; padding: 0; }
:root[data-nav="rail"] .tab svg { width: 20px; height: 20px; }

:root[data-nav="top"] .sidebar { position: sticky; top: 0; inset: auto; width: auto; height: 54px; flex-direction: row; align-items: center; gap: 26px; padding: 0 24px; border-right: 0; border-bottom: 1px solid var(--line); }
:root[data-nav="top"] .tabs { flex-direction: row; margin: 0; }
:root[data-nav="top"] .tab { width: auto; padding: 7px 12px; }
:root[data-nav="top"] .tab svg { display: none; }
:root[data-nav="top"] .topbar { position: static; }
:root[data-nav="top"] main, :root[data-nav="top"] .topbar { max-width: 1520px; margin-left: auto; margin-right: auto; }

.shell { min-width: 0; margin-left: var(--side-w); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px;
  min-height: 62px; padding: calc(12px + env(safe-area-inset-top)) 24px 12px;
  background: var(--glass); -webkit-backdrop-filter: saturate(150%) blur(14px); backdrop-filter: saturate(150%) blur(14px);
}
.page-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 12px; min-width: 0; }
.page-title h1 { font-size: 20px; font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.page-meta { display: inline-flex; align-items: center; gap: 7px; color: var(--text-3); font-size: 12px; font-family: var(--font-num); white-space: nowrap; }
.page-meta:empty { display: none; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.status-dot.warn { background: var(--warn); }
.status-dot.busy { background: var(--organic); animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.topbar-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.ctl-group { display: none; align-items: center; gap: 8px; min-width: 0; }
.ctl-global { display: flex; gap: 2px; margin-left: 4px; }
body[data-tab="live"] .ctl-group[data-for="live"],
body[data-tab="day"] .ctl-group[data-for="day"],
body[data-tab="overview"] .ctl-group[data-for="range"],
body[data-tab="rank"] .ctl-group[data-for="range"],
body[data-tab="rating"] .ctl-group[data-for="range"],
body[data-tab="behavior"] .ctl-group[data-for="behavior"] { display: flex; }
.date-range { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 12px; }
.date-range .field { width: 128px; }
#liveDate, #dayDate { width: 132px; }

.progress { flex-basis: 100%; }
.bar { height: 3px; background: var(--neutral-soft); border-radius: 3px; overflow: hidden; }
#barFill { height: 100%; width: 0; background: var(--text); border-radius: 3px; transition: width .25s; }
.progress-text { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; color: var(--text-2); font-size: 12px; font-family: var(--font-num); }

main { padding: 6px 24px 40px; max-width: 1900px; }
.panel { display: flex; flex-direction: column; gap: var(--gap); animation: rise .28s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- notices ---------- */
.notice { padding: 10px 14px; color: var(--warn); background: var(--warn-soft); border-radius: 10px; font-size: 13px; line-height: 1.6; }
.notice.bad { color: var(--bad); background: var(--bad-soft); }

/* ---------- KPI strip: hairlines come from the grid gap, so wrapping needs no extra rules ---------- */
.kpi-strip { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-card); }
.kpi-strip.n5 { grid-template-columns: 1.35fr repeat(4, minmax(0,1fr)); }
.kpi-strip.n6 { grid-template-columns: repeat(6, minmax(0,1fr)); }
.kpi { min-width: 0; padding: var(--pad); background: var(--surface); }
.kpi-label { color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { margin-top: 8px; color: var(--text); font-family: var(--font-num); font-size: var(--kpi-size); font-weight: 500; line-height: 1.15; letter-spacing: -.005em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value.pos { color: var(--good); }
.kpi-value.neg { color: var(--bad); }
.kpi:first-child .kpi-value { font-size: calc(var(--kpi-size) + 4px); }
.kpi-strip.n6 .kpi:first-child .kpi-value { font-size: var(--kpi-size); }
.cur { margin-right: 2px; color: var(--text-3); font-size: .62em; font-weight: 400; }
.dec { color: var(--text-3); font-size: .68em; }
.pos .dec, .neg .dec, .pos .cur, .neg .cur { color: inherit; opacity: .72; }
.kpi-sub { display: flex; flex-wrap: wrap; gap: 2px 10px; min-height: 18px; margin-top: 8px; color: var(--text-3); font-size: 12px; font-family: var(--font-num); line-height: 1.5; }
.delta { font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--text-2); }
.skeleton { height: 72px; border-radius: 8px; background: linear-gradient(90deg, var(--neutral-soft) 25%, transparent 50%, var(--neutral-soft) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- cards ---------- */
.card { min-width: 0; padding: var(--pad); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-card); }
.card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 14px; }
.card-head h3 { font-size: 15px; font-weight: 600; }
.card-sub { color: var(--text-3); font-size: 12px; font-family: var(--font-num); }
.card-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.card-tools input[type="search"] { width: 170px; }
.card-foot { margin-top: 12px; color: var(--text-3); font-size: 12px; line-height: 1.7; }
.count { margin-left: 4px; color: var(--text-3); font-family: var(--font-num); font-size: 13px; font-weight: 400; }

.chart { width: 100%; height: var(--chart-h); }
.chart-grid { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(0,1fr); gap: var(--gap); }
.chart-grid.movers { grid-template-columns: repeat(2, minmax(0,1fr)); }
.chart-grid.rating-grid { grid-template-columns: minmax(0,1fr) minmax(0,1.7fr); }
.live-blocks { display: flex; flex-direction: column; gap: var(--gap); }
.live-chart-layout { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: var(--gap); }
.live-chart-layout.single { grid-template-columns: minmax(0,1fr); }
.live-chart-layout.single .top-card { display: none; }
:root[data-order="table"] #liveDetailBlock { order: -1; }

/* ---------- ranked lists ---------- */
.top-list { display: flex; flex-direction: column; gap: 2px; margin: -4px -8px; }
.top-item { position: relative; display: grid; grid-template-columns: 18px minmax(0,1fr) auto auto; align-items: center; gap: 8px; width: 100%; padding: 8px 8px 11px; background: transparent; border: 0; border-radius: 8px; text-align: left; font-size: 13px; transition: background .15s; }
.top-item:hover { background: var(--neutral-soft); }
.top-rank { color: var(--text-3); font-family: var(--font-num); font-size: 12px; }
.top-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-cost { color: var(--text-2); font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 12px; }
.top-roi { min-width: 44px; text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.empty { padding: 34px 12px; color: var(--text-3); font-size: 13px; text-align: center; }

.mover-list { display: flex; flex-direction: column; margin: -6px -8px; }
.mover-item { display: grid; grid-template-columns: minmax(0,1fr) auto 64px; align-items: center; gap: 12px; width: 100%; padding: 9px 8px; background: transparent; border: 0; border-radius: 8px; text-align: left; font-size: 13px; transition: background .15s; }
.mover-item:hover { background: var(--neutral-soft); }
.mover-item > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mover-amount { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.mover-pct { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; color: var(--text-3); font-size: 12px; }

/* ---------- split bar ---------- */
.split { padding: 14px var(--pad); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-card); }
.split-track { display: flex; gap: 2px; height: 6px; border-radius: 6px; overflow: hidden; background: var(--neutral-soft); }
.split-track i { display: block; min-width: 2px; }
.split-track .paid { background: var(--paid); }
.split-track .organic { background: var(--organic); }
.split-legend { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 20px; margin-top: 10px; color: var(--text-2); font-size: 13px; }
.split-legend span { display: inline-flex; align-items: center; gap: 7px; }
.split-legend b { color: var(--text); font-family: var(--font-num); font-weight: 500; font-variant-numeric: tabular-nums; }
.split-legend em { color: var(--text-3); font-family: var(--font-num); font-style: normal; font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 2px; }
.dot.paid { background: var(--paid); }
.dot.organic { background: var(--organic); }

/* ---------- tables ---------- */
.table-wrap, .table-scroll { overflow: auto; margin: 0 calc(var(--pad) * -1); -webkit-overflow-scrolling: touch; }
.table-scroll { max-height: 72vh; }
.live-table-wrap { margin-bottom: calc(var(--pad) * -.5); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; white-space: nowrap; }
thead th { position: sticky; top: 0; z-index: 2; padding: 8px var(--cell-x); background: var(--surface); color: var(--text-3); font-weight: 500; font-size: 12px; text-align: left; border-bottom: 1px solid var(--line-strong); }
th.num, td.num { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
th.num { font-family: var(--font-ui); }
tbody td { padding: var(--row-y) var(--cell-x); border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr[data-open]:hover td { background: var(--surface-2); cursor: pointer; }
th:first-child, td:first-child { position: sticky; left: 0; z-index: 1; padding-left: var(--pad); background: var(--surface); }
thead th:first-child { z-index: 3; }
th:last-child, td:last-child { padding-right: var(--pad); }
th[data-sort] { cursor: pointer; user-select: none; -webkit-user-select: none; }
th[data-sort]:hover, th.sorted { color: var(--text); }
th .arrow { display: inline-block; width: 11px; font-size: 9px; text-align: right; }
.game-name { font-weight: 500; }
.game-name .dot { display: inline-block; margin-right: 8px; vertical-align: 1px; }
.game-sub { display: block; margin-top: 2px; color: var(--warn); font-size: 12px; font-weight: 400; }
.roi-partial { margin-left: 5px; color: var(--warn); font-family: var(--font-ui); font-size: 11px; }
.tag { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 12px; }
.spark { display: block; width: 72px; height: 22px; }
.spark polyline { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.grade { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 7px; border-radius: 6px; font-family: var(--font-num); font-weight: 600; font-size: 12px; }
.grade-cell { color: var(--text-3); font-size: 12px; }
.grade.S { background: var(--good); color: var(--surface); }
.grade.A { background: var(--good-soft); color: var(--good); }
.grade.B { background: var(--neutral-soft); color: var(--text-2); }
.grade.C { background: var(--warn-soft); color: var(--warn); }
.grade.D { background: var(--bad-soft); color: var(--bad); }
.status-cell { display: inline-flex; align-items: center; gap: 7px; color: var(--text-3); font-size: 12px; }
.status-cell.warn { color: var(--warn); white-space: normal; max-width: 220px; }

/* live detail: table or cards */
.mobile-live-cards { display: none; grid-template-columns: repeat(auto-fill, minmax(250px,1fr)); gap: 10px; }
#mobileLiveSort { display: none; }
:root[data-detail="cards"] .live-table-wrap { display: none; }
:root[data-detail="cards"] .mobile-live-cards { display: grid; }
:root[data-detail="cards"] #mobileLiveSort { display: block; }
.mobile-game-card { min-width: 0; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; }
.mobile-game-card h4 { margin-bottom: 10px; font-size: 14px; font-weight: 500; line-height: 1.45; overflow-wrap: anywhere; }
.mobile-compact-metrics { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(0,1fr) auto; gap: 10px 14px; margin: 0; }
.mobile-compact-metrics > div { min-width: 0; }
.mobile-compact-metrics > div:last-child { text-align: right; }
.mobile-compact-metrics dt { margin-bottom: 3px; color: var(--text-3); font-size: 12px; white-space: nowrap; }
.mobile-compact-metrics dd { margin: 0; font-family: var(--font-num); font-size: 17px; font-variant-numeric: tabular-nums; line-height: 1.3; overflow-wrap: anywhere; }

/* ---------- footnote ---------- */
.footnote { padding: 2px 2px; color: var(--text-3); font-size: 12px; line-height: 1.8; }
.footnote summary { width: -webkit-fit-content; width: fit-content; cursor: pointer; color: var(--text-2); }
.footnote summary:hover { color: var(--text); }
.footnote p { max-width: 860px; margin-top: 6px; }

/* ---------- action board ---------- */
.actions { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: var(--gap); align-items: start; }
.action-col h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.action-col h3 i { width: 8px; height: 8px; border-radius: 50%; }
.action-col.good h3 i { background: var(--good); }
.action-col.warn h3 i { background: var(--warn); }
.action-col.bad h3 i { background: var(--bad); }
.action-list { display: flex; flex-direction: column; margin: 0 -8px; }
.action-item { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 2px 10px; width: 100%; padding: 9px 8px; background: transparent; border: 0; border-radius: 8px; text-align: left; font-size: 13px; transition: background .15s; }
.action-item:hover { background: var(--neutral-soft); }
.action-item .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.action-item .verdict { color: var(--text-2); font-size: 12px; }
.action-item .meta { grid-column: 1 / -1; color: var(--text-3); font-size: 12px; font-family: var(--font-num); }
.action-more { padding: 8px 0 0; color: var(--text-3); font-size: 12px; }

/* ---------- game detail ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; justify-content: flex-end; background: var(--scrim); animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal-card { width: min(640px, 100%); height: 100%; padding: 22px 24px 28px; overflow: auto; background: var(--surface); border-left: 1px solid var(--line-strong); box-shadow: var(--shadow-float); animation: drawer .24s cubic-bezier(.2,.8,.2,1); }
@keyframes drawer { from { transform: translateX(28px); opacity: .4; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { font-size: 20px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.modal-tags { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; color: var(--text-2); font-size: 13px; }
.modal-tags .grade { margin-right: 4px; }
.modal-stats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 1px; margin-bottom: 18px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.modal-stats > div { min-width: 0; padding: 11px 12px; background: var(--surface); }
.modal-stats .l { color: var(--text-3); font-size: 12px; }
.modal-stats .v { margin-top: 3px; font-family: var(--font-num); font-size: 16px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-parts { margin-top: 18px; }
.score-parts h4 { margin-bottom: 10px; font-size: 14px; font-weight: 600; }
.score-row { display: grid; grid-template-columns: 84px minmax(0,1fr) 30px; align-items: center; gap: 10px; padding: 5px 0; color: var(--text-2); font-size: 13px; }
.score-track { height: 5px; background: var(--neutral-soft); border-radius: 5px; overflow: hidden; }
.score-track i { display: block; height: 100%; background: var(--text-2); border-radius: 5px; }
.score-row b { text-align: right; color: var(--text); font-family: var(--font-num); font-weight: 500; }

/* ---------- appearance popover ---------- */
.popover { position: fixed; top: 58px; right: 24px; z-index: 40; width: 292px; padding: 14px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow-float); animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }
.pref + .pref { margin-top: 14px; }
.pref h4 { margin-bottom: 7px; color: var(--text-2); font-size: 12px; font-weight: 500; }
.pref .seg { display: flex; }
.pref .seg button { flex: 1; }
.pref-choices { display: flex; gap: 8px; }
.pref-choices button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; padding: 6px 6px 7px; background: transparent; color: var(--text-2); border: 1px solid var(--line); border-radius: 10px; font-size: 12px; transition: border-color .15s, color .15s; }
.pref-choices svg { width: 100%; height: auto; max-width: 74px; border-radius: 5px; }
.pref-choices button:hover { color: var(--text); border-color: var(--line-strong); }
.pref-choices button.on { color: var(--text); border-color: var(--text); font-weight: 600; }
.pref-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; padding-top: 11px; border-top: 1px solid var(--line); color: var(--text-3); font-size: 12px; }

/* ---------- quick search ---------- */
.palette { position: fixed; inset: 0; z-index: 60; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; background: var(--scrim); animation: fade .14s ease-out; }
.palette-card { width: min(520px, 100%); max-height: 60vh; display: flex; flex-direction: column; overflow: hidden; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow-float); }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--line); color: var(--text-3); }
.palette-input svg { width: 18px; height: 18px; }
.palette-input input { flex: 1; min-width: 0; height: 48px; padding: 0; background: transparent; border: 0; color: var(--text); font-size: 15px; }
.palette-input input:focus { outline: none; }
.palette-input input::placeholder { color: var(--text-3); }
kbd { padding: 1px 6px; color: var(--text-3); border: 1px solid var(--line-strong); border-radius: 5px; font: 11px var(--font-num); }
.palette-list { padding: 6px; overflow: auto; }
.palette-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 9px 10px; background: transparent; border: 0; border-radius: 8px; color: var(--text); text-align: left; font-size: 14px; }
.palette-item span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item small { flex-shrink: 0; color: var(--text-3); font-size: 12px; }
.palette-item.on { background: var(--neutral-soft); }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 70; max-width: min(460px, calc(100% - 32px)); padding: 10px 16px; transform: translateX(-50%); background: var(--invert); color: var(--on-invert); border-radius: 10px; box-shadow: var(--shadow-float); font-size: 13px; animation: rise .2s ease-out; }

/* ---------- responsive ---------- */
@media (min-width: 1800px) {
  :root { --kpi-size: 32px; --chart-h: 340px; }
  :root[data-density="compact"] { --kpi-size: 26px; --chart-h: 280px; }
}
@media (max-width: 1320px) {
  .kpi-strip.n6 { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .live-chart-layout { grid-template-columns: minmax(0,1fr) 280px; }
}
@media (max-width: 1100px) {
  .kpi-strip.n5 { grid-template-columns: repeat(6, minmax(0,1fr)); }
  .kpi-strip.n5 .kpi { grid-column: span 2; }
  .kpi-strip.n5 .kpi:nth-child(-n+2) { grid-column: span 3; }
  .live-chart-layout, .chart-grid, .chart-grid.rating-grid { grid-template-columns: minmax(0,1fr); }
  .actions { grid-template-columns: minmax(0,1fr); }
  .topbar { position: static; }
}
@media (max-width: 760px) {
  :root { --side-w: 0px; --pad: 15px; --kpi-size: 22px; --chart-h: 240px; --cell-x: 11px; }
  :root[data-density="comfortable"] { --pad: 18px; --kpi-size: 24px; --chart-h: 270px; }
  :root[data-density="compact"] { --pad: 12px; --kpi-size: 20px; --chart-h: 210px; }
  :root[data-nav] .sidebar {
    position: fixed; inset: auto 0 0 0; z-index: 25; flex-direction: row; align-items: stretch; gap: 0;
    width: auto; height: calc(58px + env(safe-area-inset-bottom)); padding: 0 6px env(safe-area-inset-bottom);
    background: var(--glass); -webkit-backdrop-filter: saturate(150%) blur(14px); backdrop-filter: saturate(150%) blur(14px);
    border: 0; border-top: 1px solid var(--line);
  }
  :root[data-nav] .brand { display: none; }
  :root[data-nav] .tabs { flex: 1; flex-direction: row; margin: 0; }
  :root[data-nav] .tab { flex: 1; flex-direction: column; justify-content: center; gap: 3px; width: auto; height: auto; padding: 0; background: transparent; color: var(--text-3); font-size: 11px; font-weight: 500; }
  :root[data-nav] .tab span { display: block; }
  :root[data-nav] .tab svg { display: block; width: 20px; height: 20px; }
  :root[data-nav] .tab.active { color: var(--text); }
  :root[data-nav] main, :root[data-nav] .topbar { max-width: none; }
  .pref-nav { display: none; }

  /* Installed to the home screen the page runs under the status bar, hence the top inset. */
  .topbar { position: static; min-height: 0; padding: calc(12px + env(safe-area-inset-top)) 14px 8px; gap: 8px; }
  .page-title { flex: 1; min-width: 0; padding-right: 100px; }
  .page-title h1 { font-size: 19px; }
  .topbar-controls { display: contents; }
  .ctl-global { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 8px; margin: 0; }
  .ctl-group[data-for] { width: 100%; flex-wrap: wrap; }
  .ctl-group[data-for="live"] .field-game { flex: 1 1 100%; width: auto; }
  .ctl-group[data-for="behavior"] .field-game { flex: 1 1 100%; width: auto; }
  #liveDate, #dayDate { flex: 1; width: auto; }
  .date-range { flex: 1 1 100%; }
  .date-range .field { flex: 1; width: auto; }
  .ctl-group .seg { flex: 1; }
  .ctl-group .seg button { flex: 1; padding: 0 6px; }
  #pullBtn { flex: 1; }

  main { padding: 6px 14px calc(76px + env(safe-area-inset-bottom)); }
  .kpi-strip { border-radius: 12px; }
  .kpi-strip.n5, .kpi-strip.n6 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .kpi-strip.n5 .kpi, .kpi-strip.n5 .kpi:nth-child(-n+2) { grid-column: span 1; }
  .kpi-strip.n5 .kpi:first-child { grid-column: span 2; }
  .kpi-strip.n5 .kpi:first-child .kpi-value { font-size: calc(var(--kpi-size) + 8px); }
  .kpi-label { font-size: 12px; }
  .card, .split { border-radius: 12px; }
  .chart-grid.movers { grid-template-columns: minmax(0,1fr); }
  .card-head { margin-bottom: 12px; }
  .card-tools { width: 100%; }
  .card-tools input[type="search"] { flex: 1; width: auto; }
  .card-tools .seg { flex: 0 0 auto; }

  /* The phone always gets compact cards; the wide comparison table stays on larger screens. */
  :root[data-detail] .live-table-wrap { display: none; }
  :root[data-detail] .mobile-live-cards { display: grid; grid-template-columns: minmax(0,1fr); }
  :root[data-detail] #mobileLiveSort { display: block; flex: 1; min-width: 0; }
  #liveDetailMode + .seg { display: none; }

  table { font-size: 13px; }
  th:first-child, td:first-child { min-width: 7.5em; max-width: 148px; white-space: normal; }

  .modal { align-items: flex-end; }
  .modal-card { width: 100%; height: auto; max-height: 92vh; padding: 18px 15px calc(22px + env(safe-area-inset-bottom)); border-left: 0; border-radius: 16px 16px 0 0; animation-name: sheet; }
  @keyframes sheet { from { transform: translateY(32px); opacity: .4; } }
  .modal-stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .popover { top: calc(54px + env(safe-area-inset-top)); left: 14px; right: 14px; width: auto; }
  .palette { padding-top: calc(56px + env(safe-area-inset-top)); }
  kbd { display: none; }
  .toast { bottom: calc(72px + env(safe-area-inset-bottom)); }
}
@media (max-width: 360px) {
  .mobile-compact-metrics { gap: 7px; }
  .mobile-compact-metrics dd { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  :root[data-motion="auto"] *, :root[data-motion="auto"] *::before, :root[data-motion="auto"] *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
