
:root{
  --bg:#f6f7fb;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#475569;
  --line:rgba(15,23,42,.14);
  --btn:#ffffff;
  --btnText:#0f172a;
  --primary:#2563eb;
  --danger:#dc2626;
  --shadow: 0 18px 40px rgba(2,6,23,.10);
  --radius:18px;
  --pad:14px;
}

html[data-theme="dark"]{
  --bg:#0b1220;
  --card:#0f1b2e;
  --text:#e5e7eb;
  --muted:#a5b4fc;
  --line:rgba(226,232,240,.14);
  --btn:#101f36;
  --btnText:#e5e7eb;
  --shadow: 0 20px 50px rgba(0,0,0,.35);
}

*{box-sizing:border-box}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app{ max-width: 1280px; margin: 0 auto; padding: 14px; }

.topbar{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand .site{ font-weight: 900; letter-spacing:.4px; }
.brand .title{ font-weight: 900; font-size: 18px; margin-top:2px; }
.ver{ font-weight: 900; opacity:.8; font-size: 12px; padding-left:8px; }

.top-actions{ display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }

.grid{
  margin-top: 14px;
  display:grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 14px;
  align-items:start;
}
@media (max-width: 1000px){
  .grid{ grid-template-columns: 1fr; }
}

.card{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--pad);
}

.card-hd{
  display:flex; align-items:flex-start; justify-content:space-between; gap:12px;
  margin-bottom: 10px;
}
.card h2{ margin:0; font-size:18px; }
.muted{ color: var(--muted); font-weight: 700; }

.row{ display:flex; gap:10px; flex-wrap:wrap; align-items:flex-end; }
.field{ flex:1; min-width: 220px; }
label{ display:block; font-weight: 900; margin: 0 0 6px; }
input{
  width:100%;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.02);
  color: var(--text);
}
html[data-theme="dark"] input{ background: rgba(255,255,255,.04); }
.hint{ margin-top:6px; color: var(--muted); font-size: 12px; font-weight:700; }
.ok{ margin-top:8px; font-weight: 900; }

.btn{
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--btn);
  color: var(--btnText);
  font-weight: 900;
  min-height: 44px;
}
.btn:hover{ filter: brightness(0.98); }
.btn-primary{
  composes: btn;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(37,99,235,.35);
  background: rgba(37,99,235,.12);
  color: var(--text);
  font-weight: 900;
  min-height: 44px;
}
.btn-danger{
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(220,38,38,.35);
  background: rgba(220,38,38,.12);
  color: var(--text);
  font-weight: 900;
  min-height: 44px;
}

.btn-team{
  padding: 10px 12px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--btn);
  color: var(--btnText);
  font-weight: 1000;
  letter-spacing: .6px;
  min-width: 88px;
  min-height: 48px;
}
.btn-team.us.active{ background:#16a34a; color:#fff; border-color:#15803d; }
.btn-team.opp.active{ background:#dc2626; color:#fff; border-color:#b91c1c; }
.btn-team:not(.active){ opacity:.92; }

.banner{
  display:inline-flex; align-items:center; gap:8px;
  border:1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  font-weight: 900;
  background: rgba(0,0,0,.03);
}
html[data-theme="dark"] .banner{ background: rgba(255,255,255,.05); }

.team-row{ align-items:center; }
.mode-row .spacer{ flex:1; }

.modebtn.active, .split.active, .qbtn.active{
  border-width: 2px;
  box-shadow: 0 12px 24px rgba(0,0,0,.12);
}

.subhd{ margin-top: 10px; font-weight: 1000; letter-spacing:.4px; }
.player-grid{
  margin-top: 8px;
  display:grid;
  grid-template-columns: repeat(6, minmax(0,1fr));
  gap: 8px;
}
@media (max-width: 740px){
  .player-grid{ grid-template-columns: repeat(4, minmax(0,1fr)); }
}
.player-btn{
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0,0,0,.02);
  padding: 8px 8px;
  min-height: 54px;
  font-weight: 1000;
  display:flex; flex-direction:column; justify-content:center; align-items:center;
}
html[data-theme="dark"] .player-btn{ background: rgba(255,255,255,.05); }
.player-btn.active{ outline: 3px solid rgba(37,99,235,.35); }
.player-btn .num{ font-size: 16px; line-height: 1; }
.player-btn .name{ font-size: 10px; font-weight: 900; opacity:.86; margin-top:3px; text-align:center; }

.stat-grid{
  margin-top: 8px;
  display:grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 8px;
}
@media (max-width: 740px){
  .stat-grid{ grid-template-columns: repeat(2, minmax(0,1fr)); }
}
.stat-btn{
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0,0,0,.02);
  padding: 10px 10px;
  min-height: 52px;
  font-weight: 1000;
  text-align:center;
}
html[data-theme="dark"] .stat-btn{ background: rgba(255,255,255,.05); }
.stat-btn:hover{ filter: brightness(0.98); }

