:root {
  color-scheme: dark;
  --bg: #0e1110;
  --panel: #171d1b;
  --panel-strong: #202923;
  --line: rgba(238, 231, 210, 0.16);
  --text: #f6f0df;
  --muted: #bdc4b9;
  --accent: #e2b557;
  --accent-2: #60c8a0;
  --danger: #ef705f;
  --ink: #121613;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 8%, rgba(226, 181, 87, 0.14), transparent 28%),
    linear-gradient(140deg, rgba(96, 200, 160, 0.1), transparent 42%),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  appearance: none;
  background: #26312b;
  border: 1px solid rgba(246, 240, 223, 0.2);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  min-height: 42px;
  padding: 0.68rem 0.88rem;
}

button:hover {
  background: #324039;
}

button:focus-visible {
  outline: 3px solid rgba(226, 181, 87, 0.6);
  outline-offset: 2px;
}

button:disabled {
  color: rgba(246, 240, 223, 0.42);
  cursor: not-allowed;
  opacity: 0.65;
}

.shell {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 16px 0 22px;
}

.topbar {
  align-items: end;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.eyebrow,
.label {
  color: var(--accent);
  display: block;
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  margin: 0 0 0.28rem;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2.1rem, 5vw, 4.1rem);
  line-height: 0.95;
  margin: 0;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

#pulseButton {
  background: var(--accent);
  border-color: rgba(0, 0, 0, 0.18);
  color: #20170a;
}

#pulseButton:hover {
  background: #f2cd73;
}

.layout {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(270px, 328px) minmax(0, 1fr);
}

.panel,
.stage {
  background: rgba(23, 29, 27, 0.92);
  border: 1px solid var(--line);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
}

.panel {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 17px;
}

.panel p {
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.45;
  margin: 0;
}

.stat-grid {
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.stat {
  border-bottom: 1px solid rgba(246, 240, 223, 0.08);
  display: grid;
  gap: 0.22rem;
  min-width: 0;
  padding: 0.68rem 0.54rem;
}

.stat:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.stat span {
  color: var(--muted);
  font-size: 0.76rem;
}

.stat strong {
  color: var(--text);
  font-size: clamp(1rem, 2.4vw, 1.24rem);
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.stage {
  display: grid;
  gap: 10px;
  justify-items: center;
  min-width: 0;
  padding: 10px;
}

canvas {
  aspect-ratio: 1;
  background: #101411;
  display: block;
  height: auto;
  outline: none;
  touch-action: none;
  width: min(100%, 73vh, 740px);
}

.pad {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(58px, 86px));
  justify-content: center;
  width: min(100%, 290px);
}

.pad span {
  min-height: 42px;
}

.pad button {
  min-height: 46px;
  padding: 0.55rem 0.5rem;
}

.pad [data-pulse] {
  background: #315242;
}

@media (max-width: 880px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .button-row {
    justify-content: stretch;
  }

  .button-row button {
    flex: 1 1 128px;
  }

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

  .panel {
    order: 2;
  }

  canvas {
    width: min(100%, 58vh, 560px);
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100% - 14px, 1180px);
    padding-top: 10px;
  }

  .panel {
    padding: 14px;
  }

  .stage {
    padding: 7px;
  }

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

  .stat:nth-last-child(-n + 2) {
    border-bottom: 1px solid rgba(246, 240, 223, 0.08);
  }

  .stat:last-child {
    border-bottom: 0;
  }

  .pad {
    grid-template-columns: repeat(3, minmax(54px, 76px));
  }
}
