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

:root {
  color-scheme: dark;
  --time-color: rgba(236, 242, 255, 0.88);
  --date-color: rgba(200, 215, 245, 0.62);
  --glow: 0 0 40px rgba(140, 170, 255, 0.12),
    0 0 80px rgba(100, 130, 220, 0.08);
  --date-font: "Space Grotesk", system-ui, sans-serif;
  --time-font: "Exo 2", system-ui, sans-serif;
  --time-weight: 200;
  --time-tracking: 0.08em;
  --time-size: clamp(4.2rem, 15vw, 10.5rem);
}

/* 1 · Orbitron — sci-fi HUD */
body.font-1 {
  --time-font: "Orbitron", system-ui, sans-serif;
  --time-weight: 400;
  --time-tracking: 0.12em;
  --date-font: "Orbitron", system-ui, sans-serif;
}

/* 2 · Exo 2 — sleek geometric */
body.font-2 {
  --time-font: "Exo 2", system-ui, sans-serif;
  --time-weight: 200;
  --time-tracking: 0.08em;
  --time-size: clamp(4.2rem, 15vw, 10.5rem);
  --date-font: "Exo 2", system-ui, sans-serif;
}

/* 3 · Space Grotesk — refined contemporary */
body.font-3 {
  --time-font: "Space Grotesk", system-ui, sans-serif;
  --time-weight: 300;
  --time-tracking: 0.04em;
  --time-size: clamp(4.4rem, 15.5vw, 11rem);
  --date-font: "Space Grotesk", system-ui, sans-serif;
}

/* 4 · Oxanium — angular digital */
body.font-4 {
  --time-font: "Oxanium", system-ui, sans-serif;
  --time-weight: 300;
  --time-tracking: 0.08em;
  --time-size: clamp(4.2rem, 15vw, 10.5rem);
  --date-font: "Oxanium", system-ui, sans-serif;
}

/* 5 · Share Tech Mono — terminal */
body.font-5 {
  --time-font: "Share Tech Mono", ui-monospace, monospace;
  --time-weight: 400;
  --time-tracking: 0.06em;
  --time-size: clamp(4rem, 14.5vw, 10rem);
  --date-font: "Share Tech Mono", ui-monospace, monospace;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #050510;
  font-family: var(--date-font);
  cursor: none;
  user-select: none;
  -webkit-user-select: none;
}

body.cursor-visible {
  cursor: default;
}

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  pointer-events: none;
  transition: opacity 0.8s ease;
}

.overlay.hidden {
  opacity: 0;
}

.clock {
  text-align: center;
  padding: 2rem;
  transform: translateY(-2vh);
}

.date {
  font-family: var(--date-font);
  font-weight: 300;
  font-size: clamp(0.7rem, 1.5vw, 0.95rem);
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--date-color);
  margin-bottom: 1.25rem;
  opacity: 0;
  animation: fade-in 2.4s ease 0.4s forwards;
}

.time {
  font-family: var(--time-font);
  font-weight: var(--time-weight);
  font-style: normal;
  font-size: var(--time-size);
  line-height: 0.95;
  letter-spacing: var(--time-tracking);
  color: var(--time-color);
  text-shadow: var(--glow);
  font-variant-numeric: tabular-nums;
  opacity: 0;
  animation: fade-in 2.8s ease 0.2s forwards;
}

.time .sep {
  opacity: 0.45;
  margin: 0 0.02em;
  animation: pulse-sep 2s ease-in-out infinite;
}

.countdown {
  font-family: var(--time-font);
  font-weight: var(--time-weight);
  font-size: calc(var(--time-size) * 0.5);
  line-height: 0.95;
  letter-spacing: var(--time-tracking);
  color: rgba(200, 215, 245, 0.72);
  text-shadow: 0 0 28px rgba(140, 170, 255, 0.1);
  font-variant-numeric: tabular-nums;
  margin-top: 2.75rem;
  min-height: 1.2em;
  transition:
    font-size 0.55s ease,
    color 0.4s ease,
    text-shadow 0.4s ease,
    opacity 0.5s ease;
}

/* ≤ 5 minutes remaining — match clock height */
.countdown.urgent {
  font-size: var(--time-size);
  color: rgba(220, 230, 255, 0.88);
  text-shadow: 0 0 40px rgba(140, 170, 255, 0.16),
    0 0 80px rgba(100, 130, 220, 0.1);
}

.countdown[hidden] {
  display: none;
}

.countdown .sep {
  opacity: 0.45;
  margin: 0 0.02em;
}

.countdown.done {
  font-size: var(--time-size);
  color: rgba(255, 245, 240, 0.95);
  text-shadow: 0 0 30px rgba(255, 180, 140, 0.45),
    0 0 80px rgba(255, 120, 80, 0.25);
  animation: countdown-pulse 1s ease-in-out infinite;
}

/* Full-screen attention when timer ends */
.timer-alert-flash {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 200, 160, 0.22) 0%,
    rgba(120, 80, 200, 0.12) 40%,
    rgba(5, 5, 16, 0.55) 100%
  );
}

body.timer-alert .timer-alert-flash {
  animation: alert-flash 1.1s ease-in-out infinite;
}

body.timer-alert .countdown.done {
  animation: countdown-pulse 0.85s ease-in-out infinite;
}

@keyframes countdown-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.72;
    transform: scale(1.03);
  }
}

@keyframes alert-flash {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 0.95;
  }
}

