:root {
  color: #1f2937;
  background: #f3f5f7;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --canvas: #f3f5f7;
  --card: #ffffff;
  --ink: #111827;
  --text: #1f2937;
  --muted: #6b7280;
  --muted-light: #9ca3af;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --accent: #ff6b1a;
  --accent-dark: #e85408;
  --accent-soft: #fff1e9;
  --success: #16805c;
  --success-soft: #eaf8f1;
  --success-line: #b9e7d1;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--canvas);
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(255, 107, 26, 0.32);
  outline-offset: 2px;
}

.app-shell {
  width: calc(100% - 24px);
  max-width: 560px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 0 max(28px, env(safe-area-inset-bottom));
}

.hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
  padding: 22px 20px 23px;
  border-bottom: 3px solid var(--accent);
  border-radius: 18px;
  color: #ffffff;
  background: linear-gradient(135deg, #111827 0%, #1b2535 100%);
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.12);
}

.hero::after {
  position: absolute;
  right: -36px;
  bottom: -58px;
  width: 150px;
  height: 150px;
  border: 1px solid rgba(255, 107, 26, 0.2);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.hero .eyebrow {
  color: #ffad83;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  position: relative;
  z-index: 1;
  margin: 8px 0 9px;
  color: #ffffff;
  font-size: clamp(2.15rem, 11vw, 3.4rem);
  letter-spacing: -0.07em;
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  color: var(--ink);
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 25rem;
  margin-bottom: 0;
  color: #d1d5db;
  font-size: 0.9rem;
  line-height: 1.6;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 7px 20px rgba(17, 24, 39, 0.045);
}

.input-panel,
.result-panel {
  padding: 15px;
}

.input-panel {
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.result-panel {
  margin-top: 14px;
  border-color: #111827;
  color: #ffffff;
  background: linear-gradient(145deg, #111827 0%, #1d2939 100%);
  box-shadow: 0 14px 28px rgba(17, 24, 39, 0.17);
}

.section-heading,
.result-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 2px 15px;
}

.section-kicker {
  margin-bottom: 5px;
}

.section-heading h2 {
  color: var(--ink);
}

.result-heading {
  align-items: center;
  margin: 2px 2px 14px;
}

.result-heading .section-kicker {
  color: #ff9a6a;
  letter-spacing: 0.08em;
}

.result-heading h2 {
  color: #ffffff;
}

.live-badge,
.result-live-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--success-line);
  border-radius: 999px;
  padding: 8px 10px;
  color: var(--success);
  background: var(--success-soft);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  white-space: nowrap;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.result-live-label {
  border-color: rgba(255, 107, 26, 0.38);
  color: #ffb38e;
  background: rgba(255, 107, 26, 0.12);
}

.field-block {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid #edf0f2;
  border-radius: 15px;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(17, 24, 39, 0.035);
}

.field-block:last-child {
  margin-bottom: 0;
}

.field-label {
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 800;
}

.field-topline,
.wind-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.field-count {
  color: var(--muted-light);
  font-size: 0.68rem;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #eef0f2;
}

.segment-button,
.event-button,
.wind-pick {
  border: 0;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.segment-button {
  min-height: 52px;
  border-radius: 10px;
  font-size: 1rem;
}

.segment-button:hover,
.segment-button:focus-visible,
.event-button:hover,
.event-button:focus-visible,
.wind-pick:hover,
.wind-pick:focus-visible {
  color: var(--ink);
  background: #ffffff;
}

.segment-button.is-active {
  color: #ffffff;
  background: var(--ink);
  box-shadow: 0 4px 10px rgba(17, 24, 39, 0.14);
}

.segment-button.is-active:hover,
.segment-button.is-active:focus-visible {
  color: #ffffff;
  background: #1f2937;
}

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

.event-button {
  min-width: 0;
  min-height: 60px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  background: #ffffff;
  font-size: 1rem;
}

.event-button.is-active {
  border-color: var(--ink);
  color: #ffffff;
  background: var(--ink);
  box-shadow: inset 4px 0 0 var(--accent), 0 4px 10px rgba(17, 24, 39, 0.12);
}

.event-button.is-active:hover,
.event-button.is-active:focus-visible {
  color: #ffffff;
  background: #1f2937;
}

.control-input {
  width: 100%;
  min-height: 64px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  outline: none;
  color: var(--text);
  background: #ffffff;
  padding: 0 68px 0 16px;
  box-shadow: inset 0 1px 2px rgba(17, 24, 39, 0.025);
}

.control-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 107, 26, 0.12);
}

