:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

[hidden] {
  display: none !important;
}

button, input {
  font: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

/* Accueil */

#home {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 4vmin, 2rem);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  padding: calc(env(safe-area-inset-top) + 1rem) calc(env(safe-area-inset-right) + 1.25rem) calc(env(safe-area-inset-bottom) + 1rem) calc(env(safe-area-inset-left) + 1.25rem);
  background: #2D2D2D;
  color: #fff;
  overflow-y: auto;
}

#home h1 {
  margin: 0;
  font-size: clamp(1.4rem, 6vmin, 2.4rem);
  line-height: 1.15;
  text-align: center;
}

.field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
}

.field > label,
.toggle-row span {
  font-size: clamp(1rem, 3.5vmin, 1.3rem);
  letter-spacing: .05em;
}

.duration-field {
  display: flex;
  align-items: center;
  gap: .5rem;
}

#attention-input {
  width: 9ch;
  min-height: 56px;
  padding: 0 .5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(1.8rem, 7vmin, 2.6rem);
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: #fff;
  background: #1b1b1b;
  border: 2px solid #808080;
  border-radius: 8px;
}

.unit {
  font-size: 1.5rem;
  opacity: .8;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .75rem;
}

.preset {
  min-width: 64px;
  min-height: 48px;
  font-size: 1.4rem;
  color: #fff;
  background: #3a3a3a;
  border: 2px solid #808080;
  border-radius: 8px;
  cursor: pointer;
}

.preset[aria-pressed="true"] {
  background: #808080;
  border-color: #fff;
}

.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  min-height: 48px;
  cursor: pointer;
}

#sound-toggle {
  width: 32px;
  height: 32px;
  accent-color: #4ECDC4;
}

#start-btn {
  min-height: 64px;
  padding: 0 2rem;
  font-size: clamp(1.1rem, 5vmin, 1.6rem);
  font-weight: 700;
  letter-spacing: .12em;
  color: #000;
  background: #4ECDC4;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

#fullscreen-btn {
  min-height: 48px;
  padding: 0 1rem;
  font-size: clamp(.9rem, 3vmin, 1.2rem);
  letter-spacing: .12em;
  color: #fff;
  background: transparent;
  border: 2px solid #808080;
  border-radius: 8px;
  cursor: pointer;
}

/* Écran séquence */

#screen {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 4vmin, 2.5rem);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background-color: #808080;
  color: #fff;
  transition: background-color .25s ease;
}

#screen[data-phase="ATTENTE"] {
  background-color: #808080;
  color: #fff;
}

#screen[data-phase="TIR"] {
  background-color: #4ECDC4;
  color: #000;
}

#screen[data-phase="RECUP"] {
  background-color: #4A90D9;
  color: #fff;
}

#screen[data-phase="FINIE"] {
  background-color: #2D2D2D;
  color: #fff;
}

#time {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  font-size: clamp(8rem, 74vmin, 40rem);
  line-height: 1;
  letter-spacing: .02em;
  white-space: nowrap;
}

#phase-label {
  text-transform: uppercase;
  letter-spacing: .25em;
  font-size: clamp(.9rem, 3vmin, 1.6rem);
  opacity: .85;
}

#tap-hint {
  margin: 0;
  font-size: clamp(.85rem, 2.6vmin, 1.1rem);
  opacity: .7;
}

.progress-track {
  position: absolute;
  left: env(safe-area-inset-left);
  right: env(safe-area-inset-right);
  bottom: env(safe-area-inset-bottom);
  height: 6px;
  opacity: .7;
}

#progress {
  width: 0%;
  height: 100%;
  background: currentColor;
  border-radius: 3px;
}

noscript {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 1rem;
  background: #2D2D2D;
  color: #fff;
  text-align: center;
}

@media (hover: hover) {
  .preset:hover {
    background: #4a4a4a;
  }

  #start-btn:hover {
    background: #45b8b0;
  }
}
