/* Beyond Scorecard: app styles. Light app, brand-coloured stats. */
:root {
  --navy: #0B1A2E;
  --navy-2: #13284A;
  --navy-3: #1B3A6B;
  --gold: #F5B700;
  --gold-2: #FFD84D;
  --gold-3: #D99A00;
  --sky: #4FC3F7;
  --white: #FFFFFF;
  --muted-on-navy: #8FA3BF;
  --bg: #F4F6FA;
  --surface: #FFFFFF;
  --line: #DCE2EB;
  --text: #0B1A2E;
  --muted: #4E5E78;          /* grey-blue that stays readable on light backgrounds */
  --good: #3FA36B;  --good-bg: #E3F4EA;
  --mid: #D9A400;   --mid-bg: #FFF6D6;
  --bad: #D2564B;   --bad-bg: #FBE6E4;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(11, 26, 46, .06), 0 6px 20px rgba(11, 26, 46, .06);
  --font-title: 'Bebas Neue', 'Anton', Impact, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(90deg, var(--navy) 0%, var(--navy-2) 100%);
  color: var(--white);
  box-shadow: 0 2px 12px rgba(11, 26, 46, .25);
}
.topbar .wrap { display: flex; align-items: center; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.brand svg { width: 36px; height: 36px; }
.brand .word { font-family: var(--font-title); font-size: 26px; letter-spacing: 1px; line-height: 1; text-transform: uppercase; }
.brand .word b { color: var(--gold); font-weight: 400; }
.nav { display: flex; gap: 4px; }
.nav a {
  text-decoration: none; padding: 8px 12px; border-radius: 10px; font-weight: 600; font-size: 15px;
  color: var(--muted-on-navy); transition: background .2s, color .2s;
}
.nav a:hover { color: var(--white); background: rgba(255,255,255,.06); }
.nav a.active { color: var(--navy); background: var(--gold); }
.topsearch { flex: 1; min-width: 0; position: relative; }
.topsearch input {
  width: 100%; height: 40px; border-radius: 999px; border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.08); color: var(--white); padding: 0 16px 0 40px; outline: none;
}
.topsearch input::placeholder { color: var(--muted-on-navy); }
.topsearch input:focus { border-color: var(--gold); background: rgba(255,255,255,.12); }
.topsearch svg { position: absolute; left: 14px; top: 11px; width: 18px; height: 18px; color: var(--muted-on-navy); }
.usermenu { flex: none; position: relative; }
.usermenu button {
  width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--gold); background: var(--navy-3);
  color: var(--white); font-weight: 700; cursor: pointer;
}
.usermenu .menu {
  position: absolute; right: 0; top: 46px; background: var(--surface); color: var(--text); border-radius: 12px;
  box-shadow: var(--shadow); min-width: 220px; padding: 8px; border: 1px solid var(--line);
}
.usermenu .menu .who { font-size: 13px; color: var(--muted); padding: 6px 10px 10px; border-bottom: 1px solid var(--line); word-break: break-all; }
.usermenu .menu button {
  width: 100%; height: auto; border-radius: 8px; border: 0; background: none; color: var(--text);
  text-align: left; padding: 10px; font-weight: 600;
}
.usermenu .menu button:hover { background: var(--bg); }
.mobile-nav { display: none; }

@media (max-width: 820px) {
  .topbar .wrap { height: 56px; gap: 10px; }
  .brand .word { display: none; }
  .nav { display: none; }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--navy);
    border-top: 1px solid rgba(255,255,255,.08); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .mobile-nav a {
    flex: 1; text-align: center; text-decoration: none; color: var(--muted-on-navy); font-size: 12px; font-weight: 600;
    padding: 6px 0; border-radius: 10px;
  }
  .mobile-nav a.active { color: var(--gold); }
  .mobile-nav svg { display: block; margin: 0 auto 2px; width: 22px; height: 22px; }
  body { padding-bottom: 72px; }
}

