:root {
  --yellow: #ffd600;
  --yellow-deep: #efc800;
  --ink: #050505;
  --panel: #101010;
  --panel-raised: #171717;
  --line: rgba(255, 255, 255, 0.14);
  --muted: #999999;
  --white: #f7f7f2;
  --danger: #ff695e;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 60% 10%, rgba(255, 214, 0, 0.07), transparent 30%),
    var(--ink);
  color: var(--white);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

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

.app-shell {
  min-height: 100vh;
  padding: 22px clamp(18px, 3vw, 54px) 42px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(130px, 210px) 1fr auto;
  align-items: center;
  gap: 28px;
  max-width: 1600px;
  margin: 0 auto 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand-logo {
  display: block;
  width: 154px;
  height: 64px;
  object-fit: contain;
  object-position: left center;
}

.topbar-title {
  display: flex;
  align-items: baseline;
  gap: 18px;
}

.eyebrow,
.score-kicker,
.best-label,
.section-heading,
.history-rank,
.wave-card-header {
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow {
  color: var(--yellow);
  font-size: 12px;
  font-weight: 900;
}

.venue-copy {
  color: var(--muted);
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.utility-button,
.active-controls button,
.close-button,
.text-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.utility-button {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #c8c8c8;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.utility-button:hover {
  border-color: rgba(255, 214, 0, 0.55);
  color: var(--yellow);
}

.meter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 375px);
  gap: 20px;
  max-width: 1600px;
  margin: 0 auto;
}

.main-stage,
.results-panel {
  min-width: 0;
}

.main-stage {
  position: relative;
  min-height: calc(100vh - 155px);
  overflow: hidden;
  padding: clamp(22px, 3vw, 48px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.025), transparent 42%),
    #0b0b0b;
}

.main-stage::before {
  position: absolute;
  right: -90px;
  bottom: -120px;
  width: 360px;
  height: 360px;
  border: 60px solid rgba(255, 214, 0, 0.025);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.status-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #c6c6c6;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #777;
}

.status-armed,
.status-recording {
  border-color: rgba(255, 214, 0, 0.45);
  color: var(--yellow);
}

.status-armed .status-dot,
.status-recording .status-dot {
  background: var(--yellow);
  box-shadow: 0 0 12px rgba(255, 214, 0, 0.8);
}

.status-recording .status-dot {
  animation: pulse 0.9s ease-in-out infinite;
}

.status-error {
  color: var(--danger);
}

.status-error .status-dot {
  background: var(--danger);
}

.live-reading {
  color: #b5b5b5;
  font-family: "Courier New", monospace;
  font-size: 13px;
  font-weight: 700;
}

.score-lockup {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: clamp(28px, 4vh, 56px) auto clamp(24px, 4vh, 48px);
}

.score-kicker {
  margin-bottom: 2px;
  color: var(--yellow);
  font-size: 12px;
  font-weight: 900;
}

.score-line {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  line-height: 0.85;
}

.score-value {
  min-width: 0.92em;
  color: var(--yellow);
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(120px, 16vw, 255px);
  letter-spacing: -0.075em;
  text-align: center;
  text-shadow: 0 0 55px rgba(255, 214, 0, 0.12);
}

.score-total {
  margin: 0 0 0.12em 0.2em;
  color: rgba(255, 255, 255, 0.3);
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(27px, 3.3vw, 52px);
}

.peak-copy {
  margin-top: 18px;
  color: #878787;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.15em;
}

.peak-copy strong {
  margin-left: 7px;
  color: var(--white);
  font-family: "Courier New", monospace;
  font-size: 14px;
  letter-spacing: 0;
}

.wave-card {
  position: relative;
  z-index: 1;
  padding: 16px 18px 14px;
  border: 1px solid rgba(255, 214, 0, 0.2);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.55);
}

.wave-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  color: #777;
  font-size: 9px;
  font-weight: 900;
}

.wave-card-header span:first-child {
  color: var(--yellow);
}

.waveform {
  display: block;
  width: 100%;
  height: clamp(92px, 14vh, 155px);
}

.level-track {
  position: relative;
  height: 5px;
  overflow: visible;
  margin-top: 10px;
  border-radius: 999px;
  background: #232323;
}

.level-fill {
  position: absolute;
  inset: 0 auto 0 0;
  max-width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6a5b00, var(--yellow));
  box-shadow: 0 0 12px rgba(255, 214, 0, 0.35);
  transition: width 80ms linear;
}

.trigger-marker {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 13px;
  background: var(--white);
  opacity: 0.6;
}

.scale {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  color: #555;
  font-family: "Courier New", monospace;
  font-size: 9px;
}

.start-panel,
.active-controls {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 22px;
}

.start-panel {
  flex-direction: column;
}

