/* ------------------------------------------------------------------
   Match timer
   Monochrome with a single alarm red, sized for a projector. Restraint
   over decoration: no gradients, no bounce, no decorative motion.
   ------------------------------------------------------------------ */

:root {
  --bg: #0a0b0d;
  --fg: #f5f6f7;
  --muted: #8a8f98;
  --hairline: rgba(255, 255, 255, 0.12);
  --hairline-dim: rgba(255, 255, 255, 0.07);
  --alarm: #e5484d;
  --warn: #d9a441;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --pad: clamp(1.25rem, 3vw, 2.5rem);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ------------------------------------------------------------- stage */

.stage {
  width: 100%;
  padding: var(--pad);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1rem, 2.5vh, 1.75rem);
}

.stage__status {
  margin: 0;
  font-size: clamp(0.6875rem, 1.1vw, 0.8125rem);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.2s var(--ease);
}

/* ------------------------------------------------------------- clock */

.clock {
  margin: 0;
  font-size: clamp(5rem, 26vw, 22rem);
  font-weight: 200;
  line-height: 0.92;
  letter-spacing: -0.03em;
  /* Tabular figures stop the digits jittering as the value ticks over. */
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
  transition: color 0.2s var(--ease);
}

.clock--urgent {
  color: var(--alarm);
}

/* ------------------------------------------------------------- note */

.stage__note {
  margin: 0;
  min-height: 1.25em;
  font-size: clamp(0.8125rem, 1.3vw, 0.9375rem);
  font-weight: 450;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.stage__note--alarm {
  color: var(--alarm);
}

/* ------------------------------------------------------------- controls */

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.625rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 44px;
  padding: 0 1.125rem;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 450;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease),
    opacity 0.15s var(--ease);
}

.btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.22);
}

.btn:active:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
}

.btn:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

.btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.btn--primary {
  border-color: rgba(255, 255, 255, 0.26);
}

.btn--tie:not(:disabled) {
  color: var(--warn);
  border-color: rgba(217, 164, 65, 0.42);
}

.btn--tie:not(:disabled):hover {
  background: rgba(217, 164, 65, 0.1);
  border-color: rgba(217, 164, 65, 0.6);
}

/* Recovery control. Deliberately dimmer than the tie-break so it never reads
   as a routine action - you reach for it only after a misclick. */
.btn--skip {
  color: var(--muted);
  border-color: var(--hairline-dim);
}

/* ------------------------------------------------------------- hints */

.hints {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.375rem 1.125rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.75rem;
  color: var(--muted);
}

.hints li {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0.15em 0.4em;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.6875rem;
  line-height: 1.5;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--hairline-dim);
  border-radius: 4px;
}

/* ------------------------------------------------------------- sound */

.sound {
  position: fixed;
  top: var(--pad);
  right: var(--pad);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 36px;
  padding: 0 0.75rem;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 450;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--hairline-dim);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.sound:hover {
  color: var(--fg);
  border-color: var(--hairline);
}

.sound:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

.sound__icon {
  display: block;
  width: 16px;
  height: 16px;
}

.sound__icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* The slash is only drawn when audio is off. */
.sound .mute-slash,
.sound .wave {
  opacity: 0;
  transition: opacity 0.15s var(--ease);
}

.sound[data-state='on'] .wave {
  opacity: 1;
}

.sound[data-state='muted'] .mute-slash,
.sound[data-state='blocked'] .mute-slash {
  opacity: 1;
}

.sound[data-state='muted'] {
  color: var(--muted);
  opacity: 0.7;
}

/* Autoplay is blocked until a gesture - surface it in the one alarm colour
   that isn't already spoken for by the clock. */
.sound[data-state='blocked'] {
  color: var(--warn);
  border-color: rgba(217, 164, 65, 0.35);
}

/* ------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--pad) + 0.5rem);
  transform: translateX(-50%);
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--hairline-dim);
  border-radius: 999px;
  white-space: nowrap;
}

/* ------------------------------------------------------------- fullscreen
   Projection mode: strip the chrome and let the digits take the screen. */

:fullscreen .stage,
:-webkit-full-screen .stage {
  gap: clamp(1.5rem, 4vh, 3rem);
}

:fullscreen .controls,
:fullscreen .hints,
:fullscreen .sound,
:-webkit-full-screen .controls,
:-webkit-full-screen .hints,
:-webkit-full-screen .sound {
  display: none;
}

:fullscreen .clock,
:-webkit-full-screen .clock {
  font-size: min(34vw, 46vh);
}

/* ------------------------------------------------------------- a11y */

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 560px) {
  .sound__label {
    display: none;
  }

  .sound {
    padding: 0 0.625rem;
  }

  .btn kbd {
    display: none;
  }
}