* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow-x: hidden;
}

.page {
  background: #042C53;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  font-family: system-ui, -apple-system, sans-serif;
}

.hidden { display: none; }

/* ── SETUP SCREEN ── */
.setup-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
  max-width: 440px;
  background: #B5D4F4;
  border: 2.5px solid #042C53;
  border-radius: 20px;
  padding: 2rem 1.25rem;
}
.setup-title {
  font-size: clamp(20px, 5vw, 24px);
  font-weight: 500;
  color: #042C53;
  text-align: center;
  letter-spacing: 0.02em;
}
.setup-sub {
  font-size: clamp(12px, 3.5vw, 13px);
  color: #042C53;
  font-weight: 500;
  text-align: center;
  opacity: 0.7;
  margin-top: -0.5rem;
}

/* ── GOAL PICKER ── */
.goal-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: 100%;
}
.goal-pick-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  font-size: clamp(18px, 5vw, 22px);
  font-weight: 500;
  border: 2px solid #042C53;
  border-radius: 12px;
  background: #85B7EB;
  color: #042C53;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, transform 0.08s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.goal-pick-btn:hover { background: #378ADD; color: #fff; }
.goal-pick-btn:active { transform: scale(0.95); background: #378ADD; color: #fff; }
.goal-pick-btn.selected { background: #042C53; color: #B5D4F4; }

/* ── START BUTTON ── */
.start-btn {
  width: 100%;
  padding: 0.9rem 1rem;
  font-size: clamp(15px, 4vw, 16px);
  font-weight: 500;
  font-family: inherit;
  background: #042C53;
  color: #B5D4F4;
  border: 2px solid #042C53;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.1s, transform 0.08s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.start-btn:hover { background: #185FA5; border-color: #185FA5; }
.start-btn:active { transform: scale(0.98); }

/* ── COUNTER SCREEN ── */
.counter-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 440px;
  background: #B5D4F4;
  border: 2.5px solid #042C53;
  border-radius: 20px;
  padding: 1.25rem 1.25rem 1.5rem;
}

/* ── TOP ROW ── */
.top-row {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  width: 100%;
}
.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: #85B7EB;
  border: 2px solid #042C53;
  border-radius: 9px;
  color: #042C53;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.1s, transform 0.08s;
  user-select: none;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.back-btn:hover { background: #378ADD; color: #fff; }
.back-btn:active { transform: scale(0.95); background: #378ADD; color: #fff; }
.goal-label-row {
  font-size: clamp(18px, 5vw, 22px);
  font-weight: 500;
  color: #042C53;
  letter-spacing: 0.02em;
  text-align: center;
}

/* ── TABS ── */
.toggle-row {
  display: flex;
  background: #85B7EB;
  border: 2px solid #042C53;
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
  width: 100%;
}
.toggle-btn {
  flex: 1;
  padding: 0.5rem;
  font-size: clamp(12px, 3.5vw, 13px);
  font-weight: 500;
  border: 2px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #042C53;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.toggle-btn.active { background: #042C53; color: #B5D4F4; border-color: #042C53; }

/* ── DISPLAY CARD ── */
.display-card {
  background: #85B7EB;
  border: 2px solid #042C53;
  border-radius: 14px;
  width: 100%;
  overflow: hidden;
}
.two-panel { display: grid; grid-template-columns: 1fr 1fr; }
.panel { padding: 1.5rem 1rem; text-align: center; }
.panel-left { border-right: 2px solid #042C53; }
.panel-label {
  font-size: clamp(10px, 3vw, 12px);
  color: #042C53;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}
.panel-value {
  font-size: clamp(44px, 13vw, 56px);
  font-weight: 500;
  color: #042C53;
  line-height: 1;
  margin: 0.2rem 0 0;
}
.panel-single { padding: 2rem 1.5rem; text-align: center; }

/* ── COUNTER BUTTONS ── */
.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}
.counter-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 0.5rem;
  border: 2px solid #042C53;
  border-radius: 12px;
  background: #85B7EB;
  color: #042C53;
  cursor: pointer;
  transition: background 0.1s, transform 0.08s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 64px;
}
.counter-btn:hover { background: #378ADD; color: #fff; }
.counter-btn:active { transform: scale(0.97); background: #378ADD; color: #fff; }
.counter-btn:active .btn-label { color: #B5D4F4; }
.counter-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.btn-icon { font-size: clamp(20px, 5.5vw, 22px); font-weight: 500; line-height: 1; }
.btn-label { font-size: clamp(11px, 3vw, 12px); color: #042C53; font-weight: 500; margin-top: 4px; }
.counter-btn:hover .btn-label { color: #B5D4F4; }

/* ── LEVEL SELECTOR ── */
.level-wrap { width: 100%; }
.level-label-text {
  font-size: clamp(10px, 3vw, 12px);
  color: #042C53;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  display: block;
}
.level-btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  width: 100%;
}
.level-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 0.5rem;
  font-size: clamp(13px, 3.5vw, 14px);
  font-weight: 500;
  font-family: inherit;
  border: 2px solid #042C53;
  border-radius: 12px;
  background: #85B7EB;
  color: #042C53;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, transform 0.08s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.level-btn:hover { background: #378ADD; color: #fff; }
.level-btn:active { transform: scale(0.96); background: #378ADD; color: #fff; }
.level-btn.selected { background: #042C53; color: #B5D4F4; }

/* ── GOAL NAV ── */
.goal-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
}
.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: #85B7EB;
  border: 2px solid #042C53;
  border-radius: 10px;
  color: #042C53;
  font-size: 20px;
  cursor: pointer;
  transition: background 0.1s, transform 0.08s;
  user-select: none;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  flex-shrink: 0;
}
.nav-btn:hover { background: #378ADD; color: #fff; }
.nav-btn:active { transform: scale(0.95); background: #378ADD; color: #fff; }
.nav-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.nav-label { font-size: clamp(12px, 3.5vw, 13px); color: #042C53; font-weight: 500; }

/* ── MOBILE ── */
@media (max-width: 480px) {
  .page {
    padding: 1rem 0.75rem;
    align-items: flex-start;
    padding-top: max(1rem, env(safe-area-inset-top));
  }
  .counter-wrap { border-radius: 16px; gap: 0.875rem; padding: 1rem 1rem 1.25rem; }
  .setup-wrap { border-radius: 16px; padding: 1.5rem 1rem; }
  .panel { padding: 1.25rem 0.75rem; }
  .panel-single { padding: 1.5rem 1rem; }
  .btn-grid { gap: 7px; }
  .counter-btn { min-height: 60px; padding: 0.75rem 0.5rem; }
  .goal-nav { gap: 12px; }
}

@media (max-height: 700px) {
  .counter-wrap { gap: 0.75rem; }
  .panel { padding: 1rem 0.75rem; }
  .btn-grid { gap: 6px; }
  .counter-btn { min-height: 54px; padding: 0.625rem 0.5rem; }
}