.loghd{ display:flex; justify-content:space-between; align-items:center; margin-top: 12px; font-weight: 1000; }
.log{
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  max-height: 220px;
  overflow:auto;
  background: rgba(0,0,0,.02);
}
html[data-theme="dark"] .log{ background: rgba(255,255,255,.04); }
.log .item{
  padding: 10px 10px;
  border-bottom: 1px dashed rgba(0,0,0,.12);
  font-weight: 800;
  display:flex;
  justify-content:space-between;
  gap:10px;
}
html[data-theme="dark"] .log .item{ border-bottom-color: rgba(255,255,255,.12); }
.log .item:last-child{ border-bottom:none; }
.log .item .meta{ opacity:.85; font-weight:900; }

.sheet .tables{ margin-top: 12px; display:grid; grid-template-columns: 1fr; gap:12px; }
.table-wrap h3{ margin: 0 0 8px; }
.table{
  width:100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow:hidden;
}
.table th, .table td{
  padding: 10px 8px;
  border-bottom: 1px solid rgba(0,0,0,.08);
  text-align:center;
  font-weight: 900;
}
html[data-theme="dark"] .table th, html[data-theme="dark"] .table td{ border-bottom-color: rgba(255,255,255,.10); }
.table th{
  background: rgba(0,0,0,.04);
  text-transform: uppercase;
  letter-spacing: .35px;
  font-size: 12px;
}
html[data-theme="dark"] .table th{ background: rgba(255,255,255,.06); }
.table td:first-child, .table th:first-child{ text-align:left; padding-left: 12px; }

.totals-grid{
  margin-top: 10px;
  display:grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap:10px;
}
@media (max-width: 980px){ .totals-grid{ grid-template-columns: 1fr; } }
.tot-card{
  border:1px solid var(--line);
  border-radius: 16px;
  padding: 10px 12px;
  background: rgba(0,0,0,.02);
}
html[data-theme="dark"] .tot-card{ background: rgba(255,255,255,.04); }
.tot-card h4{
  margin:0 0 6px;
  font-size: 13px;
  letter-spacing:.4px;
  text-transform:uppercase;
  opacity:.9;
}
.tot-row{
  display:flex; justify-content:space-between; gap:10px;
  padding: 3px 0;
  border-bottom: 1px dashed rgba(0,0,0,.10);
}
html[data-theme="dark"] .tot-row{ border-bottom-color: rgba(255,255,255,.10); }
.tot-row:last-child{ border-bottom:none; }
.tot-row b{ font-weight: 1000; }

