/* ═══════════════════════════════════════════════════════════════════════
   style.css — ИИ-тренер: отжимания
   Dark sport theme with neon accents
   ═══════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;900&family=JetBrains+Mono:wght@700&display=swap');

:root {
  --bg: #0a0a1a;
  --bg2: #12122a;
  --bg3: #1a1a3a;
  --surface: rgba(255,255,255,0.05);
  --surface-hover: rgba(255,255,255,0.1);
  --border: rgba(255,255,255,0.08);
  --text: #ffffff;
  --text-dim: rgba(255,255,255,0.6);
  --text-muted: rgba(255,255,255,0.35);
  --green: #00ff88;
  --green-dim: rgba(0,255,136,0.15);
  --green-glow: rgba(0,255,136,0.4);
  --red: #ff3b5c;
  --red-dim: rgba(255,59,92,0.15);
  --red-glow: rgba(255,59,92,0.4);
  --yellow: #ffcc00;
  --yellow-dim: rgba(255,204,0,0.15);
  --blue: #00ccff;
  --blue-dim: rgba(0,204,255,0.15);
  --gradient-main: linear-gradient(135deg, #00ff88, #00ccff);
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Screens ───────────────────────────────────────────────────────── */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen[hidden] { display: none !important; }

/* ── Start Screen ──────────────────────────────────────────────────── */

#start-screen {
  padding: 24px 20px;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
}

.app-header {
  text-align: center;
  margin-top: 12px;
}

.app-icon {
  font-size: 52px;
  display: block;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 20px var(--green-glow));
}

.app-title {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.5px;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Mode cards */
.mode-section { width: 100%; max-width: 440px; }
.mode-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mode-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.mode-card:hover, .mode-card:active {
  background: var(--surface-hover);
  border-color: var(--green);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,255,136,0.1);
}

.mode-card.selected {
  border-color: var(--green);
  background: var(--green-dim);
}

.mode-card .icon {
  font-size: 36px;
  display: block;
  margin-bottom: 8px;
}

.mode-card .label {
  font-size: 14px;
  font-weight: 700;
}

.mode-card .desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

/* Training type selector */
.training-types {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.training-type {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.training-type:hover, .training-type:active {
  background: var(--surface-hover);
  border-color: var(--green);
}

.training-type.selected {
  border-color: var(--green);
  background: var(--green-dim);
}

.training-type .tt-icon { font-size: 24px; flex-shrink: 0; }
.training-type .tt-info { flex: 1; }
.training-type .tt-name { font-size: 14px; font-weight: 700; }
.training-type .tt-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Goal input */
.goal-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.goal-input-row input {
  width: 80px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  font-family: var(--font);
}

.goal-preset {
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.goal-preset:hover, .goal-preset.selected {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}

/* Sets config */
.sets-config {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
  flex-wrap: wrap;
}

.sets-config label {
  font-size: 13px;
  color: var(--text-dim);
}

.sets-config input {
  width: 60px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  font-family: var(--font);
}

/* Toggle switches */
.toggle-row {
  display: flex;
  gap: 16px;
  width: 100%;
  max-width: 440px;
  justify-content: center;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
}

.toggle input { display: none; }

.toggle-track {
  width: 40px;
  height: 22px;
  background: var(--bg3);
  border-radius: 11px;
  position: relative;
  transition: background 0.2s;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: all 0.2s;
}

.toggle input:checked + .toggle-track {
  background: var(--green);
}

.toggle input:checked + .toggle-track::after {
  left: 21px;
  background: var(--bg);
}

/* START button */
.btn-start {
  width: 100%;
  max-width: 440px;
  padding: 18px;
  border: none;
  border-radius: var(--radius);
  background: var(--gradient-main);
  color: var(--bg);
  font-size: 20px;
  font-weight: 900;
  font-family: var(--font);
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.btn-start::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
  transform: translateX(-100%);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  100% { transform: translateX(100%); }
}

.btn-start:active {
  transform: scale(0.97);
}

/* Small buttons */
.btn-secondary {
  padding: 10px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--green);
}

.btn-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-icon:hover {
  background: var(--surface-hover);
  border-color: var(--green);
}

/* History / bottom links */
.bottom-links {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 440px;
  justify-content: center;
}

.link-btn {
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: none;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  transition: all 0.15s;
}

.link-btn:hover { color: var(--green); background: var(--green-dim); }

.disclaimer {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
  max-width: 360px;
}

/* ── Exercise Screen ───────────────────────────────────────────────── */

#exercise-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #000;
  overflow: hidden;
  z-index: 10;
}

#exercise-screen[hidden] {
  display: none !important;
}

.video-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 1;
}

.video-container video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.video-container video.mirror {
  transform: scaleX(-1);
}

.video-container canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

/* HUD overlay */
.hud {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 16px) 16px env(safe-area-inset-bottom, 16px) 16px;
  z-index: 5;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: auto;
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.hud-bottom {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  pointer-events: auto;
}

