@font-face {
  font-family: 'DSDigital';
  src: local('Consolas');
}

:root {
  --bg: #050506;
  --panel: rgba(20, 21, 24, 0.6);
  --panel-solid: #131417;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f3f3f5;
  --muted: #8b8d95;
  --accent: #ff2b2b;
  --accent-2: #ff5b3d;
  --accent-glow: rgba(255, 43, 43, 0.55);
  --green: #2fe08a;
  --green-glow: rgba(47, 224, 138, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.bg-scene {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.bg-scene .blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  will-change: transform;
}

.bg-scene .blob.b1 {
  width: 46vw;
  height: 46vw;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  top: -12%;
  left: -10%;
  animation: drift1 22s ease-in-out infinite alternate;
}

.bg-scene .blob.b2 {
  width: 38vw;
  height: 38vw;
  background: radial-gradient(circle, #7a1fff 0%, transparent 70%);
  bottom: -14%;
  right: -8%;
  opacity: 0.22;
  animation: drift2 26s ease-in-out infinite alternate;
}

.bg-scene .blob.b3 {
  width: 30vw;
  height: 30vw;
  background: radial-gradient(circle, var(--accent-2) 0%, transparent 70%);
  top: 40%;
  left: 55%;
  opacity: 0.16;
  animation: drift3 30s ease-in-out infinite alternate;
}

.bg-scene .grid {
  position: absolute;
  inset: -2px;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black 20%, transparent 75%);
  animation: gridpulse 8s ease-in-out infinite;
}

@keyframes drift1 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(6vw, 8vh) scale(1.15); }
}
@keyframes drift2 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-5vw, -6vh) scale(1.1); }
}
@keyframes drift3 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-4vw, 5vh) scale(0.9); }
}
@keyframes gridpulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  position: relative;
  width: 380px;
  max-width: 100%;
  background: var(--panel);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px;
  animation: rise 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 21px;
  padding: 1px;
  background: conic-gradient(from var(--rot, 0deg), transparent 0deg, var(--accent-glow) 90deg, transparent 200deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.7;
  animation: rotor 6s linear infinite;
  pointer-events: none;
}

@keyframes rotor {
  to { --rot: 360deg; }
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand .mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(155deg, var(--accent-2), #7a0f0f);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 18px var(--accent-glow);
  animation: markpulse 2.4s ease-in-out infinite;
}

.brand .mark svg { width: 18px; height: 18px; }

@keyframes markpulse {
  0%, 100% { box-shadow: 0 0 14px var(--accent-glow); }
  50% { box-shadow: 0 0 26px var(--accent-glow); }
}

.brand h1 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.2px;
}

.brand .sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 7px;
  letter-spacing: 0.2px;
}

.field { margin-bottom: 18px; }

input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 14.5px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input::placeholder { color: #55565c; }

input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 0 4px rgba(255, 43, 43, 0.12);
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
}

.btn {
  position: relative;
  overflow: hidden;
  width: 100%;
  padding: 13px;
  border-radius: 9px;
  font-size: 14.5px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.2px;
  transition: transform 0.15s ease, box-shadow 0.25s ease, filter 0.2s ease;
}

.btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.25), transparent);
  transform: skewX(-20deg);
  transition: left 0.55s ease;
}

.btn:hover::after { left: 130%; }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent) 60%, #9c1414);
  box-shadow: 0 8px 24px rgba(255, 43, 43, 0.28);
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 10px 30px rgba(255, 43, 43, 0.4); }

.btn-green {
  background: linear-gradient(135deg, #46f0a4, var(--green) 65%, #1a9a5f);
  box-shadow: 0 8px 24px rgba(47, 224, 138, 0.25);
}
.btn-green:hover { filter: brightness(1.06); box-shadow: 0 10px 30px rgba(47, 224, 138, 0.38); }

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: none;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.09); border-color: var(--border-strong); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
.btn-outline:hover { border-color: var(--accent); color: var(--text); }

.btn:disabled {
  opacity: 0.35;
  cursor: default;
  filter: none;
  box-shadow: none;
  transform: none;
}
.btn:disabled::after { display: none; }

.error-msg {
  color: var(--accent-2);
  font-size: 13px;
  margin-top: 16px;
  min-height: 16px;
  opacity: 0;
}
.error-msg.show {
  opacity: 1;
  animation: shake 0.4s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 7px;
  transition: all 0.2s ease;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: rgba(255, 255, 255, 0.09); }

.ring-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto 22px;
}

.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }

.ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 8;
}

.ring-fill {
  fill: none;
  stroke: url(#ringGradient);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s linear;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.ring-fill.running { filter: drop-shadow(0 0 12px var(--accent-glow)); }

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

#displayTime {
  animation: flicker 3.2s ease-in-out infinite;
}

@keyframes flicker {
  0%, 96%, 100% { opacity: 1; }
  97% { opacity: 0.92; }
  98% { opacity: 1; }
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.3s ease;
}

.status-row.running .status-dot {
  background: var(--green);
  box-shadow: 0 0 10px var(--green-glow);
  animation: dotpulse 1.4s ease-in-out infinite;
}
.status-row.running { color: var(--green); }

@keyframes dotpulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

.row { display: flex; gap: 10px; margin-bottom: 20px; }
.row .field { flex: 1; margin-bottom: 0; }

.controls { display: flex; gap: 10px; margin-top: 22px; }
.controls .btn { flex: 1; padding: 13px 8px; font-size: 13.5px; }

.clock {
  text-align: right;
}
.clock .clock-time {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}
.clock .clock-date {
  font-size: 11px;
  color: var(--muted);
  text-transform: capitalize;
  margin-top: 1px;
}

.history-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 26px 0 12px;
}
.history-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.history-list {
  max-height: 210px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}
.history-list::-webkit-scrollbar { width: 5px; }
.history-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.history-list::-webkit-scrollbar-track { background: transparent; }

.history-empty {
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  padding: 14px 0;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  animation: histIn 0.35s ease both;
}

@keyframes histIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.history-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.history-dot.set { background: #8b8d95; }
.history-dot.start { background: var(--green); box-shadow: 0 0 8px var(--green-glow); }
.history-dot.pause { background: #f5a623; }
.history-dot.reset { background: #6c7ae0; }
.history-dot.finished { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.history-dot.defuse { background: var(--green); box-shadow: 0 0 8px var(--green-glow); }

.btn-defuse {
  width: 100%;
  background: linear-gradient(135deg, #3fdb8f, #1f8f56 65%, #0d3f26);
  color: #fff;
  box-shadow: 0 8px 24px rgba(47, 224, 138, 0.22);
}
.btn-defuse:hover { filter: brightness(1.08); box-shadow: 0 10px 30px rgba(47, 224, 138, 0.35); }

.history-main {
  flex: 1;
  min-width: 0;
}
.history-label {
  color: var(--text);
  font-weight: 500;
}
.history-duration {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.history-when {
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
  text-align: right;
}