/* modal */
.modal{
  position:fixed; inset:0;
  background: rgba(2,6,23,.55);
  display:flex; align-items:center; justify-content:center;
  padding: 14px;
}
.modal-card{
  width:min(860px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}
.modal-hd{ display:flex; justify-content:space-between; align-items:center; gap:10px; }
.modal-title{ font-weight: 1000; font-size: 16px; }
.modal-bd{ margin-top: 10px; }


/* Ensure modal is hidden unless opened */
.modal[hidden]{ display:none !important; }


/* ---- COMPACT BUTTON UPDATE (v1.2) ---- */
.btn{
  min-height: 40px;
  padding: 8px 10px;
  font-size: 13px;
}
.btn-team{
  min-height: 42px;
  min-width: 76px;
  padding: 8px 10px;
  font-size: 13px;
}
.qbtn{
  min-height: 36px;
  min-width: 56px;
  font-size: 12px;
}
.modebtn{
  min-height: 38px;
  font-size: 13px;
}
.player-btn{
  min-height: 48px;
  padding: 6px;
}
.player-btn .num{ font-size: 14px; }
.player-btn .name{ font-size: 9px; }

.stat-grid.compact{
  grid-template-columns: repeat(3, minmax(0,1fr));
}
.stat-btn{
  min-height: 46px;
  font-size: 12px;
  padding: 8px;
}

/* tighten card spacing */
.card{ padding: 12px; }
.row{ gap: 8px; }


/* v1.4 layout tightening */
.stat-grid.compact{
  grid-template-columns: repeat(3, minmax(0,1fr));
}
.log{
  max-height: 260px;
}


/* -------- GLOBAL COMPACT BUTTON PASS (v1.5) -------- */
.btn,
.btn-primary,
.btn-danger{
  min-height: 36px !important;
  padding: 6px 8px !important;
  font-size: 12px !important;
  border-radius: 10px !important;
}

.btn-team{
  min-height: 38px !important;
  min-width: 68px !important;
  padding: 6px 8px !important;
  font-size: 12px !important;
}

.qbtn{
  min-height: 32px !important;
  min-width: 48px !important;
  font-size: 11px !important;
}

.modebtn{
  min-height: 34px !important;
  font-size: 12px !important;
}

.player-btn{
  min-height: 44px !important;
  padding: 4px !important;
}
.player-btn .num{ font-size: 13px !important; }
.player-btn .name{ font-size: 8px !important; }

.stat-btn{
  min-height: 40px !important;
  font-size: 11px !important;
  padding: 6px !important;
}

/* tighten headers */
.subhd{ font-size: 13px; }


/* -------- PRINT SHEET -------- */
@media print{
  body{ background:#fff !important; }
  .topbar, .card:not(.print-only), .modal{ display:none !important; }
  .print-sheet{ display:block !important; }
  .print-sheet h1{ margin:0 0 6px; }
  .print-sheet h2{ margin:14px 0 6px; }
  .print-sheet h3{ margin:12px 0 6px; }
  .print-sheet .meta{ font-weight:900; margin-bottom:10px; }
  .print-sheet .qhdr{ margin-top: 14px; border-top:2px solid #000; padding-top:8px; }
  .print-sheet table{ width:100%; border-collapse:collapse; }
  .print-sheet th, .print-sheet td{ border:1px solid #000; padding:6px 6px; font-size:12px; }
  .print-sheet th{ background:#eee; text-transform:uppercase; letter-spacing:.3px; }
}


/* -------- v1.7: print-preview look + scroll -------- */
.modal-bd{
  max-height: 72vh;
  overflow: auto;
  padding-right: 6px;
}

.print-sheet{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: #000;
}
.print-sheet h1{ font-size: 16px; }
.print-sheet h2{ font-size: 14px; }
.print-sheet h3{ font-size: 13px; }
.print-sheet .meta{ font-size: 12px; }
.print-sheet th, .print-sheet td{ font-size: 11px; padding: 4px 5px; }
.print-sheet .qhdr{ border-top: 2px solid #000; padding-top: 6px; margin-top: 10px; }

/* Even smaller controls */
.btn, .btn-primary, .btn-danger{
  min-height: 32px !important;
  padding: 5px 7px !important;
  font-size: 11px !important;
  border-radius: 9px !important;
}
.btn-team{
  min-height: 34px !important;
  min-width: 62px !important;
  padding: 5px 7px !important;
  font-size: 11px !important;
}
.qbtn{
  min-height: 30px !important;
  min-width: 44px !important;
  font-size: 10px !important;
}
.player-btn{ min-height: 40px !important; }
.player-btn .num{ font-size: 12px !important; }
.player-btn .name{ font-size: 8px !important; }
.stat-btn{ min-height: 36px !important; font-size: 10px !important; }

/* -------- v1.8 tweaks -------- */

/* Quarter buttons: pink when active */
.qbtn.active{
  background: #ec4899 !important;   /* pink */
  border-color: #db2777 !important;
  color: #fff !important;
}

/* Left column: slightly smaller stat buttons + running log */
.stat-grid.compact{
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 6px;
}
.stat-btn{
  min-height: 32px !important;
  font-size: 10px !important;
  padding: 5px 6px !important;
  border-radius: 10px !important;
}

.log{
  max-height: 210px !important;
}
.log .item{
  padding: 8px 8px !important;
  font-size: 11px !important;
}
.log .item .meta{
  font-size: 10px !important;
}

/* Tiny icon button */
.icon-btn{
  border: 1px solid var(--line);
  background: var(--btn);
  color: var(--btnText);
  border-radius: 10px;
  padding: 4px 8px;
  min-height: 28px;
  font-weight: 1000;
}
.icon-btn:hover{ filter: brightness(0.98); }
/* -------- v1.9 Player Edit Mode -------- */
.btn.toggle-on{
  border-color: rgba(236,72,153,.55) !important;
  background: rgba(236,72,153,.14) !important;
}

.player-btn{ position: relative; }
.player-btn .edit-pen{
  position:absolute;
  top:6px;
  right:6px;
  min-height: 22px;
  padding: 2px 6px;
  font-size: 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.85);
}
html[data-theme="dark"] .player-btn .edit-pen{ background: rgba(16,31,54,.88); color: var(--btnText); }
.player-btn .edit-pen:active{ transform: scale(0.98); }
/* v1.9.1: edit pen is NOT a nested button (prevents weird iOS behavior) */
.player-btn .edit-pen{
  cursor: pointer;
  user-select: none;
  display:flex;
  align-items:center;
  justify-content:center;
  line-height: 1;
}
/* v1.9.2: ensure pencil is tappable */
.player-btn .edit-pen{ pointer-events: auto; }
/* v1.9.3: ensure pencil is above button and easy to tap */
.player-btn{ overflow: visible; }
.player-btn .edit-pen{
  z-index: 10;
  width: 26px;
  height: 26px;
}
/* v1.9.4: make pencil the top tap target */
.player-btn .edit-pen{ pointer-events: auto; }
/* v2.0: remove pencil overlay (tap-to-edit in Edit mode) */
.edit-pen{ display:none !important; }


/* v2.3: header logo placement */
.topbar .title{
  display:flex;
  align-items:center;
  gap:10px;
}
.topbar .title .logo{
  height:30px;
  width:auto;
  display:inline-block;
}

/* Southern Door cloud sync */
.status-stack{display:grid;gap:3px;justify-items:end;text-align:right}
.sync-status{font-size:11px;font-weight:900}
.sync-status.synced{color:#15803d}
.sync-status.needs{color:#b45309}
.sync-status.offline{color:#b91c1c}
.sync-status.syncing{color:#2563eb}
.cloud-game-list{display:grid;gap:8px}
.cloud-game-row{
  display:flex;align-items:center;justify-content:space-between;gap:10px;
  border:1px solid var(--line);border-radius:12px;padding:8px 10px;
}
.cloud-game-name{font-weight:1000}
.cloud-game-meta{font-size:11px;color:var(--muted);font-weight:800}
@media(max-width:740px){
  .status-stack{justify-items:start;text-align:left}
}

/* Southern Door schedule dashboard */
.dashboard-screen{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:16px;
  margin-bottom:14px;
}
.dashboard-head{
  display:flex;justify-content:space-between;align-items:flex-start;
  gap:12px;margin-bottom:14px;
}
.dashboard-head h1{margin:2px 0 4px;font-size:24px}
.dashboard-actions{display:flex;gap:8px;flex-wrap:wrap}
.schedule-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:10px;
}
.game-card{
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
  background:rgba(0,0,0,.02);
  display:grid;
  gap:8px;
}
html[data-theme="dark"] .game-card{background:rgba(255,255,255,.04)}
.game-date{font-size:12px;color:var(--muted);font-weight:900}
.game-opponent{font-size:17px;font-weight:1000}
.game-meta{font-size:12px;font-weight:800}
.game-note{font-size:11px;font-weight:900}
.game-actions{display:flex;gap:6px;flex-wrap:wrap}
.game-card.current{outline:2px solid rgba(236,72,153,.35)}
@media(max-width:900px){.schedule-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:620px){.schedule-grid{grid-template-columns:1fr}.dashboard-head{flex-direction:column}}

/* SD v1.3 — iPad numeric stat entry */
.yards-entry{
  display:grid;
  gap:10px;
}
.yards-label{
  font-size:13px;
  font-weight:900;
}
.yards-input{
  width:100%;
  font-size:28px !important;
  font-weight:1000;
  text-align:center;
  padding:10px 8px !important;
  min-height:52px;
}
.yards-actions{
  display:flex;
  justify-content:center;
  gap:7px;
  flex-wrap:wrap;
}
.yards-actions .btn,
.yards-actions .btn-primary{
  min-width:62px;
}

/* ---------- SD v1.4 compact game setup ---------- */
.setup-header{margin-bottom:6px}
.setup-title-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.setup-toggle{
  min-height:28px !important;
  padding:4px 7px !important;
  font-size:10px !important;
}
#gameSetupBody{padding-top:6px}
#gameSetupBody[hidden]{display:none !important}
.stats-top{margin-top:4px !important}

/* Selected stat category */
#mOff.active{
  background:#2563eb !important;
  border-color:#1d4ed8 !important;
  color:#fff !important;
  box-shadow:0 8px 18px rgba(37,99,235,.22) !important;
}
#mDef.active{
  background:#dc2626 !important;
  border-color:#b91c1c !important;
  color:#fff !important;
  box-shadow:0 8px 18px rgba(220,38,38,.22) !important;
}
#mST.active{
  background:#16a34a !important;
  border-color:#15803d !important;
  color:#fff !important;
  box-shadow:0 8px 18px rgba(22,163,74,.22) !important;
}
.modebtn:not(.active){opacity:.82}

/* SD v1.5 Southern Door identity */
.team-us-eagle{
  display:inline-flex !important;
  align-items:center;
  justify-content:center;
  gap:5px;
}
.team-us-eagle img{
  width:28px;
  height:22px;
  object-fit:contain;
  background:#fff;
  border-radius:4px;
}
.opponent-display{
  font-size:12px;
  font-weight:1000;
  text-align:center;
  margin:3px 0 5px;
}

/* SD v1.5.1 - embedded Eagle logo */
.team-us-eagle img{
  width:38px !important;
  height:28px !important;
  object-fit:contain !important;
  display:block !important;
  flex:0 0 auto !important;
}
.team-us-eagle{
  gap:6px !important;
}

/* ---------- SD v1.6 season roster dashboard ---------- */
.season-roster-panel{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:14px;
  margin-bottom:12px;
  background:rgba(0,0,0,.02);
}
html[data-theme="dark"] .season-roster-panel{background:rgba(255,255,255,.04)}
.season-roster-title{font-size:14px;font-weight:1000}
.season-roster-status{font-size:12px;font-weight:900;margin-top:2px}
.season-roster-actions{display:flex;gap:7px;flex-wrap:wrap;align-items:center}
.roster-file-label{display:inline-flex;align-items:center;justify-content:center;cursor:pointer}
.roster-edit-grid{
  display:grid;
  gap:6px;
}
.roster-edit-row{
  display:grid;
  grid-template-columns:80px 1fr 1fr 90px;
  gap:6px;
  align-items:center;
}
.roster-edit-row input{
  min-width:0;
  padding:7px 8px !important;
  font-size:12px !important;
}
.roster-edit-head{
  font-size:10px;
  font-weight:1000;
  text-transform:uppercase;
  color:var(--muted);
}
@media(max-width:700px){
  .season-roster-panel{align-items:flex-start;flex-direction:column}
  .roster-edit-row{grid-template-columns:64px 1fr}
  .roster-edit-row .optional-field{display:none}
}

/* SD v1.7 test game */
.test-game-wrap{
  margin-bottom:12px;
}
.test-game-label{
  font-size:11px;
  font-weight:1000;
  text-transform:uppercase;
  color:var(--muted);
  margin-bottom:5px;
}
.test-card{
  border-style:dashed;
}

/* SD v1.8 - Southern Door Eagle in US button */
#btnUS.team-us-eagle{
  display:inline-flex !important;
  align-items:center !important;
  justify-content:center !important;
  gap:6px !important;
}
#btnUS.team-us-eagle img{
  display:block !important;
  width:34px !important;
  height:26px !important;
  object-fit:contain !important;
  flex:0 0 auto !important;
  background:#fff !important;
  border-radius:4px !important;
}
#btnUS.team-us-eagle span{
  display:inline-block !important;
}

/* ---------- SD v1.9 visual refresh ---------- */
body{
  background:
    linear-gradient(180deg, rgba(37,99,235,.05), transparent 240px),
    var(--bg);
}

.dashboard-screen{
  background:
    linear-gradient(135deg, rgba(37,99,235,.08), rgba(236,72,153,.05)),
    var(--card);
}
.dashboard-brand-row{
  display:flex;
  align-items:center;
  gap:12px;
}
.dashboard-eagle{
  width:64px;
  height:48px;
  object-fit:contain;
  background:#fff;
  border-radius:10px;
  padding:3px;
  box-shadow:0 6px 18px rgba(15,23,42,.12);
}
.dashboard-head h1{
  font-size:26px;
  margin:0;
}

.game-card{
  background:
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,250,252,.92)) !important;
  border-color:rgba(37,99,235,.14) !important;
  box-shadow:0 8px 20px rgba(15,23,42,.06);
}
html[data-theme="dark"] .game-card{
  background:linear-gradient(180deg, rgba(30,41,59,.92), rgba(15,23,42,.94)) !important;
}
.game-card:hover{
  transform:translateY(-1px);
}
.game-card-top{
  display:flex;
  justify-content:space-between;
  gap:8px;
  align-items:center;
}
.site-pill{
  border-radius:999px;
  padding:3px 7px;
  font-size:10px;
  font-weight:1000;
  text-transform:uppercase;
}
.site-pill.home{
  background:rgba(22,163,74,.14);
  color:#15803d;
}
.site-pill.away{
  background:rgba(37,99,235,.14);
  color:#1d4ed8;
}
.site-pill.tbd{
  background:rgba(234,88,12,.14);
  color:#c2410c;
}
.playoff-card{
  border-color:rgba(236,72,153,.30) !important;
  background:
    linear-gradient(180deg, rgba(253,242,248,.95), rgba(255,255,255,.95)) !important;
}
.game-note{
  color:#be185d;
}

