:root {
  color-scheme: light;
  --page: #eef4f7;
  --ink: #101418;
  --soft-ink: #53606b;
  --panel: rgba(255, 255, 255, .88);
  --panel-line: rgba(45, 57, 73, .14);
  --display: #111a21;
  --display-2: #1d313b;
  --start: #11835f;
  --start-dark: #0d6f50;
  --stop: #cb4b4b;
  --stop-dark: #ad3b3b;
  --reset: #2f68d8;
  --reset-dark: #2554b2;
  --warm: #e0a53f;
  --shadow: 0 28px 75px rgba(17, 28, 39, .2);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  background:
    url("stopwatch-texture.svg") center / cover no-repeat,
    linear-gradient(135deg, #eaf1f6 0%, #f8fbff 44%, #edf2ea 100%);
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, rgba(15, 23, 42, .08), transparent 34%),
    linear-gradient(315deg, rgba(224, 165, 63, .14), transparent 42%);
}

main {
  position: relative;
  width: min(760px, calc(100% - 32px));
  padding: 28px 0;
}

.stopwatch {
  position: relative;
  display: grid;
  gap: 24px;
  padding: 30px;
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.stopwatch::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-top: 5px solid var(--warm);
  opacity: .95;
}

.topline {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 34px;
}

h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.15;
  font-weight: 780;
  letter-spacing: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(83, 96, 107, .18);
  border-radius: 999px;
  background: rgba(255, 255, 255, .72);
  color: var(--soft-ink);
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #9aa7b4;
  box-shadow: 0 0 0 4px rgba(154, 167, 180, .16);
}

body.is-running .status::before {
  background: var(--start);
  box-shadow: 0 0 0 4px rgba(17, 131, 95, .18);
}

.display {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 26px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .08), transparent 33%),
    linear-gradient(135deg, var(--display), var(--display-2));
  color: #f8fbff;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  text-align: center;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .12),
    inset 0 -20px 70px rgba(0, 0, 0, .22),
    0 20px 45px rgba(15, 23, 42, .2);
  overflow: hidden;
}

.display::before {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 50%;
  background:
    repeating-conic-gradient(from -2deg, rgba(255, 255, 255, .14) 0deg 1deg, transparent 1deg 12deg);
  opacity: .42;
}

.display::after {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 8px;
  pointer-events: none;
}

.time {
  position: relative;
  z-index: 1;
  width: 100%;
  font-size: 96px;
  line-height: .95;
  letter-spacing: 0;
  white-space: nowrap;
  text-shadow: 0 10px 26px rgba(0, 0, 0, .28);
}

.controls {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 14px;
}

button {
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 760;
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform .16s ease, box-shadow .16s ease, background-color .16s ease, opacity .16s ease;
  box-shadow: 0 14px 28px rgba(17, 28, 39, .18);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 18px 36px rgba(17, 28, 39, .22);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:focus-visible {
  outline: 3px solid rgba(47, 104, 216, .28);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: .48;
  box-shadow: none;
}

.icon {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  fill: currentColor;
}

.primary {
  background: var(--start);
}

.primary:hover:not(:disabled) {
  background: var(--start-dark);
}

.danger {
  background: var(--stop);
}

.danger:hover:not(:disabled) {
  background: var(--stop-dark);
}

.secondary {
  background: var(--reset);
}

.secondary:hover:not(:disabled) {
  background: var(--reset-dark);
}

@supports not (backdrop-filter: blur(18px)) {
  .stopwatch {
    background: rgba(255, 255, 255, .96);
  }
}

@media (prefers-reduced-motion: reduce) {
  button {
    transition: none;
  }

  button:hover:not(:disabled) {
    transform: none;
  }
}

@media (max-width: 720px) {
  body {
    place-items: stretch;
  }

  main {
    width: 100%;
    padding: 12px;
  }

  .stopwatch {
    min-height: calc(100vh - 24px);
    align-content: center;
    padding: 20px;
  }

  .topline {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .display {
    min-height: 190px;
  }

  .display::before {
    width: 320px;
    height: 320px;
  }

  .time {
    font-size: 58px;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  button {
    min-height: 54px;
  }
}

@media (max-width: 390px) {
  .stopwatch {
    padding: 16px;
  }

  .display {
    min-height: 165px;
    padding: 18px;
  }

  .time {
    font-size: 44px;
  }

  button {
    padding: 0 12px;
    font-size: 15px;
  }
}
