:root {
  --bg: #fdfcf9;
  --ink: #1a1a1a;
  --ink-soft: #5a5a5a;
  --navy: #0d1b2e;
  --gold: #f2b705;
  --red: #c0392b;
  --line: rgba(13,27,46,0.14);
  --card-w: 190px;
  --card-h: 124px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Georgia', 'Times New Roman', serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

header {
  text-align: center;
  margin: 0 -16px 24px;
  padding: 16px 16px 14px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.header-logo {
  display: block;
  height: 34px;
  width: auto;
  flex: 0 0 auto;
}

header h1 {
  font-size: clamp(18px, 3vw, 24px);
  color: var(--navy);
  margin: 0;
  font-weight: bold;
}

#question-label {
  font-size: clamp(20px, 3.2vw, 28px);
  color: var(--navy);
  font-weight: bold;
  margin: 10px 0 0;
}

.progress {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.progress .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(13,27,46,0.1);
  border: 1px solid var(--gold);
}

.progress .dot.done { background: var(--gold); }
.progress .dot.current { background: var(--red); border-color: var(--red); }

@media (max-width: 620px) {
  .header-bar { gap: 10px; }
  .header-logo { height: 24px; }
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-w), 1fr));
  gap: 10px;
  justify-items: center;
}

@media (max-width: 620px) {
  :root {
    --card-w: 130px;
    --card-h: 85px;
  }
  .grid { gap: 8px; }
}

.card {
  width: var(--card-w);
  height: var(--card-h);
  perspective: 800px;
  cursor: pointer;
}

.card.locked { cursor: default; }

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(.4,.2,.2,1);
  transform-style: preserve-3d;
}

.card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  overflow: hidden;
  backface-visibility: hidden;
  box-shadow: 0 2px 6px rgba(13,27,46,0.15);
  border: 1px solid rgba(242,183,5,0.35);
}

.card-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-back { transform: rotateY(0deg); }
.card-front { transform: rotateY(180deg); }

.card.used .card-face { opacity: 0.35; filter: grayscale(0.6); }
.card.used::after {
  content: "✓";
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--gold);
  color: var(--navy);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  z-index: 2;
}

.card:hover:not(.locked) .card-inner {
  transform: translateY(-4px);
}
.card.flipped:hover .card-inner {
  transform: rotateY(180deg) translateY(-4px);
}

/* Painel de resposta — overlay modal, mantém contraste com scrim escuro */
.panel {
  position: fixed;
  inset: 0;
  background: rgba(13,27,46,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}

.panel.open { display: flex; }

.panel-content {
  background: #fff;
  border: 1px solid var(--gold);
  border-radius: 16px;
  max-width: 600px;
  width: 100%;
  padding: 28px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(13,27,46,0.25);
}

.panel-content .selected-card {
  width: 320px;
  max-width: 100%;
  margin: 0 auto 14px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(13,27,46,0.2);
}

.panel-content .selected-card img {
  width: 100%;
  display: block;
}

.panel-content .question {
  font-size: 22px;
  font-weight: bold;
  color: var(--navy);
  margin-top: 18px;
  margin-bottom: 18px;
}

.panel-content textarea {
  width: 100%;
  min-height: 110px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  padding: 12px;
  font-family: inherit;
  font-size: 15px;
  resize: vertical;
}

.panel-content textarea:focus {
  outline: none;
  border-color: var(--gold);
}

.panel-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  justify-content: center;
}

button {
  font-family: inherit;
  font-size: 15px;
  padding: 10px 22px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--gold);
  color: var(--navy);
  font-weight: bold;
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.instructions-card .btn-primary.btn-two-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding-top: 12px;
  padding-bottom: 12px;
  line-height: 1.3;
}

.btn-two-line span {
  font-size: 12px;
  font-weight: normal;
  opacity: 0.75;
}

.btn-secondary {
  background: transparent;
  color: var(--navy);
  border: 1px solid rgba(13,27,46,0.3);
}

.diagram-screen {
  display: none;
  text-align: center;
  margin-top: 20px;
}

.diagram-screen.open { display: block; }

.diagram-card {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px;
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  text-align: left;
}

.diagram-visual {
  flex: 1 1 340px;
  min-width: 280px;
  max-width: 380px;
}

.diagram-title {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 2px;
}

