:root {
  --bg: #000000;
  --text: #ff2d2d;
  --hint: #eadf9f;
  --muted: #8c8c8c;
  --accent: #1877f2;
  --panel: #121212;
  --line: #2f2f2f;
  --timer-size: min(84vw, 62vh);
  --timer-size-mobile: min(74vw, 50vh);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: #ffffff;
  font-family: "Space Grotesk", sans-serif;
}

.clock-app {
  min-height: 100vh;
  padding: 1rem 1.2rem 2rem;
  display: flex;
  flex-direction: column;
}

.clock-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.back-link {
  color: #9e9e9e;
  text-decoration: none;
  font-size: 1rem;
}

.back-link:hover,
.back-link:focus-visible {
  color: #c9c9c9;
}

.icon-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0c0c0c;
  color: #d9d9d9;
  padding: 0.35rem 0.65rem;
  font-size: 1.1rem;
  cursor: pointer;
}

.clock-meta {
  margin-top: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.primary-btn,
.ghost-btn {
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 1.75rem;
  border: 0;
  cursor: pointer;
}

.primary-btn {
  background: var(--accent);
  color: #ffffff;
}

.primary-btn:hover,
.primary-btn:focus-visible {
  filter: brightness(1.07);
}

.ghost-btn {
  background: transparent;
  color: #e4e4e4;
  border: 1px solid var(--line);
}

.set-label {
  margin: 0;
  color: #6d6d6d;
  font-size: clamp(1.3rem, 2vw, 2rem);
}

#setValue {
  color: #1b89ff;
  font-size: clamp(2rem, 4vw, 4.5rem);
  font-weight: 700;
  padding-left: 0.25rem;
}

.timer-zone {
  flex: 1;
  margin-top: 0.5rem;
  border: 0;
  background: transparent;
  color: inherit;
  width: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  cursor: pointer;
  padding: 0;
}

.timer-value {
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  line-height: 0.9;
  font-size: var(--timer-size);
  letter-spacing: -0.04em;
}

.timer-hint {
  margin-top: -0.3em;
  color: var(--hint);
  font-weight: 700;
  font-size: clamp(2rem, 4vw, 4rem);
}

.timer-zone.running .timer-hint {
  visibility: hidden;
}

.settings-panel {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: min(90vw, 340px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 95%, #000000);
  padding: 1rem;
  z-index: 40;
  display: none;
}

.settings-panel.open {
  display: block;
}

.settings-panel h2 {
  margin: 0 0 0.7rem;
}

.settings-panel label {
  display: block;
  margin: 0.45rem 0 0.25rem;
  color: #b8b8b8;
}

.settings-panel input,
.settings-panel select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  background: #090909;
  color: #efefef;
  font-family: "IBM Plex Mono", monospace;
}

.settings-actions {
  margin-top: 0.8rem;
  display: flex;
  gap: 0.5rem;
}

.set-flash {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  color: #101010;
  z-index: 50;
  pointer-events: none;
}

.set-flash.visible {
  display: flex;
  animation: flashPulse 420ms steps(2, end) infinite;
}

.flash-set-value {
  color: inherit;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  line-height: 0.9;
  font-size: var(--timer-size);
  letter-spacing: -0.04em;
}

.tap-ack-flash {
  position: fixed;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  background: #ffffff;
  opacity: 0;
}

.tap-ack-flash.visible {
  animation: tapAckPulse 170ms ease-out 1;
}

@keyframes flashPulse {
  0%,
  100% {
    background: #ffffff;
    color: #101010;
  }
  50% {
    background: #101010;
    color: #ffffff;
  }
}

@keyframes tapAckPulse {
  0% { opacity: 0; }
  32% { opacity: 0.35; }
  100% { opacity: 0; }
}

@media (max-width: 780px) {
  .primary-btn,
  .ghost-btn {
    font-size: 1rem;
  }

  .timer-value {
    font-size: var(--timer-size-mobile);
    letter-spacing: -0.03em;
  }

  .flash-set-value {
    font-size: var(--timer-size-mobile);
    letter-spacing: -0.03em;
  }

  .timer-hint {
    font-size: clamp(1.4rem, 6vw, 2.4rem);
  }
}
