:root {
  --bg: #0a0e14;
  --bg-2: #10161f;
  --surface: #141c28;
  --line: #233043;
  --text: #e8edf4;
  --muted: #8b98ab;
  --accent: #34d399;
  --danger: #f87171;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Consolas, monospace;
  --sans: -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background:
    radial-gradient(900px 500px at 70% -10%, rgba(52, 211, 153, 0.08), transparent 60%),
    radial-gradient(700px 400px at 10% 110%, rgba(56, 132, 255, 0.06), transparent 60%),
    var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 0.55rem;
  font-weight: 700; font-size: 1.15rem; letter-spacing: 0.04em;
  color: var(--text); text-decoration: none;
}
.brand__icon { width: 26px; height: 26px; color: var(--accent); }
.brand span { color: var(--accent); }
.topbar nav { display: flex; gap: 1.4rem; }
.topbar nav a {
  color: var(--muted); text-decoration: none; font-size: 0.88rem;
  letter-spacing: 0.05em; transition: color 0.2s;
}
.topbar nav a:hover { color: var(--accent); }

/* ---------- Tool (hero) ---------- */
.tool {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: clamp(1.2rem, 3vw, 2.2rem) 1rem 1.6rem;
}
.tool h1 {
  font-size: clamp(1.7rem, 3.5vw, 2.4rem);
  letter-spacing: -0.02em;
}
.accent { color: var(--accent); }
.tool__claim {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: clamp(0.62rem, 1.4vw, 0.75rem);
  margin-top: 0.35rem;
}

.display-wrap { margin: clamp(0.9rem, 2.5vw, 1.6rem) 0; perspective: 800px; }
.display {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(3.8rem, 14vw, 8.5rem);
  line-height: 1;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  padding: clamp(0.5rem, 2vw, 1rem) clamp(1rem, 4vw, 2.5rem);
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow:
    inset 0 2px 12px rgba(0, 0, 0, 0.5),
    0 20px 50px rgba(0, 0, 0, 0.45),
    0 0 80px rgba(52, 211, 153, 0.06);
  text-shadow: 0 0 24px rgba(52, 211, 153, 0.35);
  white-space: nowrap;
}
.display__cs {
  font-size: 0.42em;
  color: var(--muted);
  text-shadow: none;
}

.controls {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 0.75rem;
}
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  min-height: 52px;
  padding: 0.65rem 1.6rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s, opacity 0.2s;
}
.btn svg { width: 18px; height: 18px; fill: currentColor; }
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn--primary {
  background: linear-gradient(180deg, #3ee6a4, #22b57c);
  color: #04140d;
  box-shadow: 0 6px 24px rgba(52, 211, 153, 0.35);
}
.btn--primary:hover:not(:disabled) { box-shadow: 0 8px 30px rgba(52, 211, 153, 0.5); }
.btn--pause {
  background: linear-gradient(180deg, #fbbf6b, #e09432);
  color: #1a0f02;
  box-shadow: 0 6px 24px rgba(251, 191, 107, 0.3);
}
.btn--danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.45);
}
.btn--danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.1); }
.btn--ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}
.btn--ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn--small { min-height: 40px; padding: 0.35rem 0.95rem; font-size: 0.85rem; }

.hints { margin-top: 1rem; color: var(--muted); font-size: 0.82rem; letter-spacing: 0.03em; }
kbd {
  font-family: var(--mono);
  font-size: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.1rem 0.45rem;
}

/* ---------- Vueltas ---------- */
.laps-zone { padding: 0 clamp(1rem, 4vw, 2.5rem); max-width: 720px; margin: 0 auto; }
.laps-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.laps-card__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; flex-wrap: wrap;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.laps-card__head h2 { font-size: 1.05rem; letter-spacing: 0.04em; display: flex; align-items: center; gap: 0.5rem; }
.badge {
  font-family: var(--mono); font-size: 0.78rem;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 0.05rem 0.6rem; color: var(--accent);
}
.laps-actions { display: flex; gap: 0.5rem; }
.laps-list { list-style: none; max-height: 320px; overflow-y: auto; }
.lap {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 1rem; align-items: baseline;
  padding: 0.6rem 1.1rem;
  font-family: var(--mono);
  font-size: 0.95rem;
  border-bottom: 1px solid rgba(35, 48, 67, 0.5);
  animation: lapIn 0.25s ease both;
}
@keyframes lapIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
.lap:last-child { border-bottom: none; }
.lap__n { font-family: var(--sans); color: var(--muted); font-size: 0.85rem; }
.lap__partial { font-weight: 700; }
.lap__total { color: var(--muted); }
.lap--best { background: rgba(52, 211, 153, 0.1); }
.lap--best .lap__partial { color: var(--accent); }
.lap--worst { background: rgba(248, 113, 113, 0.08); }
.lap--worst .lap__partial { color: var(--danger); }

/* ---------- Contenido / ads / footer ---------- */
.ad-slot {
  width: min(300px, 90%);
  aspect-ratio: 4 / 3;
  margin: 2rem auto;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.content { max-width: 760px; margin: 0 auto; padding: 1rem clamp(1rem, 4vw, 2rem) 2rem; }
.content article { margin-bottom: 2.2rem; animation: fadeUp 0.5s ease both; }
.content h2 { font-size: 1.35rem; margin-bottom: 0.7rem; letter-spacing: -0.01em; }
.content h3 { font-size: 1.05rem; margin: 1rem 0 0.4rem; }
.content p, .content li { color: var(--muted); font-size: 0.97rem; }
.content strong { color: var(--text); }
.content code {
  font-family: var(--mono); font-size: 0.85em;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 0.05rem 0.35rem; color: var(--accent);
}
.steps { padding-left: 1.3rem; }
.steps li, .uses li { margin-bottom: 0.55rem; }
.uses { list-style: none; }
.uses li { padding-left: 1.1rem; position: relative; }
.uses li::before {
  content: ""; position: absolute; left: 0; top: 0.6em;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 0.6rem;
  padding: 0.75rem 1rem;
  transition: border-color 0.2s;
}
details[open] { border-color: rgba(52, 211, 153, 0.4); }
summary {
  cursor: pointer; font-weight: 600; font-size: 0.97rem;
  outline-offset: 3px;
}
summary:hover { color: var(--accent); }
details p { margin-top: 0.5rem; }
.cta-final {
  text-align: center; font-size: 1.05rem; color: var(--text);
  padding: 1.2rem; border-top: 1px solid var(--line);
}
.cta-final a { color: var(--accent); text-decoration: none; font-weight: 600; }
.cta-final a:hover { text-decoration: underline; }

.footer {
  border-top: 1px solid var(--line);
  padding: 1.5rem clamp(1rem, 4vw, 2.5rem) 2rem;
  text-align: center;
}
.footer nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 1.2rem; margin-bottom: 0.7rem; }
.footer a { color: var(--muted); text-decoration: none; font-size: 0.87rem; }
.footer a:hover { color: var(--accent); }
.footer p { color: var(--muted); font-size: 0.8rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 1.4rem; left: 50%;
  transform: translate(-50%, 20px);
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 10px;
  padding: 0.6rem 1.2rem;
  font-weight: 600; font-size: 0.9rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 50;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.toast--show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 480px) {
  .topbar nav { display: none; }
  .controls .btn { flex: 1 1 100%; justify-content: center; }
  .lap { grid-template-columns: 1fr auto; }
  .lap__total { display: none; }
}