.diagram-subtitle {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.diagram-visual svg,
.diagram-visual img {
  width: 100%;
  height: auto;
  display: block;
}

.diagram-list {
  flex: 1.4 1 340px;
  min-width: 280px;
}

.diagram-list-heading {
  font-weight: bold;
  font-size: 17px;
  margin-bottom: 18px;
}

.qa-item {
  margin-bottom: 18px;
}

.qa-item .qa-q {
  font-weight: bold;
  font-size: 15px;
  margin-bottom: 2px;
}

.qa-item .qa-card {
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.qa-item .qa-answer {
  font-size: 14px;
  color: var(--ink);
  line-height: 1.5;
  white-space: pre-wrap;
}

.diagram-actions {
  margin-top: 24px;
  display: flex;
  justify-content: center;
  gap: 12px;
}

.diagram-textarea {
  width: 100%;
  min-height: 90px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 10px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  margin-top: 4px;
  box-sizing: border-box;
  display: block;
}

.diagram-textarea:focus {
  outline: none;
  border-color: var(--gold);
}

/* Pergunta de síntese — mesmo peso do resto, sem bold/tamanho destoante */
#diagram-synth-form .qa-q {
  font-size: 15px;
  font-weight: normal;
  line-height: 1.6;
}

.area-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.area-btn {
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 14px;
  font-weight: normal;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
}

.area-btn strong {
  font-size: 15px;
}

.area-btn:hover {
  border-color: var(--gold);
  background: #fdf6df;
}

.area-btn.selected {
  border-color: var(--gold);
  background: var(--gold);
}

.area-btn.answered {
  border-color: #7ba876;
  background: #eef7ec;
}

.area-btn.answered::after {
  content: " ✓ respondida";
  color: #3f7a38;
  font-weight: bold;
  font-size: 12px;
}

.diagram-final-note {
  margin-top: 20px;
  color: var(--navy);
  font-size: 17px;
}

.hidden { display: none !important; }

/* Tela de introdução e instruções, antes do grid — sem caixa destacada,
   parte do mesmo ambiente da página */
#instructions-screen {
  display: flex;
  justify-content: center;
  margin-top: 30px;
}

.instructions-card {
  max-width: 640px;
  width: 100%;
  padding: 0 8px;
}

.instructions-card h2 {
  color: var(--navy);
  margin: 0 0 20px;
  text-align: center;
}

.instructions-card h3 {
  color: var(--navy);
  font-size: 18px;
  margin: 28px 0 14px;
}

.instructions-card p {
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 14px;
  color: var(--ink);
}

.instructions-list {
  padding-left: 20px;
  margin: 0 0 20px;
}

.instructions-list li {
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 10px;
  color: var(--ink);
}

.instructions-card .btn-primary {
  display: block;
  margin: 24px auto 0;
}

/* Tela inicial: pede o nome — mesmo tratamento, sem caixa destacada */
#intro-screen {
  display: flex;
  justify-content: center;
  margin-top: 60px;
}

.intro-card {
  max-width: 440px;
  width: 100%;
  text-align: center;
  padding: 0 8px;
}

.intro-card .optin-label {
  text-align: left;
  font-size: 13px;
  margin-bottom: 18px;
  color: var(--ink-soft);
}

.intro-card p {
  font-size: 18px;
  margin-bottom: 16px;
  color: var(--ink);
}

.intro-card input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  margin-bottom: 16px;
}

.intro-card input:focus {
  outline: none;
  border-color: var(--gold);
}

.optin-label {
  display: flex !important;
  align-items: flex-start;
  gap: 8px;
}

.optin-label input[type="checkbox"] {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 3px;
  margin-right: 8px; /* fallback pra webviews antigas sem suporte a gap no flex */
}

.optin-label span {
  flex: 1 1 auto;
  min-width: 0;
}

/* Tela final: página própria, isolada do resto do exercício */
body.final-screen-open {
  overflow: hidden;
}

.final-screen {
  display: none;
}

.final-screen.open {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  padding: 24px 16px;
  text-align: center;
}

.done-card {
  max-width: 420px;
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px;
  text-align: center;
}

.done-check {
  width: 56px;
  height: 56px;
  line-height: 56px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--navy);
  font-size: 28px;
  font-weight: bold;
  margin: 0 auto 16px;
}

.done-card h2 {
  color: var(--navy);
  margin: 0 0 8px;
}

.final-tagline {
  margin-top: 18px;
  font-weight: bold;
  color: var(--navy);
  font-size: 17px;
}

.final-link {
  display: inline-block;
  margin-top: 24px;
  color: var(--ink-soft);
  text-decoration: underline;
  font-size: 14px;
}

.final-close {
  margin-top: 16px;
}
