.playground-page {
  background: #f6f7f4;
}

.playground-main {
  margin: 0 auto;
  max-width: 1240px;
  min-height: calc(100vh - 58px);
  padding: 24px 20px 34px;
}

.playground-header {
  align-items: end;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.playground-header h1 {
  color: var(--ink);
  font-size: 2.25rem;
  margin-bottom: 0;
}

.source-link {
  background: #17201f;
  border: 1px solid #17201f;
  border-radius: 8px;
  color: #fffdf7;
  font-weight: 800;
  min-height: 42px;
  padding: 9px 14px;
  text-decoration: none;
}

.source-link:hover {
  background: #24312f;
}

.playground-layout {
  align-items: stretch;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.18fr) minmax(320px, 0.62fr);
}

.sim-panel,
.trace-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.sim-panel {
  display: grid;
  gap: 14px;
  grid-template-rows: auto auto auto auto auto auto minmax(420px, 1fr);
  padding: 16px;
}

.control-bar {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.control-bar label {
  display: grid;
  gap: 5px;
  min-width: 180px;
}

.control-bar label span,
.status-strip span,
.compare-kicker {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

select,
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  min-height: 42px;
}

select {
  background: #fffdf7;
  padding: 8px 36px 8px 10px;
}

.toggle-label {
  min-width: 112px;
}

.toggle-label input {
  accent-color: var(--teal);
  height: 24px;
  width: 24px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button {
  background: #17201f;
  color: #fffdf7;
  cursor: pointer;
  padding: 8px 14px;
}

button:hover:not(:disabled) {
  background: #24312f;
}

button:disabled {
  background: #d9ded9;
  color: #6f7975;
  cursor: default;
}

.copy-status {
  color: var(--teal);
  font-size: 0.88rem;
  font-weight: 800;
  min-height: 1.25rem;
}

.status-strip {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.status-strip div {
  border-left: 4px solid var(--teal);
  min-width: 0;
  padding-left: 10px;
}

.status-strip div:nth-child(2) {
  border-color: var(--gold);
}

.status-strip div:nth-child(3) {
  border-color: var(--green);
}

.status-strip div:nth-child(4) {
  border-color: var(--red);
}

.status-strip strong {
  display: block;
  font-size: 0.98rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.belief-panel {
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.65fr);
  padding: 12px;
}

.belief-bars {
  display: grid;
  gap: 9px;
  min-width: 0;
}

.belief-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 42px minmax(0, 1fr) 52px;
  min-width: 0;
}

.belief-row span,
.belief-metrics span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.belief-track {
  background: #eef3ef;
  border: 1px solid var(--line);
  border-radius: 999px;
  height: 12px;
  min-width: 0;
  overflow: hidden;
}

.belief-fill {
  height: 100%;
}

.belief-red {
  background: #d94b3d;
}

.belief-blue {
  background: #2b6cb0;
}

.belief-value {
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
  text-align: right;
}

.belief-metrics {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.belief-metrics strong {
  color: var(--ink);
  display: block;
  font-size: 0.95rem;
  margin-top: 3px;
  overflow-wrap: anywhere;
  text-transform: none;
}

.replay-strip {
  align-items: center;
  background: #eef3ef;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
  padding: 10px 12px;
}

.replay-strip label {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: auto minmax(0, 1fr);
  min-width: 0;
}

.replay-strip span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.replay-strip input {
  accent-color: var(--teal);
  min-width: 0;
  width: 100%;
}

.replay-strip strong {
  color: var(--ink);
  font-size: 0.92rem;
  min-width: 64px;
  text-align: right;
}

.compare-panel {
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 12px;
}

.compare-lane {
  border-left: 5px solid var(--red);
  display: grid;
  gap: 9px;
  min-width: 0;
  padding-left: 12px;
}

.compare-lane.recovery {
  border-color: var(--green);
}

.compare-outcome {
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1.15;
}

.compare-detail {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0;
}

.compare-metrics {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compare-metrics span {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  padding-top: 6px;
  text-transform: uppercase;
}

.compare-metrics strong {
  color: var(--ink);
  display: block;
  font-size: 0.95rem;
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.mini-grid {
  --cols: 12;
  --rows: 9;
  aspect-ratio: var(--cols) / var(--rows);
  border: 2px solid #17201f;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  overflow: hidden;
  width: 100%;
}

.mini-cell {
  align-items: center;
  background: #fbfaf7;
  border: 1px solid rgba(23, 32, 31, 0.08);
  display: flex;
  font-size: clamp(0.5rem, 1vw, 0.72rem);
  font-weight: 900;
  justify-content: center;
  min-width: 0;
}

.mini-wall {
  background: #17201f;
  border-color: #17201f;
}

.mini-unsafe {
  background: #f4ce82;
}

.mini-human {
  background: #d9c8f0;
}

.mini-path {
  box-shadow: inset 0 0 0 3px #c43d32;
}

.recovery .mini-path {
  box-shadow: inset 0 0 0 3px #47743a;
}

.mini-start,
.mini-target,
.mini-storage,
.mini-stop {
  color: #ffffff;
}

.mini-start {
  background: #2b6cb0;
}

.mini-target {
  background: #805ad5;
}

.mini-storage {
  background: #5c8b4a;
}

.mini-stop {
  background: #c43d32;
}

.scene {
  align-items: center;
  background: #f2f5f1;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  min-height: 420px;
  min-width: 0;
  overflow: hidden;
  padding: 14px;
}

.tabletop-svg {
  aspect-ratio: 1 / 1;
  display: block;
  max-height: 100%;
  max-width: 100%;
  width: min(100%, 580px);
}

.tabletop-grid {
  stroke: rgba(23, 32, 31, 0.12);
  stroke-width: 0.6;
}

.svg-label {
  fill: #17201f;
  font-size: 4px;
  font-weight: 800;
  text-anchor: middle;
}

.svg-small {
  fill: #586461;
  font-size: 3px;
  font-weight: 700;
}

.house-wrap {
  display: grid;
  gap: 10px;
  max-width: 760px;
  width: 100%;
}

.house-grid {
  --cols: 12;
  --rows: 8;
  aspect-ratio: var(--cols) / var(--rows);
  border: 2px solid #17201f;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  overflow: hidden;
  width: 100%;
}

.cell {
  align-items: center;
  background: #fbfaf7;
  border: 1px solid rgba(23, 32, 31, 0.10);
  color: var(--ink);
  display: flex;
  font-size: clamp(0.6rem, 1.5vw, 0.9rem);
  font-weight: 900;
  justify-content: center;
  min-width: 0;
  position: relative;
}

.wall {
  background: #17201f;
  border-color: #17201f;
}

.safe {
  background: #f4ce82;
}

.human {
  background: #d9c8f0;
}

.planned::after,
.trail::before {
  border-radius: 999px;
  content: "";
  display: block;
  height: 24%;
  position: absolute;
  width: 24%;
}

.planned::after {
  background: #805ad5;
  opacity: 0.64;
}

.trail::before {
  background: #3182ce;
  opacity: 0.42;
}

.blocked {
  outline: 3px solid #b7791f;
  outline-offset: -4px;
}

.corrected {
  outline: 3px solid #c43d32;
  outline-offset: -4px;
}

.robot {
  background: #2b6cb0;
  color: #ffffff;
}

.red-block {
  background: #d94b3d;
  color: #ffffff;
}

.blue-block {
  background: #2b6cb0;
  color: #ffffff;
}

.storage {
  background: #5c8b4a;
  color: #ffffff;
}

.holding {
  box-shadow: inset 0 0 0 3px #fffdf7;
}

.house-legend {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.82rem;
  font-weight: 800;
  gap: 8px;
}

.house-legend span {
  align-items: center;
  display: inline-flex;
  gap: 5px;
}

.legend-swatch {
  border: 1px solid var(--line);
  display: inline-block;
  height: 12px;
  width: 12px;
}

.trace-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  max-height: calc(100vh - 124px);
  padding: 16px;
}

.trace-heading {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.trace-heading h2 {
  font-size: 1.35rem;
  margin-bottom: 0;
}

#stepCounter {
  color: var(--muted);
  font-weight: 800;
}

.timeline {
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
  margin-bottom: 12px;
  min-height: 40px;
  padding: 8px;
}

.timeline-step {
  align-items: center;
  background: #eef3ef;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  font-size: 0.72rem;
  font-weight: 900;
  height: 28px;
  justify-content: center;
  min-height: 28px;
  min-width: 0;
  padding: 0;
}

.timeline-step:hover {
  transform: translateY(-1px);
}

.timeline-active {
  box-shadow: 0 0 0 3px rgba(23, 32, 31, 0.18);
}

.timeline-ambiguous {
  background: #805ad5;
  border-color: #805ad5;
  color: #ffffff;
}

.timeline-unsafe {
  background: #f4ce82;
  border-color: #b7791f;
}

.timeline-grasp,
.timeline-human {
  background: #c43d32;
  border-color: #c43d32;
  color: #ffffff;
}

.timeline-success {
  background: #5c8b4a;
  border-color: #5c8b4a;
  color: #ffffff;
}

.trace-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 0;
  overflow: auto;
}

.trace-row {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: 30px minmax(84px, 1fr) 56px minmax(76px, 0.8fr) minmax(92px, 1fr);
  padding: 9px 10px;
}

.trace-row:last-child {
  border-bottom: 0;
}

.trace-head {
  background: #eef3ef;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  position: sticky;
  text-transform: uppercase;
  top: 0;
  z-index: 1;
}

.trace-row:not(.trace-head) {
  font-size: 0.88rem;
}

.trace-row:not(.trace-head):hover,
.trace-active {
  background: #fff8e8;
}

.trace-row:not(.trace-head) {
  cursor: pointer;
}

.trace-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.trace-failure {
  color: var(--red);
  font-weight: 900;
}

.trace-success {
  color: var(--green);
  font-weight: 900;
}

.empty-trace {
  color: var(--muted);
  font-weight: 700;
  padding: 14px;
}

@media (max-width: 980px) {
  .playground-layout {
    grid-template-columns: 1fr;
  }

  .trace-panel {
    max-height: none;
  }
}

@media (max-width: 700px) {
  .playground-main {
    padding: 18px 14px 28px;
  }

  .playground-header {
    align-items: stretch;
    flex-direction: column;
  }

  .source-link {
    text-align: center;
  }

  .control-bar,
  .button-row {
    align-items: stretch;
    flex-direction: column;
  }

  .control-bar label,
  .button-row button {
    width: 100%;
  }

  .status-strip {
    grid-template-columns: 1fr 1fr;
  }

  .belief-panel,
  .belief-metrics {
    grid-template-columns: 1fr;
  }

  .compare-panel {
    grid-template-columns: 1fr;
  }

  .replay-strip,
  .replay-strip label {
    grid-template-columns: 1fr;
  }

  .replay-strip strong {
    text-align: left;
  }

  .scene {
    min-height: 330px;
    padding: 10px;
  }

  .trace-row {
    grid-template-columns: 30px minmax(90px, 1fr) 58px minmax(78px, 0.8fr);
  }

  .trace-head {
    display: none;
  }

  .trace-row span:nth-child(5) {
    grid-column: 2 / -1;
  }
}

@media (max-width: 430px) {
  .status-strip {
    grid-template-columns: 1fr;
  }
}
