:root {
  --bg: #0f1115;
  --bg-rest: #0b2a3a;
  --bg-paused: #2a2410;
  --bg-countdown: #2b1a3d;
  --panel: #181b22;
  --text: #f2f4f8;
  --muted: #9aa3b2;
  --accent: #3ddc84;
  --accent-text: #05210f;
  --danger: #ff5c5c;
  --border: #2a2f3a;
  --radius: 14px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  transition: background-color 250ms ease;
}
body.phase-rest { background: var(--bg-rest); }
body.phase-countdown { background: var(--bg-countdown); }
body.is-paused { background: var(--bg-paused); }

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* ---------- Setup & summary ---------- */

.setup-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

h1 {
  margin: 0 0 8px;
  font-size: 1.6rem;
  font-weight: 700;
}

.hint {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.95rem;
}

.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 1rem;
}

.field input {
  width: 110px;
  padding: 12px;
  font-size: 1.2rem;
  text-align: right;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}
.field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.error {
  color: var(--danger);
  margin: 0 0 12px;
  font-size: 0.95rem;
}

.btn {
  display: block;
  width: 100%;
  min-height: 60px;
  padding: 14px 20px;
  font-size: 1.25rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
  background: var(--panel);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-secondary { background: #2b303b; }
.btn-danger { background: var(--danger); color: #2a0606; }
.btn-install { margin-top: 12px; }
.install-hint { margin: 12px 0 0; }

.summary {
  margin: 0 0 24px;
  display: grid;
  gap: 10px;
}
.summary div {
  display: flex;
  justify-content: space-between;
  font-size: 1.1rem;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.summary dt { color: var(--muted); }
.summary dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- Session ---------- */

.session {
  justify-content: space-between;
  user-select: none;
  -webkit-user-select: none;
}

.stats {
  width: 100%;
  display: flex;
  justify-content: space-around;
  gap: 8px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.stat-label {
  font-size: clamp(0.75rem, 2.5vmin, 1.1rem);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.stat-value {
  font-size: clamp(1.4rem, 6vmin, 3rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-total {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.7em;
}

.center {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 0;
}

.phase-label {
  font-size: clamp(1rem, 4vmin, 2rem);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
}
body.phase-rest .phase-label { color: #7fd3ff; }
body.phase-countdown .phase-label { color: #d9b8ff; }

.big-number {
  font-size: min(55vw, 55vh);
  font-size: min(55vw, 55dvh);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.paused-badge {
  position: absolute;
  top: 0;
  right: 0;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: clamp(0.9rem, 3vmin, 1.4rem);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.controls {
  width: 100%;
  display: flex;
  gap: 12px;
}
.controls .btn { flex: 1; }

@media (orientation: landscape) and (max-height: 500px) {
  .big-number { font-size: min(40vw, 44vh); }
  .phase-label { font-size: 0.85rem; }
  .stat-value { font-size: clamp(1.1rem, 5vmin, 1.8rem); }
  .btn { min-height: 52px; }
}
