/* =====================================================================
   MFDA Score Sheet app - mobile-first, one-thumb operation.
   Brand tokens mirror the site's styles.css :root (navy/red/gold, dark
   surfaces). System fonts on purpose: the app must render fully offline.
   ===================================================================== */
:root {
  --navy: #1b3a8f;
  --red: #d5202f;
  --gold: #f5c542;
  --bg: #0b0f17;
  --surface: #131a26;
  --surface2: #1a2333;
  --line: #263145;
  --text: #e8ecf4;
  --muted: #9aa7bd;
  --r: 14px;
  --tap: 48px; /* minimum touch target */
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
h2 { font-size: 1.25rem; margin: 0 0 .75rem; letter-spacing: .02em; }
.count { color: var(--muted); font-weight: 400; font-size: .95rem; }
.hint { color: var(--muted); font-size: .88rem; }
.sub { display: block; color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; margin: .9rem 0 .35rem; }
.req { color: var(--red); }

/* ---- header ---- */
.app-head {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .65rem;
  padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem;
  background: rgba(11, 15, 23, .96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.app-head img { border-radius: 8px; }
.app-title { display: flex; flex-direction: column; min-width: 0; }
.app-title b { font-size: .95rem; letter-spacing: .02em; }
.app-title span { font-size: .82rem; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.net-dot { margin-left: auto; width: 10px; height: 10px; border-radius: 50%; background: #3fbf6f; flex: none; }
.net-dot.off { background: var(--red); }

/* ---- panes ---- */
.pane { padding: 1rem 1rem 1.5rem; max-width: 640px; margin: 0 auto; }

/* ---- fields ---- */
.field { margin: 0 0 .8rem; }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .3rem; }
input, select {
  width: 100%; min-height: var(--tap);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: .55rem .75rem; font-size: 1rem;
}
input:focus, select:focus { outline: 2px solid var(--navy); outline-offset: 1px; }

/* ---- buttons ---- */
.btn {
  min-height: var(--tap);
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface2); color: var(--text);
  font-size: 1rem; font-weight: 600; padding: .55rem 1rem;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; font-size: 1.1rem; min-height: 54px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-row { display: flex; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }
.alt-actions { margin-top: .75rem; }

/* ---- team cards / roster ---- */
.team-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .9rem; margin-bottom: 1rem; }
.team-head { font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: .85rem; margin-bottom: .7rem; color: var(--gold); }
.team-head.away { color: #7fb2ff; }
.addrow { display: flex; gap: .5rem; }
.addrow input { flex: 1; }
.addrow .btn { flex: none; }
.roster-list { list-style: none; margin: .6rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .45rem; }
.roster-chip {
  display: inline-flex; align-items: center; gap: .45rem;
  background: var(--surface2); border: 1px solid var(--line);
  border-radius: 999px; padding: .35rem .5rem .35rem .8rem; font-size: .92rem;
}
.roster-chip button {
  width: 30px; height: 30px; border: 0; border-radius: 50%;
  background: rgba(213, 32, 47, .18); color: var(--red);
  font-size: 1.05rem; line-height: 1; cursor: pointer;
}
.rcount { display: block; margin-top: .5rem; color: var(--muted); font-size: .85rem; }
.positions { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.pos label { font-size: .8rem; color: var(--muted); display: block; margin-bottom: .25rem; }

/* ---- game cards ---- */
.game-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .8rem .9rem; margin-bottom: .7rem; }
.game-card.decided { border-color: rgba(245, 197, 66, .45); }
.game-top { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .45rem; }
.game-n { font-weight: 800; color: var(--gold); }
.game-type { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }
.game-pair { font-size: .92rem; margin: .12rem 0; }
.game-pair b { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; margin-right: .35rem; }
.win-row { display: flex; gap: .55rem; margin-top: .6rem; }
.win-btn {
  flex: 1; min-height: var(--tap);
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface2); color: var(--text);
  font-size: .95rem; font-weight: 600; padding: .4rem .5rem; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.win-btn.sel-home { background: var(--navy); border-color: var(--navy); color: #fff; }
.win-btn.sel-away { background: var(--red); border-color: var(--red); color: #fff; }
.order-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; margin: .5rem 0 .2rem; }
.order-col label { font-size: .8rem; color: var(--muted); display: block; margin-bottom: .25rem; }
.order-col select { margin-bottom: .4rem; min-height: 42px; }

/* ---- stats ---- */
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .8rem .9rem; margin-bottom: .7rem; }
.stat-head { display: flex; align-items: baseline; gap: .55rem; margin-bottom: .5rem; }
.stat-pos { font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.stat-name { font-weight: 700; }
.stat-wins { margin-left: auto; color: var(--gold); font-size: .85rem; }
.stat-row { display: flex; align-items: center; gap: .6rem; padding: .3rem 0; border-top: 1px solid var(--line); }
.stat-row:first-of-type { border-top: 0; }
.stat-label { flex: 1; font-size: .95rem; }
.stepper { display: flex; align-items: center; gap: .35rem; }
.stepper button {
  width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface2); color: var(--text); font-size: 1.35rem; line-height: 1; cursor: pointer;
}
.stepper .val { min-width: 2ch; text-align: center; font-weight: 700; font-size: 1.05rem; }
.stat-row input.hi { width: 84px; text-align: center; min-height: 44px; }
.team-label { margin: 1rem 0 .5rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: .85rem; color: var(--gold); }
.team-label.away { color: #7fb2ff; }

/* ---- send ---- */
.send-summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .8rem .9rem; margin-bottom: 1rem; font-size: .95rem; white-space: pre-line; }
.form-msg { min-height: 1.2em; font-size: .92rem; }
.form-msg.err { color: #ff8b94; }
.form-msg.ok { color: #7fe0a2; }
.queue-box { background: rgba(245, 197, 66, .08); border: 1px solid rgba(245, 197, 66, .4); border-radius: var(--r); padding: .8rem .9rem; margin-top: .8rem; }
.queue-box p { margin: 0 0 .6rem; font-size: .92rem; }

/* ---- done ---- */
.done { text-align: center; padding: 2.5rem 0; }
.done-mark {
  width: 72px; height: 72px; margin: 0 auto 1rem; border-radius: 50%;
  background: rgba(63, 191, 111, .15); color: #3fbf6f;
  font-size: 2.2rem; line-height: 72px;
}

/* ---- standings ---- */
.stand-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.stand-top h2 { margin: 0; }
.btn.small { min-height: 38px; padding: .3rem .8rem; font-size: .88rem; }
.sample-banner {
  background: rgba(245, 197, 66, .1); border: 1px solid rgba(245, 197, 66, .45);
  border-radius: var(--r); padding: .6rem .8rem; font-size: .9rem; margin: .6rem 0 .8rem;
}
.sta-wrap { overflow-x: auto; }
.sta { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.sta th, .sta td { padding: .5rem .6rem; text-align: left; font-size: .92rem; border-top: 1px solid var(--line); }
.sta thead th { border-top: 0; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.sta th.num, .sta td.num { text-align: right; }
.lead-title { font-weight: 700; color: var(--gold); margin-bottom: .35rem; }
.lead-row { display: flex; align-items: baseline; gap: .6rem; padding: .28rem 0; border-top: 1px solid var(--line); }
.lead-title + .lead-row { border-top: 0; }
.lead-player { font-weight: 600; }
.lead-team { color: var(--muted); font-size: .85rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-val { margin-left: auto; font-weight: 700; color: var(--gold); }

/* ---- bottom tab bar ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex;
  background: rgba(11, 15, 23, .97);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; min-height: 60px;
  background: none; border: 0; color: var(--muted);
  font-size: .72rem; font-weight: 600; letter-spacing: .03em;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.tab .ico { font-size: 1.25rem; }
.tab.active { color: var(--gold); }

@media (min-width: 700px) {
  .positions { grid-template-columns: repeat(4, 1fr); }
}

/* Match history cards (History tab) */
.hist-card {
  display: block; width: 100%; text-align: left; cursor: pointer; color: inherit; font: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: .8rem .9rem; margin-bottom: .7rem; -webkit-tap-highlight-color: transparent;
}
.hist-card:active { border-color: var(--gold); }
.hist-top { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; }
.hist-teams { font-weight: 700; }
.hist-status { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); white-space: nowrap; }
.hist-status.sent { color: var(--gold); }
.hist-score { font-size: 1.05rem; margin: .2rem 0; }
