:root {
  color-scheme: dark;
  --ink: #ffffff;
  --muted: #b8b8b8;
  --line: rgba(138, 145, 153, 0.42);
  --paper: #222222;
  --panel: rgba(0, 0, 0, 0.22);
  --dark: #ffffff;
  --accent: #c8ff76;
  --accent-soft: rgba(200, 255, 118, 0.16);
  --warn: #ffcf73;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

button:hover:not(:disabled) {
  filter: brightness(1.08);
}

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

.shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.topbar,
.prompt-head,
.prompt-row,
.style-row,
.parameter-grid,
.panel-head,
.transport,
.panel-vote,
.vote-strip,
.section-head {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  padding: 8px 0 18px;
}

.eyebrow,
.side-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(36px, 6vw, 76px);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.status-pill {
  min-width: 112px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 9px 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 750;
}

.prompt-band {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 14px 0 16px;
}

.prompt-band label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.prompt-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.utility-button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--accent);
}

.prompt-row {
  gap: 10px;
}

.prompt-row input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
  padding: 0 13px;
  color: var(--ink);
}

.prompt-row button {
  min-width: 140px;
}

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

.parameter-grid label {
  min-width: 0;
}

.parameter-grid span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.parameter-grid select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
  color: var(--ink);
  padding: 0 9px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.style-row {
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  min-height: 32px;
  padding: 0 10px;
  border-color: var(--line);
  background: transparent;
  color: var(--ink);
}

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

.arena-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

.beat-panel,
.leaderboard,
.notes {
  border: 1px solid var(--line);
  background: var(--panel);
}

.beat-panel {
  min-height: 470px;
  padding: 16px;
}

.panel-head {
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
}

.panel-head span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.transport {
  gap: 8px;
  margin: 8px 0 12px;
}

.icon-button {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
}

.transport button:nth-child(2),
#tieBtn,
#refreshBtn {
  border-color: var(--line);
  background: transparent;
  color: var(--ink);
}

.mood {
  min-height: 24px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

.playhead {
  display: grid;
  grid-template-columns: repeat(16, minmax(10px, 1fr));
  gap: 3px;
  margin-bottom: 8px;
}

.playhead span {
  height: 5px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
}

.playhead span.is-on {
  border-color: #c8ff76;
  background: #c8ff76;
}

.strudel-editor {
  min-height: 230px;
  max-height: 300px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  background: #222222;
  padding: 10px 0;
  color: #e8f4df;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.panel-vote {
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.panel-vote button {
  min-width: 132px;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.code-line {
  display: grid;
  grid-template-columns: 38px 1fr;
  min-height: 20px;
  padding-right: 12px;
  white-space: pre-wrap;
}

.code-line.is-active {
  background: rgba(200, 255, 118, 0.14);
}

.line-no {
  color: #6f7368;
  padding-right: 10px;
  text-align: right;
  user-select: none;
}

.code-text {
  min-width: 0;
}

.tok-comment {
  color: #73786d;
}

.tok-string {
  color: #c8ff76;
}

.tok-fn {
  color: #83cfff;
}

.tok-num {
  color: #ffcf73;
}

.tok-op {
  color: #f1f1e8;
}

.reveal {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--warn);
  font-size: 13px;
  font-weight: 750;
}

.vote-strip {
  justify-content: center;
  gap: 14px;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
}

.vote-strip p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.lower-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 14px;
  margin-top: 16px;
}

.leaderboard,
.notes {
  padding: 16px;
}

.section-head {
  justify-content: space-between;
  margin-bottom: 12px;
}

#leaderboard {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 24px;
}

#leaderboard li {
  padding: 9px 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
}

.row-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 760;
}

.row-meta,
.notes p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.notes p:last-child {
  margin-bottom: 0;
}

@media (max-width: 820px) {
  .topbar,
  .prompt-head,
  .prompt-row,
  .vote-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .prompt-row button {
    width: 100%;
  }

  .parameter-grid,
  .arena-grid,
  .lower-grid {
    grid-template-columns: 1fr;
  }
}