.dashboard-return{
  background:rgba(37,99,235,.12) !important;
  border-color:rgba(37,99,235,.28) !important;
  font-weight:1000 !important;
}

/* Give the stat screen some light structure */
.setup-card{
  background:
    linear-gradient(180deg, rgba(239,246,255,.72), rgba(255,255,255,.96)) !important;
}
.record-card{
  background:
    linear-gradient(180deg, rgba(240,253,244,.62), rgba(255,255,255,.96)) !important;
}
html[data-theme="dark"] .setup-card,
html[data-theme="dark"] .record-card{
  background:var(--card) !important;
}

.setup-header{
  padding-bottom:6px;
  border-bottom:1px solid rgba(37,99,235,.10);
}
.record-card .card-hd{
  padding-bottom:6px;
  border-bottom:1px solid rgba(22,163,74,.10);
}

.stat-grid.compact{
  padding:8px;
  border-radius:12px;
  background:rgba(255,255,255,.56);
  border:1px solid rgba(37,99,235,.08);
}
.log{
  background:rgba(255,255,255,.66) !important;
}
.player-grid{
  padding:8px;
  border-radius:12px;
  background:rgba(255,255,255,.55);
  border:1px solid rgba(22,163,74,.08);
}
html[data-theme="dark"] .stat-grid.compact,
html[data-theme="dark"] .player-grid,
html[data-theme="dark"] .log{
  background:rgba(255,255,255,.04) !important;
}

