:root {
  --paper: #F4F0E6;
  --card: #FFFFFF;
  --sand: #EAE4D7;
  --green: #14513D;
  --green-2: #0D3B2C;
  --mint: #7FD1A8;
  --ink: #111111;
  --muted: #5B574E;
  --line: rgba(13, 59, 44, 0.1);
  --sans: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

body {
  min-height: 100%;
}

body::before {
  content: "";
  display: block;
  height: 6px;
  background: var(--green);
}

button, input { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border: 0;
  background: none;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.wrap {
  width: min(100%, 440px);
  margin: 0 auto;
  padding: calc(22px + env(safe-area-inset-top)) 16px calc(36px + env(safe-area-inset-bottom));
}

.mast h1 {
  margin: 4px 0 0;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: -0.04em;
  font-weight: 750;
}

.brand {
  margin: 0;
  color: var(--green);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.18em;
}

.lede, .note, .foot, .hist-key, .rank-sub, .rank-basis {
  color: var(--muted);
}

.lede {
  margin: 10px 0 0;
  font-size: 15px;
  line-height: 1.45;
}

.loading {
  margin: 28px 0;
  color: var(--muted);
}

#tool[hidden],
#doubles[hidden],
#toast[hidden],
#loading[hidden],
#share-custom[hidden] {
  display: none !important;
}

.block { margin-top: 26px; }

.label {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 750;
  color: var(--green);
}

.picks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.picks button,
.share-presets button,
.slider-row button,
.presets button {
  min-height: 44px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 650;
  font-size: 14px;
}

.picks button[aria-pressed="true"],
.presets button[aria-pressed="true"],
.share-presets button[aria-pressed="true"] {
  background: var(--green);
  border-color: var(--green);
  color: var(--paper);
}

.picks button:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.hero { text-align: center; }

.hero .label { text-align: center; }

.hero-time {
  margin: 0;
  font-size: clamp(64px, 18vw, 76px);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 0.95;
}

.hero-time::after {
  content: "";
  display: block;
  width: 48px;
  height: 4px;
  margin: 12px auto 0;
  background: var(--mint);
  border-radius: 2px;
}

.slider-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
}

.slider-row button {
  font-size: 13px;
  font-weight: 750;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  touch-action: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background:
    linear-gradient(var(--green), var(--green)) 0 / var(--p, 50%) 100% no-repeat,
    var(--sand);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -12px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--green);
  box-shadow: 0 1px 2px rgba(17, 17, 17, 0.18);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border: 0;
  border-radius: 2px;
  background: var(--sand);
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  background: var(--green);
  border-radius: 2px;
}

input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--green);
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.presets button {
  flex: 1 1 58px;
  min-width: 58px;
}

.card {
  margin-top: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}

.rank-basis {
  margin: 0;
  font-size: 13px;
}

.rank-big {
  margin: 4px 0 0;
  font-size: 36px;
  line-height: 1.15;
  letter-spacing: -0.04em;
  font-weight: 800;
  color: var(--green-2);
}

.rank-sub {
  margin: 4px 0 14px;
  font-size: 15px;
}

.hist-plot { width: 100%; }

#hist {
  display: block;
  width: 100%;
  height: 120px;
}

.hist-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.hist-key {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
  font-size: 12px;
}

.hist-key i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--mint);
}

.pace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--sand);
  border-radius: 14px;
}

.pace button {
  min-height: 44px;
  border-radius: 11px;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}

.pace button[aria-pressed="true"] {
  background: var(--card);
  color: var(--ink);
}

.note {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.stats article {
  min-width: 0;
  background: var(--green);
  color: var(--paper);
  border-radius: 14px;
  padding: 10px 8px 11px;
}

.stats span,
.stats em {
  display: block;
  font-style: normal;
  font-size: 11px;
  letter-spacing: -0.01em;
}

.stats em { color: var(--mint); margin-top: 2px; }

.stats strong {
  display: block;
  margin-top: 6px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.segments {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.segments li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--paper);
}

.segments li:first-child { border-top: 0; }

.segments .idx {
  color: var(--green);
  font-size: 12px;
  font-weight: 750;
}

.segments b {
  display: block;
  font-size: 14px;
  font-weight: 700;
}

.segments small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.segments .clock {
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.03em;
}

.bar {
  display: block;
  height: 4px;
  margin-top: 6px;
  background: var(--sand);
  border-radius: 2px;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: 2px;
}

.total-line {
  margin: 10px 2px 0;
  text-align: right;
  font-size: 13px;
  color: var(--muted);
}

.total-line strong {
  color: var(--green-2);
  font-size: 16px;
}

.share-presets {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.share-presets button { text-align: left; padding: 0 14px; }

.share-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--sand);
}

.share-row b { font-size: 14px; }

.share-row p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 2px;
}

.stepper button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--sand);
  font-size: 18px;
  line-height: 1;
}

.stepper strong {
  min-width: 46px;
  text-align: center;
  font-size: 14px;
}

.actions { margin-top: 22px; }

.primary, .secondary {
  display: block;
  width: 100%;
  min-height: 52px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 750;
}

.primary {
  background: var(--green);
  color: var(--paper);
}

.primary:active { background: var(--green-2); }

.secondary {
  margin-top: 8px;
  background: var(--card);
  border: 1px solid var(--line);
}

.toast {
  margin: 10px 0 0;
  text-align: center;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

.foot {
  margin-top: 28px;
  font-size: 12px;
  line-height: 1.5;
}

.foot p { margin: 0 0 6px; }

@media (min-width: 480px) {
  .wrap { padding-top: 32px; }
}
