.spg-page body {
  background: #f5f7f9;
}

.spg-page main.content {
  max-width: 1180px;
}

.spg-page h2,
.spg-page h3,
.spg-page h4,
.spg-page h5,
.spg-page p {
  letter-spacing: 0;
}

.spg-page .page-columns {
  display: block;
}

.spg-page .quarto-title-block {
  display: none;
}

.iot-component-frame body {
  background: transparent;
}

.iot-component-frame .spg-page main.content,
.iot-component-frame main.content {
  margin: 0;
  max-width: none;
  padding: 0;
}

.iot-component-frame #title-block-header,
.iot-component-frame .quarto-title-block,
.iot-component-frame nav,
.iot-component-frame .toc-actions,
.iot-component-frame .sidebar,
.iot-component-frame .page-navigation {
  display: none !important;
}

.iot-component-frame .spg-hero {
  display: none;
}

.spg-game,
.spg-reference-material {
  color: #25313b;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  margin: 0 auto;
  max-width: 1120px;
}

.spg-game *,
.spg-reference-material * {
  box-sizing: border-box;
}

.spg-hero {
  background:
    radial-gradient(circle at 14% 18%, rgba(47, 128, 197, 0.18), transparent 28%),
    linear-gradient(135deg, #152d43 0%, #1f6f67 56%, #835f1e 100%);
  border-radius: 8px;
  color: #fff;
  margin: 16px 0;
  padding: 28px;
}

.spg-kicker,
.spg-metrics,
.spg-status,
.spg-scenario-top,
.spg-action-row,
.spg-feedback-top {
  align-items: center;
  display: flex;
}

.spg-kicker {
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.spg-pill {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  color: #f7fbff;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 5px 10px;
  text-transform: uppercase;
}

.spg-hero h2 {
  color: #fff;
  font-size: 2.1rem;
  line-height: 1.1;
  margin: 0 0 10px;
}

.spg-hero p {
  color: rgba(255, 255, 255, 0.88);
  font-size: 1rem;
  line-height: 1.55;
  margin: 0;
  max-width: 780px;
}

.spg-metrics {
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.spg-metric {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  min-width: 140px;
  padding: 10px 12px;
}

.spg-metric strong {
  display: block;
  font-size: 1.35rem;
}

.spg-metric span {
  color: rgba(255, 255, 255, 0.82);
  display: block;
  font-size: 0.78rem;
}

.spg-status {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(260px, 1fr) repeat(3, minmax(105px, 0.2fr));
  margin: 16px 0;
}

.spg-progress-card,
.spg-stat,
.spg-scenario-card,
.spg-panel,
.spg-feedback,
.spg-final-card,
.spg-reference-intro,
.spg-reference-section {
  background: #fff;
  border: 1px solid #dde6ec;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(22, 39, 52, 0.07);
}

.spg-progress-card,
.spg-stat {
  padding: 14px;
}

.spg-progress-label {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.spg-progress-label span,
.spg-stat span,
.spg-scenario-tag,
.spg-rule-row label span {
  color: #667987;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.spg-progress-label strong {
  color: #22313d;
  font-size: 0.9rem;
}

.spg-progress-track {
  background: #e8eef2;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.spg-progress-track > div {
  background: linear-gradient(90deg, #2f80c5, #1f8f70);
  border-radius: inherit;
  height: 100%;
  transition: width 0.2s ease;
  width: 0;
}

.spg-stat {
  text-align: center;
}

.spg-stat strong {
  color: #143247;
  display: block;
  font-size: 1.55rem;
  line-height: 1.1;
}

.spg-scenario-card {
  border-left: 5px solid #2f80c5;
  padding: 20px;
}

.spg-scenario-top {
  gap: 16px;
  justify-content: space-between;
}

.spg-scenario-card h3 {
  color: #162b3a;
  font-size: 1.35rem;
  line-height: 1.25;
  margin: 4px 0 0;
}

.spg-scenario-score {
  background: #eef6fd;
  border: 1px solid #c8dfef;
  border-radius: 999px;
  color: #246798;
  flex: 0 0 auto;
  font-size: 0.82rem;
  font-weight: 800;
  padding: 7px 10px;
}

.spg-scenario-copy {
  color: #43515c;
  line-height: 1.58;
  margin: 14px 0;
}

.spg-reqs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.spg-reqs span {
  background: #f1f5f7;
  border: 1px solid #dbe5ea;
  border-radius: 999px;
  color: #354a59;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 5px 9px;
}

.spg-workspace {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.18fr);
  margin-top: 14px;
}

.spg-panel {
  min-width: 0;
  padding: 18px;
}

.spg-step-head {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.spg-step-head > span {
  align-items: center;
  background: #163247;
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 0.82rem;
  font-weight: 800;
  height: 28px;
  justify-content: center;
  width: 28px;
}

.spg-step-head h4 {
  color: #172a38;
  font-size: 1rem;
  margin: 0 0 3px;
}

.spg-step-head p {
  color: #5c6d79;
  font-size: 0.86rem;
  line-height: 1.4;
  margin: 0;
}

.spg-stream-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.spg-stream-grid h5,
.spg-output-wrap h5 {
  color: #172a38;
  font-size: 0.84rem;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.spg-stream-grid pre,
.spg-output-wrap pre {
  background: #142231;
  border-radius: 8px;
  color: #d7f2e4;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  margin: 0;
  min-height: 168px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
}

.spg-stream-grid div:last-child pre {
  color: #cfe8ff;
}

.spg-rule-list {
  display: grid;
  gap: 10px;
}

.spg-rule-row {
  align-items: end;
  background: #f8fafb;
  border: 1px solid #dfe8ed;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(128px, 1fr) minmax(130px, 1fr) minmax(110px, 0.7fr) auto;
  padding: 12px;
}

.spg-rule-row label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.spg-rule-row select,
.spg-rule-row input {
  background: #fff;
  border: 1px solid #cdd9e2;
  border-radius: 7px;
  color: #24333d;
  font: inherit;
  min-width: 0;
  padding: 9px 10px;
  width: 100%;
}

.spg-remove-rule,
.spg-secondary,
.spg-submit {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  line-height: 1;
}

.spg-remove-rule {
  background: #f3e8e5;
  color: #9b3b25;
  padding: 10px 12px;
}

.spg-builder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}

.spg-secondary {
  background: #e9eef2;
  color: #263845;
  padding: 12px 14px;
}

.spg-output-wrap {
  margin-top: 12px;
}

.spg-output-wrap pre {
  min-height: 96px;
}

.spg-feedback {
  margin-top: 12px;
  padding: 14px;
}

.spg-feedback.is-correct {
  border-color: #9ed8bb;
}

.spg-feedback.is-wrong {
  border-color: #e5b0a5;
}

.spg-feedback-top {
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.spg-feedback-top strong {
  color: #172a38;
}

.spg-feedback-top span {
  background: #edf6f2;
  border-radius: 999px;
  color: #1f8f70;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 5px 9px;
}

.spg-feedback p {
  color: #465762;
  line-height: 1.5;
  margin: 7px 0 0;
}

.spg-action-row {
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

.spg-submit {
  background: #1f8f70;
  color: #fff;
  padding: 12px 16px;
}

.spg-submit:disabled {
  background: #98a9b5;
  cursor: not-allowed;
}

.spg-final {
  margin-top: 14px;
}

.spg-final-card {
  padding: 24px;
  text-align: center;
}

.spg-final-card > span {
  color: #7a5b24;
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.spg-final-card h3 {
  color: #143247;
  font-size: 2rem;
  margin: 5px 0 8px;
}

.spg-final-card p {
  color: #4b5d68;
  margin: 0 auto 16px;
  max-width: 620px;
}

.spg-result-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 16px auto;
  max-width: 520px;
}

.spg-result-grid div {
  background: #f5f8fa;
  border: 1px solid #dfe8ed;
  border-radius: 8px;
  padding: 12px;
}

.spg-result-grid strong {
  color: #1f8f70;
  display: block;
  font-size: 1.35rem;
}

.spg-result-grid span {
  color: #657886;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.spg-loading,
.spg-error,
.spg-reference-loading {
  background: #fff;
  border: 1px solid #dde6ec;
  border-radius: 8px;
  color: #596a76;
  padding: 18px;
}

.spg-error {
  color: #a33a2a;
}

.spg-reference-material {
  margin-top: 22px;
}

.spg-reference-intro,
.spg-reference-section {
  margin-bottom: 12px;
}

.spg-reference-intro {
  padding: 16px 18px;
}

.spg-reference-intro h3 {
  color: #172a38;
  font-size: 1.1rem;
  margin: 0 0 6px;
}

.spg-reference-intro p {
  color: #526471;
  line-height: 1.5;
  margin: 0;
}

.spg-reference-section {
  overflow: hidden;
}

.spg-reference-section summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  list-style: none;
  padding: 14px 16px;
}

.spg-reference-section summary::-webkit-details-marker {
  display: none;
}

.spg-reference-section summary span {
  color: #172a38;
  font-weight: 800;
}

.spg-reference-section summary em {
  background: #eef3f6;
  border-radius: 999px;
  color: #526471;
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 800;
  padding: 4px 8px;
  text-transform: uppercase;
}

.spg-reference-body {
  border-top: 1px solid #e5edf2;
  padding: 16px;
}

.spg-table-wrap {
  overflow-x: auto;
}

.spg-reference-table {
  border-collapse: collapse;
  width: 100%;
}

.spg-reference-table th,
.spg-reference-table td {
  border-bottom: 1px solid #e5edf2;
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.spg-reference-table th {
  color: #172a38;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.spg-reference-table td {
  color: #475a66;
  font-size: 0.9rem;
  line-height: 1.42;
}

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

.spg-card-grid article,
.spg-mini-card-grid article {
  background: #f8fafb;
  border: 1px solid #e2e9ee;
  border-radius: 8px;
  padding: 12px;
}

.spg-card-grid h4,
.spg-mini-card-grid h4 {
  color: #172a38;
  font-size: 0.95rem;
  margin: 0 0 6px;
}

.spg-card-grid p,
.spg-mini-card-grid p {
  color: #526471;
  font-size: 0.86rem;
  line-height: 1.45;
  margin: 0;
}

.spg-mini-card-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.spg-mini-card-grid article {
  display: flex;
  gap: 12px;
}

.spg-mini-card-grid span {
  align-items: center;
  background: #eaf2f8;
  border-radius: 8px;
  color: #235f8d;
  display: inline-flex;
  flex: 0 0 92px;
  font-size: 0.76rem;
  font-weight: 800;
  justify-content: center;
  padding: 8px;
  text-align: center;
  text-transform: uppercase;
}

html.iot-resource-frame-standalone #spgGame .spg-hero {
  display: none;
}

@media (max-width: 980px) {
  .spg-status,
  .spg-workspace,
  .spg-stream-grid,
  .spg-card-grid,
  .spg-mini-card-grid {
    grid-template-columns: 1fr;
  }

  .spg-rule-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .spg-remove-rule {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .spg-game,
  .spg-reference-material {
    max-width: none;
  }

  .spg-hero {
    border-radius: 0;
    margin: 0 0 14px;
    padding: 20px;
  }

  .spg-hero h2 {
    font-size: 1.55rem;
  }

  .spg-scenario-card,
  .spg-panel,
  .spg-feedback,
  .spg-final-card,
  .spg-reference-intro,
  .spg-reference-section {
    border-radius: 8px;
  }

  .spg-scenario-top,
  .spg-feedback-top,
  .spg-action-row,
  .spg-mini-card-grid article {
    align-items: stretch;
    flex-direction: column;
  }

  .spg-rule-row,
  .spg-result-grid {
    grid-template-columns: 1fr;
  }

  .spg-reference-table,
  .spg-reference-table thead,
  .spg-reference-table tbody,
  .spg-reference-table tr,
  .spg-reference-table th,
  .spg-reference-table td {
    display: block;
    width: 100%;
  }

  .spg-reference-table thead {
    display: none;
  }

  .spg-reference-table tr {
    background: #f8fafb;
    border: 1px solid #e2e9ee;
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 8px;
  }

  .spg-reference-table td {
    border-bottom: 0;
    padding: 6px 4px;
  }

  .spg-reference-table td::before {
    color: #697b87;
    content: attr(data-label);
    display: block;
    font-size: 0.7rem;
    font-weight: 800;
    margin-bottom: 2px;
    text-transform: uppercase;
  }
}