.team-row{
  padding:6px 0;
}
.mode-row{
  padding:6px 0;
}

/* SD v1.9.1 - Test Game belongs at bottom of dashboard */
.test-game-wrap{
  margin-top:16px !important;
  margin-bottom:0 !important;
  padding-top:12px;
  border-top:1px solid var(--line);
}

/* =========================================================
   SD v2.0 — iPad / Tablet usability pass
   ========================================================= */

html{
  -webkit-text-size-adjust:100%;
  touch-action:manipulation;
}

body{
  min-height:100vh;
  min-height:100dvh;
  overscroll-behavior-y:contain;
}

button,
input,
select,
textarea,
label{
  -webkit-tap-highlight-color:transparent;
}

button{
  touch-action:manipulation;
}

/* Keep the app centered and use tablet width efficiently */
.app{
  width:min(100%, 1360px);
  margin:0 auto;
  padding:
    max(10px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
}

/* Dashboard tablet layout */
.dashboard-screen{
  padding:14px !important;
}

.dashboard-head{
  align-items:center !important;
}

.dashboard-actions{
  justify-content:flex-end;
}

.schedule-grid{
  grid-template-columns:repeat(3,minmax(0,1fr)) !important;
}

.game-card{
  min-height:142px;
  padding:11px !important;
}

.game-opponent{
  font-size:16px !important;
}

.game-actions .btn,
.game-actions .btn-primary{
  min-height:38px !important;
  padding:7px 10px !important;
  font-size:11px !important;
}

/* Season roster bar */
.season-roster-panel{
  padding:9px 10px !important;
}
.season-roster-actions .btn,
.season-roster-actions .roster-file-label{
  min-height:36px !important;
  padding:6px 9px !important;
  font-size:11px !important;
}

/* Main stats screen: two balanced tablet columns */
.grid{
  grid-template-columns:minmax(330px,.82fr) minmax(500px,1.18fr) !important;
  gap:10px !important;
  align-items:start !important;
}

.card{
  padding:10px !important;
}

.card-hd{
  margin-bottom:6px !important;
}

.card h2{
  font-size:16px !important;
}

/* Top app toolbar */
.topbar{
  padding:8px 10px !important;
  gap:8px !important;
  position:sticky;
  top:max(4px, env(safe-area-inset-top));
  z-index:20;
}

.brand .title{
  font-size:16px !important;
}

.top-actions{
  gap:5px !important;
}

.top-actions .btn{
  min-height:32px !important;
  padding:5px 7px !important;
  font-size:10px !important;
}

/* Compact setup when expanded */
#gameSetupBody .field{
  min-width:170px !important;
}
#gameSetupBody input{
  padding:8px 9px !important;
  font-size:12px !important;
}