/* ---------- Page structure ---------- */
main { padding: 24px 0 40px; min-height: 70vh; }
.section { margin-top: 24px; animation: rise .5s ease both; }
.section:nth-child(2) { animation-delay: .05s; } .section:nth-child(3) { animation-delay: .1s; }
.section:nth-child(4) { animation-delay: .15s; } .section:nth-child(5) { animation-delay: .2s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
h1, h2, h3 { margin: 0; }
.h-title { font-family: var(--font-title); font-weight: 400; letter-spacing: 1px; text-transform: uppercase; }
.page-title { font-size: clamp(36px, 7vw, 56px); line-height: .95; }
.sec-title { font-size: 28px; line-height: 1; margin-bottom: 12px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sec-title small { font-family: var(--font-body); font-size: 13px; letter-spacing: 0; text-transform: none; color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 820px) { .g2, .g3 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; min-width: 0;
}
.card h3 { font-size: 13px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); font-weight: 700; margin-bottom: 14px; }

/* Navy hero (brand area) */
.hero {
  background: radial-gradient(circle at 20% 0%, var(--navy-3) 0%, var(--navy) 65%);
  color: var(--white); border-radius: 20px; padding: 28px; position: relative; overflow: hidden;
}
.hero::after {
  content: ''; position: absolute; right: -60px; top: -60px; width: 240px; height: 240px; border-radius: 50%;
  background: radial-gradient(circle, rgba(245,183,0,.18), transparent 70%);
}
.hero .eyebrow { color: var(--gold); font-weight: 700; letter-spacing: 2px; font-size: 12px; text-transform: uppercase; }
.hero .sub { color: var(--muted-on-navy); margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); color: var(--white); text-decoration: none; cursor: pointer;
}
.chip:hover { border-color: var(--gold); }
.chip.light { background: var(--surface); border-color: var(--line); color: var(--text); }
.chip.gold { background: var(--gold); border-color: var(--gold); color: var(--navy); }
.chip .x { opacity: .7; font-weight: 700; }

/* Big search */
.bigsearch { display: flex; gap: 8px; margin-top: 18px; position: relative; z-index: 1; }
.bigsearch input {
  flex: 1; min-width: 0; height: 54px; border-radius: 14px; border: 2px solid transparent; padding: 0 18px;
  font-size: 17px; background: var(--white); color: var(--navy); outline: none;
}
.bigsearch input:focus { border-color: var(--gold); }
.btn {
  height: 44px; padding: 0 18px; border-radius: 12px; border: 0; font-weight: 700; cursor: pointer;
  background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: var(--navy);
  transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(245,183,0,.35); }
