:root {
  --bg: #0f1420; --card: #182033; --line: #2a3550; --text: #e8ecf5; --muted: #93a0bd;
  --me: #4c9bff; --opp: #ff5d5d; --win: #3ecf8e; --loss: #ff6b6b; --accent: #f5b400;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: inherit; }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
h1, h2, h3 { margin: 0 0 10px; line-height: 1.2; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
small { color: var(--muted); font-weight: 400; }
.top { display: flex; align-items: center; gap: 24px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.top .brand { font-weight: 800; font-size: 18px; text-decoration: none; color: var(--accent); }
.top nav { display: flex; gap: 18px; flex-wrap: wrap; }
.top nav a { text-decoration: none; color: var(--muted); }
.top nav a:hover { color: var(--text); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.me { color: var(--me); } .opp { color: var(--opp); }
.note { color: var(--muted); font-size: 13px; }
.error { color: var(--loss); }
.back a { color: var(--muted); text-decoration: none; }
button, .button { background: #24304d; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; font: inherit; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .button:hover { border-color: var(--muted); }
button.on, .filter a.on { background: var(--accent); color: #1b1300; border-color: var(--accent); }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); }
.pill.ok { color: var(--win); border-color: var(--win); }

.login { max-width: 320px; margin: 12vh auto; display: grid; gap: 10px; }
.login input { padding: 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; }
.tile b { font-size: 22px; } .tile span { color: var(--muted); font-size: 13px; }
.tile.bad b { color: var(--loss); }
.filter { display: flex; gap: 8px; margin-bottom: 12px; }
.filter a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; }
.empty { color: var(--muted); }

.battles { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.battle { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: 10px; }
.battle.win { border-left-color: var(--win); } .battle.loss { border-left-color: var(--loss); }
.battle .row { display: grid; grid-template-columns: 96px 70px 1fr auto; gap: 12px; align-items: center; padding: 8px 12px; text-decoration: none; }
.battle .row:hover { background: #1d2740; border-radius: 0 10px 10px 0; }
.when, .score { display: grid; } .score { font-weight: 700; font-size: 17px; }
.decks { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; min-width: 0; }
.vs { color: var(--muted); font-size: 13px; }
.deck { display: inline-flex; gap: 1px; }
.deck img { display: block; width: 36px; height: 43px; object-fit: contain; }
.nocard { display: inline-grid; place-items: center; width: 28px; height: 34px; background: #24304d; border-radius: 4px; color: var(--muted); }

.head .headline { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.head .headline span { display: grid; }
.head .big { font-size: 34px; font-weight: 800; }
.head.win .big { color: var(--win); } .head.loss .big { color: var(--loss); }
.sides { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }

.stats { border-collapse: collapse; width: 100%; max-width: 620px; }
.stats th, .stats td { text-align: left; padding: 5px 10px 5px 0; border-bottom: 1px solid var(--line); }
.stats td:first-child { color: var(--muted); }

.replay { display: grid; grid-template-columns: minmax(280px, 430px) 1fr; gap: 20px; }
@media (max-width: 760px) { .replay { grid-template-columns: 1fr; } .battle .row { grid-template-columns: 80px 56px 1fr; } .tagcol { display: none; } }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.controls input[type=range] { flex: 1; min-width: 120px; accent-color: var(--accent); }
#timelabel { font-variant-numeric: tabular-nums; min-width: 3.2em; }
#arena { width: 100%; height: auto; display: block; border-radius: 10px; background: #0b1019; }
.grass { fill: #2c5a3a; } .river { fill: #2f6fb3; } .bridge { fill: #8a6a45; }
.tower { stroke-width: .12; fill-opacity: .35; }
.tower.me { fill: var(--me); stroke: var(--me); } .tower.opp { fill: var(--opp); stroke: var(--opp); }
.mk { cursor: pointer; }
.mk rect { stroke-width: .12; }
.mk.team rect { fill: #0e2a52; stroke: var(--me); } .mk.opponent rect { fill: #4a1414; stroke: var(--opp); }
.mk.old { opacity: .3; }
.mk.picked rect { stroke: var(--accent); stroke-width: .22; }
.timeline { list-style: none; margin: 0; padding: 0; max-height: 760px; overflow: auto; }
.timeline li { display: grid; grid-template-columns: 44px 30px 1fr auto; gap: 8px; align-items: center; padding: 4px 8px; border-left: 3px solid var(--me); border-bottom: 1px solid var(--line); cursor: pointer; }
.timeline li.opponent { border-left-color: var(--opp); background: rgba(255, 93, 93, .05); }
.timeline li.future { opacity: .35; } .timeline li.dim { display: none; }
.timeline li.picked { outline: 2px solid var(--accent); outline-offset: -2px; }
.timeline .t { font-variant-numeric: tabular-nums; color: var(--muted); }
.timeline .zone { color: var(--muted); font-size: 13px; text-align: right; }
.timeline img { display: block; object-fit: contain; }
.prose ol { padding-left: 20px; } .prose li { margin-bottom: 8px; }

.mu { border-collapse: collapse; width: 100%; }
.mu th, .mu td { text-align: left; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.mu th { color: var(--muted); font-weight: 500; font-size: 13px; }
.mu img { vertical-align: middle; }
.mu .neg { color: var(--loss); } .mu .pos { color: var(--win); }
.mu tr.clearbad td:first-child { box-shadow: inset 3px 0 0 var(--loss); padding-left: 8px; }
.mu tr.cleargood td:first-child { box-shadow: inset 3px 0 0 var(--win); padding-left: 8px; }
.pill.bad { color: var(--loss); border-color: var(--loss); }
