:root {
  --bg: #0d0d0f;
  --panel: #121214;
  --border: #1e1e24;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #34d399;
  --warn: #f59e0b;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  padding: 20px 24px 40px;
  max-width: 56rem;
  margin: 0 auto;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hint,
.tagline,
.side-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.tagline {
  margin-top: 4px;
  margin-left: 0;
}

.arena-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 1rem;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.arena-reward {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding-top: 2px;
  margin: 0 auto;
  text-align: center;
}

.reward-label {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
}

.reward-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 18px color-mix(in srgb, var(--accent) 65%, transparent);
}

.arena-title {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-left: -112px;
}

.brand-logo {
  display: block;
  width: min(320px, 72vw);
  height: auto;
  max-height: 64px;
  object-fit: contain;
  margin: 0;
}

@media (max-width: 640px) {
  .arena-title {
    margin-left: -84px;
  }

  .arena-reward {
    order: 3;
    width: 100%;
    margin-top: 4px;
  }
}

.arena-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
}

#badge-difficulty {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  color: var(--accent);
}

.arena-ticker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 10px;
  margin-bottom: 1.25rem;
}

.ticker-cell {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.ticker-label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 4px;
}

.ticker-value {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.worker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.worker-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
  word-break: normal;
  line-height: 1;
}

.worker-status.is-running {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

.worker-status.is-stopped {
  color: var(--muted);
}

.worker-status.is-scheduled {
  color: #fbbf24;
  border-color: color-mix(in srgb, #fbbf24 40%, var(--border));
}

.worker-btn {
  padding: 9px 12px;
  font-size: 0.78rem;
  min-height: 40px;
}

.race-lane {
  position: relative;
  height: 28px;
  margin-top: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border));
  border-radius: 999px;
  background:
    linear-gradient(
      to right,
      transparent 0,
      transparent 18px,
      color-mix(in srgb, var(--border) 70%, transparent) 18px,
      color-mix(in srgb, var(--border) 70%, transparent) 19px
    )
    0 0 / 20px 100% repeat-x,
    color-mix(in srgb, var(--panel) 86%, black);
  overflow: hidden;
}

.house-runner {
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translate(0, -50%);
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  text-shadow: none;
}

.race-lane.is-running .house-runner {
  color: var(--accent);
  text-shadow: 0 0 8px color-mix(in srgb, var(--accent) 65%, transparent);
  animation: house-race 2.4s linear infinite;
}

@keyframes house-race {
  0% {
    transform: translate(0, -50%);
  }
  50% {
    transform: translate(calc(100% - 28px), -50%);
  }
  100% {
    transform: translate(0, -50%);
  }
}

.arena-grid {
  display: grid;
  grid-template-columns: 1fr minmax(14rem, 18rem);
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 720px) {
  .arena-grid {
    grid-template-columns: 1fr;
  }
}

.arena-side {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 14px 10px;
  position: sticky;
  top: 12px;
}

.arena-side h2 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.side-hint {
  margin: 0 0 10px;
  font-size: 0.75rem;
}

.runner-names-hint {
  margin-top: -4px;
  font-size: 0.7rem;
  opacity: 0.9;
}

.leaderboard-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.leaderboard-head h2 {
  margin: 0;
}

