:root {
  --bg-1: #0f2027;
  --bg-2: #203a43;
  --bg-3: #2c5364;
  --card: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.12);
  --text: #f5f7fa;
  --muted: #9fb3c8;
  --primary: #4facfe;
  --primary-2: #00f2fe;
  --danger: #ff6b6b;
  --progress: linear-gradient(90deg, #00f2fe, #4facfe);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2), var(--bg-3));
  background-size: 200% 200%;
  animation: bgShift 18s ease infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

@keyframes bgShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.card {
  width: 100%;
  max-width: 380px;
  padding: 36px 32px;
  border-radius: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  text-align: center;
}

.title {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 18px;
}

.presets {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 22px;
}

.chip {
  flex: 1;
  padding: 8px 0;
  font-size: 13px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip:hover {
  background: rgba(79, 172, 254, 0.18);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.chip:active { transform: translateY(0); }

.display {
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 72px;
  font-weight: 700;
  letter-spacing: 2px;
  line-height: 1;
  margin-bottom: 18px;
  text-shadow: 0 0 30px rgba(79, 172, 254, 0.35);
  font-variant-numeric: tabular-nums;
}

.progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-bottom: 24px;
}

.progress-bar {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--progress);
  transition: width 0.2s linear;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  margin-bottom: 22px;
  transition: border-color 0.2s ease;
}

.input-row:focus-within { border-color: var(--primary); }

#seconds {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 18px;
  font-family: inherit;
}

#seconds::placeholder { color: var(--muted); }

.shake-error { animation: inputShake 0.4s ease; }
@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* 隐藏 number input 的上下箭头 */
#seconds::-webkit-outer-spin-button,
#seconds::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#seconds { -moz-appearance: textfield; }

.unit { color: var(--muted); font-size: 14px; }

.controls {
  display: flex;
  gap: 12px;
}

.btn {
  flex: 1;
  padding: 13px 0;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  color: #04263a;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 8px 24px rgba(79, 172, 254, 0.35);
}

.btn-primary:hover { filter: brightness(1.08); }

.btn-primary.paused {
  background: linear-gradient(135deg, #f6d365, #fda085);
  color: #3a2400;
  box-shadow: 0 8px 24px rgba(252, 160, 133, 0.35);
}

.btn-secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(255, 107, 107, 0.15);
  border-color: var(--danger);
  color: var(--danger);
}

/* 到零弹窗 */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 50;
}

.modal-overlay.show {
  display: flex;
  animation: fadeIn 0.25s ease;
}

.modal {
  width: min(320px, 86vw);
  padding: 36px 28px 28px;
  border-radius: 24px;
  background: linear-gradient(160deg, #1f3a4a, #16242f);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-icon {
  font-size: 48px;
  margin-bottom: 12px;
  animation: shake 0.6s ease;
}

.modal-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}

.modal-desc {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 24px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }
@keyframes shake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-12deg); }
  40% { transform: rotate(12deg); }
  60% { transform: rotate(-8deg); }
  80% { transform: rotate(8deg); }
}
