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

:root {
  --bg: #0b0b0b;
  --surface: #141414;
  --surface2: #1c1c1c;
  --accent: #ffb000;
  --accent2: #ff6a00;
  --text: #ffffff;
  --text-muted: #888;
  --rest-color: #4fc3f7;
  --ring-circumference: 615.75px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Background ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    url('assets/workout-bg.jpg') center/cover no-repeat,
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(255, 106, 0, 0.08) 0%, transparent 70%),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 40px,
      rgba(255,255,255,0.012) 40px,
      rgba(255,255,255,0.012) 41px
    );
  z-index: 0;
  pointer-events: none;
}

/* Dark overlay over bg image — only applies when image loads */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(11, 11, 11, 0.82);
  z-index: 0;
  pointer-events: none;
}

/* ── Screens ── */
.screen {
  display: none;
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  padding: 0 env(safe-area-inset-right, 0) var(--safe-bottom) env(safe-area-inset-left, 0);
}
.screen.active { display: flex; }

/* ── START SCREEN ── */
#screen-start {
  justify-content: center;
  align-items: stretch;
  padding: 0;
}

.start-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 48px 24px calc(40px + var(--safe-bottom));
  gap: 28px;
}

.logo-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

.logo-icon {
  font-size: 2.4rem;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
  filter: drop-shadow(0 0 12px rgba(255,176,0,0.5));
}

.logo-title {
  font-family: 'Oswald', sans-serif;
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
  text-shadow: 0 0 30px rgba(255,176,0,0.2);
}

.logo-sub {
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  color: var(--accent);
  font-weight: 500;
}

/* Summary stats */
.start-summary {
  display: flex;
  gap: 0;
  width: 100%;
  background: var(--surface);
  border: 1px solid rgba(255,176,0,0.12);
  border-radius: 12px;
  overflow: hidden;
}

.summary-row {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 8px;
  gap: 4px;
  border-right: 1px solid rgba(255,255,255,0.06);
}
.summary-row:last-child { border-right: none; }

.summary-label {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--text-muted);
}

.summary-value {
  font-family: 'Oswald', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
}

/* Exercise list */
.exercise-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ex-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text);
  border-left: 3px solid var(--accent2);
}

.ex-note {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
}

.mute-row {
  display: flex;
  align-items: center;
  justify-content: center;
}

.server-status {
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  min-height: 16px;
}
.server-status.online  { color: #4caf50; }
.server-status.offline { color: var(--text-muted); }

/* ── WORKOUT SCREEN ── */
#screen-workout {
  flex-direction: column;
  justify-content: flex-start;
}

.workout-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 24px calc(32px + var(--safe-bottom));
  min-height: 100dvh;
  gap: 0;
}

.workout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 0 16px;
}

.round-badge {
  font-family: 'Oswald', sans-serif;
  font-size: 1rem;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.phase-label {
  font-family: 'Oswald', sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.22em;
  color: var(--text-muted);
  text-align: center;
  height: 24px;
  margin-bottom: 4px;
  transition: color 0.3s;
}

.phase-label.work  { color: var(--accent);    }
.phase-label.rest  { color: var(--rest-color); }

/* Timer ring */
.timer-ring-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  flex-shrink: 0;
  margin: 4px auto;
}

.timer-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: rgba(255,255,255,0.06);
  stroke-width: 8;
}

.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.25s linear, stroke 0.4s ease;
  will-change: stroke-dashoffset;
}

.ring-progress.rest {
  stroke: var(--rest-color);
}

.timer-display {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Oswald', sans-serif;
  font-size: 4.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-shadow: 0 0 40px rgba(255,176,0,0.25);
}

.timer-display.pulse {
  animation: pulse-timer 0.5s ease;
}

@keyframes pulse-timer {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.08); color: var(--accent); }
  100% { transform: scale(1); }
}

/* Exercise block */
.exercise-block {
  text-align: center;
  margin-top: 16px;
  min-height: 68px;
}

.exercise-name {
  font-family: 'Oswald', sans-serif;
  font-size: 1.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
  transition: color 0.3s;
  line-height: 1.15;
}

.exercise-name.rest { color: var(--rest-color); }

.exercise-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 4px;
  min-height: 20px;
}

/* Next up */
.next-up {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 20px;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.06);
}

.next-label {
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  white-space: nowrap;
}

.next-name {
  font-family: 'Oswald', sans-serif;
  font-size: 0.95rem;
  color: var(--text);
  letter-spacing: 0.06em;
}

/* Total remaining */
.total-remaining {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 12px;
  letter-spacing: 0.08em;
}

/* Controls */
.controls {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-top: auto;
  padding-top: 24px;
}

/* ── COMPLETE SCREEN ── */
#screen-complete {
  justify-content: center;
  align-items: stretch;
}

.complete-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 48px 24px calc(48px + var(--safe-bottom));
  gap: 24px;
  text-align: center;
}

.complete-icon {
  font-size: 4rem;
  color: var(--accent);
  filter: drop-shadow(0 0 20px rgba(255,176,0,0.6));
  line-height: 1;
}

.complete-title {
  font-family: 'Oswald', sans-serif;
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.1;
  text-shadow: 0 0 40px rgba(255,176,0,0.2);
}

.complete-sub {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.complete-stats {
  display: flex;
  gap: 0;
  background: var(--surface);
  border: 1px solid rgba(255,176,0,0.12);
  border-radius: 12px;
  overflow: hidden;
  width: 100%;
}

.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 8px;
  gap: 4px;
  border-right: 1px solid rgba(255,255,255,0.06);
}
.stat:last-child { border-right: none; }

.stat-value {
  font-family: 'Oswald', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--text-muted);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 24px;
  border: none;
  border-radius: 10px;
  font-family: 'Oswald', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s, opacity 0.15s, box-shadow 0.15s;
  user-select: none;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: #000;
  box-shadow: 0 4px 24px rgba(255, 106, 0, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 6px 32px rgba(255, 106, 0, 0.5);
}

.btn-ghost {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.08);
}

.btn-ghost:hover { color: var(--text); }

.btn-xl {
  width: 100%;
  min-height: 60px;
  font-size: 1.1rem;
  letter-spacing: 0.14em;
  border-radius: 12px;
}

.btn-lg {
  flex: 1;
  min-height: 56px;
  font-size: 1.05rem;
}

.btn-ghost.btn-lg {
  min-width: 90px;
}

/* Mute button */
.btn-mute {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 8px 14px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s, border-color 0.2s;
  min-height: 44px;
  user-select: none;
}

.btn-mute:active { opacity: 0.7; }
.btn-mute.muted { color: var(--text-muted); opacity: 0.6; }

.mute-svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-mute-small .mute-svg { width: 22px; height: 22px; }
.icon-sound-off { display: none; }
.muted .icon-sound-on  { display: none; }
.muted .icon-sound-off { display: block; }

.btn-mute-small {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  user-select: none;
}

/* ── Countdown flash ── */
@keyframes count-flash {
  0%   { color: var(--accent2); transform: scale(1.15); }
  100% { color: var(--text); transform: scale(1); }
}

.timer-display.flash {
  animation: count-flash 0.4s ease-out;
}

/* ── Responsive tweaks ── */
@media (max-height: 700px) {
  .timer-ring-wrap { width: 180px; height: 180px; }
  .timer-display   { font-size: 3.4rem; }
  .exercise-name   { font-size: 1.5rem; }
  .start-inner     { gap: 20px; }
}

@media (min-width: 480px) {
  .logo-title { font-size: 3rem; }
  .timer-ring-wrap { width: 260px; height: 260px; }
  .timer-display   { font-size: 5rem; }
}