.btn.big { height: 54px; padding: 0 24px; border-radius: 14px; font-size: 16px; }
.btn.ghost { background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.btn.ghost:hover { box-shadow: none; border-color: var(--navy); }
.btn:disabled { opacity: .6; cursor: default; transform: none; }

/* ---------- Stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 820px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile {
  background: linear-gradient(160deg, var(--navy-2), var(--navy)); color: var(--white); border-radius: 16px; padding: 16px 18px;
  position: relative; overflow: hidden; min-width: 0;
}
.tile .lbl { color: var(--muted-on-navy); font-size: 12px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; }
.tile .num { font-family: var(--font-title); font-size: clamp(38px, 6vw, 52px); line-height: 1; margin-top: 6px; color: var(--white); }
.tile.key .num { color: var(--gold); }
.tile .foot { color: var(--muted-on-navy); font-size: 12px; margin-top: 4px; }
.minis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 12px; }
.mini { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.mini .lbl { color: var(--muted); font-size: 12px; font-weight: 600; }
.mini .v { font-size: 22px; font-weight: 800; margin-top: 2px; }

/* ---------- Bars ---------- */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr auto; align-items: center; gap: 12px; }
@media (max-width: 520px) { .bar-row { grid-template-columns: 96px 1fr auto; } }
.bar-row .name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .name a { text-decoration: none; }
.bar-row .name a:hover { text-decoration: underline; }
.bar-track { height: 14px; background: #E8EDF4; border-radius: 999px; overflow: hidden; }
.bar-fill {
  height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--gold-3), var(--gold));
  transition: width 1s cubic-bezier(.2,.8,.2,1);
}
.bar-fill.sky { background: linear-gradient(90deg, #2A9FD6, var(--sky)); }
.bar-fill.good { background: linear-gradient(90deg, #2F8A57, var(--good)); }
.bar-fill.mid { background: linear-gradient(90deg, #C99500, var(--mid)); }
.bar-fill.bad { background: linear-gradient(90deg, #B8463C, var(--bad)); }
.bar-row .val { font-weight: 800; font-size: 15px; min-width: 64px; text-align: right; }
.bar-row .val small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); }

/* Phase cards */
.phases { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 620px) { .phases { grid-template-columns: 1fr; } }
.phase { border-radius: 14px; padding: 14px; border: 1px solid var(--line); background: var(--surface); }
.phase.good { background: var(--good-bg); border-color: #BFE3CD; }
.phase.mid { background: var(--mid-bg); border-color: #F1DC93; }
.phase.bad { background: var(--bad-bg); border-color: #F2C3BE; }
.phase .pname { font-weight: 800; text-transform: uppercase; letter-spacing: 1px; font-size: 13px; }
.phase .big { font-family: var(--font-title); font-size: 44px; line-height: 1; margin-top: 6px; }
.phase .big small { font-family: var(--font-body); font-size: 13px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.phase .rows { margin-top: 8px; font-size: 13px; color: var(--muted); display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
.phase .rows b { color: var(--text); }
.tag { display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }
.tag.good { background: var(--good); color: #fff; } .tag.mid { background: var(--mid); color: var(--navy); } .tag.bad { background: var(--bad); color: #fff; }

/* ---------- Tables ---------- */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 700; padding: 8px 6px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 9px 6px; border-bottom: 1px solid #EDF1F6; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: #F8FAFD; }
td a { text-decoration: none; font-weight: 600; }
td a:hover { text-decoration: underline; }
.outcome { font-weight: 700; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.outcome.won { background: var(--good-bg); color: #24714A; }
.outcome.lost { background: var(--bad-bg); color: #A23D34; }
.outcome.other { background: #EEF1F5; color: var(--muted); }

/* ---------- Filters ---------- */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.filters select, .filters input {
  height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 10px;
  font-size: 15px; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text); min-width: 0;
}
.filters select:focus, .filters input:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.filter-toggle { display: none; }
@media (max-width: 820px) {
  .filter-toggle { display: inline-flex; }
  .filters.collapsed { display: none; }
}

/* Tabs (Batting / Bowling, formats) */
.tabs { display: inline-flex; background: #E6EBF2; border-radius: 12px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.tabs button, .tabs a {
  border: 0; background: none; padding: 8px 16px; border-radius: 9px; font-weight: 700; cursor: pointer; color: var(--muted);
  text-decoration: none; font-size: 15px;
}
.tabs .on { background: var(--navy); color: var(--white); box-shadow: 0 2px 8px rgba(11,26,46,.2); }

/* Player header */
.p-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.p-head .meta { color: var(--muted-on-navy); margin-top: 8px; font-size: 14px; }
.avatar {
  width: 64px; height: 64px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--gold-2), var(--gold-3)); color: var(--navy);
  font-family: var(--font-title); font-size: 30px;
}

/* Lists */
.list { display: flex; flex-direction: column; }
.list a, .list .item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid #EDF1F6; text-decoration: none; }
.list a:hover { background: #F8FAFD; }
.list .item:last-child, .list a:last-child { border-bottom: 0; }
.list .main { flex: 1; min-width: 0; }
.list .main b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .main span { font-size: 13px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .side { font-weight: 800; white-space: nowrap; }
.iconbtn { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 6px; border-radius: 8px; font-size: 18px; line-height: 1; }
.iconbtn:hover { background: var(--bg); color: var(--bad); }

/* Competition cards */
.comps { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.comp {
  display: block; text-decoration: none; border-radius: 14px; padding: 16px; background: var(--surface); border: 1px solid var(--line);
  transition: transform .2s, box-shadow .2s, border-color .2s; position: relative; overflow: hidden;
}
.comp:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--gold); }
.comp .cname { font-family: var(--font-title); font-size: 30px; line-height: 1; letter-spacing: 1px; }
.comp .cinfo { font-size: 13px; color: var(--muted); margin-top: 6px; }
.comp::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--gold); }

/* Notes and states */
.note { font-size: 13px; color: var(--muted); background: #EEF2F8; border-radius: 10px; padding: 10px 12px; margin-top: 12px; }
.note.warn { background: var(--mid-bg); color: #6B5200; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.loading { display: flex; justify-content: center; padding: 60px 0; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 4px solid #DCE3EE; border-top-color: var(--gold); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, #E8EDF4 25%, #F3F6FA 50%, #E8EDF4 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.error { background: var(--bad-bg); color: #8A2F28; border-radius: 12px; padding: 14px; }

/* ---------- Login ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(circle at 20% 10%, var(--navy-3), var(--navy) 60%); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 22px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35); animation: rise .5s ease both; }
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-logo svg { width: 52px; height: 52px; }
.auth-logo .word { font-family: var(--font-title); font-size: 32px; line-height: .9; text-transform: uppercase; }
.auth-logo .word b { color: var(--gold-3); font-weight: 400; display: block; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.auth-card label { font-size: 13px; font-weight: 700; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.auth-card input { height: 48px; border-radius: 12px; border: 1px solid var(--line); padding: 0 14px; font-size: 16px; outline: none; }
.auth-card input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245,183,0,.25); }
.auth-card .btn { height: 50px; font-size: 16px; margin-top: 4px; }
.auth-card .link { background: none; border: 0; color: var(--navy-3); font-weight: 600; cursor: pointer; padding: 0; text-decoration: underline; }
.auth-msg { font-size: 14px; border-radius: 10px; padding: 10px 12px; }
.auth-msg.ok { background: var(--good-bg); color: #24714A; }
.auth-msg.err { background: var(--bad-bg); color: #8A2F28; }

footer.site { color: var(--muted); font-size: 13px; padding: 24px 0 40px; border-top: 1px solid var(--line); margin-top: 24px; }
footer.site .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
