/* Slop Bender · player-facing stylesheet.
   Everything a developer needs carries class="dev" in the markup and only shows while
   <body class="dev"> is set (press ` or open the page with ?dev). */

:root {
  /* Palette drawn from the Slop Bender logo: rock brown and wave blue on a warm dark ground. */
  --bg: #14120f;
  --bg-raised: #1c1916;
  --bg-sunken: #0d0b09;
  --line: #2c2823;
  --line-strong: #453d34;
  --text: #efe9e1;
  --text-2: #c2b8ab;
  --muted: #948a7d;
  --accent: #62afd8;
  --accent-ink: #08202f;
  --earth: #c9906a;
  --water: #8fd3f4;
  --good: #8fcf7a;
  --bad: #f3ab8c;
  --glass: rgba(14, 12, 9, .78);
  --r-s: 6px;
  --r-m: 10px;
  --r-l: 14px;
  --fs-xs: 11px;
  --fs-s: 12px;
  --fs-m: 14px;
  --fs-l: 16px;
  --fs-xl: 20px;
  --gutter: clamp(16px, 4vw, 48px);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: inherit; }
[hidden] { display: none !important; }
body:not(.dev) .dev { display: none !important; }
body:not(.dev) .conditions .value { display: none; }

/* Header ---------------------------------------------------------------- */
header {
  height: 64px;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { display: block; }
.brand .mark { width: 34px; height: 34px; }
.brand .wordmark { height: 16px; width: auto; }
.header-actions, .scene-actions { display: flex; align-items: center; gap: 10px; }
.pill {
  font-size: var(--fs-xs);
  color: var(--text-2);
  padding: 5px 10px 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--good); }
.pill.dev::before { background: var(--earth); }

main { max-width: 1400px; margin: auto; padding: 28px var(--gutter) 64px; }