.start-panel p {
  max-width: 520px;
  margin: 0;
  color: #777;
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.start-panel .error-copy {
  color: var(--danger);
}

.primary-button {
  min-height: 52px;
  padding: 0 27px;
  border: 0;
  border-radius: 999px;
  background: var(--yellow);
  color: #000;
  cursor: pointer;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  box-shadow: 0 10px 35px rgba(255, 214, 0, 0.12);
}

.primary-button:hover {
  background: #ffe13b;
  transform: translateY(-1px);
}

.active-controls {
  justify-content: space-between;
  color: #777;
  font-size: 11px;
}

.active-controls button {
  color: #aaa;
  font-size: 11px;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.results-panel {
  display: flex;
  min-height: calc(100vh - 155px);
  flex-direction: column;
  gap: 14px;
}

.best-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  padding: 26px;
  border-radius: 20px;
  background: var(--yellow);
  color: #000;
}

.best-label {
  align-self: start;
  font-size: 11px;
  font-weight: 950;
}

.best-score {
  grid-row: span 2;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 94px;
  letter-spacing: -0.06em;
  line-height: 0.78;
}

.best-total {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.65;
}

.history-card {
  flex: 1;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
  color: var(--white);
  font-size: 10px;
  font-weight: 900;
}

.section-heading span:last-child {
  color: #666;
  letter-spacing: 0;
  text-transform: none;
}

.history-list {
  display: flex;
  flex-direction: column;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 112px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.history-item:last-child {
  border-bottom: 0;
}

.history-rank {
  color: #707070;
  font-size: 9px;
  font-weight: 900;
}

.history-score {
  grid-row: span 2;
  min-width: 80px;
  color: #8e8e8e;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 62px;
  line-height: 0.9;
  text-align: right;
}

.history-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #555;
  font-size: 10px;
}

.history-meta strong {
  color: #a0a0a0;
  font-family: "Courier New", monospace;
  font-size: 11px;
}

.history-item.is-latest .history-score {
  color: var(--yellow);
}

.history-item.is-latest .history-rank {
  color: var(--yellow);
}

.history-item.is-empty {
  opacity: 0.62;
}

.privacy-note {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 17px 20px;
  border: 1px solid rgba(255, 214, 0, 0.16);
  border-radius: 16px;
  color: #777;
  font-size: 10px;
  line-height: 1.45;
}

.privacy-note strong {
  display: block;
  color: #b8b8b8;
  font-size: 10px;
  text-transform: uppercase;
}

.privacy-icon {
  color: var(--yellow);
  font-size: 12px;
  text-shadow: 0 0 10px rgba(255, 214, 0, 0.8);
}

.modal-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(12px);
}

.settings-modal {
  width: min(640px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 30px;
  border: 1px solid rgba(255, 214, 0, 0.28);
  border-radius: 24px;
  background: #101010;
  box-shadow: 0 24px 100px rgba(0, 0, 0, 0.6);
}

.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.modal-heading h2 {
  margin: 5px 0 0;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 42px;
  font-weight: 400;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.close-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #aaa;
  font-size: 26px;
}

.settings-list {
  border-top: 1px solid var(--line);
}

.setting {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 20px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.setting-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.setting-label {
  font-size: 13px;
  font-weight: 800;
}

.setting-description {
  color: #777;
  font-size: 10px;
}

.setting-value {
  color: var(--yellow);
  font-family: "Courier New", monospace;
  font-size: 12px;
  font-weight: 800;
}

.setting input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--yellow);
  cursor: pointer;
}

.score-formula {
  margin: 22px 0 0;
  padding: 16px;
  border-radius: 12px;
  background: rgba(255, 214, 0, 0.07);
}

.score-formula span {
  color: var(--yellow);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.score-formula p {
  margin: 5px 0 0;
  color: #aaa;
  font-size: 11px;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
}

.text-button {
  color: #9c9c9c;
  font-size: 11px;
  font-weight: 800;
}

.danger-button:hover {
  color: var(--danger);
}

.compact-button {
  min-height: 46px;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(0.82);
  }
  50% {
    opacity: 1;
    transform: scale(1.12);
  }
}

@media (max-width: 960px) {
  .topbar {
    grid-template-columns: 120px 1fr auto;
  }

  .brand-logo {
    width: 120px;
  }

  .venue-copy {
    display: none;
  }

  .meter-grid {
    grid-template-columns: 1fr;
  }

  .main-stage,
  .results-panel {
    min-height: auto;
  }

  .results-panel {
    display: grid;
    grid-template-columns: 1fr 2fr;
  }

  .history-card {
    grid-row: span 2;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px 12px 28px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
    gap: 12px;
  }

  .topbar-title {
    display: none;
  }

  .brand-logo {
    width: 108px;
    height: 50px;
  }

  .utility-button {
    padding: 9px 10px;
    font-size: 9px;
  }

  .main-stage {
    padding: 20px 16px;
    border-radius: 18px;
  }

  .status-pill {
    padding: 8px 10px;
    font-size: 9px;
  }

  .live-reading {
    font-size: 11px;
  }

  .score-value {
    font-size: clamp(112px, 42vw, 175px);
  }

  .score-total {
    font-size: 25px;
  }

  .wave-card {
    padding: 13px 12px 12px;
  }

  .active-controls {
    align-items: flex-start;
    flex-direction: column;
  }

  .results-panel {
    display: flex;
  }

  .history-item {
    min-height: 96px;
  }

  .settings-modal {
    padding: 24px 18px;
    border-radius: 18px;
  }

  .setting {
    gap: 8px 12px;
  }
}

