html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

.p3d {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

/* ---------- cabeçalho ---------- */
.p3d-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.p3d-header .back {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}
.p3d-header h1 {
  font-size: 1.05rem;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.p3d-header .subject-tag {
  background: #8b5cf6;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}
.badge-3d {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--primary);
  color: var(--primary);
  white-space: nowrap;
}
.p3d-header .spacer {
  flex: 1;
}

/* ---------- palco ---------- */
.p3d-main {
  position: relative;
  min-height: 0;
  overflow: hidden;
}
.p3d-stage {
  position: absolute;
  inset: 0;
}
.p3d-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}
.p3d-stage canvas:active {
  cursor: grabbing;
}

/* ---------- painel do roteiro ---------- */
.p3d-panel {
  position: absolute;
  top: 12px;
  left: 12px;
  bottom: 12px;
  width: min(360px, calc(100% - 24px));
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 3;
}
.p3d-panel-toggle {
  border: 0;
  background: transparent;
  color: var(--text);
  font: 700 0.95rem var(--font);
  text-align: left;
  padding: 12px 16px 6px;
  cursor: pointer;
}
.p3d-panel.is-collapsed {
  bottom: auto;
  width: auto;
}
.p3d-panel.is-collapsed .p3d-panel-body {
  display: none;
}
.p3d-panel-body {
  overflow-y: auto;
  padding: 0 16px 16px;
  font-size: 0.9rem;
  line-height: 1.45;
}
.p3d-panel-body .theory summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
}
.p3d-panel-body .theory ul {
  padding-left: 18px;
}
.sec {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 18px 0 8px;
}
.steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}
.step {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}
.step-num {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--text-muted);
}
.step.is-done {
  opacity: 0.6;
}
.step.is-done .step-num {
  background: var(--success);
  color: #fff;
}
.step.is-current {
  background: var(--primary-soft);
  outline: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
}
.step.is-current .step-num {
  background: var(--primary);
  color: #fff;
}
.step-body p {
  margin: 6px 0;
}
.entry {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.entry label {
  display: grid;
  gap: 4px;
  font-weight: 600;
  font-size: 0.85rem;
}
.entry input,
.entry textarea {
  font: 500 1rem var(--font);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.entry textarea {
  background: repeating-linear-gradient(var(--surface), var(--surface) 25px, #c8d8ee 26px);
  line-height: 26px;
  resize: vertical;
}
.feedback {
  color: var(--warning);
  font-weight: 600;
}
.compare p {
  margin: 6px 0;
}
.nb-line {
  margin: 0 0 8px;
  font-size: 0.85rem;
}
.nb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.nb-table th,
.nb-table td {
  border-bottom: 1px solid var(--border);
  padding: 6px 4px;
  text-align: left;
}
.nb-table .num {
  font-family: var(--mono);
  font-weight: 700;
}
.nb-note {
  font-size: 0.85rem;
}
.muted {
  color: var(--text-muted);
}
.q p {
  margin: 10px 0 6px;
}
.opt {
  display: block;
  width: 100%;
  text-align: left;
  margin: 4px 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: 500 0.88rem var(--font);
  cursor: pointer;
}
.opt.is-right {
  border-color: var(--success);
  background: color-mix(in srgb, var(--success) 14%, var(--surface));
}
.opt.is-wrong {
  border-color: var(--acid);
  background: color-mix(in srgb, var(--acid) 12%, var(--surface));
}
.opt.is-dim {
  opacity: 0.55;
}
.explain {
  font-size: 0.84rem;
  color: var(--text-muted);
}
.done-card {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  text-align: center;
}
.done-card .stars {
  font-size: 1.8rem;
  color: #f2b01e;
}
.real-life {
  text-align: left;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 10px 0;
}
.real-life p {
  margin: 6px 0 0;
}

/* ---------- cenário do eletrodo, avaliação e limpeza ---------- */
.scenario {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 4px 0 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.scenario > span {
  margin-right: 4px;
  font-weight: 600;
}
.seg {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: 600 0.78rem var(--font);
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.seg.is-on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.cal-result {
  font-family: var(--mono);
  font-size: 0.85rem;
  background: var(--surface-2);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}
.judge {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}
.judge .btn {
  justify-content: flex-start;
  text-align: left;
  font-size: 0.84rem;
}
.soak {
  height: 10px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.soak span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #f2b01e, var(--success));
  transition: width 0.15s linear;
}

/* ---------- missão, visor e barra de ações ---------- */
.p3d-mission {
  position: absolute;
  top: 12px;
  left: calc(min(360px, 100% - 24px) + 28px);
  right: 220px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  background: #1c2433;
  color: #fff;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  z-index: 2;
  max-width: 560px;
  justify-self: center;
}
.p3d-mission-step {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #ffd76a;
  white-space: nowrap;
}
.p3d-mission-text {
  flex: 1;
  min-width: 0;
}
.p3d-mission .hint-btn {
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  font: 700 0.8rem var(--font);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}
.p3d-chip {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 190px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  padding: 8px 12px 10px;
  border-radius: var(--radius);
  background: linear-gradient(#c4d4b6, #adc09f);
  color: #1d2a1b;
  font-family: var(--mono);
  box-shadow: var(--shadow);
  border: 3px solid #1f2633;
  z-index: 2;
}
.p3d-chip-cal {
  grid-column: 1 / -1;
  font-size: 0.72rem;
  font-weight: 700;
}
.p3d-chip-value {
  font-size: 2.1rem;
  font-weight: 700;
  text-align: right;
}
.p3d-chip-unit {
  font-weight: 700;
  padding-left: 6px;
}
.p3d-chip-status {
  grid-column: 1 / -1;
  font-size: 0.72rem;
  font-weight: 700;
  min-height: 1em;
}
.p3d-chip.is-stable .p3d-chip-status {
  color: #0f5d2a;
}
.p3d-toolbar {
  position: absolute;
  bottom: 36px;
  left: calc(min(360px, 100% - 24px) + 28px);
  right: 12px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  z-index: 2;
}
.p3d-toolbar .btn {
  box-shadow: var(--shadow);
}
.p3d-help {
  position: absolute;
  bottom: 8px;
  left: calc(min(360px, 100% - 24px) + 28px);
  right: 12px;
  margin: 0;
  text-align: center;
  font-size: 0.75rem;
  color: #4a5568;
  pointer-events: none;
}
.p3d-tip {
  position: absolute;
  top: 0;
  left: 0;
  padding: 5px 9px;
  border-radius: 8px;
  background: #1c2433;
  color: #fff;
  font-size: 0.8rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 4;
  white-space: nowrap;
}
.p3d-tip.is-on {
  opacity: 1;
}
.p3d-toast {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translate(-50%, 12px);
  max-width: min(520px, calc(100% - 32px));
  padding: 10px 14px;
  border-radius: 12px;
  background: #1c2433;
  color: #fff;
  font-size: 0.88rem;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 5;
}
.p3d-toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}
.p3d-toast[data-tone='warn'] {
  background: #8a4b0c;
}
.p3d-toast[data-tone='ok'] {
  background: #17603a;
}

/* ---------- celular / tela estreita ---------- */
@media (max-width: 820px) {
  .p3d-header {
    padding: 8px 12px;
    gap: 8px;
  }
  .p3d-header .subject-tag,
  .badge-3d,
  .p3d-header [data-nav-help],
  .p3d-header [data-action='home'] {
    display: none;
  }
  .p3d-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 42%;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .p3d-panel.is-collapsed {
    width: auto;
    bottom: 0;
  }
  .p3d-mission {
    left: 8px;
    right: 8px;
    top: 8px;
    font-size: 0.82rem;
  }
  .p3d-chip {
    top: 64px;
    right: 8px;
    width: 150px;
    padding: 6px 10px;
  }
  .p3d-chip-value {
    font-size: 1.6rem;
  }
  .p3d-toolbar {
    left: 8px;
    right: 8px;
    bottom: calc(42% + 8px);
    gap: 6px;
  }
  .p3d-panel.is-collapsed ~ .p3d-toolbar {
    bottom: 56px;
  }
  .p3d-toolbar .btn {
    padding: 6px 10px;
    font-size: 0.8rem;
  }
  .p3d-help {
    display: none;
  }
  .p3d-toast {
    bottom: auto;
    top: 120px;
  }
}

/* ---------- desempenho (estrelas por critério), resolução e recomeçar ---------- */
.rb-title {
  margin: 14px 0 4px;
  text-align: left;
  font-size: 0.95rem;
}
.rubric {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  text-align: left;
}
.rubric > li {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
}
.rubric p {
  margin: 2px 0;
}
.rb-mk {
  flex: 0 0 18px;
  font-weight: 800;
  text-align: center;
}
.rb-ok .rb-mk {
  color: var(--success);
}
.rb-no .rb-mk {
  color: var(--acid);
}
.rb-todo .rb-mk {
  color: var(--text-muted);
}
.rb-sum,
.rb-det .x {
  color: var(--text-muted);
  font-weight: 400;
}
.rb-det {
  margin: 4px 0;
  padding-left: 18px;
}
.rb-det li {
  margin: 2px 0;
}
.rb-tip {
  color: var(--text-muted);
}
.nb-errors {
  margin: 10px 0 4px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warning) 12%, var(--surface));
  font-size: 0.86rem;
}
.nb-errors summary {
  cursor: pointer;
  font-weight: 700;
}
.nb-errors ul {
  margin: 2px 0 6px;
  padding-left: 18px;
}
.nb-errors p {
  margin: 6px 0 2px;
}
.reveal-offer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 8px;
  font-size: 0.84rem;
  color: var(--text-muted);
}
.reveal-card {
  margin: 6px 0 2px;
  padding: 8px 10px;
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  background: color-mix(in srgb, var(--primary) 7%, var(--surface));
  font-size: 0.86rem;
}
.reveal-card p {
  margin: 4px 0 0;
}
@media (max-width: 820px) {
  .btn-restart .lbl {
    display: none;
  }
}

/* seletor de idioma no cabeçalho dos experimentos: "PT | EN" curto fora das telas largas */
@media (max-width: 1279px) {
  .p3d-header .lang-seg .ls-long {
    display: none;
  }
  .p3d-header .lang-seg .ls-short {
    display: inline;
  }
}

/* convite para feedback no cartão de experimento concluído */
.done-feedback {
  margin: 12px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.done-feedback a {
  color: #6d4ae0;
  font-weight: 700;
}
