@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap');

/* ========== THEME VARIABLES ========== */
:root {
  --bg: radial-gradient(circle at top, #020617, #000);
  --card-bg: rgba(15, 23, 42, 0.9);
  --text-color: #e5e7eb;
  --accent: #0ea5e9;
  --accent-soft: rgba(56, 189, 248, 0.35);
  --accent-strong: #38bdf8;
  --border-subtle: rgba(148, 163, 184, 0.45);
  --shadow-strong: 0 20px 60px rgba(15, 23, 42, 0.95);
}

body.light-theme {
  --bg: radial-gradient(circle at top, #e0f2fe, #bfdbfe);
  --card-bg: rgba(255, 255, 255, 0.96);
  --text-color: #0f172a;
  --accent: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.25);
  --accent-strong: #3b82f6;
  --border-subtle: rgba(148, 163, 184, 0.7);
  --shadow-strong: 0 16px 40px rgba(15, 23, 42, 0.3);
}

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

body {
  background: var(--bg);
  color: var(--text-color);
  font-family: 'Poppins', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.wrapper {
  width: 100%;
  max-width: 900px;
  padding: 16px;
  animation: fadeIn 0.9s ease-out;
}

/* ========== CARD ========== */
.stopwatch-card {
  background: var(--card-bg);
  border-radius: 22px;
  padding: 20px 18px 18px;
  box-shadow: var(--shadow-strong);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(14px);
  max-width: 640px;
  margin: 0 auto;
}

/* ========== TOP BAR ========== */
.top-bar {
  max-width: 640px;
  margin: 0 auto 10px auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.title {
  font-size: 28px;
  letter-spacing: 1.5px;
  color: var(--accent-strong);
  text-shadow: 0 0 14px var(--accent-soft);
}

.theme-toggle {
  background: transparent;
  border-radius: 999px;
  border: 1px solid var(--accent-soft);
  padding: 6px 14px;
  font-size: 14px;
  color: var(--accent-strong);
  cursor: pointer;
  transition: 0.25s;
}

.theme-toggle:hover {
  background: var(--accent-strong);
  color: #020617;
}

/* ========== TIMER ========== */
.timer-circle {
  position: relative;
  width: 240px;
  height: 240px;
  margin: 12px auto 18px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.progress-ring {
  position: absolute;
  top: 0;
  left: 0;
}

/* Force SVG to scale with container */
.timer-circle svg {
  width: 100%;
  height: 100%;
}

.progress-ring__background {
  fill: none;
  stroke: rgba(148, 163, 184, 0.35);
  stroke-width: 10;
}

.progress-ring__circle {
  fill: none;
  stroke: var(--accent-strong);
  stroke-width: 10;
  stroke-linecap: round;
  filter: drop-shadow(0 0 10px var(--accent-soft));
  stroke-dasharray: 0;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.25s linear;
}

.timer-display {
  position: relative;
  font-size: 36px;
  font-weight: 600;
  color: var(--accent-strong);
  text-shadow: 0 0 14px var(--accent-soft);
  padding: 10px 22px;
  border-radius: 16px;
  background: radial-gradient(circle, rgba(15, 23, 42, 0.75), transparent);
}

/* ========== BUTTONS ========== */
.buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}

.buttons.single {
  margin-top: 2px;
}

.buttons button {
  min-width: 90px;
  background: transparent;
  border-radius: 999px;
  border: 1px solid var(--accent-strong);
  padding: 9px 16px;
  font-size: 14px;
  color: var(--accent-strong);
  cursor: pointer;
  letter-spacing: 0.4px;
  transition: 0.25s;
}

.buttons button:hover {
  background: var(--accent-strong);
  color: #020617;
  box-shadow: 0 0 22px var(--accent-soft);
  transform: translateY(-1px) scale(1.03);
}

.buttons button:active {
  transform: translateY(1px) scale(0.96);
}

/* ========== LAPS & HISTORY ========== */
.bottom-section {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 14px;
  margin-top: 8px;
}

.laps,
.history {
  background: rgba(15, 23, 42, 0.8);
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  padding: 10px 12px;
  max-height: 230px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.light-theme .laps,
body.light-theme .history {
  background: rgba(255, 255, 255, 0.96);
}

.laps h2,
.history h2 {
  font-size: 16px;
  margin-bottom: 6px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.small-btn {
  background: transparent;
  border-radius: 999px;
  border: 1px solid var(--accent-soft);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--accent-strong);
  cursor: pointer;
  transition: 0.2s;
}

.small-btn:hover {
  background: var(--accent-soft);
  color: #020617;
}

.laps ul,
.history ul {
  list-style: none;
  margin-top: 6px;
  padding-right: 4px;
  overflow-y: auto;
  font-size: 14px;
}

.laps li,
.history li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.4);
}

.laps li span:first-child {
  opacity: 0.7;
}

/* Scrollbars */
.laps ul::-webkit-scrollbar,
.history ul::-webkit-scrollbar {
  width: 6px;
}
.laps ul::-webkit-scrollbar-thumb,
.history ul::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.7);
  border-radius: 999px;
}

/* ========== ANIM ========== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== TABLET ========== */
@media (max-width: 768px) {
  .title {
    font-size: 24px;
  }

  .timer-circle {
    width: 210px;
    height: 210px;
  }

  .timer-display {
    font-size: 30px;
  }

  .bottom-section {
    grid-template-columns: 1fr;
  }

  .laps,
  .history {
    max-height: 260px;
  }
}

/* ========== MOBILE (Option B layout) ========== */
@media (max-width: 480px) {
  .wrapper {
    padding: 10px;
  }

  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .title {
    font-size: 20px;
  }

  .stopwatch-card {
    padding: 16px 10px 14px;
  }

  .timer-circle {
    width: 180px;
    height: 180px;
  }

  .timer-display {
    font-size: 26px;
  }

  .buttons {
    gap: 8px;
  }

  .buttons button {
    min-width: 72px;
    padding: 7px 10px;
    font-size: 12px;
  }

  .bottom-section {
    grid-template-columns: 1fr;
  }
}