.control-input::placeholder {
  color: #9ca3af;
}

.input-with-unit {
  position: relative;
  display: block;
}

.large-input .control-input {
  font-size: clamp(1.5rem, 7vw, 1.9rem);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.input-unit {
  position: absolute;
  top: 50%;
  right: 16px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  pointer-events: none;
  transform: translateY(-50%);
}

.field-help {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

.wind-status-row {
  align-items: center;
  flex-wrap: wrap;
}

.wind-direction {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--muted);
  background: #f3f4f6;
  font-size: 0.72rem;
  line-height: 1;
}

.wind-direction.is-headwind {
  border-color: var(--success-line);
  color: var(--success);
  background: var(--success-soft);
}

.wind-direction.is-tailwind {
  border-color: #dbe1e7;
  color: #4b5563;
  background: #f3f4f6;
}

.wind-direction.is-invalid {
  border-color: #ffc7a9;
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.wind-picks {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.wind-pick {
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #4b5563;
  background: #ffffff;
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.wind-pick.is-active {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.wind-pick.is-active:hover,
.wind-pick.is-active:focus-visible {
  color: var(--accent-dark);
  background: #ffe8da;
}

.wind-reference-note {
  min-height: 1.05em;
  margin: -1px 0 0;
}

.result-heading .section-kicker {
  margin-bottom: 5px;
}

.result-score-display {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 104px;
  padding: 12px 0 19px;
}

.result-value {
  color: #ffffff;
  font-size: clamp(4rem, 22vw, 7rem);
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  letter-spacing: -0.09em;
  line-height: 0.9;
}

.result-unit {
  color: #cbd5e1;
  font-size: 1.1rem;
  font-weight: 800;
}

.result-panel.is-pending .result-value {
  color: #64748b;
}

.qualification-summary {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.summary-label {
  display: block;
  margin-bottom: 3px;
  color: #cbd5e1;
  font-size: 0.74rem;
  font-weight: 700;
}

.summary-score {
  color: #ffffff;
  font-size: 1.12rem;
  font-variant-numeric: tabular-nums;
}

.points-difference {
  color: #cbd5e1;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.points-difference.is-cleared {
  color: #6ee7b7;
}

.points-difference.is-close {
  color: #ffb38e;
}

.qualification-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 14px 15px;
  border: 1px solid rgba(110, 231, 183, 0.32);
  border-radius: 14px;
  color: #a7f3d0;
  background: rgba(22, 128, 92, 0.2);
}

.qualification-card strong {
  color: #dcfce9;
  font-size: 0.96rem;
}

.qualification-icon {
  display: grid;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #073b2a;
  background: #6ee7b7;
  font-size: 0.92rem;
  font-weight: 900;
  place-items: center;
}

.result-hint {
  margin: 14px 0 0;
  color: #cbd5e1;
  font-size: 0.76rem;
  line-height: 1.55;
}

.target-explanation {
  margin-top: 14px;
  padding: 13px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.72rem;
  line-height: 1.65;
}

.target-explanation p {
  margin-bottom: 5px;
}

.target-count {
  color: #94a3b8;
  font-size: 0.68rem;
}

.calculation-details {
  margin-top: 13px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

details summary {
  min-height: 44px;
  padding: 12px 0 2px;
  color: #cbd5e1;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
}

.details-content {
  padding: 4px 0 2px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  font-size: 0.76rem;
}

.detail-row strong {
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}

.detail-row-total strong {
  color: #ffffff;
}

.wind-why {
  margin-top: 4px;
}

.wind-why summary {
  color: #cbd5e1;
  font-size: 0.74rem;
}

.wind-why p {
  margin: 0 0 4px;
  color: #aebaca;
  font-size: 0.72rem;
  line-height: 1.7;
}

.app-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 16px 4px 0;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.5;
}

.app-footer a {
  color: var(--accent-dark);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

.is-hidden {
  display: none !important;
}

@media (min-width: 640px) {
  .app-shell {
    padding-top: 32px;
  }

  .hero {
    padding: 26px 26px 27px;
  }

  .result-panel {
    padding: 22px;
  }

  .event-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

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