/* Team / quarter / mode controls stay in a compact row */
.team-row,
.mode-row{
  gap:5px !important;
  flex-wrap:wrap !important;
}

.btn-team{
  min-width:62px !important;
  min-height:36px !important;
  padding:5px 7px !important;
  font-size:11px !important;
}

#btnUS.team-us-eagle img{
  width:30px !important;
  height:22px !important;
}

.qbtns{
  gap:4px !important;
}
.qbtn{
  min-width:42px !important;
  min-height:32px !important;
  padding:4px 6px !important;
  font-size:10px !important;
}

.modebtn{
  min-height:33px !important;
  padding:5px 8px !important;
  font-size:11px !important;
}

#btnEditMode,
#btnUndo,
#btnViewSheet{
  min-height:33px !important;
  padding:5px 8px !important;
  font-size:10px !important;
}

/* Player grid: more players on screen, still large enough to tap */
.player-grid{
  grid-template-columns:repeat(7,minmax(0,1fr)) !important;
  gap:5px !important;
  padding:6px !important;
}

.player-btn{
  min-height:42px !important;
  padding:4px 3px !important;
  border-radius:10px !important;
}

.player-btn .num{
  font-size:13px !important;
}

.player-btn .name{
  font-size:8px !important;
  line-height:1.05 !important;
  max-width:100%;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

/* Stat buttons: compact but dependable touch targets */
.stat-grid.compact{
  grid-template-columns:repeat(3,minmax(0,1fr)) !important;
  gap:5px !important;
  padding:6px !important;
}

.stat-btn{
  min-height:34px !important;
  padding:5px 5px !important;
  font-size:9.5px !important;
  line-height:1.1 !important;
  border-radius:9px !important;
}

/* Running stats should not dominate the left column */
.log{
  max-height:170px !important;
  overflow:auto !important;
  -webkit-overflow-scrolling:touch;
}

.log .item{
  padding:6px !important;
  font-size:10px !important;
  line-height:1.2 !important;
}

.log .item .meta{
  font-size:9px !important;
}

.icon-btn{
  min-height:24px !important;
  padding:2px 6px !important;
  font-size:10px !important;
}

/* Modals: fit inside an iPad screen and always scroll */
.modal{
  padding:
    max(8px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left)) !important;
}

