:root {
  --bg: #eef5f2;
  --ink: #17202a;
  --muted: #51616c;
  --panel: #ffffff;
  --panel-soft: #f6faf8;
  --line: #ccd8d3;
  --primary: #0f766e;
  --primary-dark: #0b4f4a;
  --accent: #f59e0b;
  --accent-dark: #92400e;
  --signal: #22d3ee;
  --precision: #7c3aed;
  --hint-soft: #f1eaff;
  --success: #157347;
  --success-soft: #e7f6ee;
  --error: #b42318;
  --error-soft: #fdecec;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.16);
  --glow: 0 0 0 1px rgba(34, 211, 238, 0.25), 0 20px 46px rgba(15, 118, 110, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background:
    linear-gradient(120deg, rgba(245, 158, 11, 0.12), transparent 36%),
    linear-gradient(240deg, rgba(34, 211, 238, 0.14), transparent 38%),
    linear-gradient(90deg, rgba(15, 118, 110, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(15, 118, 110, 0.08) 1px, transparent 1px),
    var(--bg);
  background-size: auto, auto, 32px 32px, 32px 32px, auto;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.app {
  width: min(1060px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.screen {
  position: relative;
  overflow: hidden;
  min-height: calc(100vh - 64px);
  padding: 32px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: screen-in 260ms ease both;
}

.screen[hidden] {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}

.brand-mark {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: #ffffff;
  background: var(--primary);
  border-radius: 8px;
}

.hero-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 32px;
  align-items: center;
  min-height: 620px;
}

.hero-copy {
  max-width: 640px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 780px;
  margin-bottom: 20px;
  font-size: 3rem;
  line-height: 1.08;
}

h2 {
  margin-bottom: 14px;
  font-size: 2rem;
  line-height: 1.15;
}

h3 {
  font-size: 1.2rem;
  line-height: 1.25;
}

p {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.65;
}

.hero-subtitle {
  margin-bottom: 12px;
  color: var(--primary-dark);
  font-size: 1.14rem;
  font-weight: 800;
}

.hero-actions,
.screen-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.mission-dashboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 24px;
}

.mission-dashboard div {
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
}

.mission-dashboard span {
  display: block;
  color: var(--primary-dark);
  font-size: 1.5rem;
  font-weight: 900;
}

.mission-dashboard strong {
  color: var(--muted);
  font-size: 0.86rem;
}

.primary-button,
.secondary-button,
.sound-toggle {
  padding: 12px 18px;
}

.primary-button {
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), #0ea5a3);
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.primary-button:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  box-shadow: 0 14px 26px rgba(15, 118, 110, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.secondary-button,
.sound-toggle {
  color: var(--primary-dark);
  background: #e3f4f1;
  border: 1px solid #b7dcd5;
}

.secondary-button:hover:not(:disabled),
.sound-toggle:hover:not(:disabled) {
  background: #d1eee8;
}

.sequence-board {
  display: grid;
  position: relative;
  overflow: hidden;
  gap: 16px;
  padding: 24px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.94), rgba(16, 24, 40, 0.94)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    #101828;
  background-size: auto, 28px 28px, 28px 28px, auto;
  border: 1px solid rgba(186, 230, 253, 0.24);
  border-radius: 14px;
  box-shadow: var(--glow);
}

.sequence-board::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 0 42%, rgba(255, 255, 255, 0.1) 50%, transparent 58% 100%);
  transform: translateX(-60%);
  animation: code-scan 5s ease-in-out infinite;
  pointer-events: none;
}

.sequence-board > * {
  position: relative;
}

.board-label {
  margin-bottom: 0;
  color: #d1fae5;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sequence-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(54px, 1fr));
  gap: 10px;
}

.sequence-row span,
.formula-chip {
  display: grid;
  position: relative;
  min-height: 64px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 1.2rem;
  font-weight: 800;
}

.sequence-row span:not(:last-child)::after {
  content: "\2192";
  position: absolute;
  right: -14px;
  color: #bae6fd;
  font-size: 1rem;
  font-weight: 900;
  z-index: 1;
}

.formula-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  padding: 12px 16px;
  color: #fff7ed;
  background: rgba(245, 158, 11, 0.2);
  font-size: 1.35rem;
  line-height: 1.2;
  max-width: 100%;
  overflow-x: auto;
  white-space: nowrap;
}

.formula-chip sub,
.formula-chip sup {
  line-height: 0;
}

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

