/* Ry Game Day — dark sporty theme, built for one-handed use in sunlight.
   Big touch targets, high contrast, minimal chrome. */

:root {
  --bg: #0b0e14;
  --bg2: #11151d;
  --card: #161b26;
  --line: #2a3140;
  --text: #f5f7fa;
  --muted: #aeb6c6;
  --accent: #ffd60a;
  --accent-ink: #1a1a1a;
  --green: #3ddc84;
  --red: #ff5c5c;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  overscroll-behavior-y: none;
}

body {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
}

button { font-family: inherit; }

/* ---------- header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 14, 20, 0.96);
  border-bottom: 1px solid var(--line);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-header h1 {
  font-size: 20px;
  margin: 0;
  letter-spacing: 1px;
  font-weight: 800;
}
.app-header h1 .ry { color: var(--accent); }
.back-btn {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  min-width: 52px;
  min-height: 44px;
  font-size: 22px;
}
.sync-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
}
.sync-badge[hidden] { display: none; }

/* ---------- views ---------- */
.view { display: none; padding: 16px; }
.view.active { display: block; }

/* ---------- buttons ---------- */
.btn {
  display: block;
  width: 100%;
  min-height: 64px;
  border: none;
  border-radius: var(--radius);
  font-size: 19px;
  font-weight: 700;
  cursor: pointer;
  margin: 0 0 12px;
  padding: 14px 16px;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn-danger { background: #3a1414; color: #ffb3b3; border: 1px solid #7a2a2a; }
.btn:active { transform: scale(0.98); opacity: 0.92; }

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.btn-grid .btn { margin: 0; }

/* ---------- game header / controls ---------- */
.game-meta { margin: 4px 0 12px; }
.game-meta .opp { font-size: 22px; font-weight: 800; }
.game-meta .sub { color: var(--muted); font-size: 15px; margin-top: 2px; }
.pitcher-line {
  margin-top: 8px;
  background: var(--card);
  border: 1px dashed var(--line);
  color: var(--muted);
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  padding: 10px 18px;
  min-height: 48px;
}
.pitcher-line.has-pitcher {
  border-style: solid;
  border-color: var(--accent);
  color: var(--accent);
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 12px;
}
/* Explicit two-row order: row 1 = game state (inning + half), row 2 =
   count + actions. Keeps 390px phones clean with nothing clipped. */
.stepper { order: 1; flex: 0 0 auto; }
.half-toggle { order: 2; flex: 1 1 150px; min-width: 150px; }
.count-box { order: 3; flex: 0 0 auto; }
.newab-btn { order: 4; flex: 0 0 auto; }
.undo-btn { order: 5; flex: 1 1 120px; }
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.stepper button {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 28px;
  font-weight: 800;
  min-width: 56px;
  min-height: 64px;
}
.stepper .inning-val {
  min-width: 76px;
  text-align: center;
  font-size: 19px;
  font-weight: 800;
}
.stepper .inning-val small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }

.half-toggle {
  display: flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  flex: 1;
}
.half-toggle button {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
  min-height: 64px;
}
.half-toggle button.on { background: var(--accent); color: var(--accent-ink); }

.undo-btn {
  background: #3a1414;
  color: #ffb3b3;
  border: 2px solid #7a2a2a;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 800;
  padding: 0 18px;
  min-height: 64px;
}

/* ---------- live count + new at-bat ---------- */
.count-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 78px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
}
.count-box small { font-size: 11px; color: var(--muted); font-weight: 600; }
.count-box span {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.newab-btn {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
  padding: 6px 12px;
  min-height: 64px;
}
.newab-btn:active { transform: scale(0.98); opacity: 0.92; }

/* ---------- mode tabs ---------- */
.tabs {
  display: flex;
  gap: 8px;
  margin: 4px 0 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 0 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  font-size: 16px;
  font-weight: 800;
  padding: 14px 18px;
  white-space: nowrap;
}
.tabs button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.panel { display: none; }
.panel.active { display: block; }
.panel h3 { margin: 6px 0 10px; font-size: 16px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

/* ---------- zone grid ---------- */
.zone-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}
.zone-grid button {
  aspect-ratio: 1.35;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
  min-height: 64px;
}
.zone-grid button.sel { border-color: var(--accent); background: #2a2410; color: var(--accent); }
.offplate {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.offplate button {
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
  min-height: 56px;
}
.offplate button.sel { border-color: var(--accent); background: #2a2410; color: var(--accent); }

.flow-hint {
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  margin: 4px 0 12px;
  min-height: 22px;
}
.zone-caption {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 10px 0 6px;
}

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; font-weight: 700; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.field input, .field textarea, .field select {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  font-size: 18px;
  padding: 14px;
  font-family: inherit;
}
.field textarea { min-height: 90px; resize: vertical; }

/* ---------- lists ---------- */
.game-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  width: 100%;
  text-align: left;
  color: var(--text);
  font-size: 17px;
}
.game-card .d { color: var(--muted); font-size: 14px; }
.game-card .o { font-size: 20px; font-weight: 800; margin: 2px 0; }
.game-card .t { color: var(--accent); font-size: 15px; font-weight: 700; }
.game-row { display: flex; gap: 8px; align-items: stretch; margin-bottom: 12px; }
.game-row .game-card { margin-bottom: 0; flex: 1; min-width: 0; }
.game-del {
  flex: 0 0 56px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  color: #ff6b6b;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 17px; }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 640px;
  display: flex;
  background: rgba(17, 21, 29, 0.98);
  border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}
.bottom-nav button {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  padding: 14px 0;
  border-radius: 10px;
}
.bottom-nav button.on { color: var(--accent); }
.bottom-nav[hidden] { display: none; }

/* ---------- stopwatch ---------- */
.stopwatch {
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 16px;
  margin-bottom: 14px;
}
.stopwatch .time {
  font-size: 56px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}
.stopwatch .time small { font-size: 20px; color: var(--muted); }
.times-list { list-style: none; margin: 0 0 14px; padding: 0; }
.times-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.times-list li button {
  background: none;
  border: none;
  color: var(--red);
  font-size: 20px;
  padding: 6px 10px;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  bottom: calc(100px + env(safe-area-inset-bottom));
  background: #1e2a1e;
  border: 1px solid var(--green);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 50;
  max-width: 90%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.warn { background: #2a1e1e; border-color: var(--red); }

.recruiting-flag {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  font-size: 17px;
  font-weight: 700;
}
.recruiting-flag input { width: 26px; height: 26px; accent-color: var(--accent); }

/* ---------- stats tab ---------- */
.stat-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.stat-section h4 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 6px;
}
.stat-grid:last-child { margin-bottom: 0; }
.stat-cell { text-align: center; padding: 4px 0; }
.stat-cell .v {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.stat-cell .l {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
}
.stat-row:last-child { border-bottom: none; }
.stat-row .v {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text);
}
