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

:root {
  --green-dark: #1f5c3d;
  --green-mid: #2e7d52;
  --green-light: #e8f5e9;
  --green-accent: #a5d6a7;
  --text: #1a1a1a;
  --text-light: #f5f5f5;
  --danger: #c0392b;
  --white: #ffffff;
  --radius: 12px;
}

html {
  font-size: 18px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--green-light);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 2rem;
}

/* Tabs */
#tabs {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--green-dark);
}

.tab {
  flex: 1;
  padding: 1rem;
  border: none;
  background: transparent;
  color: var(--green-accent);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab.active {
  background: var(--green-mid);
  color: var(--white);
}

/* Views */
.view {
  display: none;
  padding: 1.25rem 1rem;
}

.view.active {
  display: block;
}

h1 {
  font-size: 1.5rem;
  color: var(--green-dark);
  margin-bottom: 0.75rem;
}

h2 {
  font-size: 1.1rem;
  color: var(--green-dark);
  margin-bottom: 0.5rem;
}

/* Hint text */
.hint {
  background: var(--green-accent);
  color: var(--green-dark);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  line-height: 1.4;
  font-weight: 500;
}

/* Calibration points */
.cal-points {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cal-point {
  background: var(--white);
  border: 2px solid var(--green-mid);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cal-point label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cal-label-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--green-dark);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.cal-label {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--green-dark);
  padding-bottom: 0.25rem;
}

.cal-dist {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #ccc;
  border-radius: 8px;
  font-size: 1.1rem;
  background: var(--white);
  color: var(--text);
}

.cal-dist {
  font-weight: 700;
  font-size: 1.3rem;
  text-align: center;
}

.cal-dist:focus {
  outline: none;
  border-color: var(--green-mid);
}

/* Warning */
.warning {
  background: #fff3cd;
  color: #856404;
  border: 2px solid #ffc107;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-top: 1rem;
  font-weight: 600;
}

/* Buttons */
.cal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
  min-height: 52px;
}

.btn:active {
  opacity: 0.8;
}

.btn-primary {
  background: var(--green-dark);
  color: var(--white);
  flex: 2;
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
  flex: 1;
}

.saved-msg {
  text-align: center;
  color: var(--green-dark);
  font-weight: 700;
  margin-top: 0.75rem;
  font-size: 1.1rem;
}

.hidden {
  display: none !important;
}

/* Play mode */
.no-cal {
  text-align: center;
  padding: 3rem 1rem;
}

.no-cal p {
  font-size: 1.2rem;
  margin-bottom: 1.5rem;
  color: var(--green-dark);
  font-weight: 600;
}

.input-section {
  margin-bottom: 1.5rem;
}

.input-label {
  display: block;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.dist-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-adjust {
  background: var(--green-mid);
  color: var(--white);
  width: 64px;
  height: 64px;
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#dist-input {
  flex: 1;
  text-align: center;
  font-size: 2rem;
  font-weight: 700;
  padding: 0.75rem;
  border: 2px solid var(--green-mid);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text);
  min-width: 0;
}

#dist-input:focus {
  outline: none;
  border-color: var(--green-dark);
}

/* Slope buttons */
.slope-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.slope-btn {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.25rem;
  border: 2px solid var(--green-mid);
  border-radius: 8px;
  background: var(--white);
  color: var(--green-dark);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.slope-btn.active {
  background: var(--green-dark);
  color: var(--white);
  border-color: var(--green-dark);
}

/* Slider */
.slider-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.slider-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--green-dark);
  white-space: nowrap;
}

#slope-slider {
  flex: 1;
  height: 40px;
  accent-color: var(--green-dark);
}

.slope-value {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--green-dark);
  margin-top: 0.25rem;
}

/* Result */
.result {
  background: var(--white);
  border: 3px solid var(--green-dark);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.result-primary {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--green-dark);
  line-height: 1.4;
  margin-bottom: 0.75rem;
}

.result-secondary {
  font-size: 0.95rem;
  color: #555;
}

/* Reference table */
.ref-table {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem;
  border: 2px solid var(--green-accent);
}

.ref-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--green-light);
  font-size: 0.95rem;
}

.ref-row:last-child {
  border-bottom: none;
}

.ref-row-label {
  font-weight: 600;
  color: var(--green-dark);
}

.ref-row-dist {
  font-weight: 700;
}

/* Utilities */
@media (prefers-color-scheme: dark) {
  /* Keep light theme for outdoor readability */
}
