:root {
  --bg: #000;
  --text: #fff;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

body {
  position: fixed;
  inset: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}

.layout-mobile {
  position: absolute;
  inset: 0;
}

.app {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 1.5rem) 1.25rem calc(var(--safe-bottom) + 1.5rem);
}

.display {
  width: min(100%, 26rem);
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12em;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: min(28vw, 14vh, 7.5rem);
  letter-spacing: 0.02em;
  line-height: 0.92;
  text-align: center;
  outline: none;
  cursor: pointer;
  touch-action: none;
}

.display .hundredths {
  color: rgba(255, 255, 255, 0.42);
  font-size: 0.78em;
  font-weight: 500;
}

.layout-desktop {
  display: none;
  height: 100%;
  width: 100%;
  place-items: center;
  padding: 2rem;
}

.desktop-app {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  column-gap: 0.55em;
  row-gap: 0.2em;
}

.desktop-digit {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  line-height: 1;
  text-align: right;
}

.desktop-hours { grid-column: 1; grid-row: 1; }
.desktop-minutes { grid-column: 1; grid-row: 2; }
.desktop-seconds { grid-column: 1; grid-row: 3; }
.desktop-hundredths { grid-column: 1; grid-row: 4; }

.desktop-app button {
  appearance: none;
  background: transparent;
  color: var(--text);
  border: none;
  font: inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
  justify-self: start;
  width: 1.7em;
  height: 1.35em;
  line-height: 1;
}

#desktop-toggle {
  grid-column: 2;
  grid-row: 2;
}

#desktop-reset {
  grid-column: 2;
  grid-row: 3;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

#desktop-toggle svg {
  width: 1.15em;
  height: 1.15em;
  display: block;
}

#desktop-toggle .icon-pause {
  display: none;
}

#desktop-toggle.is-running .icon-play {
  display: none;
}

#desktop-toggle.is-running .icon-pause {
  display: block;
}

.desktop-app button:active {
  transform: scale(0.94);
}

.desktop-app button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

@media (min-width: 900px) {
  html,
  body {
    overflow: auto;
  }

  body {
    position: static;
    inset: auto;
    display: grid;
    place-items: center;
    touch-action: auto;
  }

  .layout-mobile {
    display: none;
  }

  .layout-desktop {
    display: grid;
  }
}