/* Type ------------------------------------------------------------------ */
.eyebrow { font-size: var(--fs-xs); font-weight: 650; letter-spacing: .22em; color: var(--accent); }
h1 { font-weight: 500; font-size: clamp(34px, 5vw, 60px); line-height: 1.07; letter-spacing: -.04em; margin: 18px 0; }
h1 em { font-style: normal; color: #9fd0ec; }
h2 { font-size: var(--fs-xl); font-weight: 500; margin: 6px 0; }
p { color: var(--text-2); font-size: var(--fs-m); line-height: 1.6; }
.muted, .privacy { color: var(--muted); font-size: var(--fs-s); }
.bad { color: var(--bad) !important; }

/* Controls -------------------------------------------------------------- */
button, .button {
  border: 1px solid var(--line-strong);
  background: var(--bg-raised);
  color: var(--text);
  border-radius: var(--r-s);
  padding: 9px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  text-decoration: none;
  line-height: 1.2;
}
button:hover, .button:hover { background: #262119; }
button:disabled { opacity: .4; cursor: default; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.primary:hover { background: #7fc3e6; }
.quiet { background: transparent; border-color: var(--line); }
.tiny { padding: 3px 8px; font-size: var(--fs-xs); border-radius: 4px; }
.tiny.active { background: #24455b; }
select, input, textarea {
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-s);
  padding: 6px 8px;
  font: inherit;
  font-size: var(--fs-s);
}
select.tiny { padding: 3px 6px; max-width: 150px; }
input[type=number] { width: 64px; }
input[type=checkbox] { accent-color: var(--accent); margin: 0; }
.control-row, .settings { display: flex; gap: 8px 20px; flex-wrap: wrap; align-items: center; margin: 14px 0; }
.control-row label, .settings label { display: flex; align-items: center; gap: 8px; font-size: var(--fs-s); color: var(--text-2); }
kbd {
  font: 500 var(--fs-xs)/1 inherit;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 2px 5px;
}

/* Welcome --------------------------------------------------------------- */
.welcome { padding: 48px 0 24px; max-width: 720px; margin: auto; text-align: center; }
.welcome > p { margin: 0 auto; max-width: 480px; }
.hero-mark { display: block; width: 140px; height: 140px; margin: 0 auto 10px; filter: drop-shadow(0 14px 30px rgba(0, 0, 0, .45)); }
.upload-zone {
  margin: 32px auto 20px;
  max-width: 520px;
  padding: 30px 28px;
  border: 1px dashed #4f7a95;
  background: var(--bg-raised);
  border-radius: var(--r-l);
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.upload-zone:hover { background: #1c2229; border-color: var(--accent); }
.upload-zone strong { font-size: var(--fs-l); font-weight: 500; }
.upload-zone span:not(.upload-icon) { font-size: var(--fs-s); color: var(--muted); line-height: 1.7; }
.upload-icon { font-size: 26px; color: var(--accent); }
.recent { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.recent:not(:empty)::before { content: "Recent"; width: 100%; font-size: var(--fs-xs); letter-spacing: .18em; color: var(--muted); margin-bottom: 2px; }
.recent button { border-radius: 999px; padding: 6px 14px; font-size: var(--fs-s); }
.welcome-footer { margin-top: 28px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.welcome-footer p { margin: 0; }
.preparation-options { text-align: left; margin: 24px auto 0; max-width: 560px; border: 1px solid var(--line); border-radius: var(--r-m); padding: 12px 16px; }
.preparation-options summary { cursor: pointer; font-size: 13px; color: #e0d8cd; }
.preparation-options label { display: block; margin: 10px 0 4px; font-size: var(--fs-s); color: var(--text-2); }
.preparation-options textarea, .preparation-options select { display: block; width: 100%; margin-top: 4px; }
.preparation-options .control-row label { display: flex; }
.preparation-options .control-row select, .preparation-options .control-row input { width: auto; }

/* Preparation ----------------------------------------------------------- */
.preparation { padding: 96px 0; text-align: center; }
.preparation h1 { font-size: 34px; }
progress { width: min(460px, 90%); height: 6px; accent-color: var(--accent); margin: 22px auto; display: block; }
.preparation button { margin-top: 8px; }

/* Playground ------------------------------------------------------------ */
.scene-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; }
.scene-heading h2 { font-size: 22px; }
.stage-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: stretch; }
body.dev .stage-row:not(.no-overlay) { grid-template-columns: minmax(0, 1fr) 340px; }
.stage {
  position: relative;
  background: var(--bg-sunken);
  border-radius: var(--r-l);
  overflow: hidden;
  line-height: 0;
  aspect-ratio: 1280 / 716;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
#view { width: 100%; height: 100%; outline: none; display: block; }

/* Camera thumbnail, top left */
#controller, #pose-overlay, #camera-placeholder, #framing-warning {
  position: absolute;
  left: 16px;
  top: 16px;
  width: 22%;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-m);
  object-fit: contain;
  background: var(--glass);
}
#controller { display: none; box-shadow: 0 6px 24px rgba(0, 0, 0, .4); }
#pose-overlay { background: transparent; pointer-events: none; }
#camera-placeholder {
  border: 1px solid rgba(255, 255, 255, .1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  color: var(--text-2);
  line-height: 1.4;
  padding: 16px;
  text-align: center;
}
.framing-warning {
  background: rgba(90, 42, 30, .85) !important;
  border: 1px solid var(--bad);
  color: #ffe3d3;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: clamp(11px, 1.3vw, 15px);
  font-weight: 600;
  line-height: 1.4;
  padding: 12px;
  pointer-events: none;
  z-index: 2;
}

/* Status pill, bottom left */
.stage-status { position: absolute; left: 16px; bottom: 16px; display: flex; gap: 8px; align-items: center; pointer-events: none; line-height: 1.3; }
#framing, #fps {
  background: var(--glass);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: var(--fs-s);
  color: var(--text);
}
#framing:empty { display: none; }
#fps { font-variant-numeric: tabular-nums; color: var(--accent); }

/* Move feed, top right: what the scene just did with your move */
.move-feed {
  position: absolute;
  right: 16px;
  top: 16px;
  width: min(280px, 34%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  line-height: 1.35;
}
.card {
  background: var(--glass);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--r-m);
  padding: 10px 12px;
  transition: opacity .8s;
}
.card.enter { animation: card-in .25s ease-out; }
.card.fading { opacity: 0; }
@keyframes card-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.card-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.card .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.card.earth .dot { background: var(--earth); }
.card.water .dot { background: var(--water); }
.card .hit { margin-left: auto; font-weight: 400; font-size: var(--fs-s); color: var(--text-2); white-space: nowrap; }
.card .bar { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .12); margin-top: 8px; overflow: hidden; }
.card .bar i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.card.earth .bar i { background: var(--earth); }
.card.water .bar i { background: var(--water); }
.card .note { margin-top: 6px; font-size: var(--fs-s); color: var(--text-2); }
.card.rejected { border-color: rgba(243, 171, 140, .45); }
.card.rejected .dot { background: var(--bad); }
.card.rejected .note { color: var(--bad); }

/* Under the stage */
.below-stage { display: flex; align-items: center; gap: 20px; min-height: 40px; font-size: 13px; }
#runtime-stats { margin-left: auto; }
.settings { margin: 16px 0 6px; }

/* Moves guide */
.moves { margin-top: 18px; }
.moves > summary { list-style: none; cursor: pointer; font-size: 13px; color: var(--text-2); display: inline-flex; align-items: center; gap: 8px; padding: 6px 0; }
.moves > summary::-webkit-details-marker { display: none; }
.moves > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.moves[open] > summary::before { transform: rotate(45deg); }
.moves > summary:hover { color: var(--text); }
.moves > p { margin: 6px 0 0; font-size: 13px; }
.move-guide { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-top: 14px; }
.move-guide article { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--r-m); padding: 12px; }
.move-guide b { font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.move-guide p { font-size: var(--fs-s); margin: 6px 0 0; line-height: 1.5; }
.move-guide video, .tutorial-placeholder {
  width: 100%;
  height: 104px;
  border-radius: var(--r-s);
  background: var(--bg-sunken);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 10px;
  object-fit: contain;
  color: #c6bbad;
  letter-spacing: .04em;
  font-size: var(--fs-s);
}
.move-guide video { display: block; }

/* Developer sidebar and panels ------------------------------------------ */
.dev-overlay { position: relative; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--bg-sunken); min-height: 0; }
.dev-overlay-inner { position: absolute; inset: 0; display: flex; flex-direction: column; }
.dev-overlay-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px; min-height: 38px; padding: 6px 12px; border-bottom: 1px solid var(--line); font-size: var(--fs-xs); flex: none; }
.dev-overlay-head .eyebrow { white-space: nowrap; }
.dev-overlay-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#overlay-fixture { max-width: 110px; }
#action-json { flex: 1; min-height: 0; margin: 0; padding: 12px; font: 11px/1.45 Consolas, "SF Mono", Menlo, monospace; color: #cbc1b3; white-space: pre-wrap; word-break: break-word; overflow: auto; }
#action-json .k { color: #8fb6c9; }
#action-json .rejected { color: var(--bad); }
.move-history { flex: 1; min-height: 0; margin: 0; padding: 6px 12px; overflow: auto; font-size: var(--fs-xs); line-height: 1.45; color: #cbc1b3; }
.move-history article { border-bottom: 1px solid #2a2621; padding: 8px 0; }
.move-history .move-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 650; color: var(--text); }
.move-head .element { color: var(--earth); letter-spacing: .12em; font-size: 9px; margin-left: 4px; }
.move-head .element.water { color: var(--water); }
.move-history .attrs { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; margin-top: 4px; }
.attrs span:nth-child(odd) { color: #8fb6c9; }
.move-history .status { margin-top: 3px; color: #c6bbad; }
.move-history article.rejected .status { color: var(--bad); }
.history-empty { padding: 8px 0; }

.panel { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--r-m); padding: 16px; }
.panel summary { font-size: 13px; cursor: pointer; color: #e0d8cd; }
.tuning { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 24px; font-size: var(--fs-s); }
.tuning label { display: block; }
.tuning input[type=file] { display: block; width: 100%; margin: 8px 0; }
.tuning textarea { display: block; width: 100%; margin: 8px 0; font-family: monospace; font-size: var(--fs-s); }
.audit { max-height: 220px; overflow: auto; font: 11px monospace; color: #bfb5a8; line-height: 1.6; }
.audit div { border-bottom: 1px solid #2c2823; padding: 6px; }

/* Onboarding ------------------------------------------------------------ */
.onboarding { padding: 28px 0 10px; }
.onboarding h1 { font-size: clamp(30px, 4vw, 48px); }
.onboarding > p { max-width: 720px; }
.onboarding-stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 24px; margin-top: 24px; align-items: start; }
.camera-mount { position: relative; aspect-ratio: 16 / 9; background: var(--bg-sunken); border-radius: var(--r-m); overflow: hidden; line-height: 0; }
.camera-mount #controller, .camera-mount #pose-overlay, .camera-mount #camera-placeholder, .camera-mount #framing-warning { position: absolute; left: 0; top: 0; width: 100%; height: 100%; border-radius: 0; aspect-ratio: auto; }
.camera-mount #camera-placeholder { font-size: 13px; border: none; }
.camera-mount .framing-warning { font-size: 18px; }
.move-steps { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.move-steps li { border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 8px; font-size: var(--fs-s); text-align: center; color: var(--muted); line-height: 1.4; }
.move-steps li b { display: block; color: var(--text); font-weight: 600; }
.move-steps li.current { border-color: var(--accent); color: var(--text); background: var(--bg-raised); }
.move-steps li.done { border-color: #5fa9d3; color: #cfe8f7; }
.move-steps li.skipped { opacity: .6; }
.move-steps .mark { display: block; font-size: 16px; margin-top: 4px; height: 20px; }
.lesson { border: 1px solid var(--line); border-radius: var(--r-m); padding: 16px; background: var(--bg-raised); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 16px; }
.lesson-media { position: relative; aspect-ratio: 16 / 9; background: var(--bg-sunken); border-radius: var(--r-s); overflow: hidden; line-height: 0; }
#tutorial-clip { width: 100%; height: 100%; object-fit: contain; display: block; }
.tutorial-missing { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; font-size: var(--fs-s); line-height: 1.6; color: var(--muted); padding: 16px; }
.tutorial-missing code { font-size: var(--fs-xs); color: #d8d0c5; }
.lesson-text h2 { margin: 4px 0 6px; }
.lesson-text p { margin: 0 0 10px; font-size: 13px; }
.lesson-check { font-size: var(--fs-m); font-weight: 600; padding: 10px 12px; border-radius: var(--r-s); background: #1f1b17; border: 1px solid var(--line); color: #d8d0c5; min-height: 42px; }
.lesson-check.pass { background: #183245; border-color: #5fa9d3; color: #cfe8f7; }
.lesson-check.near { border-color: #c9a86a; }
.lesson-check.other { color: #ffbb9b; }
.lesson-meter { height: 6px; border-radius: 3px; background: #2a2621; margin: 10px 0; overflow: hidden; }
#lesson-meter-fill { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.conditions { list-style: none; margin: 0 0 6px; padding: 0; font-size: var(--fs-s); line-height: 1.5; max-height: 190px; overflow: auto; }
.conditions li { display: flex; gap: 8px; padding: 3px 0; border-bottom: 1px solid #2a2621; color: #c4bab0; }
.conditions li .ok { color: var(--good); flex: 0 0 14px; }
.conditions li .fail { color: var(--bad); flex: 0 0 14px; }
.conditions li .value { margin-left: auto; font-family: monospace; color: var(--muted); white-space: nowrap; }
.conditions li.failed { color: #e9d9cf; }
.onboarding-footer { justify-content: flex-end; margin-top: 22px; }

/* Overlays -------------------------------------------------------------- */
#error {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 90vw;
  background: #3a1d17;
  border: 1px solid var(--bad);
  color: #ffe3d3;
  padding: 12px 18px;
  border-radius: var(--r-m);
  font-size: 13px;
  z-index: 10;
}
dialog { background: var(--bg-sunken); border: 1px solid var(--line-strong); border-radius: var(--r-m); padding: 16px; max-width: 90vw; color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .7); }
dialog img { display: block; max-width: 85vw; max-height: 80vh; margin-top: 12px; }

/* Responsive ------------------------------------------------------------ */
@media (max-width: 1100px) {
  body.dev .stage-row:not(.no-overlay) { grid-template-columns: minmax(0, 1fr); }
  .dev-overlay { height: 280px; }
  .onboarding-stage, .lesson { grid-template-columns: 1fr; }
  .move-guide { grid-template-columns: repeat(3, 1fr); }
  .tuning { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  header { height: 56px; }
  .scene-heading { flex-direction: column; align-items: flex-start; }
  .move-steps, .move-guide { grid-template-columns: repeat(2, 1fr); }
  .move-feed { width: 46%; }
  #controller, #pose-overlay, #camera-placeholder, #framing-warning { width: 30%; left: 10px; top: 10px; }
  .stage-status { left: 10px; bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .card.enter { animation: none; }
}
