:root {
  --bg: #f2f2f7; --card: #ffffff; --text: #111; --sub: #6b6b70; --line: rgba(60,60,67,.14);
  --accent: #1c7d2e; --accent-soft: rgba(28,125,46,.12); --red: #d92d20; --orange: #c2410c;
  --glass: rgba(255,255,255,.72); --chip: rgba(120,120,128,.14);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000; --card: #1c1c1e; --text: #f5f5f7; --sub: #98989f; --line: rgba(84,84,88,.6);
          --accent: #4cc761; --accent-soft: rgba(76,199,97,.16); --red: #ff6b5e; --orange: #ff9f43;
          --glass: rgba(30,30,32,.72); --chip: rgba(120,120,128,.26); }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.35 var(--font); }
body { padding: env(safe-area-inset-top) 0 0; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select { font: inherit; color: var(--text); }
.splash { display: grid; place-items: center; height: 80vh; }
.splash img { width: 96px; height: 96px; border-radius: 22px; }

.page { max-width: 680px; margin: 0 auto; padding: 0 16px calc(110px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: 10px 16px 8px; margin: 0 -16px 8px; background: var(--glass);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); }
.topbar h1 { font-size: 22px; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .back { font-size: 26px; color: var(--accent); padding: 0 6px 0 0; }
.big-title { font-size: 32px; font-weight: 800; margin: 18px 0 12px; }
.sub { color: var(--sub); font-size: 13px; }
.section { color: var(--sub); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; margin: 18px 4px 6px; }
.card { background: var(--card); border-radius: 14px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; min-height: 52px; position: relative; width: 100%; text-align: left; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 12px; right: 0; border-top: .5px solid var(--line); }
.row.sel { background: var(--accent-soft); }
.row.target { box-shadow: inset 3px 0 0 var(--accent); }
.row.dim { opacity: .45; }
.grow { flex: 1; min-width: 0; }
.name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos { color: var(--sub); font-size: 12px; font-weight: 400; margin-left: 4px; }
.slot { width: 40px; flex: none; text-align: center; font-size: 12px; font-weight: 700; padding: 4px 0; border-radius: 8px; background: var(--chip); }
.shot { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex: none; background: var(--chip); }
.shot.sm { width: 30px; height: 30px; }
.stats { display: flex; gap: 0; margin-top: 2px; }
.stats div { width: 38px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 600; }
.stats div span { display: block; font-size: 10px; color: var(--sub); font-weight: 400; }
.zr { text-align: right; font-variant-numeric: tabular-nums; flex: none; }
.zr b { display: block; font-size: 15px; }
.zr .up { color: var(--accent); font-size: 12px; font-weight: 600; } .zr .down { color: var(--red); font-size: 12px; font-weight: 600; }
.empty { color: var(--sub); font-style: italic; }

.btn { background: var(--accent); color: #fff; font-weight: 600; border-radius: 12px; padding: 12px 16px; width: 100%; }
.btn.secondary { background: var(--chip); color: var(--text); }
.btn.danger { background: var(--red); }
.btn:disabled { opacity: .45; }
.btn.small { width: auto; padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.field { width: 100%; padding: 12px 14px; border-radius: 12px; border: 0; background: var(--card); margin: 6px 0 12px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 6px 12px; border-radius: 999px; background: var(--chip); font-size: 14px; font-weight: 600; }
.chip.on { background: var(--accent); color: #fff; }
.tag { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--chip); color: var(--sub); }
.tag.red { background: rgba(217,45,32,.14); color: var(--red); }
.tag.green { background: var(--accent-soft); color: var(--accent); }

.dock { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30;
  display: flex; gap: 2px; padding: 6px; border-radius: 26px; background: var(--glass);
  backdrop-filter: saturate(180%) blur(22px); -webkit-backdrop-filter: saturate(180%) blur(22px);
  box-shadow: 0 6px 24px rgba(0,0,0,.14), inset 0 0 0 .5px var(--line); max-width: calc(100vw - 20px); }
.dock button { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 54px; padding: 6px 4px; border-radius: 20px; font-size: 10px; color: var(--sub); }
.dock button svg { width: 24px; height: 24px; }
.dock button.on { color: var(--accent); background: var(--accent-soft); }

table.st { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13px; }
.st-wrap { overflow-x: auto; background: var(--card); border-radius: 14px; }
table.st th, table.st td { padding: 9px 6px; text-align: right; white-space: nowrap; }
table.st th { color: var(--sub); font-weight: 600; font-size: 12px; position: sticky; top: 0; background: var(--card); cursor: pointer; }
table.st th.on { color: var(--text); font-weight: 800; }
table.st td:first-child, table.st th:first-child { text-align: left; position: sticky; left: 0; background: var(--card); max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
table.st tr + tr td { border-top: .5px solid var(--line); }
table.st tr.me td { color: var(--accent); font-weight: 700; }

.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--bg); width: 100%; max-width: 680px; max-height: 88vh; overflow-y: auto; border-radius: 18px 18px 0 0;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); animation: up .22s cubic-bezier(.2,.9,.3,1); }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
@keyframes up { from { transform: translateY(40%); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 60;
  background: #222; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; }
.toast.err { background: var(--red); }
.tray { position: sticky; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 10; margin-top: 12px; padding: 10px 12px;
  border-radius: 18px; background: var(--glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: 0 4px 18px rgba(0,0,0,.12); }
.mini { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 2px; border-radius: 999px; background: var(--accent-soft); font-size: 12px; font-weight: 600; margin: 2px; }
.mini.pick { padding: 4px 8px; }
.code { font: 600 28px ui-monospace, Menlo, monospace; letter-spacing: .3em; text-align: center; }
.center { text-align: center; }
.mt { margin-top: 12px; }
.hstack { display: flex; gap: 8px; align-items: center; }
.live { color: var(--red); font-weight: 700; font-size: 11px; }
