.game-loop-lab {
  --n-ink: #19251f;
  --n-muted: #52645a;
  --n-paper: #f8f5ec;
  --n-panel: #fffdf7;
  --n-line: #d9dfd2;
  --n-variable: #cc5c3e;
  --n-fixed: #276c70;
  --n-accent: #c58a32;
  --n-success: #2f754d;
  --n-warning: #9e4c26;
  --n-primary: #276c70;

  color: var(--n-ink);
  background-color: var(--n-paper);
  border: 1px solid var(--n-line);
  border-radius: 1.25rem;
  overflow: hidden;
}

.theme-dark .game-loop-lab {
  --n-ink: #f2f0e7;
  --n-muted: #b5c3b8;
  --n-paper: #202622;
  --n-panel: #29312b;
  --n-line: #4a574d;
  --n-variable: #f08a63;
  --n-fixed: #78c8c0;
  --n-accent: #e2b75d;
  --n-success: #8ed39c;
  --n-warning: #f4a274;
  --n-primary: #78c8c0;
}

.gll-stage-heading p,
.gll-timeline-heading p,
.gll-model-note,
.gll-privacy {
  color: var(--n-muted);
  line-height: 1.6;
}

.gll-kicker {
  margin: 0 0 .35rem;
  color: var(--n-accent);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.gll-shell {
  display: grid;
  grid-template-columns: minmax(15rem, 20rem) minmax(0, 1fr);
  gap: 1px;
  background-color: var(--n-line);
}

.gll-controls,
.gll-stage {
  background-color: var(--n-panel);
}

.gll-controls {
  display: flex;
  flex-direction: column;
  gap: .8rem;
  padding: 1.35rem;
}

.gll-control-heading {
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--n-line);
}

.gll-range-field,
.gll-number-field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: .45rem .65rem;
}

.gll-range-field span,
.gll-number-field span {
  font-size: .88rem;
  font-weight: 700;
}

.gll-range-field output {
  min-width: 4.7rem;
  padding: .28rem .45rem;
  border: 1px solid var(--n-line);
  border-radius: .4rem;
  color: var(--n-fixed);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.gll-range-field input[type='range'] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--n-fixed);
}

.gll-number-field input {
  width: 5.5rem;
  padding: .38rem .45rem;
  border: 1px solid var(--n-line);
  border-radius: .4rem;
  background-color: var(--n-paper);
  color: var(--n-ink);
  font: inherit;
  text-align: right;
}

.gll-field-hint {
  margin: -.35rem 0 .1rem;
  color: var(--n-muted);
  font-size: .75rem;
  line-height: 1.4;
}

.gll-clamp {
  padding-top: .8rem;
  border-top: 1px solid var(--n-line);
}

.gll-check-field {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-size: .88rem;
  font-weight: 700;
}

.gll-check-field input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--n-fixed);
}

.gll-clamp[data-disabled='true'] {
  opacity: .55;
}

.gll-actions {
  display: flex;
  gap: .6rem;
  padding-top: .5rem;
}

.gll-actions button {
  flex: 1;
  min-height: 2.5rem;
  padding: .5rem .7rem;
  border-radius: .5rem;
  font: inherit;
  font-size: .84rem;
  font-weight: 800;
  cursor: pointer;
}

.gll-primary {
  border: 1px solid var(--n-fixed);
  background-color: var(--n-fixed);
  color: var(--n-panel);
}

.gll-secondary {
  border: 1px solid var(--n-line);
  background-color: var(--n-paper);
  color: var(--n-ink);
}

.gll-actions button:focus-visible,
.gll-range-field input:focus-visible,
.gll-number-field input:focus-visible,
.gll-check-field input:focus-visible {
  outline: 3px solid var(--n-accent);
  outline-offset: 2px;
}

.gll-stage {
  min-width: 0;
  padding: 1.35rem;
}

.gll-stage-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

.gll-stage-heading h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
}

.gll-stage-heading p {
  margin: .35rem 0 0;
  font-size: .9rem;
}

.gll-live-badge {
  display: inline-flex;
  padding: .35rem .55rem;
  border: 1px solid var(--n-line);
  border-radius: 99rem;
  color: var(--n-success);
  font-size: .76rem;
  font-weight: 800;
  white-space: nowrap;
}

.gll-stage-visual {
  margin-top: 1.1rem;
  border: 1px solid var(--n-line);
  border-radius: .95rem;
  overflow: hidden;
}

