:root {
  --bg: #0a0e13;
  --fg: #f4f8fc;
  --muted: #5d6b7a;
  --panel: #141b23;
  --line: #26313d;
  --normal: #7ee787;
  --warn: #ffb020;
  --danger: #ff4b3e;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.clock {
  position: fixed;
  top: 1.1rem;
  right: 1.4rem;
  font-size: clamp(0.9rem, 2.2vw, 1.8rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--muted);
  z-index: 5;
  user-select: none;
}

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

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1vh;
  padding: 2vh 2vw;
}

.activity {
  font-size: min(6vw, 9vh);
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
  color: var(--fg);
  opacity: 0.75;
  max-width: 90vw;
  overflow-wrap: break-word;
}

.time {
  font-size: min(22vw, 46vh);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  color: var(--normal);
  transition: color 0.3s ease;
  user-select: none;
}

/* "1:23:45" needs more horizontal room than "12:34" */
.time.long { font-size: min(15vw, 34vh); }

.time.warn { color: var(--warn); }

.time.danger {
  color: var(--danger);
  animation: pulse 1s ease-in-out infinite;
}

.time.done {
  color: var(--danger);
  animation: pulse 0.7s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.985); }
}

@media (prefers-reduced-motion: reduce) {
  .time.danger, .time.done { animation: none; }
}

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

.controls {
  flex: 0 0 auto;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 0.9rem 1.2rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  transition: opacity 0.35s ease;
}

.controls.hidden {
  opacity: 0;
  pointer-events: none;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.field {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.field.grow { flex: 1 1 14rem; }
.field.grow input { flex: 1 1 auto; min-width: 0; }

input[type="text"] {
  background: #0a0e13;
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.5rem 0.65rem;
  font: inherit;
  font-size: 0.95rem;
}

input[type="text"]:focus-visible,
button:focus-visible {
  outline: 2px solid #4c8dff;
  outline-offset: 2px;
}

button {
  background: #1e2833;
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.5rem 0.95rem;
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

button:hover { background: #27333f; }

button.active {
  background: #2b3a4a;
  border-color: #4c8dff;
}

button.primary {
  background: #2f7d4f;
  border-color: #3d9b64;
  font-weight: 600;
  min-width: 7.5rem;
}

button.primary:hover { background: #37905c; }

button.secondary { padding-inline: 0.8rem; }

.actions { margin-top: 0.15rem; }

.hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

kbd {
  background: #0a0e13;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.75rem;
}