@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;
  }
}

@media (min-width: 1100px) and (min-height: 760px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .app-shell {
    display: grid;
    grid-template-rows: 86px minmax(0, 1fr);
    width: 100%;
    height: 100vh;
    padding: 12px clamp(26px, 2.4vw, 52px) 24px;
    overflow: hidden;
  }

  .topbar {
    width: 100%;
    height: 86px;
    max-width: 1820px;
    margin: 0 auto;
    padding: 0 0 12px;
  }

  .brand-logo {
    width: 142px;
    height: 62px;
  }

  .topbar-title {
    gap: 22px;
  }

  .eyebrow {
    font-size: 14px;
  }

  .venue-copy {
    font-size: 13px;
  }

  .utility-button {
    min-height: 44px;
    padding: 0 18px;
    font-size: 12px;
  }

  .meter-grid {
    grid-template-columns: minmax(0, 1fr) 370px;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-width: 1820px;
    gap: 18px;
  }

  .main-stage {
    display: grid;
    grid-template-rows: 50px minmax(0, 1fr) 78px;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 30px 38px 22px;
    border-radius: 28px;
  }

  .status-row {
    grid-row: 1;
  }

  .status-pill {
    min-height: 38px;
    padding: 0 16px;
    font-size: 12px;
  }

  .status-dot {
    width: 9px;
    height: 9px;
  }

  .live-reading {
    font-size: 15px;
  }

  .score-lockup {
    position: absolute;
    z-index: 3;
    top: 238px;
    left: 72px;
    align-items: flex-start;
    margin: 0;
    pointer-events: none;
  }

  .score-lockup::before {
    position: absolute;
    z-index: -1;
    top: -34px;
    right: -86px;
    bottom: -40px;
    left: -34px;
    background: radial-gradient(
      ellipse at 35% 48%,
      rgba(6, 6, 6, 0.98) 0%,
      rgba(6, 6, 6, 0.88) 48%,
      rgba(6, 6, 6, 0) 76%
    );
    content: "";
  }

  .score-kicker {
    margin-bottom: 12px;
    font-size: 14px;
  }

  .score-line {
    justify-content: flex-start;
  }

  .score-value {
    min-width: auto;
    font-size: clamp(172px, 11.2vw, 220px);
    line-height: 0.78;
    text-align: left;
  }

  .score-total {
    margin: 0 0 0.1em 0.24em;
    font-size: clamp(40px, 3vw, 54px);
  }

  .peak-copy {
    margin-top: 22px;
    font-size: 13px;
  }

  .peak-copy strong {
    margin-left: 10px;
    font-size: 17px;
  }

  .wave-card {
    display: grid;
    grid-row: 2;
    grid-template-rows: 34px minmax(0, 1fr) 8px 26px;
    min-height: 0;
    margin-top: 16px;
    padding: 22px 24px 16px;
    overflow: hidden;
    border-color: rgba(255, 214, 0, 0.26);
    border-radius: 22px;
    background:
      radial-gradient(circle at 65% 55%, rgba(255, 214, 0, 0.08), transparent 35%),
      linear-gradient(180deg, rgba(255, 214, 0, 0.025), transparent 55%),
      rgba(0, 0, 0, 0.7);
  }

  .wave-card-header {
    margin: 0;
    font-size: 11px;
  }

  .waveform {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  .level-track {
    align-self: center;
    width: 100%;
    height: 6px;
    margin: 0;
  }

  .scale {
    align-items: end;
    margin: 8px 0 0;
    font-size: 10px;
  }

  .start-panel,
  .active-controls {
    grid-row: 3;
    margin: 16px 0 0;
  }

  .start-panel {
    align-items: center;
    flex-direction: row;
    justify-content: flex-start;
  }

  .start-panel p {
    max-width: 560px;
    font-size: 13px;
    text-align: left;
  }

  .primary-button {
    min-height: 58px;
    padding: 0 32px;
    font-size: 14px;
  }

  .active-controls {
    font-size: 13px;
  }

  .active-controls button {
    font-size: 13px;
  }

  .results-panel {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  .best-card {
    min-height: 174px;
    padding: 30px;
  }

  .best-label {
    font-size: 13px;
  }

  .best-score {
    font-size: 110px;
  }

  .best-total {
    font-size: 13px;
  }

  .history-card {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    padding: 28px;
    overflow: hidden;
  }

  .section-heading {
    min-height: 40px;
    font-size: 11px;
  }

  .history-list {
    min-height: 0;
    flex: 1;
  }

  .history-item {
    min-height: 0;
    flex: 1;
    padding: 16px 0;
  }

  .history-rank {
    font-size: 11px;
  }

  .history-score {
    min-width: 96px;
    font-size: 76px;
  }

  .history-meta {
    gap: 6px;
    font-size: 12px;
  }

  .history-meta strong {
    font-size: 13px;
  }

  .privacy-note {
    min-height: 68px;
    padding: 16px 20px;
    font-size: 11px;
  }

  .privacy-note strong {
    font-size: 11px;
  }
}
