/* ===== Theme Variables ===== */
:root {
  --bg: #0b0e14;
  --fg: #e9eefc;
  --muted: #9aa6c3;
  --bead: rgba(233, 238, 252, 0.16);
  --beadActive: rgba(233, 238, 252, 0.95);
  --beadPassed: rgba(233, 238, 252, 0.35);
  --lapBead: rgba(247, 231, 165, 0.18);
  --lapBeadActive: rgba(247, 231, 165, 0.85);
  --lapBeadPassed: rgba(247, 231, 165, 0.45);
  --lapRingBead: rgba(246, 179, 122, 0.20);
  --lapRingBeadActive: rgba(246, 179, 122, 0.85);
  --lapRingBeadPassed: rgba(246, 179, 122, 0.50);
  --guruForward: #f7e7a5;
  --guruBackward: #f6b37a;
  --ring: rgba(233, 238, 252, 0.08);
  --accent: #a9c7ff;
  --danger: #ff6b8b;
  --gradient-color: rgba(169, 199, 255, 0.12);
  --border-color: rgba(233, 238, 252, 0.12);
}

[data-theme="light"] {
  --bg: #f5f7fa;
  --fg: #1a1d24;
  --muted: #5a6273;
  --bead: rgba(26, 29, 36, 0.12);
  --beadActive: rgba(26, 29, 36, 0.85);
  --beadPassed: rgba(26, 29, 36, 0.30);
  --lapBead: rgba(241, 217, 122, 0.20);
  --lapBeadActive: rgba(241, 217, 122, 0.90);
  --lapBeadPassed: rgba(241, 217, 122, 0.50);
  --lapRingBead: rgba(242, 168, 104, 0.20);
  --lapRingBeadActive: rgba(242, 168, 104, 0.90);
  --lapRingBeadPassed: rgba(242, 168, 104, 0.55);
  --guruForward: #f1d97a;
  --guruBackward: #f2a868;
  --ring: rgba(26, 29, 36, 0.08);
  --accent: #4a7cc7;
  --danger: #d94965;
  --gradient-color: rgba(74, 124, 199, 0.08);
  --border-color: rgba(26, 29, 36, 0.12);
}

[data-theme="earth"] {
  --bg: #2d2416;
  --fg: #f5e6d3;
  --muted: #b89968;
  --bead: rgba(245, 230, 211, 0.16);
  --beadActive: rgba(245, 230, 211, 0.95);
  --beadPassed: rgba(245, 230, 211, 0.35);
  --lapBead: rgba(242, 213, 154, 0.18);
  --lapBeadActive: rgba(242, 213, 154, 0.90);
  --lapBeadPassed: rgba(242, 213, 154, 0.50);
  --lapRingBead: rgba(233, 163, 106, 0.20);
  --lapRingBeadActive: rgba(233, 163, 106, 0.90);
  --lapRingBeadPassed: rgba(233, 163, 106, 0.55);
  --guruForward: #f2d59a;
  --guruBackward: #e9a36a;
  --ring: rgba(245, 230, 211, 0.08);
  --accent: #d4a574;
  --danger: #c97854;
  --gradient-color: rgba(212, 165, 116, 0.12);
  --border-color: rgba(245, 230, 211, 0.12);
}

[data-theme="ocean"] {
  --bg: #050a14;
  --fg: #e0f2f1;
  --muted: #648da1;
  --bead: rgba(0, 150, 136, 0.15);
  --beadActive: rgba(0, 255, 242, 0.95);
  --beadPassed: rgba(0, 150, 136, 0.40);
  --lapBead: rgba(0, 188, 212, 0.18);
  --lapBeadActive: rgba(0, 230, 255, 0.85);
  --lapBeadPassed: rgba(0, 188, 212, 0.50);
  --lapRingBead: rgba(38, 198, 218, 0.20);
  --lapRingBeadActive: rgba(128, 222, 234, 0.85);
  --lapRingBeadPassed: rgba(38, 198, 218, 0.55);
  --guruForward: #00ffd4;
  --guruBackward: #00e5ff;
  --ring: rgba(0, 150, 136, 0.10);
  --accent: #00bcd4;
  --danger: #ff5277;
  --gradient-color: rgba(0, 188, 212, 0.15);
  --border-color: rgba(0, 150, 136, 0.15);
}

[data-theme="moonlight"] {
  --bg: #000000;
  --fg: #f0f0f0;
  --muted: #70757a;
  --bead: rgba(255, 255, 255, 0.10);
  --beadActive: rgba(255, 255, 255, 0.95);
  --beadPassed: rgba(255, 255, 255, 0.30);
  --lapBead: rgba(200, 200, 200, 0.15);
  --lapBeadActive: rgba(255, 255, 255, 0.90);
  --lapBeadPassed: rgba(200, 200, 200, 0.40);
  --lapRingBead: rgba(150, 150, 150, 0.15);
  --lapRingBeadActive: rgba(255, 255, 255, 0.85);
  --lapRingBeadPassed: rgba(150, 150, 150, 0.45);
  --guruForward: #ffffff;
  --guruBackward: #cccccc;
  --ring: rgba(255, 255, 255, 0.05);
  --accent: #ffffff;
  --danger: #ff4757;
  --gradient-color: rgba(255, 255, 255, 0.05);
  --border-color: rgba(255, 255, 255, 0.12);
}