/* Giant counter */
.counter {
  font-family: var(--mono);
  font-size: clamp(100px, 30vw, 200px);
  font-weight: 700;
  color: var(--green);
  text-shadow:
    0 0 40px var(--green-glow),
    0 0 80px rgba(0,255,136,0.2);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  line-height: 1;
}

.counter.bounce {
  transform: scale(1.2);
}

.counter.error {
  color: var(--red);
  text-shadow:
    0 0 40px var(--red-glow),
    0 0 80px rgba(255,59,92,0.2);
}

/* Sub counter info */
.counter-sub {
  font-size: 16px;
  color: var(--text-dim);
  font-weight: 600;
  margin-top: 8px;
}

/* Countdown overlay */
.countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  z-index: 10;
}

.countdown-number {
  font-family: var(--mono);
  font-size: 200px;
  font-weight: 700;
  color: var(--green);
  text-shadow: 0 0 60px var(--green-glow);
  animation: countPulse 1s ease-in-out infinite;
}

@keyframes countPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.8; }
}

/* Feedback banner */
.feedback-banner {
  position: absolute;
  left: 10%; right: 10%;
  top: 50%;
  transform: translateY(-50%);
  padding: 24px;
  border-radius: var(--radius);
  text-align: center;
  font-size: clamp(20px, 5vw, 36px);
  font-weight: 900;
  z-index: 5;
  animation: feedbackIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.feedback-banner.error {
  background: var(--red-dim);
  color: var(--red);
  border: 2px solid var(--red);
  box-shadow: 0 0 40px var(--red-glow);
}

.feedback-banner.warning {
  background: var(--yellow-dim);
  color: var(--yellow);
  border: 2px solid var(--yellow);
}

.feedback-banner.info {
  background: var(--blue-dim);
  color: var(--blue);
  border: 2px solid var(--blue);
}

.feedback-banner.visibility {
  background: rgba(0,0,0,0.8);
  color: var(--text);
  border: 2px solid var(--border);
  font-size: clamp(14px, 3.5vw, 22px);
  font-weight: 600;
}

@keyframes feedbackIn {
  from { transform: translateY(-50%) scale(0.8); opacity: 0; }
  to { transform: translateY(-50%) scale(1); opacity: 1; }
}

/* Progress bar */
.progress-bar-container {
  width: 100%;
  max-width: 300px;
  height: 8px;
  background: var(--surface);
  border-radius: 4px;
  margin-top: 12px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient-main);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* HUD buttons */
.hud-btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.hud-btn:active { transform: scale(0.9); }

/* Rest timer */
.rest-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.85);
  z-index: 15;
}

.rest-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.rest-timer {
  font-family: var(--mono);
  font-size: 120px;
  font-weight: 700;
  color: var(--blue);
  text-shadow: 0 0 40px rgba(0,204,255,0.4);
}

.rest-info {
  font-size: 16px;
  color: var(--text-muted);
  margin-top: 16px;
}

.rest-skip {
  margin-top: 24px;
  pointer-events: auto;
}

/* ── Results Screen ────────────────────────────────────────────────── */

#results-screen {
  padding: 40px 20px;
  align-items: center;
  gap: 24px;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 50%, var(--bg) 100%);
}

.results-emoji { font-size: 64px; }

.results-main-number {
  font-family: var(--mono);
  font-size: 96px;
  font-weight: 700;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.results-label {
  font-size: 18px;
  color: var(--text-dim);
  font-weight: 600;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  width: 100%;
  max-width: 440px;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.result-card .value {
  font-size: 28px;
  font-weight: 900;
  font-family: var(--mono);
}

.result-card .label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.result-card.green .value { color: var(--green); }
.result-card.red .value { color: var(--red); }
.result-card.yellow .value { color: var(--yellow); }
.result-card.blue .value { color: var(--blue); }

.results-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-share {
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius);
  background: var(--gradient-main);
  color: var(--bg);
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: transform 0.15s;
}

.btn-share:active { transform: scale(0.95); }

.btn-again {
  padding: 14px 28px;
  border: 1px solid var(--green);
  border-radius: var(--radius);
  background: transparent;
  color: var(--green);
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
}

.btn-home {
  padding: 14px 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-dim);
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
}

/* New record badge */
.new-record {
  background: var(--green-dim);
  border: 1px solid var(--green);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--green);
  animation: recordPulse 1.5s infinite;
}

@keyframes recordPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--green-glow); }
  50% { box-shadow: 0 0 20px 4px var(--green-glow); }
}

/* ── History Screen ────────────────────────────────────────────────── */

#history-screen {
  padding: 20px;
  gap: 20px;
  background: var(--bg);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-header h2 {
  font-size: 22px;
  font-weight: 900;
}

