* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg: #0c0e0a;
  --panel: #171a12;
  --panel-2: #202419;
  --line: #343a29;
  --text: #f0f2dc;
  --muted: #a8ad93;
  --accent: #b7ff5a;
  --warn: #f0b45b;
  --bad: #ff6f61;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #202912 0, var(--bg) 36rem);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.72rem 1rem;
  background: rgba(240, 242, 220, 0.08);
  color: var(--text);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #15190f;
  font-weight: 800;
}

button.danger {
  background: var(--bad);
  border-color: var(--bad);
  color: #160806;
}

select,
textarea,
input[type="file"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem;
  background: #11140d;
  color: var(--text);
}

label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.9rem;
}

video,
img,
canvas {
  display: block;
  width: 100%;
  background: #060705;
}

.play-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  gap: 1rem;
}

.hero,
.stage-grid,
.board-section,
.controls-grid,
.debug-strip {
  border: 1px solid var(--line);
  background: rgba(23, 26, 18, 0.9);
  border-radius: 28px;
  padding: 1rem;
}

.hero,
.section-head,
.status-cluster,
.stage-toolbar,
.eval-head,
.toggle-row,
.debug-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.eyebrow,
.label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(1.65rem, 5vw, 4rem);
  line-height: 0.95;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.38rem 0.75rem;
  background: #282d20;
  color: var(--text);
  font-size: 0.85rem;
}

.pill.fresh,
.pill.ready {
  background: rgba(183, 255, 90, 0.18);
  color: var(--accent);
}

.pill.held,
.pill.working {
  background: rgba(240, 180, 91, 0.2);
  color: var(--warn);
}

.pill.blocked,
.pill.waiting_for_anchor {
  background: rgba(255, 111, 97, 0.16);
  color: var(--bad);
}

.stage-grid {
  display: grid;
  gap: 1rem;
}

.camera-stage {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: #050604;
}

#camera-preview {
  min-height: 48vh;
  object-fit: cover;
}

.stage-toolbar {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  justify-content: center;
  padding: 0.5rem;
  border-radius: 999px;
  background: rgba(6, 7, 5, 0.72);
  backdrop-filter: blur(14px);
}

.assistant-panel {
  display: grid;
  gap: 1rem;
}

.move-card,
.eval-card,
.state-card {
  display: grid;
  gap: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel-2);
  padding: 1rem;
}

#best-move {
  font-size: clamp(2.4rem, 12vw, 5rem);
  line-height: 0.9;
}

.eval-track {
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(90deg, #232323 0 50%, #e9ead8 50% 100%);
}

.eval-fill {
  width: 50%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

#fen-line {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-radius: 14px;
  padding: 0.75rem;
  background: #10130d;
  color: #dfe8bc;
}

.board-section {
  display: grid;
  gap: 0.8rem;
}

#board-canvas {
  border: 1px solid var(--line);
  border-radius: 24px;
}

.last-capture {
  border: 1px solid var(--line);
  border-radius: 24px;
  max-height: 42vh;
  object-fit: contain;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}

.wide {
  grid-column: 1 / -1;
}

.debug-strip {
  color: var(--muted);
  font-size: 0.9rem;
}

.debug-strip a {
  color: var(--accent);
}

.hidden {
  display: none;
}

@media (min-width: 860px) {
  .stage-grid {
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.55fr);
  }

  .controls-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .stage-toolbar {
    position: static;
    border-radius: 0;
  }

  #camera-preview {
    min-height: 52vh;
  }
}