[data-theme="rose"] {
  --bg: #1a0f16;
  --fg: #fce4ec;
  --muted: #9e7d8a;
  --bead: rgba(236, 64, 122, 0.12);
  --beadActive: rgba(244, 143, 177, 0.95);
  --beadPassed: rgba(236, 64, 122, 0.35);
  --lapBead: rgba(186, 104, 200, 0.15);
  --lapBeadActive: rgba(225, 190, 231, 0.90);
  --lapBeadPassed: rgba(186, 104, 200, 0.45);
  --lapRingBead: rgba(255, 138, 101, 0.15);
  --lapRingBeadActive: rgba(255, 204, 188, 0.90);
  --lapRingBeadPassed: rgba(255, 138, 101, 0.50);
  --guruForward: #f48fb1;
  --guruBackward: #ce93d8;
  --ring: rgba(236, 64, 122, 0.06);
  --accent: #f06292;
  --danger: #ff5252;
  --gradient-color: rgba(240, 98, 146, 0.10);
  --border-color: rgba(236, 64, 122, 0.12);
}

/* ===== Base Styles ===== */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 900px at 50% 25%, var(--gradient-color), transparent 60%), var(--bg);
  color: var(--fg);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  padding: 8px;
}

/* ===== Links ===== */
a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: opacity 0.2s ease;
}

a:hover {
  opacity: 0.8;
}

/* ===== Layout ===== */
.wrap {
  width: 100%;
  max-width: 100vw;
  height: 100%;
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(10px);
  grid-template-rows: auto auto 1fr auto;
}

[data-theme="light"] .wrap {
  background: rgba(255, 255, 255, 0.6);
}