.stats-overview {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.stat-card .value {
  font-size: 32px;
  font-weight: 900;
  font-family: var(--mono);
  color: var(--green);
}

.stat-card .label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Calendar */
.calendar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.calendar-header h3 {
  font-size: 15px;
  font-weight: 700;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border-radius: 6px;
  color: var(--text-muted);
}

.calendar-day.active {
  background: var(--green-dim);
  color: var(--green);
  font-weight: 700;
}

.calendar-day.today {
  border: 1px solid var(--green);
}

.calendar-day-label {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  font-weight: 600;
}

/* Workout history list */
.workout-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.workout-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}

.workout-item .wi-date {
  font-size: 13px;
  color: var(--text-dim);
}

.workout-item .wi-reps {
  font-size: 20px;
  font-weight: 900;
  font-family: var(--mono);
  color: var(--green);
}

.workout-item .wi-type {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Program Screen ────────────────────────────────────────────────── */

#program-screen {
  padding: 20px;
  gap: 16px;
  background: var(--bg);
}

.program-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.program-header h2 {
  font-size: 20px;
  font-weight: 900;
}

.program-progress {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.program-progress .day-label {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.program-progress .day-number {
  font-size: 48px;
  font-weight: 900;
  font-family: var(--mono);
  color: var(--green);
}

.program-day-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.program-day-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}

.program-sets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.program-set {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 18px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--green);
}

.program-set.completed {
  opacity: 0.4;
  text-decoration: line-through;
}

.program-rest-info {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 12px;
}

.program-days-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

.program-day-mini {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}

.program-day-mini.completed {
  border-color: var(--green);
  background: var(--green-dim);
}

.program-day-mini.current {
  border-color: var(--blue);
  background: var(--blue-dim);
}

.program-day-mini .pdm-day {
  font-size: 12px;
  color: var(--text-muted);
}

.program-day-mini .pdm-total {
  font-size: 18px;
  font-weight: 900;
  font-family: var(--mono);
  color: var(--text);
  margin-top: 2px;
}

/* ── Loading overlay ───────────────────────────────────────────────── */

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10,10,26,0.95);
  z-index: 50;
  gap: 16px;
}

.spinner {
  width: 48px; height: 48px;
  border: 3px solid var(--surface);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 14px;
  color: var(--text-dim);
}

/* ── Camera error ──────────────────────────────────────────────────── */

.camera-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 40px;
  text-align: center;
  gap: 16px;
}

.camera-error .error-icon { font-size: 48px; }
.camera-error h3 { font-size: 20px; font-weight: 700; }
.camera-error p { font-size: 14px; color: var(--text-dim); max-width: 360px; line-height: 1.6; }

/* ── Video file input ──────────────────────────────────────────────── */

.video-input-area {
  width: 100%;
  max-width: 440px;
}

/* ── Rep quality dots ──────────────────────────────────────────────── */

.rep-dots {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
  max-width: 300px;
}

.rep-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  animation: dotPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rep-dot.good { background: var(--green); box-shadow: 0 0 6px var(--green-glow); }
.rep-dot.fair { background: var(--yellow); }
.rep-dot.bad { background: var(--red); }
.rep-dot.rejected { background: rgba(255,255,255,0.2); }

@keyframes dotPop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

/* ── Responsive ────────────────────────────────────────────────────── */

@media (max-height: 600px) {
  #start-screen { padding: 12px 16px; gap: 10px; }
  .app-icon { font-size: 36px; }
  .app-title { font-size: 20px; }
  .mode-card { padding: 10px; }
  .mode-card .icon { font-size: 28px; }
  .btn-start { padding: 14px; font-size: 18px; }
}

@media (min-width: 768px) {
  .mode-cards { grid-template-columns: 1fr 1fr; max-width: 480px; }
  .training-types { max-width: 480px; }
}

/* Landscape phone */
@media (orientation: landscape) and (max-height: 500px) {
  #start-screen {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    padding: 8px 16px;
    gap: 8px;
  }
  .app-header { width: 100%; margin-top: 0; }
  .app-icon { font-size: 28px; display: inline; }
  .app-title { font-size: 18px; display: inline; }
  .app-subtitle { display: none; }
  .mode-section, .training-types, .toggle-row, .btn-start { max-width: 48%; }
}

/* Hide in landscape during exercise */
@media (orientation: landscape) {
  .hud { padding: 8px 16px; }
  .counter { font-size: clamp(60px, 15vw, 120px); }
}

/* ── Fatal Error Boundary ──────────────────────────────────────────── */
.fatal-error {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  z-index: 99999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  gap: 16px;
}
.fatal-error[hidden] { display: none !important; }
.fatal-icon { font-size: 54px; }
.fatal-title { font-size: 22px; font-weight: 700; color: var(--text); }
.fatal-text { font-size: 14px; color: var(--text-dim); max-width: 360px; line-height: 1.5; }
.fatal-actions { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }

