/* CoC Tracker — styles (mobile first) */
:root {
  --bg: #0d1016;
  --panel: #161b24;
  --panel-2: #1d2330;
  --panel-3: #242b3a;
  --line: #2a3242;
  --text: #e8ebf1;
  --muted: #8f99ab;
  --gold: #f2b84b;
  --gold-2: #ffd27a;
  --atk: #3ecf8e;
  --def: #ef6262;
  --blue: #5aa9ff;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px rgba(0, 0, 0, .18);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
body { min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; width: 100%; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; width: 100%; }
.muted { color: var(--muted); }
.gold { color: var(--gold); } .atk { color: var(--atk); } .def { color: var(--def); }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar { background: rgba(22, 27, 36, .92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-in { display: flex; align-items: center; gap: 14px; height: 62px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--gold); font-size: 20px; }
.search { flex: 1; display: flex; gap: 8px; min-width: 0; max-width: 520px; }
.search input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); color: var(--text); padding: 10px 14px; border-radius: 11px; font-size: 15px; outline: none; transition: border-color .15s; }
.search input:focus { border-color: var(--gold); }
.search button, .btn { background: var(--gold); color: #1a1300; border: 0; border-radius: 11px; padding: 0 18px; font-weight: 700; cursor: pointer; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.search button:hover, .btn:hover { background: var(--gold-2); text-decoration: none; }
.btn.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--panel-3); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 9px; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { color: var(--muted); padding: 8px 12px; border-radius: 9px; font-weight: 600; font-size: 14.5px; }
.nav a:hover { text-decoration: none; color: var(--text); background: var(--panel-2); }
.nav a.on { color: var(--text); background: var(--panel-2); }

