/* Bases Loaded — light mode only, blue/red as the only accents. See CLAUDE.md
   "Design principles to carry through every phase". */

:root {
  color-scheme: light only;
  --ink: #111111;
  --ink-soft: #55575c;
  --ink-faint: #8b8d92;
  --bg: #ffffff;
  --line: #e3e4e7;
  --line-strong: #cfd1d6;
  --panel: #f6f7f8;
  --blue: #1656d9;
  --blue-dark: #103f9e;
  --blue-tint: #e8f0fe;
  --red: #d02b3a;
  --red-dark: #a11f2c;
  --red-tint: #fbe9ea;
  --radius: 14px;
  --radius-sm: 9px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

input, textarea {
  user-select: text;
}

.app-root {
  height: 100dvh;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.screen--scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen--fixed {
  overflow: hidden;
}

h1, h2, h3, p { margin: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.topbar h1, .topbar h2 {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
}

.icon-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
}
.icon-btn:active { background: var(--panel); }

.topbar-action {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--blue);
  font-size: 14px;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.topbar-action:active { background: var(--panel); }

.content {
  flex: 1;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Buttons ---------- */

.btn {
  appearance: none;
  border: 2px solid var(--ink);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  padding: 14px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: default; }

.btn-block { width: 100%; }

.btn-blue {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}
.btn-blue:active { background: var(--blue-dark); }

.btn-red {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}
.btn-red:active { background: var(--red-dark); }

.btn-outline-blue {
  border-color: var(--blue);
  color: var(--blue);
  background: #fff;
}
.btn-outline-red {
  border-color: var(--red);
  color: var(--red);
  background: #fff;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-soft);
  font-weight: 500;
}

.btn-lg { padding: 18px 20px; font-size: 18px; }
.btn-sm { padding: 8px 12px; font-size: 14px; min-height: 36px; border-width: 1.5px; }

.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="datetime-local"], select, textarea {
  font-size: 16px;
  padding: 12px 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  width: 100%;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
}

.error-text { color: var(--red); font-size: 13px; margin-top: -6px; margin-bottom: 10px; }
.hint-text { color: var(--ink-faint); font-size: 13px; }

/* ---------- Lists / cards ---------- */

.card {
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  background: #fff;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: none; }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.pill-blue { background: var(--blue-tint); color: var(--blue-dark); }
.pill-red { background: var(--red-tint); color: var(--red-dark); }
.pill-gray { background: var(--panel); color: var(--ink-soft); }

.empty-state {
  text-align: center;
  color: var(--ink-faint);
  padding: 40px 20px;
}

/* ---------- Modal (never native confirm/alert/prompt) ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17,17,17,0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
}
@media (min-width: 520px) {
  .modal-backdrop { align-items: center; }
}

.modal-sheet {
  background: #fff;
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 480px;
  padding: 20px 18px calc(20px + var(--safe-bottom));
  max-height: 85vh;
  overflow-y: auto;
}
@media (min-width: 520px) {
  .modal-sheet { border-radius: 18px; }
}

.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.modal-body { color: var(--ink-soft); font-size: 15px; margin-bottom: 18px; }

/* ---------- Live scoring screen ---------- */

.scoreboard {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--ink);
  color: #fff;
  flex-shrink: 0;
}
.scoreboard .team {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 46px;
}
.scoreboard .team-name { font-size: 11px; text-transform: uppercase; opacity: 0.75; letter-spacing: 0.04em; }
.scoreboard .team-score { font-size: 26px; font-weight: 800; line-height: 1; }
.scoreboard .mid {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.scoreboard .inning { font-size: 13px; font-weight: 700; }
.scoreboard .outs { display: flex; gap: 5px; }
.out-dot {
  width: 9px; height: 9px; border-radius: 50%;
  border: 1.5px solid #fff; background: transparent;
}
.out-dot.filled { background: var(--red); border-color: var(--red); }

.lastplay {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  min-height: 34px;
  display: flex;
  align-items: center;
}

.pitcher-line {
  padding: 4px 14px 0;
  font-size: 12px;
  color: var(--ink-faint);
  flex-shrink: 0;
}

.batter-row {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  flex-shrink: 0;
  align-items: center;
}

.batter-card { flex: 1; min-width: 0; }
.batter-card .label { font-size: 11px; font-weight: 700; color: var(--blue); text-transform: uppercase; letter-spacing: 0.04em; }
.batter-card .name { font-size: 20px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batter-card .sub { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }

.next-batters { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--ink-soft); flex-shrink: 0; }
.next-batters .row { display: flex; gap: 6px; }
.next-batters .tag { font-weight: 700; color: var(--ink-faint); min-width: 58px; }

.diamond-mini {
  width: 56px; height: 56px;
  flex-shrink: 0;
  cursor: pointer;
}

.count-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px 10px;
  flex-shrink: 0;
}
.pips { display: flex; gap: 6px; align-items: center; }
.pip-group { display: flex; gap: 4px; }
.pip {
  width: 13px; height: 13px; border-radius: 50%;
  border: 1.5px solid var(--line-strong);
}
.pip.ball-filled { background: var(--blue); border-color: var(--blue); }
.pip.strike-filled { background: var(--red); border-color: var(--red); }
.pitch-count { font-size: 12px; color: var(--ink-faint); font-weight: 600; }

.pitch-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 14px;
  flex-shrink: 0;
}
.pitch-buttons .btn { padding: 16px 8px; font-size: 15px; }

.ball-in-play-row { padding: 0 14px 10px; flex-shrink: 0; }

.bottom-tabs {
  display: flex;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  padding-bottom: var(--safe-bottom);
}
.bottom-tabs .tab {
  flex: 1;
  padding: 12px 6px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  background: none;
  border: none;
}
.bottom-tabs .tab:active { background: var(--panel); }

/* ---------- Diamond ---------- */

.diamond-svg .base {
  fill: #fff;
  stroke: var(--ink-faint);
  stroke-width: 3;
}
.diamond-svg .base.occupied {
  fill: var(--blue);
  stroke: var(--blue);
}
.diamond-svg .base.scored {
  fill: var(--red);
  stroke: var(--red);
}

/* ---------- Play review ---------- */

.review-diamond-wrap {
  display: flex;
  justify-content: center;
  padding: 10px 0 4px;
  flex-shrink: 0;
}

.runner-chip-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 14px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.runner-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #fff;
}
.runner-chip .who { font-weight: 700; }
.runner-chip .state { font-size: 13px; color: var(--ink-soft); }
.runner-chip.scored { border-color: var(--red); background: var(--red-tint); }
.runner-chip.out { border-color: var(--ink-faint); background: var(--panel); opacity: 0.75; }