@media (prefers-reduced-motion: reduce) {
  .countdown.done,
  body.timer-alert .timer-alert-flash {
    animation: none;
  }

  body.timer-alert .timer-alert-flash {
    opacity: 0.55;
  }
}

.font-label {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 300;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(170, 195, 240, 0.4);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.font-label.show {
  opacity: 1;
}

.sky-status {
  position: fixed;
  bottom: 1.75rem;
  left: 1.5rem;
  z-index: 2;
  max-width: min(52vw, 28rem);
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 0.65rem;
  font-weight: 300;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(150, 175, 220, 0.28);
  pointer-events: none;
  line-height: 1.4;
  transition: opacity 1.2s ease;
}

.hint {
  position: fixed;
  bottom: 1.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 0.68rem;
  font-weight: 300;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(160, 180, 220, 0.22);
  transition: opacity 1.2s ease;
  pointer-events: none;
  white-space: nowrap;
}

.hint a {
  pointer-events: auto;
  color: rgba(180, 200, 240, 0.4);
  text-decoration: none;
  border-bottom: 1px solid rgba(140, 160, 200, 0.2);
}

.hint a:hover {
  color: rgba(210, 225, 255, 0.7);
}

.hint kbd {
  font-family: inherit;
  font-size: inherit;
  letter-spacing: 0.08em;
  color: rgba(180, 200, 240, 0.35);
  border: 1px solid rgba(140, 160, 200, 0.18);
  border-radius: 3px;
  padding: 0.1em 0.4em;
}

.hint.fade {
  opacity: 0;
}

.hint.fade a {
  pointer-events: none;
}

/* Help / keyboard commands */
.help-panel {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  background: rgba(4, 6, 16, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: default;
  padding: 1.5rem;
}

.help-panel[hidden] {
  display: none;
}

.help-card {
  width: min(420px, 100%);
  padding: 1.75rem 1.6rem 1.35rem;
  border-radius: 14px;
  border: 1px solid rgba(150, 175, 230, 0.16);
  background: rgba(10, 14, 32, 0.88);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.help-title {
  font-family: "Exo 2", "Space Grotesk", system-ui, sans-serif;
  font-weight: 300;
  font-size: 0.72rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: rgba(180, 200, 240, 0.55);
  text-align: center;
  margin-bottom: 1.25rem;
}

.help-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.help-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 0.85rem;
  align-items: baseline;
}

.help-row dt {
  font-family: "Exo 2", "Space Grotesk", system-ui, sans-serif;
  font-weight: 300;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: rgba(200, 215, 245, 0.75);
  text-align: right;
}

.help-row dd {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-weight: 300;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
  color: rgba(170, 190, 230, 0.55);
}

.help-row kbd,
.help-foot kbd {
  font-family: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: rgba(200, 220, 255, 0.75);
  border: 1px solid rgba(140, 160, 200, 0.22);
  border-radius: 3px;
  padding: 0.12em 0.42em;
  background: rgba(20, 28, 55, 0.5);
}

.help-foot {
  margin-top: 1.35rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(140, 160, 200, 0.1);
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-weight: 300;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: rgba(150, 170, 210, 0.38);
  text-align: center;
  line-height: 1.45;
}

body.help-open {
  cursor: default;
}

body.help-open .hint {
  opacity: 0;
  pointer-events: none;
}

/* Timer dialog — only visible when setting a countdown */
.timer-dialog {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(4, 6, 16, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: default;
}

.timer-dialog[hidden] {
  display: none;
}

.timer-panel {
  width: min(420px, calc(100vw - 2.5rem));
  padding: 1.75rem 1.6rem 1.4rem;
  border-radius: 14px;
  border: 1px solid rgba(150, 175, 230, 0.16);
  background: rgba(10, 14, 32, 0.82);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.timer-label {
  display: block;
  font-family: "Exo 2", "Space Grotesk", system-ui, sans-serif;
  font-weight: 300;
  font-size: 0.72rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: rgba(180, 200, 240, 0.55);
  margin-bottom: 1rem;
}

.timer-input {
  width: 100%;
  appearance: none;
  border: none;
  border-bottom: 1px solid rgba(150, 175, 230, 0.28);
  background: transparent;
  color: rgba(236, 242, 255, 0.92);
  font-family: "Exo 2", "Space Grotesk", system-ui, sans-serif;
  font-weight: 200;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  letter-spacing: 0.08em;
  text-align: center;
  padding: 0.35rem 0.25rem 0.55rem;
  outline: none;
  caret-color: rgba(180, 205, 255, 0.8);
  user-select: text;
  -webkit-user-select: text;
}

.timer-input::placeholder {
  color: rgba(150, 170, 210, 0.28);
  font-size: 0.55em;
  letter-spacing: 0.06em;
}

.timer-input:focus {
  border-bottom-color: rgba(170, 200, 255, 0.55);
}

.timer-help {
  margin-top: 1rem;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-weight: 300;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: rgba(150, 170, 210, 0.4);
  line-height: 1.45;
}

.timer-error {
  margin-top: 0.65rem;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-weight: 300;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: rgba(255, 170, 170, 0.75);
}

body.timer-open {
  cursor: default;
}

body.timer-open .hint {
  opacity: 0;
  pointer-events: none;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse-sep {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 0.18;
  }
}

@media (prefers-reduced-motion: reduce) {
  .date,
  .time {
    animation: none;
    opacity: 1;
  }

  .time .sep {
    animation: none;
  }
}
