/* ── Reset & base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #0f3460;
  --accent: #e94560;
  --accent2: #53c28b;
  --text: #eaeaea;
  --text-muted: #9ea3b0;
  --border: #2a2a4a;
  --phase-auto: #f0a500;
  --phase-teleop: #4fc3f7;
  --phase-endgame: #e94560;
  --radius: 12px;
  --touch: 52px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* ── Offline banner ─────────────────────────────────────────────────────── */
.offline-banner {
  background: var(--accent);
  color: #fff;
  text-align: center;
  padding: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 100;
}
.offline-banner.hidden { display: none; }

/* ── Screens ────────────────────────────────────────────────────────────── */
.screen {
  min-height: 100dvh;
  padding: 24px 16px 40px;
  max-width: 480px;
  margin: 0 auto;
}

/* ── Setup screen ───────────────────────────────────────────────────────── */
.screen-header {
  text-align: center;
  margin-bottom: 40px;
  padding-top: 24px;
}
.app-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.5px;
}
.app-subtitle {
  color: var(--text-muted);
  margin-top: 4px;
}

.setup-form { display: flex; flex-direction: column; gap: 20px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.field input {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.2rem;
  padding: 14px 16px;
  min-height: var(--touch);
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus { border-color: var(--accent); }
.field input::placeholder { color: var(--text-muted); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch);
  padding: 0 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  transition: transform 0.08s, opacity 0.1s;
}
.btn:active { transform: scale(0.96); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-full { width: 100%; }
.btn-start {
  background: var(--accent2);
  color: #111;
  padding: 0 24px;
}

/* Count buttons */
.btn-count {
  background: var(--surface2);
  color: var(--text);
  flex: 1;
  flex-direction: column;
  gap: 4px;
  padding: 16px 12px;
  min-height: 80px;
}
.btn-count .btn-label { font-size: 0.9rem; color: var(--text-muted); }
.counter-badge {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent2);
  line-height: 1;
}
.btn-undo {
  background: var(--surface);
  color: var(--text-muted);
  flex: 0 0 var(--touch);
  width: var(--touch);
  font-size: 1.2rem;
}

/* Hold buttons */
.btn-hold {
  background: var(--surface2);
  color: var(--text);
  flex: 1;
  flex-direction: column;
  gap: 2px;
  padding: 14px 8px;
  min-height: 72px;
  border: 2px solid transparent;
  transition: background 0.1s, border-color 0.1s, transform 0.08s;
}
.btn-hold .hold-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.btn-hold.holding {
  background: var(--phase-teleop);
  color: #000;
  border-color: #fff4;
  transform: scale(0.97);
}
.btn-hold.holding .hold-hint { color: #0008; }

/* Endgame buttons */
.btn-endgame {
  background: var(--surface);
  color: var(--text-muted);
  flex: 1;
  border: 2px solid var(--border);
}
.btn-endgame.active {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--accent);
}

/* ── Scout screen layout ────────────────────────────────────────────────── */
.scout-screen { padding: 0 0 40px; }

.scout-header {
  background: var(--surface);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.scout-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.9rem;
}
.scout-meta strong { font-size: 1.1rem; }
.label-scout { color: var(--text-muted); font-size: 0.8rem; }

.timer-block {
  display: flex;
  align-items: center;
  gap: 10px;
}
.timer-display {
  font-size: 1.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 56px;
  text-align: right;
}
.phase-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--surface2);
  color: var(--text-muted);
}
.phase-badge.phase-auto { background: var(--phase-auto); color: #000; }
.phase-badge.phase-teleop { background: var(--phase-teleop); color: #000; }
.phase-badge.phase-endgame { background: var(--phase-endgame); color: #fff; }

/* ── Phase sections ─────────────────────────────────────────────────────── */
.phase-section {
  padding: 16px 16px 0;
}
.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.btn-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.hold-row { flex-wrap: wrap; }

/* ── Notes ──────────────────────────────────────────────────────────────── */
.notes-section {
  padding: 16px;
}
.notes-section label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.notes-input {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  padding: 12px;
  resize: none;
  outline: none;
}
.notes-input:focus { border-color: var(--accent); }

/* ── Submit ─────────────────────────────────────────────────────────────── */
.submit-row { padding: 16px; }
.submit-status {
  text-align: center;
  margin-top: 10px;
  font-size: 0.9rem;
  min-height: 20px;
  color: var(--accent2);
}
.submit-status.error { color: var(--accent); }
