:root {
  --bg: #f7efe6;
  --panel: #fffdf9;
  --panel-soft: #f7efe7;
  --ink: #612127;
  --muted-line: #eee2d5;
  --teal: #35c4c5;
  --pink: #ef3e70;
  --orange: #ffb13e;
  --gold: #ffd36a;
  --shadow: 0 18px 42px rgba(84, 45, 24, 0.1);
  color: var(--ink);
  background: var(--bg);
  font-family: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}

.app-shell {
  width: 100%;
  max-width: 520px;
  height: 100dvh;
  max-height: 980px;
  padding: max(12px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom));
  display: grid;
  overflow: hidden;
}

.timer-card {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(96px, 20%) minmax(0, 1fr) auto 84px;
  gap: clamp(10px, 2dvh, 20px);
  padding: clamp(18px, 3.8dvh, 44px) clamp(14px, 4vw, 34px) 0;
  border: clamp(8px, 2.2vw, 14px) solid rgba(255, 255, 255, 0.92);
  border-radius: clamp(28px, 7vw, 48px);
  background: linear-gradient(180deg, var(--panel) 0%, #fffaf5 72%, var(--panel-soft) 100%);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(98, 57, 34, 0.03);
  overflow: hidden;
}

.timer-title {
  min-height: 0;
  display: grid;
  place-items: center;
  align-self: stretch;
  border-radius: clamp(22px, 5vw, 34px);
  background:
    radial-gradient(circle at 22% 20%, rgba(255, 211, 106, 0.95), transparent 34%),
    radial-gradient(circle at 80% 24%, rgba(53, 196, 197, 0.62), transparent 34%),
    linear-gradient(135deg, #fff6d8 0%, #ffe5df 42%, #e9fbf8 100%);
  box-shadow: inset 0 0 0 1px rgba(97, 33, 39, 0.05);
  overflow: hidden;
}

.timer-title h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(2.05rem, 8vw, 3.8rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 3px 14px rgba(97, 33, 39, 0.12);
}

.time-stack {
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr 1px 1fr;
  align-items: center;
  gap: clamp(18px, 5dvh, 52px);
}

.timer-display {
  display: block;
  width: 100%;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-size: clamp(3.25rem, 15vw, 7.1rem);
  font-weight: 850;
  line-height: 0.95;
  letter-spacing: 0;
  text-align: center;
  color: var(--ink);
  text-shadow: 0 2px 8px rgba(97, 33, 39, 0.1);
  white-space: nowrap;
}

.divider {
  width: 92%;
  height: 2px;
  justify-self: center;
  background: var(--muted-line);
  border-radius: 999px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
  justify-items: center;
  gap: clamp(12px, 5vw, 36px);
  min-height: clamp(82px, 14dvh, 126px);
}

.round-button {
  width: clamp(70px, 21vw, 112px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #3f2026;
  font-size: clamp(2.15rem, 9vw, 3.45rem);
  font-weight: 850;
  line-height: 1;
  box-shadow: 0 15px 28px rgba(77, 39, 34, 0.12);
}

.round-button.start {
  background: var(--teal);
}

.round-button.stop {
  background: var(--pink);
}

.round-button.reset {
  background: var(--orange);
  font-size: clamp(1.7rem, 7.2vw, 2.7rem);
}

.round-button:active,
.wide-button:active,
.duration-button:active,
.manual-tab:active {
  transform: translateY(1px) scale(0.99);
}

.manual-tab {
  position: relative;
  width: 100%;
  height: 100%;
  justify-self: center;
  display: grid;
  place-items: center;
  align-self: end;
  background: var(--panel-soft);
  border-top: 8px solid rgba(255, 255, 255, 0.95);
  border-radius: 38px 38px 0 0;
  color: var(--ink);
  font-size: clamp(1.9rem, 8vw, 2.8rem);
  font-weight: 850;
}

.manual-tab span {
  z-index: 1;
}

.sheet-view {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100dvh;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  background: rgba(247, 239, 230, 0.96);
}

.sheet-view[hidden] {
  display: none;
}

.sheet-panel {
  width: min(100%, 430px);
  max-height: 100%;
  display: grid;
  gap: clamp(10px, 2.2dvh, 18px);
  padding: clamp(18px, 5.5vw, 34px);
  border: 10px solid rgba(255, 255, 255, 0.94);
  border-radius: 34px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sheet-panel h1,
.complete-view h1,
.complete-kicker {
  margin: 0;
  text-align: center;
  color: var(--ink);
}

.sheet-panel h1 {
  font-size: clamp(2.4rem, 10vw, 4rem);
  line-height: 1;
}

.duration-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.custom-duration {
  display: grid;
  gap: 10px;
}

.custom-duration h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.25rem, 5vw, 1.65rem);
  font-weight: 850;
  text-align: center;
}

.wheel-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.wheel-group {
  display: grid;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: center;
  gap: 6px;
  min-width: 0;
}

.wheel-group span {
  font-size: clamp(0.86rem, 3.4vw, 1.08rem);
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.wheel-list {
  position: relative;
  width: 100%;
  height: 108px;
  display: grid;
  gap: 5px;
  padding: 36px 3px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-snap-type: y mandatory;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  border-radius: 22px;
  background:
    linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(50% - 17px),
      var(--gold) calc(50% - 17px),
      var(--gold) calc(50% + 17px),
      transparent calc(50% + 17px)
    ),
    #f8eadc;
  box-shadow: inset 0 0 0 2px rgba(97, 33, 39, 0.06);
}

.wheel-option {
  position: relative;
  z-index: 1;
  min-height: 34px;
  display: grid;
  place-items: center;
  scroll-snap-align: center;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: clamp(1.05rem, 4.4vw, 1.42rem);
  font-weight: 850;
}

.wheel-option[aria-selected="true"] {
  color: var(--ink);
}

.custom-apply:disabled {
  opacity: 0.45;
}

.duration-button,
.wide-button {
  min-height: 58px;
  border-radius: 999px;
  background: #f3e5d6;
  color: var(--ink);
  font-size: clamp(1.2rem, 5.2vw, 1.65rem);
  font-weight: 800;
}

.duration-button[aria-pressed="true"] {
  background: var(--orange);
  box-shadow: inset 0 0 0 3px rgba(97, 33, 39, 0.18);
}

.wide-button {
  width: 100%;
  background: var(--pink);
  color: #fff7f7;
}

.custom-apply {
  background: var(--teal);
  color: #3f2026;
}

.complete-view .sheet-panel {
  justify-items: center;
}

.complete-kicker {
  font-size: clamp(1.5rem, 7vw, 2.2rem);
  font-weight: 850;
}

.complete-view h1 {
  font-variant-numeric: tabular-nums;
  font-size: clamp(3.5rem, 17vw, 6rem);
  font-weight: 850;
  line-height: 1;
}

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

  .timer-card {
    grid-template-rows: minmax(74px, 16%) minmax(0, 1fr) auto 68px;
    gap: 8px;
    padding-top: 18px;
  }

  .timer-title h1 {
    font-size: clamp(1.75rem, 7vw, 2.35rem);
  }

  .time-stack {
    gap: 14px;
  }

  .timer-display {
    font-size: clamp(3rem, 13.8vw, 5.8rem);
  }

  .controls {
    min-height: 82px;
  }

  .round-button {
    width: clamp(68px, 20vw, 86px);
  }

  .manual-tab {
    font-size: clamp(1.65rem, 7vw, 2.1rem);
  }

  .sheet-panel {
    gap: 8px;
  }

  .duration-button,
  .wide-button {
    min-height: 48px;
  }

  .wheel-list {
    height: 84px;
    padding: 25px 3px;
  }

  .wheel-option {
    min-height: 28px;
  }
}
