:root {
  --bg: #f5f1e9;
  --ink: #000000;
  --on: #00b050;
  --off: #ff6600;
  --blue: #007aff;
  --yellow: #ffb000;
  --purple: #a855f7;
  --radius: 2rem;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
}

body {
  font-family: "Sora", sans-serif;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(168, 85, 247, 0.12), transparent 55%),
    radial-gradient(90% 60% at 0% 100%, rgba(0, 122, 255, 0.1), transparent 50%),
    var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  user-select: none;
}

.app {
  min-height: 100dvh;
  width: min(100%, 28rem);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: calc(1rem + var(--safe-top)) 1.25rem calc(1.25rem + var(--safe-bottom));
  gap: 0.75rem;
}

.brand {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.phase {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.55;
  text-align: center;
  transition: color 180ms ease, opacity 180ms ease;
}

.phase.is-on {
  color: var(--on);
  opacity: 1;
}

.phase.is-off {
  color: var(--off);
  opacity: 1;
}

.timer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52vh;
  max-height: calc(100dvh - 17rem);
  min-height: 16rem;
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.55);
  box-shadow:
    0 0 0 3px rgba(0, 0, 0, 0.06),
    0 18px 40px rgba(0, 0, 0, 0.08);
  isolation: isolate;
  flex: 0 0 auto;
}

.timer.is-flash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.35);
  animation: flash 220ms ease-out;
  pointer-events: none;
  z-index: 2;
}

@keyframes flash {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.timer__fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: var(--on);
  transition: background-color 220ms ease;
  z-index: 0;
  will-change: height;
}

.timer__fill[data-phase="off"] {
  background: var(--off);
}

.timer__time {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.5rem;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: clamp(4rem, 20vw, 6.5rem);
  font-weight: 800;
  letter-spacing: -0.06em;
  line-height: 1;
  color: var(--ink);
  text-align: center;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
  caret-color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
  -webkit-user-select: text;
  user-select: text;
  pointer-events: none;
}

.timer__time.is-editable {
  pointer-events: auto;
  cursor: text;
}

.timer__time.is-editing {
  text-shadow: none;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 1rem;
}

.timer__time:focus {
  outline: none;
}

.timer__time:read-only {
  cursor: default;
}

.next {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  min-height: 3.5rem;
  padding: 0.85rem 1.2rem;
  border-radius: 1.35rem;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
  cursor: text;
}

.next.is-on {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--on) 55%, transparent);
}

.next.is-off {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--off) 55%, transparent);
}

.next__label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.45);
}

.next.is-on .next__label {
  color: var(--on);
}

.next.is-off .next__label {
  color: var(--off);
}

.next__time {
  -webkit-appearance: none;
  appearance: none;
  min-width: 5rem;
  margin: 0;
  padding: 0.35rem 0.45rem;
  border: none;
  border-radius: 0.65rem;
  background: transparent;
  font-family: inherit;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--ink);
  text-align: right;
  caret-color: var(--ink);
  -webkit-user-select: text;
  user-select: text;
}

.next__time:focus {
  outline: none;
  background: rgba(0, 0, 0, 0.06);
}

.control {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  min-height: 4.25rem;
  margin: 0;
  border: none;
  border-radius: 1.35rem;
  padding: 1.15rem 1.25rem;
  background: var(--purple);
  color: #fff;
  font-family: inherit;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 10px 24px rgba(168, 85, 247, 0.35);
}

.control:active {
  transform: scale(0.985);
}

.control.is-running {
  background: var(--ink);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

.control:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.1rem;
}

.lap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 6.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  background: rgba(168, 85, 247, 0.18);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hint {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(0, 0, 0, 0.45);
  text-align: center;
}