.move-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

/* ---------- Drawer / more menu ---------- */

.drawer-list { display: flex; flex-direction: column; gap: 4px; }
.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 6px;
  border: none;
  background: none;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.drawer-item:last-child { border-bottom: none; }
.drawer-item.danger { color: var(--red); }

/* ---------- Linescore table ---------- */

table.linescore { width: 100%; border-collapse: collapse; font-size: 14px; }
table.linescore th, table.linescore td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-align: center;
}
table.linescore th { background: var(--panel); font-weight: 700; }
table.linescore td.team-label { text-align: left; font-weight: 700; }

/* ---------- Log ---------- */

.log-entry {
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.log-entry .meta { font-size: 11px; color: var(--ink-faint); font-weight: 700; text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
.log-entry--flagged { background: var(--red-tint); margin: 0 -4px; padding: 8px; border-radius: 8px; }

/* ---------- QR ---------- */

.qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px;
}
.qr-wrap canvas, .qr-wrap img { border: 1px solid var(--line); border-radius: 12px; }

.scanner-wrap { position: relative; width: 100%; aspect-ratio: 1; background: #000; border-radius: var(--radius); overflow: hidden; }
.scanner-wrap video { width: 100%; height: 100%; object-fit: cover; }

/* utility */
.center { display: flex; align-items: center; justify-content: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.spacer { flex: 1; }
.text-faint { color: var(--ink-faint); }
.text-center { text-align: center; }