@media (max-width: 720px) {
  .topbar-in { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; gap: 10px; }
  .brand { order: 1; font-size: 17px; }
  .nav { order: 2; }
  .nav a { padding: 6px 10px; font-size: 14px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
}

.demo-bar { margin-top: 14px; background: #2a2110; border: 1px dashed rgba(242, 184, 75, .6); color: var(--gold); border-radius: 12px; padding: 9px 14px; font-size: 13.5px; }
.demo-bar code { background: rgba(0, 0, 0, .25); color: var(--gold-2); }

/* ---------- cards & layout ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; margin: 0 0 14px; }
.card-h h3 { margin: 0; font-size: 12.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 700; }
.card-h .sub { font-size: 12.5px; color: var(--muted); }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.g2 > * { min-width: 0; }
@media (max-width: 760px) { .g2 { grid-template-columns: 1fr; } }
.page-top { margin-top: 18px; }

/* ---------- player header ---------- */
.phead { display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; margin-top: 18px; }
.thb { width: 78px; height: 78px; border-radius: 18px; background: linear-gradient(140deg, #3d3013, #80621a); display: grid; place-items: center; text-align: center; color: var(--gold); font-weight: 800; font-size: 12px; line-height: 1.05; box-shadow: inset 0 0 0 1px rgba(255, 210, 122, .25); flex: none; }
.thb b { display: block; font-size: 30px; }
.thb small { display: block; font-size: 10.5px; color: var(--gold-2); opacity: .85; margin-top: 2px; }
.pname { margin: 0; font-size: 26px; line-height: 1.15; word-break: break-word; }
.ptag { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); font-size: 13px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.copy { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 0; font-size: 12.5px; }
.clanline { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 14px; flex-wrap: wrap; }
.cbadge { width: 22px; height: 22px; border-radius: 6px; object-fit: contain; flex: none; }
.cbadge.ph { background: linear-gradient(135deg, #b8322e, #f2b84b); display: inline-block; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.pill { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; font-size: 13px; white-space: nowrap; }
.pill b { font-variant-numeric: tabular-nums; }
.lgbox { display: flex; align-items: center; gap: 12px; justify-content: flex-end; text-align: right; }
.bigtr { font-size: 27px; font-weight: 800; color: var(--gold); line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 640px) {
  .phead { grid-template-columns: auto 1fr; gap: 14px; align-items: start; }
  .thb { width: 64px; height: 64px; border-radius: 15px; }
  .thb b { font-size: 25px; }
  .pname { font-size: 22px; }
  .lgbox { grid-column: 1 / -1; justify-content: flex-start; text-align: left; border-top: 1px solid var(--line); padding-top: 14px; }
}

/* league badge */
.lgb { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 17px; border: 3px solid rgba(255, 255, 255, .22); flex: none; text-shadow: 0 1px 2px rgba(0, 0, 0, .45); }
.lgb.sm { width: 26px; height: 26px; font-size: 10.5px; border-width: 2px; }
.lgb.xs { width: 22px; height: 22px; font-size: 9.5px; border-width: 2px; }
img.lgb { background: none; border: 0; object-fit: contain; }
.f-unranked { background: #4a5060; } .f-skeleton { background: #7e838e; } .f-barbarian { background: #b5651d; } .f-archer { background: #c2437a; }
.f-wizard { background: #6a4bc4; } .f-valkyrie { background: #d97b2b; } .f-witch { background: #7a3fa0; } .f-golem { background: #6d7f5a; }
.f-pekka { background: #3d5a8a; } .f-titan { background: #a67c1c; } .f-dragon { background: #b8322e; } .f-electro { background: #2a9fd6; } .f-legend { background: linear-gradient(135deg, #6b3fd8, #a77bff); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 4px 0 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { color: var(--muted); padding: 12px 16px; font-weight: 700; font-size: 14.5px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); border-color: var(--gold); }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; margin-bottom: 14px; flex-wrap: wrap; max-width: 100%; }
.seg button { background: none; border: 0; color: var(--muted); padding: 7px 14px; border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 13.5px; }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; }

/* ---------- tiles / key-values ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; }
@media (max-width: 420px) { .tiles { grid-template-columns: 1fr 1fr; } }
.tile { background: var(--panel-2); border-radius: 11px; padding: 10px 12px; min-width: 0; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 20px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.3; overflow-wrap: anywhere; }
.tile .s { font-size: 12px; color: var(--muted); }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.kv:last-child { border-bottom: 0; }
.kv > span:first-child { color: var(--muted); }
.kv b { text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.zone { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-weight: 700; font-size: 13px; }
.zone.promotion { background: rgba(62, 207, 142, .14); color: var(--atk); }
.zone.demotion { background: rgba(239, 98, 98, .14); color: var(--def); }
.zone.safe { background: var(--panel-2); color: var(--muted); }

/* ---------- battle rows ---------- */
.slots { display: flex; gap: 4px; flex-wrap: wrap; margin: -4px 0 12px; }
.slot { width: 13px; height: 13px; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--line); }
.slot.a { background: var(--atk); border-color: var(--atk); }
.slot.d { background: var(--def); border-color: var(--def); }
.blist { display: flex; flex-direction: column; gap: 6px; }
.b { display: grid; grid-template-columns: 46px 56px 46px 1fr; gap: 8px; align-items: center; background: var(--panel-2); border-radius: 10px; padding: 8px 11px; font-variant-numeric: tabular-nums; font-size: 14px; }
.b .t { font-weight: 800; }
.b .st { color: var(--gold); letter-spacing: 1px; white-space: nowrap; }
.b .st i { color: #46506a; font-style: normal; }
.b .meta { text-align: right; min-width: 0; }
.b .op { display: block; font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b .tm { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; }
.empty { color: var(--muted); padding: 6px 0; }

/* ---------- units ---------- */
.units { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; }
.u { background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; padding: 7px 4px 6px; text-align: center; min-width: 0; }
.u .ic { width: 38px; height: 38px; border-radius: 10px; margin: 0 auto 4px; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.u .lv { font-weight: 800; font-size: 13.5px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.u .lv span { color: var(--muted); font-weight: 500; font-size: 11px; }
.u .nm { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 2px; }
.u.max { border-color: rgba(242, 184, 75, .55); }
.u.max .lv { color: var(--gold); }
.u.lock { opacity: .38; }
.u.rush { border-color: rgba(239, 98, 98, .55); }
.c-elixir { background: #8e44ad; } .c-dark { background: #3a3f58; } .c-super { background: #c0392b; } .c-siege { background: #8a6d3b; }
.c-elixir_spells { background: #2e86c1; } .c-dark_spells { background: #5b2c6f; } .c-pets { background: #1e8449; } .c-heroes { background: #b7950b; } .c-equipment { background: #566573; }
.prog { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.bar { width: 90px; height: 6px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--gold); border-radius: 4px; }
.hrow { display: grid; grid-template-columns: 74px 1fr; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.hrow:last-child { border-bottom: 0; }
.hrow .hn { font-weight: 700; font-size: 14.5px; margin-bottom: 4px; }
.eqs { display: flex; gap: 6px; flex-wrap: wrap; }
.eq { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px 8px; font-size: 12.5px; white-space: nowrap; }
.eq b { font-variant-numeric: tabular-nums; }
.eq.max { border-color: rgba(242, 184, 75, .55); }
.eq.max b { color: var(--gold); }
.eq.on { box-shadow: inset 0 0 0 1px var(--blue); }
.eq.on::before { content: "● "; color: var(--blue); font-size: 10px; }
.legend-note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.eqline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--line); }
.eqline:last-child { border-bottom: 0; }
.mini { width: 26px; height: 26px; border-radius: 7px; display: inline-grid; place-items: center; font-size: 9.5px; font-weight: 800; color: #fff; flex: none; }

/* ---------- tables ---------- */
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child, th.l, td.l { text-align: left; }
th { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; font-weight: 650; }
tr.me td { background: rgba(242, 184, 75, .12); }
tr.z-promotion td:first-child { box-shadow: inset 3px 0 var(--atk); }
tr.z-demotion td:first-child { box-shadow: inset 3px 0 var(--def); }
tr.zl td { padding: 3px 8px; font-size: 11px; border: 0; text-transform: uppercase; letter-spacing: .6px; font-weight: 700; text-align: left; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
tr.today td { background: rgba(242, 184, 75, .08); }
td sup { font-size: 10px; color: var(--muted); margin-left: 1px; }
.trend-up { color: var(--atk); font-size: 11px; } .trend-dn { color: var(--def); font-size: 11px; }
.ttag { font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); }

/* ---------- misc ---------- */
.daypick { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; margin-bottom: 14px; padding-bottom: 2px; scrollbar-width: thin; }
.daypick button { background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); border-radius: 9px; padding: 5px 11px; cursor: pointer; font-size: 13px; font-weight: 600; white-space: nowrap; }
.daypick button.on { background: var(--gold); color: #1a1300; border-color: var(--gold); }
.notice { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 14px; color: var(--muted); margin-bottom: 16px; }
.notice b { color: var(--text); }
.err { background: rgba(239, 98, 98, .1); border: 1px solid rgba(239, 98, 98, .35); color: #ffb9b9; padding: 14px 16px; border-radius: 12px; margin-top: 18px; }
.loading { padding: 50px 0; text-align: center; color: var(--muted); }
.spin { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.hero-home { text-align: center; padding: 46px 16px 30px; }
.hero-home h1 { font-size: clamp(26px, 5vw, 38px); margin: 0 0 8px; line-height: 1.15; }
.hero-home p { color: var(--muted); margin: 0 auto 22px; max-width: 560px; }
.hero-home .search { margin: 0 auto; max-width: 520px; }
.hero-home .search input { padding: 14px 16px; font-size: 16px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px 5px 6px; color: var(--text); font-size: 13.5px; }
.chip:hover { border-color: var(--gold); text-decoration: none; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 10px; }
.features .card h4 { margin: 0 0 6px; font-size: 16px; }
.features .card p { margin: 0; color: var(--muted); font-size: 14px; }
@media (max-width: 760px) { .features { grid-template-columns: 1fr; } }
.foot { color: var(--muted); font-size: 12px; text-align: center; padding: 28px 16px calc(28px + env(safe-area-inset-bottom)); }
select, .input { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); padding: 9px 10px; border-radius: 10px; font-size: 14px; min-height: 40px; max-width: 100%; }
.input { flex: 1; min-width: 150px; }
.chart { width: 100%; height: auto; display: block; margin-bottom: 12px; }
.chart text { fill: var(--muted); font-size: 11px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--panel-3); color: var(--text); padding: 9px 16px; border-radius: 10px; font-size: 14px; z-index: 50; box-shadow: var(--shadow); }
