:root {
  --bg: #000000;
  --accent: #f3b664;
  --hot: #ff5b3a;
  --acc: var(--accent);
  --ink: #f4f1ea;
  --metal-hi: #9aa0a8;
  --metal-mid: #3d4045;
  --metal-lo: #1d1f22;
  --face: #0b0b0c;
  --hl: 0;
  --heat: 0;
  --d: min(300px, 72vw, 54vh);
}

* { box-sizing: border-box; }

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

body {
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 12px;
}

.timer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(14px, 3.6vh, 28px);
}

/* the dial */
.dial {
  position: relative;
  width: var(--d);
  height: var(--d);
  border-radius: 50%;
  touch-action: none;
  cursor: grab;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.dial.is-grab { cursor: grabbing; }
.dial__shake, .dial__press { position: absolute; inset: 0; }

.dial__glow {
  position: absolute;
  inset: -18%;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--acc), transparent 72%);
  opacity: calc(0.05 + var(--heat) * 0.16);
  pointer-events: none;
}

.dial__housing {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.05), transparent 46%),
    radial-gradient(circle at 50% 50%, #151517 0%, #0d0d0e 62%, #08080a 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.11),
    inset 0 -1px 0 rgba(0, 0, 0, 0.9),
    inset 0 0 0 1px rgba(255, 255, 255, 0.035),
    0 0 0 1px rgba(255, 255, 255, 0.045),
    0 30px 60px -24px rgba(0, 0, 0, 1);
  transition: box-shadow 0.4s;
}
.dial:focus-visible .dial__housing {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.11),
    0 0 0 1px rgba(255, 255, 255, 0.045),
    0 0 0 4px rgba(255, 255, 255, 0.2);
}