.decoder-strip span {
  padding: 8px 10px;
  color: #f0fdfa;
  text-align: center;
  background: rgba(15, 118, 110, 0.36);
  border: 1px solid rgba(209, 250, 229, 0.22);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.mission-map {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.mission-map span {
  display: grid;
  min-height: 44px;
  place-items: center;
  padding: 10px 8px;
  color: #ecfeff;
  text-align: center;
  background: rgba(34, 211, 238, 0.14);
  border: 1px solid rgba(34, 211, 238, 0.32);
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

.screen-header {
  max-width: 760px;
  margin-bottom: 28px;
}

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

.instructions-grid article {
  min-height: 180px;
  padding: 22px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.instructions-grid h3 {
  margin-bottom: 8px;
}

.instructions-grid p {
  margin-bottom: 0;
}

.quiz-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.quiz-topbar h2 {
  margin-bottom: 0;
}

.status-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0 12px;
}

.status-panel div {
  position: relative;
  overflow: hidden;
  padding: 16px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-panel div::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--primary), var(--accent));
}

.status-panel span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-panel strong {
  font-size: 1.5rem;
}

.attempts-meter {
  color: var(--precision);
}

.attempts-meter::after {
  content: " tentativas";
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.attempts-meter[data-level="0"] {
  color: var(--error);
}

.attempts-meter[data-level="1"] {
  color: var(--accent-dark);
}

.progress-track {
  height: 16px;
  overflow: hidden;
  background: #d8e3df;
  border-radius: 999px;
  box-shadow: inset 0 1px 4px rgba(23, 32, 42, 0.16);
}

.progress-track span {
  display: block;
  position: relative;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--signal), var(--accent));
  border-radius: inherit;
  transition: width 260ms ease;
}

.progress-track span::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.44), transparent);
  animation: progress-shine 2.4s ease-in-out infinite;
}

.transition-banner {
  margin: 16px 0 0;
  padding: 14px 16px;
  color: #3b2505;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  font-size: 0.98rem;
  font-weight: 800;
  animation: slide-in 260ms ease both;
}

.question-panel {
  margin-top: 24px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(34, 211, 238, 0.06), transparent 34%),
    #ffffff;
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.question-panel.is-correct-answer {
  border-color: var(--success);
  box-shadow: 0 12px 26px rgba(21, 115, 71, 0.16);
  animation: correct-pulse 260ms ease both;
}

.question-panel.is-wrong-answer {
  border-color: var(--error);
  box-shadow: 0 12px 26px rgba(180, 35, 24, 0.12);
  animation: wrong-shake 240ms ease both;
}

.stage-name {
  margin-bottom: 6px;
  color: var(--primary-dark);
  font-size: 0.95rem;
  font-weight: 800;
  text-transform: uppercase;
}

.story-text {
  max-width: 760px;
  margin-bottom: 16px;
  font-size: 1rem;
}

.formula-note {
  display: inline-block;
  margin-bottom: 16px;
  padding: 8px 12px;
  color: var(--primary-dark);
  background: #e3f4f1;
  border: 1px solid #b7dcd5;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 700;
}

.hint-button {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  margin: 0 0 16px 10px;
  padding: 8px 12px;
  color: #4c1d95;
  background: var(--hint-soft);
  border: 1px solid #c4b5fd;
  border-radius: 8px;
  font-size: 0.92rem;
}

.hint-button:hover:not(:disabled) {
  background: #e9d5ff;
}

.hint-text {
  margin: 0 0 16px;
  padding: 12px 14px;
  color: #3b0764;
  background: var(--hint-soft);
  border: 1px solid #c4b5fd;
  border-radius: 8px;
  font-size: 0.98rem;
  font-weight: 700;
  animation: slide-in 220ms ease both;
}

#question-text {
  margin-bottom: 18px;
  font-size: 1.35rem;
}

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

.option-button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 14px;
  color: var(--ink);
  text-align: left;
  background: #f8fbfa;
  border: 2px solid #d5e1dd;
  box-shadow: 0 6px 14px rgba(23, 32, 42, 0.06);
}

.option-button span {
  display: inline-grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #ffffff;
  background: var(--primary);
  border-radius: 8px;
}

.option-button:hover:not(:disabled) {
  border-color: var(--primary);
  box-shadow: 0 10px 20px rgba(15, 118, 110, 0.16);
}

.option-button:disabled {
  opacity: 1;
}

.option-button.is-correct {
  color: #0b3f2a;
  background: var(--success-soft);
  border-color: var(--success);
  animation: correct-pulse 240ms ease both;
}