.runner-names-btn {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.runner-names-btn:hover {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.runner-dialog {
  max-width: min(26rem, 94vw);
  width: 100%;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.runner-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.runner-dialog-inner {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
}

.runner-dialog h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.runner-dialog-desc {
  margin: 0 0 14px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.runner-field {
  display: block;
  margin-bottom: 12px;
}

.runner-field span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.runner-field input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0d0d0f;
  color: var(--text);
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
}

.runner-form-error {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: #f87171;
}

.runner-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.runner-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.88rem;
}

.runner-btn.primary {
  border-color: var(--accent);
  color: var(--accent);
}

.runner-list-wrap {
  padding: 14px 18px 18px;
}

.runner-list-title {
  margin: 0 0 8px;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.runner-saved-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 12rem;
  overflow-y: auto;
}

.runner-saved-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

.runner-saved-list li:last-child {
  border-bottom: none;
}

.runner-saved-meta {
  min-width: 0;
  flex: 1;
}

.runner-saved-name {
  font-weight: 600;
  color: var(--accent);
}

.runner-saved-addr {
  display: block;
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  color: var(--muted);
  word-break: break-all;
  margin-top: 2px;
}

.runner-saved-remove {
  flex-shrink: 0;
  padding: 4px 8px;
  font-size: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.runner-saved-remove:hover {
  color: #f87171;
  border-color: #f87171;
}

.lb-id {
  display: block;
  min-width: 0;
}

.lb-name {
  font-weight: 600;
  color: var(--accent);
}

.lb-pk-short {
  color: var(--muted);
  font-weight: 400;
}

.leaderboard {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 1.5rem 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.leaderboard li:last-child {
  border-bottom: none;
}

.lb-rank {
  color: var(--muted);
  font-size: 0.75rem;
}

.lb-pk {
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-score {
  color: var(--accent);
  font-weight: 600;
}

.lb-empty {
  display: block;
  color: var(--muted);
  padding: 8px 0;
}

.leaderboard.lb-flash {
  animation: lbflash 0.4s ease-out;
}

@keyframes lbflash {
  from {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 60%, transparent);
  }
  to {
    box-shadow: none;
  }
}

.leaderboard li.lb-you {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  margin: 0 -8px;
  padding: 6px 8px;
  border-radius: 6px;
}

.you-vs {
  margin-bottom: 12px;
  padding: 10px 10px;
  border-radius: 8px;
  border: 1px dashed color-mix(in srgb, var(--accent) 35%, var(--border));
  font-size: 0.78rem;
}

.you-vs-nick {
  margin-bottom: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

.you-vs-nick .you-vs-pk {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.78rem;
}

.you-vs-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  align-items: baseline;
}

.you-vs-grid strong.accent {
  color: var(--accent);
}

.commitment {
  margin: 0 0 1.25rem;
  padding: 12px 14px;
  background: var(--panel);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.commitment h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.commitment dl {
  margin: 0;
}

.commitment dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-top: 8px;
}

.commitment dd {
  margin: 4px 0 0;
}

.prize-balances {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.prize-usdc {
  display: inline-block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 14px color-mix(in srgb, var(--accent) 55%, transparent);
}

.prize-sol {
  color: var(--muted);
}

.constraints {
  margin: 0 0 1rem;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--warn) 12%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--border));
  border-radius: 10px;
}

.constraints h2 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.constraints-env-label {
  margin: 10px 0 4px;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.constraints-env-line {
  margin: 0;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
  border: 1px solid var(--border);
  line-height: 1.4;
}

.small {
  font-size: 0.88rem;
  line-height: 1.45;
}

.mono {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.82rem;
  word-break: break-all;
}

#puzzle {
  margin: 12px 0 20px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--accent);
  text-shadow: 0 0 14px color-mix(in srgb, var(--accent) 35%, transparent);
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

#input {
  flex: 1;
  min-width: 12rem;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0d0d0f;
  color: var(--text);
}

button {
  padding: 10px 16px;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-weight: 600;
}

button:hover {
  background: rgba(255, 255, 255, 0.08);
}

h2,
h3 {
  font-weight: 600;
}

#logs,
#sse-logs {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  min-height: 100px;
  max-height: 220px;
  overflow-y: auto;
  background: #0d0d0f;
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
}

#sse-logs {
  background: rgba(56, 189, 248, 0.05);
  border-color: rgba(56, 189, 248, 0.22);
}

.log-line {
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.log-line.sse {
  border-bottom-color: rgba(56, 189, 248, 0.22);
}

.log-line:first-child {
  border-bottom: none;
}

/* Developer entry (arena) */
.arena-nav {
  align-self: center;
}
.arena-nav a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.95rem;
  white-space: nowrap;
}
.arena-nav a:hover {
  text-decoration: underline;
}

.ticker-value-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
}
a.api-pill {
  text-decoration: none;
}
.api-pill {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
}
.api-pill:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* /developers page */
.dev-page .dev-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.dev-back {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}
.dev-back:hover {
  text-decoration: underline;
}
.dev-title {
  font-size: 1.35rem;
  margin: 0.75rem 0 0.5rem;
}
.dev-lead {
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
  font-size: 0.95rem;
}
.dev-section {
  margin-bottom: 1.75rem;
}
.dev-section h2 {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}
.dev-muted {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 0.5rem;
}
.dev-code {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.45;
}
.dev-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.dev-table th,
.dev-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.dev-table td code {
  font-size: 0.82rem;
}
.dev-list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text);
  line-height: 1.6;
}
.dev-list a {
  color: var(--accent);
}

.dev-callout {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: 10px;
  padding: 14px 16px;
}
.dev-callout-title {
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
  color: var(--text);
}
.dev-callout-text {
  margin: 0 0 0.5rem;
}
.dev-callout-meta {
  margin: 0;
  font-size: 0.85rem;
}

.dev-steps {
  margin: 0.5rem 0 0;
  padding-left: 1.35rem;
  line-height: 1.65;
  color: var(--text);
}
.dev-steps li {
  margin-bottom: 0.35rem;
}
.dev-steps code {
  font-size: 0.88em;
}

.dev-key-request {
  margin: 0.75rem 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.dev-btn {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.95rem;
}
.dev-btn:hover {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
}
.dev-link {
  color: var(--accent);
  font-weight: 600;
}

.dev-example-note {
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.dev-reinforce {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
}
.dev-reinforce-text {
  margin: 0;
  line-height: 1.6;
  color: var(--text);
  font-size: 0.95rem;
}
.dev-reinforce-text code {
  font-size: 0.88em;
}

.arena-footer {
  text-align: center;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.app-version {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
  letter-spacing: 0.02em;
}
