:root {
  --bg: #0d0f13;
  --surface: #171a21;
  --surface-active: #232733;
  --accent: #5b8cff;
  --text: #f2f4f8;
  --text-dim: #8b93a7;
  --danger: #ff6b6b;
  --radius: 16px;
}

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

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  touch-action: manipulation;
}

.header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.header__title {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.counter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  padding: 0 0.75rem 0.6rem;
}

.tab-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  background: var(--surface);
  color: var(--text-dim);
  border: none;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  min-height: 30px;
  max-width: 8.5rem;
}

.tab-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-chip.active {
  background: var(--accent);
  color: #fff;
}

.tab-chip__add {
  flex: 0 0 auto;
  background: transparent;
  border: 1px dashed var(--text-dim);
  color: var(--text-dim);
  border-radius: 999px;
  min-width: 30px;
  min-height: 30px;
  font-size: 0.95rem;
}

.counter-display {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 1rem;
}

.counter-name {
  color: var(--text-dim);
  font-size: 1.3rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.counter-value {
  font-size: clamp(4rem, 22vw, 10rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transition: transform 0.08s ease;
}

.counter-value.pulse {
  transform: scale(1.06);
}

.counter-value.positive {
  color: #4cd964;
}

.counter-value.negative {
  color: #ff6b6b;
}

.step-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.step-indicator {
  color: var(--text-dim);
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
  min-width: 7rem;
  cursor: pointer;
  border-bottom: 1px dotted var(--text-dim);
  padding-bottom: 2px;
}

.step-btn {
  background: var(--surface);
  color: var(--text);
  border: none;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  font-size: 1.8rem;
  line-height: 1;
}

.controls {
  display: flex;
  gap: 1rem;
  padding: 1.5rem 1rem;
}

.control-btn {
  flex: 1;
  background: var(--surface);
  color: var(--text);
  border: none;
  border-radius: var(--radius);
  font-size: 2.2rem;
  font-weight: 300;
  min-height: 80px;
}

.control-btn:active {
  background: var(--surface-active);
}

.control-btn--plus {
  color: var(--accent);
}

.reset-btn {
  align-self: center;
  margin-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--surface);
  border-radius: 999px;
  padding: 0.6rem 1.5rem;
  font-size: 1.1rem;
  min-height: 44px;
}

.reset-btn:active {
  background: var(--surface);
}

.chip-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}

.chip-menu {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 20rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chip-menu__title {
  padding: 1rem 1.25rem 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  border-bottom: 1px solid var(--surface-active);
  padding-bottom: 1rem;
}

.chip-menu__btn {
  background: transparent;
  border: none;
  border-top: 1px solid var(--surface-active);
  color: var(--text);
  font-size: 1.1rem;
  padding: 1rem;
  min-height: 52px;
}

.chip-menu__btn:active {
  background: var(--surface-active);
}

.chip-menu__btn--danger {
  color: var(--danger);
}
