:root {
  --bg-top: #f8f1df;
  --bg-bottom: #eedac1;
  --panel: rgba(255, 251, 245, 0.82);
  --panel-border: rgba(109, 76, 29, 0.12);
  --ink-strong: #1e2a1f;
  --ink-soft: #57645b;
  --accent: #c76a24;
  --accent-deep: #9f4f15;
  --success: #2f9e44;
  --success-soft: rgba(47, 158, 68, 0.16);
  --danger: #d04f35;
  --lane: #f5e5c8;
  --lane-line: rgba(103, 74, 33, 0.18);
  --shadow: 0 24px 80px rgba(92, 68, 28, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Trebuchet MS", "Gill Sans", sans-serif;
  color: var(--ink-strong);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.7), transparent 34%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

button,
input,
select,
textarea {
  font: inherit;
}

.page-shell {
  min-height: 100vh;
  padding: 24px 18px 40px;
  position: relative;
  overflow: hidden;
}

.page-shell::before,
.page-shell::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  filter: blur(8px);
  z-index: 0;
}

.page-shell::before {
  width: 220px;
  height: 220px;
  top: -60px;
  right: -40px;
  background: rgba(255, 255, 255, 0.45);
}

.page-shell::after {
  width: 260px;
  height: 260px;
  left: -120px;
  bottom: -90px;
  background: rgba(199, 106, 36, 0.16);
}

.hero,
.app-grid {
  position: relative;
  z-index: 1;
}

.hero {
  max-width: 720px;
  margin: 0 auto 20px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  color: var(--accent-deep);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.5rem, 8vw, 4.8rem);
  line-height: 0.95;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
}

.hero-copy {
  margin: 14px 0 0;
  max-width: 50ch;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.5;
}

.app-grid {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.panel-topline,
.pitch-target-row,
.pitch-stage-toolbar,
.controls-row,
.detected-note-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.phase-pill,
.round-readout {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 0.9rem;
}

.phase-pill {
  background: rgba(199, 106, 36, 0.14);
  color: var(--accent-deep);
}

.phase-pill.success {
  background: var(--success-soft);
  color: var(--success);
}

.phase-pill.alert {
  background: rgba(208, 79, 53, 0.12);
  color: var(--danger);
}

.round-readout {
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink-soft);
}

.target-card,
.pitch-stage-card,
.current-note-card {
  margin-top: 18px;
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(109, 76, 29, 0.08);
}

.pitch-stage-card,
.current-note-card {
  margin-top: 0;
}

.label {
  margin: 0 0 8px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}

.target-note,
.detected-note {
  margin: 0;
  font-size: clamp(3rem, 12vw, 5.75rem);
  line-height: 0.95;
}

.countdown-text,
.support-text,
.status-text,
.guidance-text,
.detected-detail,
.detected-frequency {
  margin: 10px 0 0;
  color: var(--ink-soft);
  line-height: 1.45;
}

.mission-panel,
.feedback-panel {
  display: grid;
  gap: 18px;
  align-content: start;
}

.pitch-stage-card {
  margin-top: 0;
  padding: 18px;
  position: relative;
}

.pitch-stage-toolbar {
  align-items: flex-start;
}

.pitch-stage-actions,
.stage-controls-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pitch-stage-toolbar .label,
.pitch-target-label {
  margin-bottom: 0;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(109, 76, 29, 0.08);
  color: var(--ink-soft);
  cursor: pointer;
}

.toggle-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-chip-track {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: rgba(30, 42, 31, 0.12);
  padding: 3px;
  display: inline-flex;
  align-items: center;
  transition: background 160ms ease;
}

.toggle-chip-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 3px 8px rgba(30, 42, 31, 0.18);
  transform: translateX(0);
  transition: transform 160ms ease;
}

.toggle-chip input:checked + .toggle-chip-track {
  background: rgba(47, 158, 68, 0.28);
}

.toggle-chip input:checked + .toggle-chip-track .toggle-chip-thumb {
  transform: translateX(18px);
}

.toggle-chip-text {
  font-size: 0.92rem;
  white-space: nowrap;
}

.stage-controls-overlay {
  position: absolute;
  inset: 66px 18px 18px;
  z-index: 4;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  padding: 24px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 251, 245, 0.86), rgba(255, 251, 245, 0.76));
  backdrop-filter: blur(10px);
  text-align: center;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.stage-controls-overlay[data-visible="false"] {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.stage-overlay-title,
.stage-overlay-copy {
  margin: 0;
}

.stage-overlay-title {
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  font-weight: 700;
}

.stage-overlay-copy {
  max-width: 32ch;
  color: var(--ink-soft);
  line-height: 1.5;
}

.pitch-stage-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
}

.pitch-target-block {
  min-width: 0;
  flex: 1 1 auto;
}

.pitch-target-row {
  align-items: flex-end;
  gap: 16px;
}

.pitch-target-row .target-note {
  font-size: clamp(3.2rem, 10vw, 5.6rem);
  flex: 0 0 auto;
}

.pitch-target-row .countdown-text {
  margin: 0;
  max-width: 22ch;
}