.top {
  grid-row: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

/* ===== Typography ===== */
.count {
  font-size: 34px;
  font-weight: 750;
  letter-spacing: 0.2px;
  line-height: 1.05;
  transition: color 0.15s ease;
}

.count.blocked {
  animation: blink-orange 0.4s ease;
}

.count.counted {
  animation: fade-in 0.5s ease;
}

@keyframes blink-orange {

  0%,
  100% {
    color: var(--fg);
  }

  50% {
    color: #ff9f43;
  }
}

@keyframes fade-in {
  0% {
    opacity: 0.3;
  }

  100% {
    opacity: 1;
  }
}

.sub {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.small {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* ===== Components ===== */
.pill {
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 13px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  white-space: normal;
}

.timer {
  grid-row: 2;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  gap: 6px;
  align-items: center;
  font-variant-numeric: tabular-nums;
}

.status-icon {
  /*
  width: 10px;
  height: 10px;
  */
  display: inline-block;
}

.status-icon.playing {
  color: var(--accent);
}

.status-icon.paused {
  color: var(--muted);
  /* opacity: 0.5; */
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.9;
  margin-left: auto;
}


/* ===== Canvas ===== */
.canvas {
  grid-row: 3;
  width: 100%;
  /* 
  height: 100%;
  */
  min-height: 0;
  border-radius: 18px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

svg {
  width: 100%;
  height: 100%;
  display: block;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.badge {
  pointer-events: none;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 12px;
  width: min(84%, 380px);
  text-align: center;
  line-height: 1.35;
}

[data-theme="light"] .badge {
  background: rgba(255, 255, 255, 0.85);
}

/* ===== Install Toast ===== */
.install-toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%) translateY(10px);
  opacity: 0;
  pointer-events: none;
  z-index: 60;
  max-width: min(92vw, 520px);
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid var(--border-color);
  color: var(--fg);
  font-size: 12.5px;
  line-height: 1.35;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.install-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

[data-theme="light"] .install-toast {
  background: rgba(255, 255, 255, 0.92);
  color: var(--fg);
}

/* ===== Buttons ===== */
select,
button,
input[type="range"] {
  font-family: inherit;
}

button {
  width: 100%;
  background: rgba(233, 238, 252, 0.06);
  color: var(--fg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
}

[data-theme="light"] button {
  background: rgba(26, 29, 36, 0.04);
}

.btnrow {
  grid-row: 4;
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  min-height: 0;
}

.btnrow button {
  width: auto;
  cursor: pointer;
  padding: 8px 18px;
  font-size: 13px;
  line-height: 1.2;
}

button:active {
  transform: translateY(1px);
}

.warn {
  color: rgba(255, 107, 139, 0.9);
}

/* ===== Accessibility ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ===== Modals ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  place-items: center;
  padding: 8px;
  z-index: 50;
}

[data-theme="light"] .modal {
  background: rgba(26, 29, 36, 0.4);
}

.modal[aria-hidden="false"] {
  display: grid;
}

.panel {
  width: min(98vw, 760px);
  max-height: calc(100vh - 16px);
  overflow: auto;
  border: 1px solid var(--border-color);
  border-radius: 18px;
  background: rgba(11, 14, 20, 0.92);
  backdrop-filter: blur(10px);
  padding: 12px;
}

[data-theme="light"] .panel {
  background: rgba(245, 247, 250, 0.95);
}

.panelTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.panelTitle {
  font-size: 16px;
  font-weight: 750;
  letter-spacing: 0.2px;
}

.panelGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ===== KPI Cards ===== */
.kpi {
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.02);
}

[data-theme="light"] .kpi {
  background: rgba(255, 255, 255, 0.4);
}

.kpi .label {
  color: var(--muted);
  font-size: 12px;
}

.kpi .value {
  font-size: 18px;
  font-weight: 750;
  margin-top: 4px;
}

/* ===== Table ===== */
.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  overflow: hidden;
}

.table th,
.table td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid rgba(233, 238, 252, 0.08);
  font-size: 13px;
  color: var(--fg);
  vertical-align: top;
}

[data-theme="light"] .table th,
[data-theme="light"] .table td {
  border-bottom: 1px solid rgba(26, 29, 36, 0.08);
}

.table th {
  color: var(--muted);
  font-weight: 650;
  background: rgba(255, 255, 255, 0.02);
}

[data-theme="light"] .table th {
  background: rgba(26, 29, 36, 0.02);
}

.table tr:last-child td {
  border-bottom: none;
}

.panelBtns {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.panelBtns button {
  cursor: pointer;
  flex: 1;
  min-width: 160px;
}

/* ===== Form Fields ===== */
.field {
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.02);
}

[data-theme="light"] .field {
  background: rgba(255, 255, 255, 0.4);
}

.field label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}

.field select {
  width: 100%;
  margin-top: 8px;
  background: rgba(233, 238, 252, 0.06);
  color: var(--fg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
}

[data-theme="light"] .field select {
  background: rgba(26, 29, 36, 0.04);
}

.field input[type="range"] {
  width: 100%;
  margin-top: 10px;
}

.help {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

/* ===== Info Modal ===== */
.info-content section {
  margin-bottom: 20px;
}

.info-content h3 {
  font-size: 15px;
  font-weight: 650;
  margin: 0 0 8px 0;
  color: var(--fg);
}

.info-content p {
  margin: 0;
  line-height: 1.5;
  color: var(--muted);
}

.info-content ul,
.info-content ol {
  margin: 8px 0 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.6;
}

.info-content li {
  margin-bottom: 6px;
}

.info-content strong {
  color: var(--fg);
  font-weight: 650;
}

/* ===== Onboarding ===== */
.onboarding-content {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
}

.onboarding-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.onboarding-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.onboarding-step h3 {
  font-size: 18px;
  font-weight: 750;
  margin: 0;
  color: var(--fg);
}

.onboarding-step p {
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
  margin: 0;
  max-width: 400px;
}

.onboarding-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(233, 238, 252, 0.08);
}

[data-theme="light"] .onboarding-nav {
  border-top: 1px solid rgba(26, 29, 36, 0.08);
}

.onboarding-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  grid-column: 2;
}

.onboarding-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.3;
  transition: opacity 0.2s;
}

.onboarding-dots .dot.active {
  opacity: 1;
  background: var(--accent);
}

.onboarding-nav-btn {
  width: auto;
}

#onboardingPrev {
  justify-self: start;
}

.onboarding-nav>div:last-child {
  justify-self: end;
}

/* ===== Streak ===== */
.streak {
  font-size: 13px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(233, 238, 252, 0.14);
  background: rgba(233, 238, 252, 0.08);
  color: var(--muted);
}

/* ===== Utility Classes ===== */
.hidden {
  display: none;
}

.invisible {
  visibility: hidden;
}

.text-center {
  text-align: center;
}

/* ===== Count Section ===== */
.count-separator {
  color: var(--muted);
  font-weight: 650;
}

#goalLabel {
  color: var(--muted);
  font-weight: 650;
}

.streak-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

/* ===== Stats KPI ===== */
.kpi-full-width {
  grid-column: 1 / -1;
}

#kpiFunStat {
  font-size: 14px;
  line-height: 1.4;
}

.table-actions-column {
  width: 50px;
}

#statsNote {
  margin-top: 10px;
}

/* ===== Modal Buttons ===== */
.modal-close-btn {
  width: auto;
  padding: 8px 10px;
}

.onboarding-nav-btn {
  width: auto;
  padding: 8px 16px;
}

/* ===== Onboarding ===== */
.onboarding-panel {
  max-width: 500px;
}