/* ==========================================================================
   Allmand Cricket Tracker — style.css
   Mobile-first dark theme. Cricket green / ball red / gold.
   ========================================================================== */

:root {
  --green: #3b6cff;        /* primary accent (kept var name; now royal blue) */
  --green-light: #5b86ff;
  --red: #e0463e;
  --gold: #f0b429;

  --bg: #0b1020;
  --bg-2: #111831;
  --card: #141b30;
  --card-2: #1c2742;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text: #e8ecf6;
  --muted: #8a93ad;
  --muted-2: #5b6480;

  --radius: 16px;
  --radius-sm: 10px;
  --nav-h: 64px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);

  --font-head: "Rajdhani", system-ui, sans-serif;
  --font-body: "DM Sans", system-ui, sans-serif;
}

/* ---------- Reset / base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 700; line-height: 1.1; letter-spacing: 0.2px; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--gold); color: #1a1a1a; }

/* ---------- App shell ---------- */
#app { min-height: 100%; }

.screen { display: none; min-height: 100vh; padding-bottom: calc(var(--nav-h) + 16px); }
.screen.active { display: block; animation: fade 0.18s ease; }
.screen--full { padding-bottom: 0; }   /* live scoring covers nav */
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.wrap { padding: 16px; max-width: 640px; margin: 0 auto; }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(180deg, var(--bg-2), rgba(17, 28, 23, 0.85));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.app-header h1 { font-size: 22px; flex: 1; }
.app-header .sub { color: var(--muted); font-size: 12px; font-family: var(--font-body); font-weight: 500; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-size: 20px;
  background: var(--card); border: 1px solid var(--border); color: var(--text);
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn--gold { background: var(--gold); color: #1a1a1a; border-color: transparent; font-weight: 700; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px; border-radius: var(--radius-sm);
  font-weight: 700; font-size: 15px; letter-spacing: 0.2px;
  background: var(--card-2); color: var(--text); border: 1px solid var(--border);
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn--block { width: 100%; }
.btn--gold { background: var(--gold); color: #1a1a1a; border-color: transparent; }
.btn--green { background: var(--green); color: #fff; border-color: transparent; }
.btn--red { background: var(--red); color: #fff; border-color: transparent; }
.btn--ghost { background: transparent; }
.btn--lg { padding: 16px; font-size: 17px; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.section-title {
  font-family: var(--font-head); font-size: 13px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--muted); margin: 22px 4px 10px;
}

.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--green), #16307a 70%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius); padding: 22px; margin-top: 4px;
}
/* Banner image feathered into the hero with a gradient mask (smooth blend, no hard edges) */
.hero-logo {
  position: absolute; right: -6px; top: 50%; transform: translateY(-50%);
  height: 165%; width: auto; pointer-events: none; opacity: 0.92;
  -webkit-mask-image: linear-gradient(to right, transparent 6%, #000 64%);
          mask-image: linear-gradient(to right, transparent 6%, #000 64%);
}
.hero h2 { font-size: 28px; color: #fff; position: relative; }
.hero p { position: relative; }
.hero p { color: rgba(255, 255, 255, 0.8); font-size: 13px; margin-top: 4px; }

/* quick stats bar */
.stat-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.stat-bar .stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 10px; text-align: center; }
.stat-bar .stat b { font-family: var(--font-head); font-size: 24px; color: var(--gold); display: block; }
.stat-bar .stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ---------- Match card ---------- */
.match-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; transition: transform 0.08s ease; }
.match-card:active { transform: scale(0.985); }
.match-card__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.match-card__name { font-family: var(--font-head); font-size: 17px; font-weight: 600; }
.match-card__teams { display: flex; flex-direction: column; gap: 6px; }
.team-line { display: flex; align-items: baseline; justify-content: space-between; }
.team-line .tn { font-weight: 600; }
.team-line .ts { font-family: var(--font-head); font-size: 18px; color: var(--gold); font-weight: 700; }
.team-line .to { color: var(--muted); font-size: 12px; margin-left: 6px; }

.badge { font-size: 11px; font-weight: 700; letter-spacing: 0.6px; padding: 4px 9px; border-radius: 999px; text-transform: uppercase; }
.badge--live { background: rgba(224, 62, 62, 0.16); color: #ff7a7a; position: relative; padding-left: 18px; }
.badge--live::before { content: ""; position: absolute; left: 8px; top: 50%; transform: translateY(-50%); width: 6px; height: 6px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 0 rgba(224,62,62,0.6); animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(224,62,62,0.6); } 70% { box-shadow: 0 0 0 7px rgba(224,62,62,0); } 100% { box-shadow: 0 0 0 0 rgba(224,62,62,0); } }
.badge--complete { background: rgba(59, 108, 255, 0.16); color: var(--green-light); }
.match-card__result { margin-top: 8px; font-size: 12px; color: var(--muted); }

/* ---------- Empty state ---------- */
.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty .ico { font-size: 44px; opacity: 0.5; }
.empty p { margin-top: 8px; }

/* ---------- PIN screen ---------- */
#screen-pin { display: none; }
#screen-pin.active { display: flex; }
.pin-screen {
  min-height: 100vh; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px; gap: 6px;
  background: radial-gradient(120% 80% at 50% 0%, #131c3e 0%, var(--bg) 60%);
}
.pin-logo { width: 86px; height: 86px; border-radius: 26px; display: grid; place-items: center; font-size: 44px; background: linear-gradient(135deg, var(--green), #16225a); box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,0.1); }
.pin-title { font-size: 30px; letter-spacing: 2px; margin-top: 18px; }
.pin-sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.pin-dots { display: flex; gap: 16px; margin: 10px 0 6px; }
.pin-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); transition: all 0.15s ease; }
.pin-dot--filled { background: var(--gold); border-color: var(--gold); transform: scale(1.05); }
.pin-error { color: #ff7a7a; font-size: 13px; height: 18px; font-weight: 600; }
.pin-error.shake { animation: shake 0.35s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-7px)} 40%,80%{transform:translateX(7px)} }
.numpad { display: grid; grid-template-columns: repeat(3, 78px); gap: 14px; margin-top: 18px; }
.numpad button { height: 78px; border-radius: 50%; font-family: var(--font-head); font-size: 30px; font-weight: 600; background: var(--card); border: 1px solid var(--border); transition: transform 0.06s ease, background 0.15s; }
.numpad button:active { transform: scale(0.92); background: var(--card-2); }
.numpad button.np-action { background: transparent; font-size: 22px; color: var(--muted); }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }
.input, input[type=text], input[type=number], input[type=password], select, textarea {
  width: 100%; padding: 13px 14px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--border-strong); color: var(--text);
  font-size: 15px; outline: none; transition: border-color 0.15s;
}
.input:focus, input:focus, select:focus { border-color: var(--green-light); }
input:disabled, select:disabled, textarea:disabled { opacity: 0.45; cursor: not-allowed; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238ba79a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* segmented buttons (bat/bowl, scorers count) */
.seg { display: grid; grid-auto-flow: column; gap: 10px; }
.seg button { padding: 14px; border-radius: var(--radius-sm); background: var(--bg-2); border: 1.5px solid var(--border-strong); font-weight: 700; }
.seg button.active { background: var(--green); border-color: var(--green); color: #fff; }

/* player checklist */
.checklist { display: flex; flex-direction: column; gap: 8px; max-height: 230px; overflow-y: auto; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-2); }
.check-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--radius-sm); }
.check-item.checked { background: rgba(59, 108, 255, 0.14); }
.check-item input { width: 20px; height: 20px; accent-color: var(--green-light); }
.check-item .nm { flex: 1; font-weight: 500; }
.check-item .rl { font-size: 11px; color: var(--muted); }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: var(--nav-h);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(15, 23, 19, 0.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav.hidden { display: none; }
.nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted-2); font-size: 10.5px; font-weight: 600; letter-spacing: 0.3px; }
.nav-item .ico { font-size: 21px; line-height: 1; }
.nav-item.active { color: var(--gold); }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px); transform: translateX(-50%) translateY(20px); z-index: 100; opacity: 0; pointer-events: none; transition: all 0.25s ease; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast { background: #1b2440; color: var(--text); border: 1px solid var(--border-strong); padding: 12px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); }
.toast--success { background: #15235a; border-color: var(--green); }
.toast--error { background: #3a1717; border-color: var(--red); color: #ffd2d2; }

/* ---------- Spinner ---------- */
#spinner { position: fixed; inset: 0; z-index: 90; display: none; place-items: center; background: rgba(5, 9, 7, 0.55); backdrop-filter: blur(2px); }
#spinner.show { display: grid; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(255,255,255,0.15); border-top-color: var(--gold); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Bottom-sheet modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,0.55); display: none; align-items: flex-end; justify-content: center; }
.modal-backdrop.show { display: flex; animation: fade 0.18s; }
.sheet { width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; background: var(--bg-2); border-radius: 22px 22px 0 0; border: 1px solid var(--border); border-bottom: none; padding: 10px 18px 26px; box-shadow: var(--shadow); animation: rise 0.24s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { transform: translateY(100%); } to { transform: none; } }
.sheet__top { position: sticky; top: 0; z-index: 3; background: var(--bg-2); margin: -10px -18px 10px; padding: 8px 18px 4px; border-radius: 22px 22px 0 0; }
.sheet__handle { width: 42px; height: 5px; border-radius: 999px; background: var(--border-strong); margin: 0 auto 4px; }
.sheet__close { position: absolute; top: 6px; right: 12px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--card-2); border: 1px solid var(--border-strong); color: var(--muted); font-size: 14px; line-height: 1; }
.sheet__close:active { transform: scale(0.92); }
.sheet__title { font-size: 21px; margin-bottom: 16px; }
.sheet--center { align-self: center; margin: auto; border-radius: 22px; border-bottom: 1px solid var(--border); max-width: 420px; }
.modal-backdrop.center { align-items: center; }

/* ---------- Avatars / player rows ---------- */
.avatar { width: 42px; height: 42px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; font-size: 16px; color: #fff; flex-shrink: 0; background: linear-gradient(135deg, var(--green), #16225a); }
.avatar--lg { width: 92px; height: 92px; font-size: 34px; border-radius: 28px; }
.player-row { display: flex; align-items: center; gap: 13px; padding: 12px 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; }
.player-row:active { transform: scale(0.99); }
.player-row .meta { flex: 1; min-width: 0; }
.player-row .meta .nm { font-weight: 600; font-size: 16px; }
.player-row .meta .rl { font-size: 12px; color: var(--muted); }
.player-row .qs { text-align: right; font-size: 12px; color: var(--muted); }
.player-row .qs b { font-family: var(--font-head); color: var(--gold); font-size: 17px; display: block; }

/* ---------- Player profile ---------- */
.profile-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 16px 0 6px; }
.profile-head h2 { font-size: 26px; }
.profile-head .style { color: var(--muted); font-size: 13px; }
.profile-badges { display: flex; gap: 10px; margin-top: 6px; }
.pill { background: var(--card-2); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-size: 12px; font-weight: 600; }
.pill b { color: var(--gold); }
.stat-card { margin-top: 14px; }
.stat-card h3 { font-size: 14px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-grid .it { text-align: center; }
.stat-grid .it b { font-family: var(--font-head); font-size: 22px; color: var(--text); display: block; }
.stat-grid .it span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.recent-line { display: flex; justify-content: space-between; padding: 10px 2px; border-bottom: 1px solid var(--border); font-size: 14px; }
.recent-line:last-child { border-bottom: none; }
.recent-line .rb { color: var(--muted); font-size: 12px; }

/* ==========================================================================
   LIVE SCORING SCREEN
   ========================================================================== */
.live { display: flex; flex-direction: column; min-height: 100vh; }

.live-top { position: sticky; top: 0; z-index: 10; background: linear-gradient(180deg, #101a3a, var(--bg-2)); border-bottom: 1px solid var(--border); padding: 12px 16px 14px; }
.live-top .bar { display: flex; align-items: center; gap: 10px; }
.live-top .title { flex: 1; font-family: var(--font-head); font-weight: 600; font-size: 16px; }
.live-innings { color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.live-score { display: flex; align-items: baseline; gap: 12px; margin-top: 2px; }
.live-score .rw { font-family: var(--font-head); font-size: 46px; font-weight: 700; line-height: 1; }
.live-score .rw .w { color: var(--red); }
.live-score .ov { color: var(--muted); font-size: 13px; }
.live-score .ov b { color: var(--text); font-family: var(--font-head); }
.live-target { margin-top: 8px; font-size: 13px; color: var(--gold); font-weight: 600; background: rgba(240,180,41,0.1); border: 1px solid rgba(240,180,41,0.25); padding: 7px 12px; border-radius: var(--radius-sm); }

.ball-log { display: flex; gap: 7px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.ball-log .lbl { font-size: 11px; color: var(--muted-2); margin-right: 2px; text-transform: uppercase; letter-spacing: 0.5px; }
.ball { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; font-size: 13px; flex-shrink: 0; }
.ball--0 { background: #2a3a32; color: var(--muted); }
.ball--run { background: var(--green); color: #fff; }
.ball--four { background: var(--gold); color: #1a1a1a; }
.ball--six { background: var(--red); color: #fff; }
.ball--wkt { background: var(--red); color: #fff; box-shadow: 0 0 0 2px rgba(224,62,62,0.4); }
.ball--extra { background: #2a3a32; color: var(--gold); font-size: 11px; }

/* middle */
.live-mid { flex: 1; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.bat-card { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.bat-card--striker { border-color: var(--gold); background: linear-gradient(90deg, rgba(240,180,41,0.1), var(--card)); box-shadow: 0 0 0 1px rgba(240,180,41,0.3); }
.bat-card .star { color: var(--gold); width: 14px; }
.bat-card .nm { flex: 1; font-weight: 600; }
.bat-card .nm small { color: var(--muted); font-weight: 400; font-size: 11px; display: block; }
.bat-card .figs { font-family: var(--font-head); font-size: 20px; font-weight: 700; }
.bat-card .sr { color: var(--muted); font-size: 11px; text-align: right; }

.bowler-row { display: flex; align-items: center; gap: 12px; background: var(--card-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 14px; }
.bowler-row .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.bowler-row .nm { flex: 1; font-weight: 600; }
.bowler-row .figs { font-family: var(--font-head); font-weight: 700; }

/* small inline "correct this player" pencil on bat cards / bowler row */
.mini-edit { flex: none; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-2); color: var(--muted); font-size: 13px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.mini-edit:active { transform: scale(0.92); }

/* auto-balanced team creator result */
.tc-result { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tc-team { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; }
.tc-team__head { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.tc-player { display: flex; justify-content: space-between; gap: 6px; font-size: 13px; padding: 3px 0; }
.tc-player .muted { font-size: 11px; white-space: nowrap; }
.tc-team__tot { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }

.innings-banner { text-align: center; background: linear-gradient(135deg, var(--green), #16225a); border-radius: var(--radius); padding: 18px; margin-top: 6px; }
.innings-banner h3 { font-size: 20px; color: #fff; }
.innings-banner p { color: rgba(255,255,255,0.85); font-size: 13px; margin-top: 4px; }

/* view-only notice */
.viewonly { text-align: center; background: var(--card); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 14px; color: var(--muted); font-size: 13px; }
.viewonly b { color: var(--text); }

/* scoring pad */
.pad-wrap { position: sticky; bottom: 0; background: var(--bg-2); border-top: 1px solid var(--border); padding: 10px 14px calc(14px + env(safe-area-inset-bottom, 0)); }
.pad-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.pad-head .lbl { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pad button { height: 56px; border-radius: var(--radius-sm); font-family: var(--font-head); font-size: 22px; font-weight: 700; background: var(--card); border: 1px solid var(--border-strong); transition: transform 0.06s; }
.pad button:active { transform: scale(0.94); }
.pad .k4 { color: var(--gold); }
.pad .k6 { color: var(--red); }
.pad .kw { background: var(--red); color: #fff; border-color: transparent; }
.pad .kx { color: var(--gold); font-size: 16px; }
.pad .kundo { font-size: 18px; color: var(--muted); }
.pad .kempty { visibility: hidden; }
.pad button.armed { outline: 2px solid var(--gold); outline-offset: -2px; }
.swap-btn { font-size: 13px; font-weight: 700; color: var(--gold); padding: 6px 12px; border-radius: 999px; border: 1px solid rgba(240,180,41,0.3); background: rgba(240,180,41,0.08); }

/* ==========================================================================
   SCORECARD
   ========================================================================== */
.result-banner { background: linear-gradient(135deg, var(--gold), #c98a12); color: #1a1a1a; border-radius: var(--radius); padding: 16px 18px; font-weight: 700; text-align: center; margin-bottom: 16px; }
.result-banner .lbl { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; opacity: 0.7; }
.result-banner .res { font-family: var(--font-head); font-size: 19px; margin-top: 2px; }

.sc-innings { margin-bottom: 22px; }
.sc-innings__head { display: flex; align-items: baseline; justify-content: space-between; padding: 10px 4px; border-bottom: 2px solid var(--green); margin-bottom: 6px; }
.sc-innings__head .tm { font-family: var(--font-head); font-size: 18px; font-weight: 600; }
.sc-innings__head .tot { font-family: var(--font-head); font-size: 22px; color: var(--gold); font-weight: 700; }
.sc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sc-table th { text-align: right; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.sc-table th:first-child { text-align: left; }
.sc-table td { padding: 9px 6px; text-align: right; border-bottom: 1px solid var(--border); }
.sc-table td:first-child { text-align: left; }
.sc-table .bn { font-weight: 600; }
.sc-table .dm { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.sc-table .notout { color: var(--green-light); }
.sc-extras { font-size: 12.5px; color: var(--muted); padding: 9px 6px; }
.sc-extras b { color: var(--text); }
.sc-sub { font-family: var(--font-head); font-size: 13px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin: 14px 4px 4px; }

/* ==========================================================================
   LEADERBOARD
   ========================================================================== */
.tabs { display: flex; gap: 6px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 5px; margin-bottom: 16px; }
.tab { flex: 1; padding: 10px; border-radius: 8px; font-weight: 700; font-size: 13px; color: var(--muted); text-align: center; }
.tab.active { background: var(--green); color: #fff; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 9px; }
.rank { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; font-size: 15px; background: var(--card-2); color: var(--muted); flex-shrink: 0; }
.rank--1 { background: linear-gradient(135deg, #f7d046, #d49b12); color: #3a2a00; }
.rank--2 { background: linear-gradient(135deg, #d8dde2, #9aa3ad); color: #2a2f35; }
.rank--3 { background: linear-gradient(135deg, #e0a06a, #b06f38); color: #3a1f08; }
.lb-row .meta { flex: 1; min-width: 0; }
.lb-row .meta .nm { font-weight: 600; }
.lb-row .meta .sub { font-size: 12px; color: var(--muted); }
.lb-row .big { font-family: var(--font-head); font-size: 22px; font-weight: 700; color: var(--gold); }

/* ---------- Settings ---------- */
.settings-group { margin-bottom: 18px; }
.muted { color: var(--muted); }
.fine { font-size: 12px; color: var(--muted-2); text-align: center; padding: 16px; }

/* utility */
.gap { height: 8px; }
.flex { display: flex; gap: 10px; }
.flex > * { flex: 1; }
.mt { margin-top: 14px; }

/* ---------- Logos / avatar images ---------- */
.header-logo { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.pin-logo img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }

/* ---------- Home gallery carousel ---------- */
#home-gallery:empty { display: none; }
.carousel-wrap { position: relative; margin: 2px 0 8px; }
.carousel {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--card);
  aspect-ratio: 16 / 10; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.carousel::-webkit-scrollbar { display: none; }
.carousel__slide { flex: 0 0 100%; scroll-snap-align: center; height: 100%; }
.carousel__slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
.carousel__dots { display: flex; gap: 7px; justify-content: center; margin-top: 9px; }
.carousel__dots .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); transition: all 0.2s; cursor: pointer; }
.carousel__dots .dot--active { background: var(--gold); width: 18px; border-radius: 999px; }
.carousel__tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 8px; }
.carousel__tool { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, 0.5); border: 1px solid rgba(255, 255, 255, 0.2); color: #fff; font-size: 16px; backdrop-filter: blur(4px); }
.carousel__tool:active { transform: scale(0.92); }
.gallery-empty { border: 1px dashed var(--border-strong); background: var(--card); color: var(--muted); }

/* ---------- Player photo editor ---------- */
.photo-row { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.photo-actions { display: flex; flex-direction: column; gap: 8px; }
.photo-actions .btn { padding: 9px 14px; }

/* ==========================================================================
   Responsive — widen the layout on tablets / desktop.
   Mobile stays a single centered column; from 768px up the content column
   grows and card lists flow into multiple columns to use the width. The
   full-width header + bottom nav get matching side padding so their contents
   line up with the centered content column.
   ========================================================================== */
@media (min-width: 768px) {
  .wrap { max-width: 960px; padding-left: 24px; padding-right: 24px; padding-top: 22px; }

  .app-header,
  .bottom-nav {
    padding-left: max(24px, calc((100% - 960px) / 2 + 24px));
    padding-right: max(24px, calc((100% - 960px) / 2 + 24px));
  }

  /* Card lists fill the wider column instead of stacking in one narrow strip */
  #home-matches,
  #matches-list,
  #players-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    align-items: start;
  }
  #home-matches .match-card,
  #matches-list .match-card,
  #players-list .player-row { margin-bottom: 0; }

  /* Live scoring stays a focused, comfortably-sized panel rather than stretching */
  .live { max-width: 760px; margin-inline: auto; }
}

@media (min-width: 1200px) {
  .wrap { max-width: 1100px; }
  .app-header,
  .bottom-nav {
    padding-left: max(24px, calc((100% - 1100px) / 2 + 24px));
    padding-right: max(24px, calc((100% - 1100px) / 2 + 24px));
  }
}
