@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700&display=swap");

:root {
  color-scheme: light;
  --background: #f5f5ef;
  --surface: rgba(255, 255, 255, 0.78);
  --ink: #284438;
  --ink-muted: #728078;
  --line: rgba(40, 68, 56, 0.11);
  --green: #dcebbd;
  --green-strong: #9fbd7d;
  --green-deep: #678653;
  --pink: #f1d5de;
  --pink-strong: #d99aad;
  --yolk: #efbd52;
  --shadow: 0 12px 32px rgba(66, 82, 72, 0.09);
  font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--background);
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-width: 320px;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(150deg, rgba(220, 235, 189, 0.3), transparent 38%),
    linear-gradient(20deg, transparent 60%, rgba(241, 213, 222, 0.34)),
    var(--background);
  overscroll-behavior: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(103, 134, 83, 0.34);
  outline-offset: 2px;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 230px;
  height: 230px;
  border-radius: 50%;
  filter: blur(20px);
  pointer-events: none;
}

.ambient--green {
  top: -130px;
  left: -105px;
  background: rgba(193, 220, 149, 0.34);
}

.ambient--pink {
  right: -145px;
  bottom: 5vh;
  background: rgba(234, 177, 194, 0.27);
}

.app-shell {
  display: flex;
  width: min(100%, 540px);
  height: 100%;
  min-height: 0;
  flex-direction: column;
  margin: 0 auto;
  overflow: hidden;
  padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.app-header {
  display: grid;
  flex: 0 0 auto;
  min-height: 58px;
  place-items: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-family: "Manrope", sans-serif;
  font-size: clamp(1.45rem, 3.2vh, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  text-decoration: none;
}

.brand__mark {
  display: grid;
  width: clamp(32px, 4.8vh, 39px);
  height: clamp(38px, 5.7vh, 46px);
  place-items: center;
}

.brand__mark svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.brand__mark path {
  fill: var(--green);
  stroke: var(--ink);
  stroke-width: 2.5;
}

.brand__mark circle {
  fill: var(--pink-strong);
}

.app-view {
  flex: 1 1 auto;
  animation: view-in 300ms cubic-bezier(0.2, 0.75, 0.25, 1) both;
}

.setup-view {
  display: flex;
  min-height: 0;
}

.selection-form {
  display: grid;
  width: 100%;
  flex: 1 1 auto;
  grid-template-rows: minmax(0, 1.38fr) minmax(0, 0.92fr) minmax(0, 0.78fr) minmax(0, 0.92fr) auto;
  grid-auto-rows: auto;
  gap: clamp(7px, 1.2vh, 11px);
  padding-top: 7px;
}

.choice-section {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice-section legend {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 6px;
  padding: 0 2px;
  font-family: "Manrope", sans-serif;
  font-size: clamp(0.78rem, 1.9vh, 0.96rem);
  font-weight: 700;
  letter-spacing: -0.015em;
}

.choice-section legend span {
  display: grid;
  width: clamp(21px, 3.3vh, 27px);
  height: clamp(21px, 3.3vh, 27px);
  place-items: center;
  border-radius: 50%;
  color: var(--green-deep);
  background: var(--green);
  font-family: "DM Sans", sans-serif;
  font-size: clamp(0.55rem, 1.2vh, 0.66rem);
}

.choice-grid {
  display: grid;
  min-height: 0;
  flex: 1 1 auto;
  gap: 7px;
}

.choice-grid--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choice-grid--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-card,
.size-choice {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
  box-shadow: 0 5px 18px rgba(66, 82, 72, 0.045);
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.choice-card:active,
.size-choice:active {
  transform: scale(0.98);
}

.choice-card[aria-pressed="true"],
.size-choice[aria-pressed="true"] {
  border-color: rgba(103, 134, 83, 0.22);
  background: linear-gradient(145deg, rgba(220, 235, 189, 0.98), rgba(241, 213, 222, 0.94));
  box-shadow: 0 7px 20px rgba(103, 134, 83, 0.11);
}

.choice-card[aria-pressed="true"]::after,
.size-choice[aria-pressed="true"]::after {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--green-deep);
  content: "✓";
  font-size: 0.61rem;
  font-weight: 700;
}

.choice-card--doneness {
  display: flex;
  min-width: 0;
  min-height: clamp(88px, 12vh, 104px);
  align-items: center;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 8px 5px;
}

.choice-card--doneness > span:last-child,
.choice-card--line > span {
  display: grid;
  min-width: 0;
  gap: 1px;
  text-align: left;
}

.choice-card--doneness > span:last-child {
  text-align: center;
}

.choice-card strong,
.size-choice strong {
  font-size: clamp(0.78rem, 1.8vh, 1rem);
  white-space: nowrap;
}

.choice-card small,
.size-choice small {
  color: var(--ink-muted);
  font-size: clamp(0.61rem, 1.25vh, 0.75rem);
  white-space: nowrap;
}

.egg-visual {
  display: grid;
  width: clamp(40px, 7vh, 58px);
  height: clamp(47px, 8.2vh, 68px);
  flex: 0 0 auto;
  place-items: center;
  border-radius: 52% 48% 48% 52% / 62% 62% 38% 38%;
  background: #efe7d8;
  transform: rotate(8deg);
}

.egg-visual__white {
  display: grid;
  width: 79%;
  height: 79%;
  place-items: center;
  border-radius: inherit;
  background: #fffdf7;
}

.egg-visual__yolk {
  display: block;
  width: 57%;
  height: 55%;
  border-radius: 50%;
  background: var(--yolk);
}

.egg-visual--soft .egg-visual__yolk {
  border-radius: 46% 54% 60% 40% / 54% 42% 58% 46%;
  background: linear-gradient(145deg, #f7d875, #eaae46);
}

.egg-visual--firm .egg-visual__yolk {
  background: #e6aa3d;
  box-shadow: inset -3px -3px 0 rgba(174, 109, 35, 0.15);
}

.choice-card--line {
  display: flex;
  min-height: clamp(54px, 7.2vh, 62px);
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 12px;
}

.line-icon {
  width: clamp(27px, 4.6vh, 37px);
  flex: 0 0 clamp(27px, 4.6vh, 37px);
  fill: none;
  stroke: var(--pink-strong);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.size-choice {
  display: flex;
  min-height: clamp(48px, 6.5vh, 56px);
  align-items: center;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 9px 5px;
  line-height: 1.15;
}

.size-choice strong {
  font-family: "Manrope", sans-serif;
  font-size: clamp(1rem, 2.5vh, 1.3rem);
}

.altitude-card {
  position: relative;
  display: grid;
  min-height: clamp(60px, 8.5vh, 72px);
  grid-template-columns: auto minmax(0, 1fr) clamp(68px, 12vh, 92px);
  align-items: center;
  gap: 9px;
  padding: 6px 8px 5px 15px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(120deg, rgba(220, 235, 189, 0.55), rgba(241, 213, 222, 0.54));
  box-shadow: 0 5px 18px rgba(66, 82, 72, 0.05);
  flex: 1 1 auto;
}

.altitude-card.is-complete {
  border-color: rgba(103, 134, 83, 0.3);
}

.altitude-input-line {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.altitude-input-line input {
  width: clamp(84px, 23vw, 112px);
  padding: 0;
  border: 0;
  border-bottom: 2px solid rgba(40, 68, 56, 0.16);
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  font-family: "Manrope", sans-serif;
  font-size: clamp(1.5rem, 3.6vh, 2rem);
  font-weight: 600;
  letter-spacing: -0.05em;
  outline: none;
  -moz-appearance: textfield;
}

.altitude-input-line input::-webkit-inner-spin-button,
.altitude-input-line input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.altitude-input-line span,
.altitude-card p {
  color: var(--ink-muted);
  font-size: clamp(0.62rem, 1.35vh, 0.76rem);
}

.altitude-card p {
  margin: 0;
  min-width: 0;
  line-height: 1.35;
}

.altitude-card p span {
  display: block;
}

.mountain-icon {
  width: clamp(68px, 12vh, 92px);
  height: clamp(52px, 9.2vh, 70px);
  align-self: end;
  justify-self: end;
  margin-bottom: -5px;
  max-width: 100%;
}

.mountain-icon path:first-child {
  fill: rgba(217, 154, 173, 0.55);
  stroke: var(--pink-strong);
  stroke-linejoin: round;
  stroke-width: 1.4;
}

.mountain-icon path:last-child {
  fill: rgba(255, 255, 255, 0.84);
}

.primary-button,
.secondary-button,
.text-button,
.install-button {
  cursor: pointer;
}

.primary-button,
.secondary-button {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 18px;
  font-size: clamp(0.9rem, 2vh, 1.08rem);
  font-weight: 700;
}

.primary-button {
  border: 0;
  color: white;
  background: var(--ink);
  box-shadow: 0 9px 24px rgba(40, 68, 56, 0.19);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
  box-shadow: none;
}

.primary-button svg,
.secondary-button svg,
.install-button svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.calculate-button {
  min-height: clamp(54px, 8vh, 68px);
  margin-top: 1px;
}

.install-button {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: -4px auto 0;
  padding: 3px 10px;
  border: 0;
  color: var(--ink-muted);
  background: transparent;
  font-size: 0.66rem;
  font-weight: 600;
}

.timer-view {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 3px 0 0;
}

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

.eyebrow {
  margin: 2px 0 2px;
  color: var(--green-deep);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.timer-heading h1 {
  margin: 0;
  font-family: "Manrope", sans-serif;
  font-size: clamp(3rem, 13vw, 4.3rem);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: -0.08em;
  line-height: 1;
}

.timer-heading h1 small {
  margin-left: 2px;
  color: var(--ink-muted);
  font-family: "DM Sans", sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0;
}

.summary-chips {
  display: flex;
  min-height: 25px;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin-top: 8px;
}

.summary-chips span {
  padding: 4px 8px;
  border: 1px solid rgba(40, 68, 56, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  font-size: 0.59rem;
  font-weight: 600;
}

.race-track {
  position: relative;
  height: clamp(210px, 31vh, 270px);
  margin: clamp(14px, 2.5vh, 24px) 0 13px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 29px;
  background: linear-gradient(180deg, #f3dfe5 0%, #f7e9d9 53%, #dcebbd 54%, #bed594 100%);
  box-shadow: var(--shadow);
}

.race-track__sun {
  position: absolute;
  top: 22px;
  right: 35px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 0 0 12px rgba(255, 255, 255, 0.15);
}

.race-track__hill {
  position: absolute;
  border-radius: 50% 50% 0 0;
  background: rgba(159, 189, 125, 0.4);
}

.race-track__hill--one {
  right: -50px;
  bottom: 38%;
  width: 250px;
  height: 90px;
}

.race-track__hill--two {
  bottom: 38%;
  left: -35px;
  width: 190px;
  height: 58px;
  background: rgba(159, 189, 125, 0.27);
}

.race-track__path {
  position: absolute;
  right: 18px;
  bottom: 24px;
  left: 18px;
  height: 3px;
  border-radius: 999px;
  background: repeating-linear-gradient(90deg, rgba(40, 68, 56, 0.24) 0 12px, transparent 12px 21px);
}

.start-egg {
  position: absolute;
  z-index: 2;
  bottom: 29px;
  left: 17px;
  width: 34px;
  height: 20px;
  border: 3px solid rgba(103, 134, 83, 0.62);
  border-top: 0;
  border-radius: 0 0 18px 18px;
}

.start-egg span {
  position: absolute;
  bottom: 6px;
  left: 7px;
  width: 16px;
  height: 22px;
  border: 2px solid var(--green-deep);
  border-radius: 52% 48% 48% 52% / 62% 62% 38% 38%;
  background: #fffdf7;
}

.finish-flag {
  position: absolute;
  z-index: 1;
  right: 18px;
  bottom: 23px;
  width: 3px;
  height: 74px;
  border-radius: 2px;
  background: var(--ink);
}

.finish-flag span {
  position: absolute;
  top: 0;
  right: 0;
  width: 35px;
  height: 24px;
  background:
    linear-gradient(45deg, var(--ink) 25%, transparent 25%) 0 0 / 12px 12px,
    linear-gradient(45deg, transparent 75%, var(--ink) 75%) 0 0 / 12px 12px,
    linear-gradient(45deg, transparent 75%, var(--ink) 75%) 6px -6px / 12px 12px,
    linear-gradient(45deg, var(--ink) 25%, #fff 25%) 6px 6px / 12px 12px;
}

.runner-position {
  position: absolute;
  z-index: 4;
  bottom: 29px;
  left: 0;
  width: clamp(82px, 25vw, 110px);
  transform: translateX(var(--runner-shift, 0%));
  transition: left 280ms linear, transform 280ms linear;
}

.chicken {
  display: block;
  width: 100%;
  overflow: visible;
  filter: drop-shadow(0 7px 4px rgba(40, 68, 56, 0.14));
  transform-origin: 50% 100%;
}

.chicken.is-running {
  animation: chicken-bob 360ms ease-in-out infinite alternate;
}

.chicken.is-done {
  animation: chicken-celebrate 520ms ease-in-out 2;
}

.chicken__body,
.chicken__head {
  fill: #fffaf0;
  stroke: var(--ink);
  stroke-width: 4;
}

.chicken__tail,
.chicken__comb {
  fill: var(--pink-strong);
  stroke: var(--ink);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.chicken__beak {
  fill: var(--yolk);
  stroke: var(--ink);
  stroke-linejoin: round;
  stroke-width: 3;
}

.chicken__eye {
  fill: var(--ink);
}

.chicken__wing {
  fill: var(--green);
  stroke: var(--ink);
  stroke-width: 3.5;
}

.chicken__leg {
  fill: none;
  stroke: #b87c3e;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
  transform-box: fill-box;
  transform-origin: top center;
}

.chicken.is-running .chicken__leg--front {
  animation: leg-step 360ms ease-in-out infinite alternate;
}

.chicken.is-running .chicken__leg--back {
  animation: leg-step 360ms ease-in-out infinite alternate-reverse;
}

.timer-copy {
  min-height: 54px;
  text-align: center;
}

.timer-status {
  color: var(--green-deep);
  font-size: 0.67rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.timer-copy p {
  margin: 4px auto 0;
  color: var(--ink-muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.timer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 10px;
}

.timer-actions .primary-button,
.timer-actions .secondary-button {
  grid-column: 1 / -1;
}

.primary-button svg path:first-child {
  fill: currentColor;
  stroke: none;
}

.secondary-button {
  border: 1px solid rgba(40, 68, 56, 0.12);
  background: rgba(255, 255, 255, 0.7);
}

.text-button {
  min-height: 35px;
  padding: 4px;
  border: 0;
  color: var(--ink-muted);
  background: transparent;
  font-size: 0.66rem;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgba(40, 68, 56, 0.22);
  text-underline-offset: 3px;
}

.timer-note {
  margin: 9px 0 0;
  color: var(--ink-muted);
  font-size: 0.58rem;
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 18px;
  width: fit-content;
  max-width: calc(100% - 36px);
  margin: auto;
  padding: 12px 17px;
  border-radius: 999px;
  color: white;
  background: var(--ink);
  box-shadow: var(--shadow);
  font-size: 0.75rem;
  font-weight: 600;
  animation: view-in 220ms ease both;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes chicken-bob {
  from { transform: translateY(0) rotate(-1deg); }
  to { transform: translateY(-4px) rotate(1.5deg); }
}

@keyframes chicken-celebrate {
  0%, 100% { transform: translateY(0) rotate(0); }
  45% { transform: translateY(-13px) rotate(-6deg); }
  70% { transform: translateY(-6px) rotate(5deg); }
}

@keyframes leg-step {
  from { transform: rotate(-20deg); }
  to { transform: rotate(20deg); }
}

@media (max-height: 700px) {
  .app-shell {
    padding-top: 6px;
  }

  .app-header {
    min-height: 50px;
  }

  .selection-form {
    gap: 6px;
    padding-top: 2px;
  }

  .choice-section legend {
    margin-bottom: 4px;
  }

  .choice-card--doneness {
    min-height: 79px;
  }

  .choice-card--line {
    min-height: 48px;
  }

  .size-choice {
    min-height: 43px;
    padding-block: 6px;
  }

  .altitude-card {
    min-height: 54px;
  }

  .calculate-button {
    min-height: 47px;
  }

  .race-track {
    height: 190px;
    margin-block: 10px;
  }
}

@media (max-width: 460px) {
  .altitude-card {
    grid-template-columns: auto minmax(0, 1fr) clamp(62px, 10vh, 78px);
    gap: 4px;
    padding-right: 6px;
    padding-left: 12px;
  }

  .mountain-icon {
    width: 100%;
  }
}

@media (max-width: 370px) {
  .app-shell {
    padding-right: 11px;
    padding-left: 11px;
  }

  .egg-visual {
    width: 34px;
    height: 40px;
  }

  .egg-visual__white {
    width: 27px;
    height: 32px;
  }

  .egg-visual__yolk {
    width: 15px;
    height: 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