.gll-stage-svg,
.gll-chart-svg {
  display: block;
  width: 100%;
  height: auto;
}

.gll-paper {
  fill: var(--n-paper);
}

.gll-base-line,
.gll-grid-line,
.gll-zero-line {
  stroke: var(--n-line);
  stroke-width: 1.5;
}

.gll-frame-bar {
  fill: var(--n-line);
}

.gll-spike-bar {
  fill: var(--n-variable);
}

.gll-plot-title,
.gll-plot-label,
.gll-plot-axis {
  fill: var(--n-muted);
  font-size: 11px;
}

.gll-plot-title,
.gll-plot-label {
  font-weight: 800;
}

.gll-difference-line {
  fill: none;
  stroke: var(--n-accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gll-divider,
.gll-track {
  fill: none;
  stroke: var(--n-line);
  stroke-width: 1.5;
}

.gll-variable-token {
  fill: var(--n-variable);
  stroke: var(--n-paper);
  stroke-width: 4;
}

.gll-fixed-token {
  fill: var(--n-fixed);
  stroke: var(--n-paper);
  stroke-width: 4;
}

.gll-lane-label,
.gll-marker-value,
.gll-stage-axis,
.gll-chart-label {
  fill: var(--n-muted);
  font-size: 11px;
}

.gll-marker-value {
  fill: var(--n-ink);
  font-weight: 800;
}

.gll-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .65rem;
  margin-top: 1rem;
}

.gll-summary-grid div {
  padding: .72rem;
  border-top: 2px solid var(--n-line);
}

.gll-summary-grid span {
  display: block;
  color: var(--n-muted);
  font-size: .75rem;
  line-height: 1.3;
}

.gll-summary-grid strong {
  display: block;
  margin-top: .25rem;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.gll-diagnostic {
  margin: .9rem 0 0;
  padding: .65rem .8rem;
  border-left: 3px solid var(--n-success);
  background-color: var(--n-paper);
  color: var(--n-ink);
  font-size: .84rem;
  line-height: 1.45;
}

.gll-diagnostic-notice {
  border-color: var(--n-accent);
}

.gll-diagnostic-warning {
  border-color: var(--n-warning);
}

.gll-timeline-heading {
  margin-top: 1.35rem;
}

.gll-timeline-heading h3 {
  margin: 0;
  font-size: 1.05rem;
}

.gll-timeline-heading p {
  margin: .3rem 0 .6rem;
  font-size: .84rem;
}

.gll-chart-axis {
  stroke: var(--n-line);
  stroke-width: 1.5;
}

.gll-variable-line,
.gll-fixed-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gll-variable-line {
  stroke: var(--n-variable);
}

.gll-fixed-line {
  stroke: var(--n-fixed);
  stroke-dasharray: 7 5;
}

.gll-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  color: var(--n-muted);
  font-size: .78rem;
}

.gll-legend span {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}

.gll-legend-dot {
  width: .65rem;
  height: .65rem;
  border-radius: 50%;
}

.gll-variable-dot {
  background-color: var(--n-variable);
}

.gll-fixed-dot {
  background-color: var(--n-fixed);
}

.gll-table {
  margin-top: 1.1rem;
  overflow-x: auto;
}

.gll-table h3 {
  margin: 0 0 .55rem;
  font-size: .95rem;
}

.gll-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: .76rem;
}

.gll-table th,
.gll-table td {
  padding: .48rem .55rem;
  border-bottom: 1px solid var(--n-line);
  text-align: right;
  white-space: nowrap;
}

.gll-table th {
  color: var(--n-muted);
  font-size: .75rem;
  text-align: right;
}

.gll-table th:first-child,
.gll-table td:first-child {
  text-align: left;
}

.gll-model-note,
.gll-privacy {
  margin: 1rem 0 0;
  font-size: .78rem;
}

.gll-privacy {
  padding-top: .8rem;
  border-top: 1px solid var(--n-line);
}

@media (max-width: 760px) {
  .gll-shell {
    grid-template-columns: 1fr;
  }

  .gll-controls {
    border-bottom: 1px solid var(--n-line);
  }

  .gll-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .gll-controls,
  .gll-stage {
    padding: 1rem;
  }

  .gll-stage-heading {
    display: block;
  }

  .gll-live-badge {
    margin-top: .75rem;
  }

  .gll-summary-grid {
    gap: .45rem;
  }

  .gll-summary-grid div {
    padding: .55rem;
  }
}