.option-button.is-correct::after {
  content: "Correta";
  margin-left: auto;
  padding: 4px 8px;
  color: #ffffff;
  background: var(--success);
  border-radius: 999px;
  font-size: 0.78rem;
}

.option-button.is-wrong {
  color: #7f1d1d;
  background: var(--error-soft);
  border-color: var(--error);
  animation: wrong-shake 220ms ease both;
}

.option-button.is-wrong::after {
  content: "Sua resposta";
  margin-left: auto;
  padding: 4px 8px;
  color: #ffffff;
  background: var(--error);
  border-radius: 999px;
  font-size: 0.78rem;
}

.feedback-panel {
  margin-top: 16px;
  padding: 18px;
  border-radius: 8px;
  border: 2px solid var(--line);
  animation: slide-in 220ms ease both;
}

.feedback-panel h3 {
  margin-bottom: 8px;
}

.feedback-panel p {
  margin-bottom: 0;
}

.feedback-panel.success {
  background: var(--success-soft);
  border-color: var(--success);
  box-shadow: 0 10px 22px rgba(21, 115, 71, 0.12);
}

.feedback-panel.error {
  background: var(--error-soft);
  border-color: var(--error);
  box-shadow: 0 10px 22px rgba(180, 35, 24, 0.1);
}

.result-score {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0;
}

.result-score span,
.result-score strong {
  display: grid;
  min-height: 120px;
  place-items: center;
  background: linear-gradient(135deg, #f6faf8, #ecfeff);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 2.4rem;
}

.result-score strong {
  color: var(--primary-dark);
}

.result-badges {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.result-badges div {
  padding: 18px;
  background: linear-gradient(135deg, #fff7ed, #ecfeff);
  border: 1px solid #f1d18a;
  border-radius: 8px;
}

.result-badges span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.result-badges strong {
  color: var(--primary-dark);
  font-size: 1.15rem;
}

.result-message {
  max-width: 720px;
  font-size: 1.12rem;
}

.mistakes-summary {
  margin-top: 22px;
  padding: 20px;
  background: #fffdf6;
  border: 1px solid #f1d18a;
  border-radius: 8px;
}

.mistakes-summary h3 {
  margin-bottom: 12px;
}

.mistake-item {
  padding: 14px 0;
  border-top: 1px solid #f1d18a;
}

.mistake-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.mistake-item h4 {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 1rem;
}

.mistake-item p {
  margin-bottom: 6px;
  font-size: 0.98rem;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes correct-pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.01);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes wrong-shake {
  0%,
  100% {
    transform: translateX(0);
  }

  35% {
    transform: translateX(-4px);
  }

  70% {
    transform: translateX(4px);
  }
}

@keyframes code-scan {
  0%,
  68% {
    transform: translateX(-70%);
  }

  100% {
    transform: translateX(70%);
  }
}

@keyframes progress-shine {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

@media (max-width: 820px) {
  .app {
    width: min(100% - 20px, 720px);
    padding: 10px 0;
  }

  .screen {
    min-height: calc(100vh - 20px);
    padding: 22px;
    border-radius: 12px;
  }

  .brand {
    align-items: flex-start;
  }

  .hero-layout {
    grid-template-columns: 1fr;
    min-height: auto;
    margin-top: 32px;
  }

  h1 {
    font-size: 2.15rem;
  }

  h2 {
    font-size: 1.6rem;
  }

  .instructions-grid,
  .options-grid,
  .result-score,
  .result-badges {
    grid-template-columns: 1fr;
  }

  .quiz-topbar,
  .hero-actions,
  .screen-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .sound-toggle,
  .primary-button,
  .secondary-button {
    width: 100%;
  }

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

  .mission-dashboard {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .screen {
    padding: 18px;
  }

  .brand {
    font-size: 0.85rem;
  }

  h1 {
    font-size: 1.85rem;
  }

  p {
    font-size: 1rem;
  }

  .sequence-board {
    padding: 16px;
  }

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

  .sequence-row span:not(:last-child)::after {
    display: none;
  }

  .formula-chip {
    min-height: 64px;
    font-size: 1.12rem;
  }

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

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

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

  .question-panel {
    padding: 18px;
  }

  .hint-button {
    width: 100%;
    justify-content: center;
    margin-left: 0;
  }

  .option-button {
    min-height: 58px;
    flex-wrap: wrap;
  }

  .option-button.is-correct::after,
  .option-button.is-wrong::after {
    margin-left: 46px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
