:root {
  --bg: #0c0d11; --panel: #16181f; --panel2: #1e2129; --line: #2a2e39; --text: #eceef3; --muted: #8a90a0;
  --accent: #ff3d52; --accent2: #ffcc33; --win: #35d07f; --loss: #ff5a67; --radius: 14px;
  --nav-h: calc(62px + env(safe-area-inset-bottom));
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif; -webkit-text-size-adjust: 100%; }
body.locked { overflow: hidden; }
@media (min-width: 470px) { html, body { background: #050608; } #app { border-left: 1px solid #16181f; border-right: 1px solid #16181f; } }
#app { max-width: 430px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; background: var(--bg); position: relative; padding-bottom: calc(var(--nav-h) + 16px); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
/* 16px+ on inputs stops iPhone Safari from zooming in when a field is tapped */
input, select, textarea { font-size: 16px; }

header.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: calc(12px + env(safe-area-inset-top)) 16px 10px; background: linear-gradient(var(--bg) 75%, transparent); }
.brand { font-weight: 900; letter-spacing: .06em; font-size: 20px; font-style: italic; }
.brand span { color: var(--accent); margin-left: 4px; }
.gear { background: none; border: none; color: var(--muted); padding: 6px; margin: -6px; }
.gear svg { width: 22px; height: 22px; display: block; }

.tab { display: none; padding: 0 16px; }
.tab.active { display: block; }
h2 { font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 14px 2px 8px; font-weight: 700; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.lbl { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.lbl-note { text-transform: none; letter-spacing: 0; font-weight: 500; }
.sub { margin-top: 12px; }
.sublbl { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.muted { color: var(--muted); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--panel2); border-radius: 99px; padding: 7px 12px; font-size: 14px; white-space: nowrap; transition: background .12s, border-color .12s; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.chip.ghost { background: transparent; border-style: dashed; color: var(--muted); }
.chips.big .chip { flex: 1; text-align: center; padding: 10px 0; font-weight: 700; }
.chips.big .chip.on.w { background: var(--win); border-color: var(--win); color: #062414; }
.chips.big .chip.on.l { background: var(--loss); border-color: var(--loss); }
.chips.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); }
.txt { width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; }
.txt:focus { border-color: var(--accent); }
textarea.txt { min-height: 70px; resize: vertical; }
input[type="datetime-local"].txt { min-height: 44px; }
.row { display: flex; gap: 8px; align-items: center; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.hide { display: none !important; }

.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.stat { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; position: relative; }
.stat label { font-size: 11px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; font-weight: 700; }
.stat input { width: 100%; background: none; border: none; outline: none; font-size: 26px; font-weight: 800; padding: 0; }
.stat .tag { position: absolute; top: 7px; right: 8px; font-size: 9px; letter-spacing: .1em; color: var(--muted); display: none; }
.stat.auto .tag { display: block; }

/* K/D tiers: under 1 red, 1–1.99 yellow, 2–2.99 green, 3+ shiny ruby */
.kd-bad { color: #ff5a67 !important; }
.kd-ok { color: #ffcc33 !important; }
.kd-good { color: #35d07f !important; }
.kd-ruby { color: #e0115f !important; animation: ruby 2.2s ease-in-out infinite; }
@keyframes ruby {
  0%, 100% { color: #c2104f; text-shadow: 0 0 4px rgba(224, 17, 95, .45); }
  50% { color: #ff4d8d; text-shadow: 0 0 10px rgba(255, 77, 141, .9), 0 0 18px rgba(224, 17, 95, .5); }
}
@media (prefers-reduced-motion: reduce) { .kd-ruby { animation: none; text-shadow: 0 0 8px rgba(255, 77, 141, .8); } }

.rs { display: flex; gap: 8px; }
.rs button { width: 48px; flex: none; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); font-size: 20px; font-weight: 800; }
.rs button.pos { color: var(--win); } .rs button.neg { color: var(--loss); }
.rs button.on.pos { background: var(--win); border-color: var(--win); color: #062414; }
.rs button.on.neg { background: var(--loss); border-color: var(--loss); color: #fff; }

.wrow { display: grid; grid-template-columns: 108px 1fr; gap: 8px; align-items: center; margin-bottom: 6px; }
.wrow .chip { text-align: center; }
.wrow input { padding: 8px 10px; }

.save { position: sticky; bottom: calc(var(--nav-h) + 10px); margin: 14px 0 4px; width: 100%; padding: 15px; border: none; border-radius: 14px; background: var(--accent); color: #fff; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: 15px; box-shadow: 0 8px 24px rgba(255, 61, 82, .3); z-index: 3; }
.save:active { transform: scale(.99); }
.linkbtn { display: block; margin: 6px auto 0; background: none; border: none; color: var(--muted); font-size: 13px; text-decoration: underline; padding: 8px; }
.editbar { background: #2b2210; border: 1px solid #5b4715; color: var(--accent2); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.editbar button { background: none; border: 1px solid #5b4715; color: var(--accent2); border-radius: 8px; padding: 4px 10px; }
.inline { display: flex; gap: 6px; margin-top: 8px; }
.inline .txt { padding: 8px 10px; }
.btn { border: 1px solid var(--line); background: var(--panel2); border-radius: 10px; padding: 8px 12px; font-size: 14px; white-space: nowrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.danger, .btn.danger.primary { background: var(--loss); border-color: var(--loss); color: #fff; white-space: normal; }

nav.bottom { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 430px; height: var(--nav-h); display: flex; background: rgba(18, 19, 24, .96); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 8px 0 env(safe-area-inset-bottom); z-index: 10; }
nav.bottom button { flex: 1; background: none; border: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
nav.bottom button.on { color: var(--accent); }
nav svg { width: 24px; height: 24px; }

.toolbar { display: flex; gap: 6px; align-items: center; justify-content: space-between; margin: 4px 0 10px; flex-wrap: wrap; }
.rec { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; cursor: pointer; }
.rec .r1 { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.rec .r2 { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 4px; gap: 10px; }
.rec .title { font-weight: 700; font-size: 16px; }
.rec .rsv { font-size: 14px; } .rsv.pos { color: var(--win); } .rsv.neg { color: var(--loss); }
.rec .kd { font-size: 24px; font-weight: 900; line-height: 1; text-align: right; }
.rec .kd small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.badge { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 99px; letter-spacing: .05em; }
.badge.W { background: rgba(53, 208, 127, .15); color: var(--win); } .badge.L { background: rgba(255, 90, 103, .15); color: var(--loss); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tags span { font-size: 11px; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; color: #c5c9d4; }
.tags span.warn { border-color: #5b4715; color: var(--accent2); }
.detail { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; color: #c5c9d4; }
.detail div { margin-bottom: 3px; }
.detail b { color: var(--muted); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; font-size: 14px; }
.empty .big { font-size: 18px; font-weight: 800; color: var(--text); margin-bottom: 6px; }

.seg { display: flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.seg button { flex: 1; border: none; background: none; border-radius: 8px; padding: 7px 8px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--accent); color: #fff; }
.gctl { display: grid; gap: 8px; margin-bottom: 10px; }
.chartwrap { height: 290px; position: relative; }
.chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); font-size: 14px; padding: 30px; pointer-events: none; }
.legendnote { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legendnote i { display: inline-block; width: 9px; height: 9px; background: var(--muted); margin-right: 5px; vertical-align: middle; }
.legendnote i.c { border-radius: 50%; }
.txt.preset { padding: 6px 8px; width: auto; max-width: 150px; font-size: 13px; }
.ln { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 6px; }
.ln.off { opacity: .45; }
.ln .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.ln .meta { flex: 1; min-width: 0; }
.ln .name { font-weight: 700; font-size: 14px; }
.ln .count { color: var(--muted); font-weight: 500; font-size: 12px; }
.ln .sum { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ln .ib { background: none; border: none; color: var(--muted); padding: 6px; }
.ln .ib svg { width: 18px; height: 18px; display: block; }
.add { width: 100%; border: 1px dashed var(--line); background: none; color: var(--text); border-radius: 12px; padding: 11px; font-weight: 700; }

.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 20; display: none; }
.scrim.open { display: block; }
.sheet { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 430px; max-height: 88vh; max-height: 88dvh; overflow: auto; overscroll-behavior: contain; background: var(--bg); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; z-index: 21; padding: 8px 16px calc(24px + env(safe-area-inset-bottom)); display: none; }
.sheet.open { display: block; }
.grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 10px; }
.sheethead { display: flex; justify-content: space-between; align-items: center; position: sticky; top: -8px; background: var(--bg); padding: 6px 0 10px; z-index: 2; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.sw.on { border-color: #fff; }
.fsec { margin-top: 14px; }
.fsec .sublbl { display: flex; justify-content: space-between; gap: 8px; }
.fsec .sublbl em { font-style: normal; color: var(--accent2); white-space: nowrap; }
.mrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.mrow:last-child { border-bottom: none; }

#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translateX(-50%) translateY(20px); background: #fff; color: #111; padding: 10px 16px; border-radius: 99px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 40; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Stats tab ---------- */
.pos { color: var(--win); } .neg { color: var(--loss); }
.rec-summary { margin: -4px 2px 10px; font-size: 13px; color: var(--muted); font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; }
.tile { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; min-width: 0; }
.tile > span { display: block; font-size: 11px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; font-weight: 700; }
.tile b { display: block; font-size: 22px; font-weight: 900; line-height: 1.2; }
.tile small { display: block; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kd-bad-bg { background: #ff5a67; } .kd-ok-bg { background: #ffcc33; } .kd-good-bg { background: #35d07f; } .kd-ruby-bg { background: #e0115f; }
.tierbar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; gap: 2px; }
.tierbar i { display: block; min-width: 4px; }
.tierlegend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.tierlegend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.bar { display: grid; grid-template-columns: 1fr 1.2fr auto; gap: 8px; align-items: center; font-size: 13px; margin-bottom: 5px; }
.bar div { height: 8px; background: var(--panel2); border-radius: 5px; overflow: hidden; }
.bar div i { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.bar em { font-style: normal; color: var(--muted); font-size: 12px; min-width: 64px; text-align: right; }
.hl div { font-size: 14px; padding: 7px 0; border-bottom: 1px solid var(--line); color: #c5c9d4; }
.hl div:last-child { border-bottom: none; }
.hl b { color: var(--text); }
details.bd { padding: 0; }
details.bd summary { list-style: none; display: flex; justify-content: space-between; align-items: center; padding: 13px 14px; font-weight: 700; cursor: pointer; }
details.bd summary::-webkit-details-marker { display: none; }
details.bd summary em { font-style: normal; color: var(--muted); font-size: 12px; font-weight: 600; }
details.bd summary em::after { content: ' ▾'; }
details.bd[open] summary em::after { content: ' ▴'; }
details.bd > :not(summary) { margin: 0 14px 12px; }
table.bt { width: calc(100% - 28px); border-collapse: collapse; font-size: 14px; }
table.bt th { font-size: 11px; color: var(--muted); font-weight: 700; text-align: right; padding: 4px 6px; letter-spacing: .06em; }
table.bt td { padding: 7px 6px; border-top: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; vertical-align: middle; }
table.bt td:first-child, table.bt th:first-child { text-align: left; padding-left: 0; word-break: break-word; }
table.bt td:nth-child(4) { font-weight: 800; }
table.bt td small { display: block; font-size: 10px; color: var(--muted); font-weight: 500; }
table.bt td:last-child, table.bt th:last-child { width: 34px; padding-right: 0; }
.gt { background: var(--panel2); border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 5px; line-height: 0; }
.gt svg, .gt-inline svg { width: 15px; height: 15px; }
.gt-inline { display: inline-block; vertical-align: middle; color: var(--muted); line-height: 0; }
.chipbar { display: flex; align-items: center; justify-content: space-between; background: #2b2210; border: 1px solid #5b4715; color: var(--accent2); border-radius: 10px; padding: 6px 6px 6px 12px; font-size: 13px; font-weight: 600; }
.chipbar button { background: none; border: none; color: var(--accent2); padding: 2px 8px; font-size: 14px; }
.export-only { display: none; }
.exp-title { font-weight: 800; font-size: 16px; margin: 0 2px 10px; }
.sess.live { border-color: rgba(53, 208, 127, .45); }
.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--win); margin-right: 7px; vertical-align: middle; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.sessbar { display: flex; align-items: center; gap: 4px; background: rgba(53, 208, 127, .1); border: 1px solid rgba(53, 208, 127, .4); border-radius: 12px; padding: 9px 12px; margin-bottom: 10px; font-size: 14px; cursor: pointer; }
.sessbar span:first-of-type { flex: 1; }
.sessbar .go { color: var(--muted); font-size: 13px; }
.ps { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 6px; cursor: pointer; }
.ps.on { border-color: var(--accent2); }
.ps .name { font-weight: 700; font-size: 14px; }
.ps b { white-space: nowrap; }
body.demo header.top::after { content: 'DEMO · NOT SAVED'; position: absolute; right: 50px; font-size: 10px; letter-spacing: .12em; color: var(--accent2); border: 1px solid #5b4715; padding: 3px 7px; border-radius: 99px; }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

/* multiple weapon names per type */
.wrow { align-items: start; }
.wnames { display: grid; gap: 6px; }
.wname { display: flex; gap: 6px; }
.wname .txt { flex: 1; min-width: 0; }
.wx { flex: none; width: 36px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; color: var(--muted); }
.wmore { justify-self: start; background: none; border: none; color: var(--muted); font-size: 13px; padding: 2px 2px 4px; text-decoration: underline; }

.myrs .bigrs { font-size: 26px; font-weight: 900; line-height: 1.2; }

/* personal copy: player tag under the logo */
header.top { flex-wrap: wrap; }
header.top .player { order: 3; flex-basis: 100%; font-size: 11px; color: var(--accent2); text-decoration: none; letter-spacing: .04em; margin-top: 1px; }
