:root {
  --bg: #07090a;
  --panel: #111517;
  --panel-2: #181d20;
  --line: #262d31;
  --text: #eef3ef;
  --muted: #8b9892;
  --neon: #39ff14;
  --neon-dim: rgba(57, 255, 20, 0.14);
  --neon-glow: 0 0 18px rgba(57, 255, 20, 0.45);
  --danger: #ff4d5e;
  --warn: #ffc233;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; background: var(--bg); color: var(--text); }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 32px;
}

header.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-size: 1.15rem;
}
a.brand { color: var(--text); text-decoration: none; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.brand span { color: var(--neon); text-shadow: var(--neon-glow); }

h1 { font-size: 1.6rem; margin: 8px 0 4px; }
h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 20px 0 10px;
  font-weight: 700;
}
p { margin: 0 0 12px; }
a { color: var(--neon); }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.hidden { display: none !important; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

label { display: block; font-weight: 600; margin-bottom: 6px; }

input[type="text"], input[type="password"], input[type="tel"] {
  width: 100%;
  font: inherit;
  font-size: 1.1rem; /* >=16px stops iOS zooming in */
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  outline: none;
}
input:focus { border-color: var(--neon); box-shadow: 0 0 0 3px var(--neon-dim); }
input.code { text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; }

button {
  font: inherit;
  cursor: pointer;
  border: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.btn {
  display: block;
  width: 100%;
  font-weight: 800;
  font-size: 1.05rem;
  padding: 14px 16px;
  border-radius: 12px;
  color: #041000;
  background: var(--neon);
  box-shadow: var(--neon-glow);
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; box-shadow: none; }
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
  font-weight: 600;
}
.btn + .btn { margin-top: 10px; }

.link-btn {
  background: none;
  color: var(--muted);
  font-size: 0.86rem;
  padding: 6px 4px;
  text-decoration: underline;
}

/* ---------- Coach: pitch + zone pickers ---------- */

.pitch-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 420px) { .pitch-grid { grid-template-columns: repeat(3, 1fr); } }

.choice {
  position: relative;
  min-height: 58px;
  padding: 10px 8px;
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  border: 2px solid var(--line);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.15;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}
.choice:active { transform: scale(0.97); }
.choice.selected {
  border-color: var(--neon);
  background: var(--neon-dim);
  color: var(--neon);
  box-shadow: var(--neon-glow);
}
.choice.add {
  border-style: dashed;
  color: var(--neon);
  background: transparent;
}
.choice .del {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 0.9rem;
  line-height: 26px;
  font-weight: 800;
  display: none;
}
.editing .choice .del { display: block; }

.zone-wrap {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 10px;
}
.zone-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px;
  border-radius: 14px;
  border: 1px dashed var(--line);
}
.zone-grid .choice { min-height: 64px; font-size: 1.6rem; font-weight: 800; }
.zone-extra { display: grid; grid-template-rows: repeat(3, 1fr); gap: 8px; padding: 8px 0; }
.zone-extra .choice { font-size: 0.95rem; }

.send-bar {
  position: sticky;
  bottom: 0;
  padding: 12px 0 calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgba(7, 9, 10, 0));
  margin-top: 16px;
}
.send-btn {
  width: 100%;
  min-height: 78px;
  border-radius: 18px;
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #041000;
  background: var(--neon);
  box-shadow: 0 0 28px rgba(57, 255, 20, 0.55);
}
.send-btn .preview { display: block; font-size: 0.95rem; font-weight: 700; opacity: 0.75; letter-spacing: 0; }
.send-btn:disabled {
  background: var(--panel-2);
  color: var(--muted);
  box-shadow: none;
}
.send-btn:not(:disabled):active { transform: scale(0.985); }

.status {
  min-height: 1.4em;
  margin: 10px 0 0;
  text-align: center;
  font-weight: 600;
}
.status.ok { color: var(--neon); }
.status.err { color: var(--danger); }
.status.warn { color: var(--warn); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.live { color: var(--neon); }
.pill.live .dot { background: var(--neon); box-shadow: var(--neon-glow); }

.history { list-style: none; padding: 0; margin: 0; }
.history li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
.history li:last-child { border-bottom: none; }

/* ---------- Player page ---------- */

.steps { margin: 0; padding-left: 0; list-style: none; counter-reset: step; }
.steps li {
  position: relative;
  padding: 0 0 14px 44px;
  counter-increment: step;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -2px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--neon-dim);
  border: 1px solid var(--neon);
  color: var(--neon);
  font-weight: 800;
  text-align: center;
  line-height: 28px;
}
.share-icon {
  display: inline-block;
  vertical-align: -3px;
  width: 18px;
  height: 18px;
}
.callout {
  border-left: 3px solid var(--warn);
  background: rgba(255, 194, 51, 0.08);
  padding: 10px 12px;
  border-radius: 8px;
  margin: 12px 0 0;
  font-size: 0.92rem;
}
.callout.good { border-left-color: var(--neon); background: var(--neon-dim); }

.home-links { display: grid; gap: 12px; margin-top: 18px; }
.home-links a { text-decoration: none; }

.page-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.page-nav a, .nav-btn {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  background: none;
  padding: 10px 4px;
}
.page-nav a:hover, .nav-btn:hover { color: var(--text); }
.nav-btn { color: var(--danger); }

/* ---------- Coach: pitch codes + fastball location ---------- */

.choice.pitch { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.choice.pitch .code { font-size: 1.2rem; font-weight: 900; letter-spacing: 0.03em; }
.choice.pitch .name { font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.choice.pitch.selected .name { color: var(--neon); opacity: 0.85; }

.loc-hint { text-transform: none; letter-spacing: 0; font-weight: 600; margin-left: 6px; color: var(--muted); }
.loc-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.loc-grid .choice { min-height: 60px; font-size: 1.6rem; font-weight: 800; }
.loc-grid.off .choice { opacity: 0.3; }