.guidance-text-stage {
  margin: 0;
  font-size: 1rem;
}

.feedback-panel .controls-row,
.feedback-panel .status-text,
.feedback-panel .round-track {
  margin-top: 0;
}

.success-ring {
  --progress-deg: calc(var(--progress) * 1turn);
  width: min(60vw, 240px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    conic-gradient(var(--success) var(--progress-deg), rgba(255, 255, 255, 0.72) 0),
    radial-gradient(circle at center, rgba(255, 255, 255, 0.86) 57%, transparent 58%);
  padding: 16px;
  transition: background 120ms linear, transform 180ms ease;
}

.success-ring.active {
  transform: scale(1.02);
}

.success-ring-compact {
  width: clamp(112px, 18vw, 150px);
  padding: 10px;
  flex: 0 0 auto;
}

.ring-core {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(255, 251, 245, 0.98);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1px solid rgba(109, 76, 29, 0.08);
}

.ring-label {
  font-size: 0.84rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

#hold-timer {
  margin-top: 8px;
  font-size: clamp(1.8rem, 8vw, 3rem);
}

.primary-button,
.secondary-button,
.ghost-button {
  border: 0;
  border-radius: 999px;
  min-height: 52px;
  padding: 0 18px;
  cursor: pointer;
  transition:
    transform 140ms ease,
    opacity 140ms ease,
    background 140ms ease;
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active {
  transform: scale(0.98);
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: white;
  font-weight: 700;
  flex: 1 1 0;
}

.secondary-button {
  background: rgba(30, 42, 31, 0.08);
  color: var(--ink-strong);
  flex: 1 1 0;
}

.ghost-button {
  min-height: 40px;
  background: rgba(199, 106, 36, 0.12);
  color: var(--accent-deep);
  white-space: nowrap;
  flex: 0 0 auto;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pitch-lane-shell {
  display: grid;
  gap: 12px;
}

.pitch-lane {
  position: relative;
  height: clamp(320px, 48vw, 460px);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(208, 79, 53, 0.18), rgba(255, 255, 255, 0.74), rgba(61, 122, 77, 0.24)),
    var(--lane);
  overflow: hidden;
  border: 1px solid rgba(109, 76, 29, 0.1);
}

.lane-label {
  position: absolute;
  left: 16px;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(30, 42, 31, 0.58);
}

.lane-high {
  top: 14px;
}

.lane-center {
  top: 50%;
  transform: translateY(calc(-100% - 14px));
}

.lane-low {
  bottom: 14px;
}

.lane-center-line {
  position: absolute;
  inset-inline: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 2px;
  background: var(--lane-line);
}

.pitch-arrow {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) translateY(0px);
  width: 62px;
  height: 62px;
  border-radius: 18px;
  background: rgba(255, 251, 245, 0.94);
  border: 1px solid rgba(109, 76, 29, 0.12);
  display: grid;
  place-items: center;
  box-shadow: 0 16px 32px rgba(92, 68, 28, 0.16);
  will-change: transform, opacity;
  transition: opacity 180ms ease;
  opacity: 0;
}

.pitch-arrow[data-visible="true"] {
  opacity: 1;
}

.pitch-arrow[data-state="center"] {
  background: rgba(47, 158, 68, 0.14);
  border-color: rgba(47, 158, 68, 0.35);
}

.arrow-glyph {
  display: inline-block;
  font-size: 1.65rem;
  color: var(--accent-deep);
  transition: transform 180ms ease;
}

.pitch-arrow[data-state="center"] .arrow-glyph {
  color: var(--success);
}

.round-track {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
}

.round-chip {
  min-height: 72px;
  border-radius: 22px;
  border: 1px solid rgba(109, 76, 29, 0.1);
  background: rgba(255, 255, 255, 0.54);
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  font-weight: 700;
  transition:
    transform 180ms ease,
    background 180ms ease,
    color 180ms ease;
}

.round-chip.active {
  background: rgba(199, 106, 36, 0.14);
  color: var(--accent-deep);
  transform: translateY(-4px);
}

.round-chip.complete {
  background: var(--success-soft);
  color: var(--success);
}

@media (min-width: 880px) {
  .app-grid {
    grid-template-columns: 1.3fr 0.7fr;
    align-items: start;
  }

  .panel {
    padding: 24px;
  }
}

@media (max-width: 540px) {
  .page-shell {
    padding-inline: 14px;
  }

  .pitch-stage-toolbar,
  .pitch-stage-actions,
  .stage-controls-row,
  .pitch-target-row,
  .controls-row,
  .detected-note-row {
    flex-direction: column;
    align-items: stretch;
  }

  .pitch-stage-footer {
    align-items: flex-end;
  }

  .ghost-button,
  .primary-button,
  .secondary-button {
    flex: 0 0 auto;
    width: 100%;
  }

  .pitch-lane {
    height: 280px;
  }

  .pitch-target-row .countdown-text {
    max-width: none;
  }

  .success-ring-compact {
    align-self: flex-end;
  }

  .toggle-chip {
    justify-content: center;
  }

  .stage-controls-overlay {
    inset: 74px 18px 18px;
    padding: 20px 16px;
  }
}

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