.modal-card{
  width:min(920px, 96vw) !important;
  max-height:92dvh !important;
  overflow:hidden !important;
  display:flex !important;
  flex-direction:column !important;
}

.modal-bd{
  max-height:none !important;
  flex:1 1 auto;
  overflow:auto !important;
  -webkit-overflow-scrolling:touch;
}

.modal-hd{
  flex:0 0 auto;
}

/* Numeric yardage entry is centered and keypad friendly */
.yards-input{
  font-size:24px !important;
  min-height:46px !important;
}

.yards-actions .btn,
.yards-actions .btn-primary{
  min-height:36px !important;
  padding:6px 10px !important;
}

/* Printable preview stays readable and scrollable */
.print-sheet{
  min-width:0 !important;
}
.print-sheet table{
  font-size:10px !important;
}
.print-sheet th,
.print-sheet td{
  padding:3px 4px !important;
}

/* iPad portrait */
@media (min-width:700px) and (max-width:900px){
  .schedule-grid{
    grid-template-columns:repeat(2,minmax(0,1fr)) !important;
  }

  .grid{
    grid-template-columns:1fr !important;
  }

  .player-grid{
    grid-template-columns:repeat(8,minmax(0,1fr)) !important;
  }

  .stat-grid.compact{
    grid-template-columns:repeat(4,minmax(0,1fr)) !important;
  }

  .topbar{
    position:static;
  }
}

/* iPad landscape */
@media (min-width:901px) and (max-width:1190px){
  .schedule-grid{
    grid-template-columns:repeat(3,minmax(0,1fr)) !important;
  }

  .grid{
    grid-template-columns:minmax(300px,.78fr) minmax(500px,1.22fr) !important;
  }

  .player-grid{
    grid-template-columns:repeat(7,minmax(0,1fr)) !important;
  }
}

/* Smaller tablets / phones still remain usable */
@media (max-width:699px){
  .app{
    padding:8px !important;
  }

  .grid{
    grid-template-columns:1fr !important;
  }

  .schedule-grid{
    grid-template-columns:1fr !important;
  }

  .dashboard-head,
  .season-roster-panel{
    flex-direction:column !important;
    align-items:stretch !important;
  }

  .dashboard-actions,
  .season-roster-actions{
    justify-content:flex-start !important;
  }

  .player-grid{
    grid-template-columns:repeat(5,minmax(0,1fr)) !important;
  }

  .stat-grid.compact{
    grid-template-columns:repeat(3,minmax(0,1fr)) !important;
  }
}