.dial__track, .dial__index {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.track { fill: none; stroke: rgba(255, 255, 255, 0.055); stroke-width: 3; }
.arc {
  fill: none;
  stroke: var(--acc);
  stroke-width: 3;
  stroke-dasharray: 0 360;
  filter: drop-shadow(0 0 3px color-mix(in srgb, var(--acc) 60%, transparent));
  transition: stroke 0.3s;
}
.timer.is-paused .arc { stroke: rgba(244, 241, 234, 0.38); filter: none; }
.flash { fill: none; stroke: var(--hot); stroke-width: 3; opacity: 0; }

/* the shadow the bezel throws on the housing */
.dial__drop {
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  box-shadow: 0 9px 18px rgba(0, 0, 0, 0.75), 0 2px 3px rgba(0, 0, 0, 0.9);
}

/* brushed metal: the highlights stay with the light while the bezel turns under them */
.dial__bezel {
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.04) 0 0.6px, rgba(0, 0, 0, 0.06) 0.6px 1.7px),
    conic-gradient(from calc(var(--hl) * 1deg),
      var(--metal-mid) 0deg, var(--metal-hi) 38deg, #4a4d53 84deg, var(--metal-lo) 150deg,
      #737981 214deg, #36393e 262deg, #191b1e 318deg, var(--metal-mid) 360deg);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3), inset 0 -1px 1px rgba(0, 0, 0, 0.6);
  -webkit-mask: radial-gradient(closest-side, transparent 69%, #000 69.6%);
  mask: radial-gradient(closest-side, transparent 69%, #000 69.6%);
}

.dial__turn {
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  will-change: transform;
}
.dial__knurl {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(rgba(0, 0, 0, 0.5) 0deg 0.9deg, rgba(255, 255, 255, 0.09) 0.9deg 1.4deg, transparent 1.4deg 3deg);
  -webkit-mask: radial-gradient(closest-side, transparent 94.4%, #000 95%);
  mask: radial-gradient(closest-side, transparent 94.4%, #000 95%);
}
.dial__ticks { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.tick { stroke: rgba(10, 11, 13, 0.82); stroke-width: 1; stroke-linecap: round; transition: stroke 0.22s; }
.tick.is-major { stroke-width: 1.9; }
.tick.is-lit { stroke: var(--acc); }
.num {
  fill: rgba(12, 13, 15, 0.78);
  font-size: 10.5px;
  font-weight: 650;
  font-variation-settings: "wdth" 104;
  text-anchor: middle;
  dominant-baseline: central;
}
.num--hi { fill: rgba(255, 255, 255, 0.16); }

.needle { stroke: var(--acc); stroke-width: 2.6; stroke-linecap: round; transition: stroke 0.3s; }
.needle__shadow { stroke: rgba(0, 0, 0, 0.55); stroke-width: 5.4; stroke-linecap: round; }
.timer.is-paused .needle { stroke: rgba(244, 241, 234, 0.6); }

/* the face in the middle: it does not turn */
.face {
  position: absolute;
  inset: 20.8%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--d) * 0.012);
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.07), transparent 52%),
    radial-gradient(circle at 50% 50%, #161618 0%, var(--face) 74%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -10px 22px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(0, 0, 0, 0.95),
    0 0 0 2px rgba(255, 255, 255, 0.05),
    0 7px 16px rgba(0, 0, 0, 0.7);
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.face:focus-visible { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 0 0 2px rgba(255, 255, 255, 0.45); }

.face__brand {
  font-size: calc(var(--d) * 0.03);
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(244, 241, 234, 0.3);
  padding-left: 0.3em;
}

.face__time {
  display: flex;
  align-items: center;
  font-size: calc(var(--d) * 0.168);
  font-weight: 560;
  font-variation-settings: "wdth" 106;
  line-height: 1;
  letter-spacing: -0.01em;
  transition: opacity 0.35s, color 0.35s;
}
.timer.is-paused .face__time { opacity: 0.5; }
.timer.is-idle .face__time { color: rgba(244, 241, 234, 0.42); }
.dig {
  position: relative;
  display: block;
  width: 0.6em;
  height: 1.1em;
  overflow: hidden;
  -webkit-mask: linear-gradient(transparent, #000 22%, #000 78%, transparent);
  mask: linear-gradient(transparent, #000 22%, #000 78%, transparent);
}
.col { position: absolute; left: 0; right: 0; top: 0.05em; display: block; }
.col > span { display: block; height: 1em; line-height: 1; text-align: center; }
.colon { width: 0.28em; text-align: center; opacity: 0.55; transform: translateY(-0.06em); }

.face__label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  height: 1.4em;
  font-size: calc(var(--d) * 0.042);
  font-weight: 500;
  color: rgba(244, 241, 234, 0.58);
}
.glyph { width: 0.85em; height: 0.85em; fill: currentColor; flex: none; display: none; }
.timer.is-running .glyph, .timer.is-paused .glyph { display: block; }
.glyph__play { opacity: 0; }
.timer.is-paused .glyph__pause { opacity: 0; }
.timer.is-paused .glyph__play { opacity: 1; }
.face__words {
  position: relative;
  display: block;
  height: 1.4em;
  min-width: 7.6em;
  overflow: hidden;
}
.timer.is-running .face__words, .timer.is-paused .face__words { min-width: 3.6em; }
.w {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  line-height: 1.4em;
  text-align: center;
  white-space: nowrap;
}
.timer.is-done .face__label { color: var(--acc); }

/* the presets */
.presets { display: flex; gap: 8px; }
.preset {
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(#161618, #0c0c0d);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 6px 14px -6px rgba(0, 0, 0, 0.9);
  color: rgba(244, 241, 234, 0.78);
  font: inherit;
  font-size: 14px;
  font-weight: 520;
  font-variation-settings: "wdth" 100;
  cursor: pointer;
  white-space: nowrap;
  transition: font-variation-settings 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
    border-color 0.3s, background 0.3s, color 0.3s;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.preset b { margin-left: 0.36em; font-weight: 650; color: var(--acc); transition: color 0.3s; }
.preset:active { transform: scale(0.94); }
.preset:focus-visible { border-color: rgba(255, 255, 255, 0.4); }
.preset.is-on {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--acc) 50%, transparent);
  background: linear-gradient(color-mix(in srgb, var(--acc) 12%, #161618), #0c0c0d);
}
@media (hover: hover) {
  .preset:hover { font-variation-settings: "wdth" 118; color: var(--ink); border-color: rgba(255, 255, 255, 0.16); transform: translateY(-1px); }
  .preset:active { transform: scale(0.94); }
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  margin: 0;
}

.ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  pointer-events: none;
  fill: #f4f1ea;
  stroke: #0b0b0c;
  stroke-width: 1.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  opacity: 0;
  visibility: hidden;
  z-index: 5;
}

@media (max-width: 380px) {
  .preset { padding: 0 13px; font-size: 13px; height: 38px; }
}
