* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f0f1a;
  color: #e0e0f0;
  line-height: 1.6;
}

.page {
  max-width: 740px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: #818cf8;
  text-decoration: none;
  font-size: 0.9rem;
}
.back-link:hover { text-decoration: underline; }

h1 {
  font-size: 2rem;
  margin-bottom: 0.3rem;
  color: #fff;
  letter-spacing: -0.02em;
}

.subtitle {
  color: #9ca3af;
  margin-bottom: 2rem;
}

/* Cards */
.card {
  background: #1a1a2e;
  border: 1px solid #2d2d4a;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h2 {
  font-size: 1.1rem;
  color: #c7d2fe;
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
}

.card-desc {
  color: #9ca3af;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.card-desc code {
  background: rgba(129, 140, 248, 0.15);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.85em;
  color: #c7d2fe;
}

/* Buttons */
.btn-row {
  display: flex;
  gap: 0.75rem;
}

.btn {
  padding: 0.5rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: #6366f1;
  color: white;
}

.btn-secondary {
  background: #1f2937;
  color: #c7d2fe;
  border: 1px solid #374151;
}

/* Board card header */
.board-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.board-header h2 {
  margin-bottom: 0;
}

/* Board */
.board-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 300px;
}

.cell {
  width: 96px;
  height: 96px;
  background: #252540;
  border: 2px solid #2d2d4a;
  border-radius: 10px;
  font-size: 2.5rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

.cell:hover:not(.occupied):not(.game-over) {
  border-color: #818cf8;
  background: #2a2a48;
}

.cell.occupied {
  cursor: default;
}

.cell.game-over {
  cursor: default;
}

.cell .piece {
  position: relative;
  z-index: 2;
  line-height: 1;
}

.cell .piece.x { color: #f87171; }
.cell .piece.o { color: #60a5fa; }

.cell.winning {
  border-color: #34d399 !important;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.3);
}

/* Heatmap overlay */
.cell .heat-overlay {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.heat-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.cell .optimal-marker {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.75rem;
  z-index: 3;
  color: #fbbf24;
  text-shadow: 0 0 6px rgba(251, 191, 36, 0.6);
}

/* Legend bar */
.legend-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-label {
  font-size: 0.75rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.legend-gradient {
  width: 160px;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, #ef4444, #f59e0b, #34d399);
}

/* Pipeline */
.pipeline {
  display: flex;
  align-items: flex-start;
  gap: 0.25rem;
  overflow-x: auto;
  padding: 0.5rem 0;
}

.pipeline-stage {
  flex: 1;
  min-width: 120px;
  background: #0f0f1a;
  border: 1px solid #2d2d4a;
  border-radius: 10px;
  padding: 1rem 0.75rem;
  text-align: center;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.pipeline-stage.active {
  border-color: #818cf8;
  box-shadow: 0 0 12px rgba(129, 140, 248, 0.2);
}

.stage-icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.stage-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #c7d2fe;
  margin-bottom: 0.3rem;
}

.stage-desc {
  font-size: 0.7rem;
  color: #6b7280;
  line-height: 1.4;
}

.pipeline-arrow {
  display: flex;
  align-items: center;
  color: #4b5563;
  font-size: 1.2rem;
  padding-top: 1.5rem;
  flex-shrink: 0;
}

/* Section subheadings */
.section-subhead {
  font-size: 0.9rem;
  color: #a5b4fc;
  margin: 1.25rem 0 0.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.section-subhead:first-of-type {
  margin-top: 0.5rem;
}

/* Code block */
.code-block {
  background: #0f0f1a;
  border-radius: 8px;
  padding: 1rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  color: #9ca3af;
  overflow-x: auto;
  line-height: 1.5;
}

/* Info list */
.info-list {
  padding-left: 1.5rem;
}
.info-list li {
  margin-bottom: 0.5rem;
  color: #d1d5db;
  font-size: 0.9rem;
}
.info-list strong {
  color: #c7d2fe;
}

/* On-chain status */
.onchain-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.onchain-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.onchain-label {
  font-size: 0.7rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.onchain-value {
  font-size: 0.85rem;
  color: #e0e0f0;
  font-weight: 500;
}

.onchain-value.mono {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
}

.onchain-link {
  color: #818cf8;
  text-decoration: none;
}
.onchain-link:hover { text-decoration: underline; }

/* Proof section */
.proof-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.proof-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.proof-label {
  font-size: 0.7rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.proof-value {
  font-size: 0.85rem;
  color: #e0e0f0;
  font-weight: 500;
}

.proof-value.mono {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
}

.proof-optimal {
  color: #34d399;
}

.proof-suboptimal {
  color: #f87171;
}

/* API Explorer */
.api-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.api-panel {
  background: #0f0f1a;
  border: 1px solid #2d2d4a;
  border-radius: 8px;
  overflow: hidden;
}

.api-panel-header {
  padding: 0.5rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #2d2d4a;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.api-status {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.7rem;
  text-transform: none;
  letter-spacing: 0;
}

.api-status.ok { color: #34d399; }
.api-status.error { color: #f87171; }
.api-status.loading { color: #fbbf24; }

.api-json {
  padding: 0.75rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.72rem;
  color: #9ca3af;
  line-height: 1.5;
  overflow: auto;
  max-height: 220px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.api-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 0.75rem;
}

.api-detail-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.api-detail-label {
  font-size: 0.7rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.api-detail-value {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  color: #e0e0f0;
  font-weight: 500;
}

.api-detail-value.optimal { color: #34d399; }

@media (max-width: 600px) {
  .board { width: 264px; }
  .cell { width: 84px; height: 84px; font-size: 2rem; }
  .pipeline { flex-wrap: wrap; }
  .pipeline-arrow { display: none; }
  .pipeline-stage { min-width: 45%; }
  .onchain-grid { grid-template-columns: 1fr; }
  .proof-grid { grid-template-columns: 1fr; }
  .api-panels { grid-template-columns: 1fr; }
  .api-detail-grid { grid-template-columns: 1fr 1fr; }
}
