:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --success: #22c55e;
  --error: #ef4444;
  --background: #0f172a;
  --surface: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --gold: #fbbf24;
  --border: rgba(255,255,255,.1);
  --font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: var(--font-family);
  background:
    radial-gradient(circle at top, rgba(99,102,241,.22), transparent 38%),
    var(--background);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-x: hidden;
}

button {
  border: 0;
  outline: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  transition: transform .1s, opacity .2s, filter .2s;
}

button:active {
  transform: scale(.97);
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(.25);
}

a {
  color: inherit;
  text-decoration: none;
}

.app-container {
  width: 100%;
  min-height: 100vh;
  max-width: 520px;
  background: var(--surface);
  position: relative;
  box-shadow: 0 0 50px rgba(0,0,0,.55);
  overflow: hidden;
}

@media (min-width: 540px) {
  body {
    padding: 24px 12px;
    align-items: center;
  }

  .app-container {
    min-height: min(92vh, 900px);
    border-radius: 26px;
    border: 1px solid var(--border);
  }
}

.screen {
  width: 100%;
  min-height: 100vh;
  background: var(--surface);
  display: none;
  flex-direction: column;
  opacity: 0;
  transition: opacity .25s ease;
}

.screen.active {
  display: flex;
  opacity: 1;
}

.menu-screen {
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding: max(16px, env(safe-area-inset-top)) 20px max(18px, env(safe-area-inset-bottom));
  overflow-y: auto;
}

.back-link {
  align-self: flex-start;
  font-size: .82rem;
  color: var(--text-muted);
  background: rgba(255,255,255,.06);
  padding: 8px 11px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.logo-anim {
  font-size: clamp(2.4rem, 10vw, 4rem);
  margin: 4px 0 8px;
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 0 18px rgba(99,102,241,.55));
}

h1 {
  font-size: clamp(1.8rem, 7vw, 2.45rem);
  letter-spacing: -1px;
}

.subtitle {
  color: var(--text-muted);
  font-size: .95rem;
  line-height: 1.45;
  max-width: 360px;
  margin: 8px auto 18px;
}

.section-label {
  width: 100%;
  text-align: left;
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 900;
  letter-spacing: .6px;
  margin: 4px 0 10px;
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  width: 100%;
  margin-bottom: 18px;
}

.cat-btn {
  background: rgba(255,255,255,.055);
  border: 2px solid transparent;
  border-radius: 16px;
  color: var(--text-muted);
  min-height: 78px;
  padding: 10px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.cat-btn span {
  font-size: 1.45rem;
}

.cat-btn strong {
  font-size: .76rem;
}

.cat-btn.selected {
  border-color: var(--primary);
  background: rgba(99,102,241,.17);
  color: white;
}

.cat-wide {
  grid-column: span 3;
  flex-direction: row;
  min-height: 58px;
  gap: 10px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 17px;
  border-radius: 17px;
  width: 100%;
  font-size: 1.05rem;
  letter-spacing: .7px;
  text-transform: uppercase;
  box-shadow: 0 10px 24px rgba(99,102,241,.33);
}

.btn-secondary {
  background: rgba(255,255,255,.1);
  color: white;
  padding: 14px;
  border-radius: 15px;
  width: 100%;
  margin-top: 13px;
  border: 1px solid var(--border);
}

.load-error {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.35);
  color: #fecaca;
  border-radius: 14px;
  padding: 12px;
  line-height: 1.35;
  font-size: .88rem;
  margin-bottom: 12px;
}

.game-screen {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}

header {
  padding: max(14px, env(safe-area-inset-top)) 20px 10px;
  background: rgba(0,0,0,.22);
  width: 100%;
  flex-shrink: 0;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.lvl-badge {
  background: var(--primary);
  padding: 6px 12px;
  border-radius: 9px;
  font-size: .78rem;
  font-weight: 900;
}

.lives {
  font-size: 1.18rem;
  letter-spacing: 1px;
}

.hud-small {
  font-size: .85rem;
  color: var(--text-muted);
}

.timer-track {
  width: 100%;
  height: 7px;
  background: rgba(255,255,255,.1);
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0 8px;
}

.timer-bar {
  height: 100%;
  width: 100%;
  background: var(--gold);
  transform-origin: left;
}

.game-area {
  flex: 1;
  padding: 12px 18px 82px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: 100%;
  position: relative;
}

.q-card {
  background: white;
  color: var(--background);
  padding: clamp(18px, 4.5vh, 28px) 18px;
  border-radius: 22px;
  min-height: 165px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
  margin-bottom: 16px;
  animation: popIn .42s ease;
}

.q-tag {
  background: #e2e8f0;
  color: #475569;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 900;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.q-text {
  font-size: clamp(1.04rem, 4vw, 1.28rem);
  font-weight: 800;
  line-height: 1.36;
  text-align: center;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.btn-game {
  padding: 17px 10px;
  font-size: 1.06rem;
  border-radius: 16px;
  color: white;
  box-shadow: 0 7px 0 rgba(0,0,0,.23);
}

.btn-mito {
  background: var(--error);
  box-shadow: 0 6px 0 #b91c1c;
}

.btn-verdade {
  background: var(--success);
  box-shadow: 0 6px 0 #15803d;
}

.feedback-sheet {
  position: absolute;
  bottom: 58px;
  left: 0;
  width: 100%;
  background: rgba(15,23,42,.985);
  border-radius: 22px 22px 0 0;
  padding: 22px 22px max(22px, env(safe-area-inset-bottom));
  transform: translateY(120%);
  transition: transform .35s cubic-bezier(.16,1,.3,1);
  border-top: 4px solid transparent;
  z-index: 50;
  box-shadow: 0 -12px 42px rgba(0,0,0,.48);
  max-height: 58vh;
  overflow-y: auto;
}

.feedback-sheet.show {
  transform: translateY(0);
}

.feedback-sheet.correct {
  border-color: var(--success);
}

.feedback-sheet.incorrect {
  border-color: var(--error);
}

.feedback-sheet h2 {
  margin-bottom: 8px;
}

.feedback-sheet p {
  color: var(--text-muted);
  line-height: 1.42;
  margin-bottom: 16px;
  font-size: .92rem;
}

.feedback-sheet .btn-primary,
#btn-next {
  padding: 14px;
  font-size: .98rem;
}

.result-screen {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 20px;
  min-height: 100vh;
}

.level-screen {
  background: radial-gradient(circle, #312e81 0%, #0f172a 100%);
}

.result-icon {
  font-size: 4rem;
  margin-bottom: 12px;
}

.result-screen h2 {
  font-size: clamp(1.8rem, 7vw, 2.25rem);
  margin-bottom: 6px;
  color: var(--gold);
}

.danger-title {
  color: var(--error) !important;
}

.score-box {
  width: 100%;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  margin: 22px 0;
}

.score-box p {
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 900;
  letter-spacing: .7px;
}

.score-box strong {
  display: block;
  font-size: clamp(3rem, 15vw, 4rem);
  line-height: 1;
  color: white;
  margin-top: 8px;
}

#final-score {
  color: var(--primary);
}

.reward {
  color: var(--success);
  margin-bottom: 20px;
}

#confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

#share-canvas {
  display: none;
}

@media (max-width: 480px) {
  header {
    padding: max(10px, env(safe-area-inset-top)) 16px 8px;
  }

  .timer-track {
    margin: 8px 0 7px;
  }

  .game-area {
    padding: 10px 16px 76px;
  }

  .q-card {
    min-height: 138px;
    padding: 18px 16px;
    margin-bottom: 12px;
    border-radius: 18px;
  }

  .q-tag {
    margin-bottom: 8px;
    font-size: .64rem;
  }

  .q-text {
    font-size: 1.02rem;
    line-height: 1.32;
  }

  .actions {
    gap: 10px;
  }

  .btn-game {
    padding: 14px 8px;
    font-size: .98rem;
    border-radius: 14px;
  }

  .feedback-sheet {
    bottom: 48px;
    padding: 18px 18px max(18px, env(safe-area-inset-bottom));
    max-height: 56vh;
  }

  .feedback-sheet h2 {
    margin-bottom: 6px;
    font-size: 1.35rem;
  }

  .feedback-sheet p {
    font-size: .88rem;
    line-height: 1.38;
    margin-bottom: 14px;
  }

  #btn-next {
    padding: 13px;
    font-size: .94rem;
  }
}

@media (max-height: 740px) {
  .menu-screen {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .back-link {
    margin-bottom: 6px;
  }

  .logo-anim {
    font-size: 2.35rem;
    margin: 0 0 4px;
  }

  h1 {
    font-size: 1.65rem;
  }

  .subtitle {
    font-size: .82rem;
    margin-bottom: 11px;
  }

  .section-label {
    margin-bottom: 7px;
  }

  .cat-grid {
    gap: 7px;
    margin-bottom: 12px;
  }

  .cat-btn {
    min-height: 63px;
    padding: 7px 4px;
    border-radius: 13px;
  }

  .cat-btn span {
    font-size: 1.18rem;
  }

  .cat-btn strong {
    font-size: .68rem;
  }

  .cat-wide {
    min-height: 50px;
  }

  .btn-primary {
    padding: 14px;
    font-size: .95rem;
  }

  header {
    padding-top: max(9px, env(safe-area-inset-top));
    padding-bottom: 7px;
  }

  .hud-small {
    font-size: .78rem;
  }

  .timer-track {
    height: 6px;
    margin: 7px 0 6px;
  }

  .game-area {
    padding-top: 8px;
    padding-bottom: 68px;
  }

  .q-card {
    min-height: 125px;
    padding: 15px;
    margin-bottom: 10px;
  }

  .q-tag {
    margin-bottom: 7px;
  }

  .q-text {
    font-size: .96rem;
    line-height: 1.28;
  }

  .btn-game {
    padding: 12px 8px;
    font-size: .92rem;
  }

  .feedback-sheet {
    bottom: 38px;
    padding: 16px 18px max(16px, env(safe-area-inset-bottom));
    max-height: 54vh;
  }

  .feedback-sheet h2 {
    font-size: 1.22rem;
  }

  .feedback-sheet p {
    font-size: .84rem;
    line-height: 1.34;
    margin-bottom: 12px;
  }

  #btn-next {
    padding: 12px;
    font-size: .9rem;
  }
}

@media (max-height: 640px) {
  header {
    padding-top: max(7px, env(safe-area-inset-top));
  }

  .lvl-badge {
    padding: 5px 9px;
    font-size: .7rem;
  }

  .lives {
    font-size: 1rem;
  }

  .game-area {
    padding: 7px 14px 60px;
  }

  .q-card {
    min-height: 112px;
    padding: 13px;
    margin-bottom: 8px;
  }

  .q-text {
    font-size: .9rem;
    line-height: 1.24;
  }

  .actions {
    gap: 8px;
  }

  .btn-game {
    padding: 10px 6px;
    font-size: .88rem;
  }

  .feedback-sheet {
    bottom: 28px;
    max-height: 52vh;
  }
}

@media (max-width: 360px) {
  .cat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .cat-wide {
    grid-column: span 2;
  }

  .game-area {
    padding-left: 12px;
    padding-right: 12px;
  }

  .q-card {
    min-height: 118px;
  }

  .q-text {
    font-size: .92rem;
  }

  .btn-game {
    font-size: .86rem;
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

@keyframes popIn {
  from {
    transform: scale(.88);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* AJUSTE FORTE MOBILE - SOBE PERGUNTA E RESPOSTA */
@media (max-width: 480px) {

  .game-screen {
    min-height: 100svh;
    height: 100svh;
    overflow: hidden;
  }

  header {
    padding: max(8px, env(safe-area-inset-top)) 14px 6px;
    max-height: 82px;
  }

  .timer-track {
    margin: 6px 0 5px;
    height: 5px;
  }

  .hud-small {
    font-size: .74rem;
  }

  .lvl-badge {
    padding: 4px 8px;
    font-size: .68rem;
  }

  .lives {
    font-size: .96rem;
  }

  @media (max-width: 480px) {
  .game-area {
    flex: 1;
    height: auto;
    padding: 75px 14px 0;
    justify-content: flex-start;
  }

  .q-card {
    margin-top: 0;
    margin-bottom: 12px;
  }

  .actions {
    margin-top: 0;
  }


  .q-tag {
    padding: 4px 10px;
    margin-bottom: 7px;
    font-size: .6rem;
  }

  .q-text {
    font-size: .94rem;
    line-height: 1.25;
  }

  .actions {
    gap: 8px;
  }

  .btn-game {
    padding: 11px 6px;
    font-size: .86rem;
    border-radius: 13px;
    box-shadow: 0 4px 0 rgba(0,0,0,.23);
  }

  .btn-mito {
    box-shadow: 0 4px 0 #b91c1c;
  }

  .btn-verdade {
    box-shadow: 0 4px 0 #15803d;
  }

  .feedback-sheet {
  bottom: auto;
  top: 50%;
  transform: translateY(120%);
  border-radius: 20px 20px 0 0;
  padding: 16px 18px;
  max-height: 45vh;
  overflow-y: auto;
}

  .feedback-sheet.show {
  transform: translateY(-35%);
}

  .feedback-sheet h2 {
    font-size: 1.15rem;
    margin-bottom: 5px;
  }

  .feedback-sheet p {
    font-size: .82rem;
    line-height: 1.32;
    margin-bottom: 10px;
  }

  #btn-next {
    padding: 11px;
    font-size: .86rem;
    border-radius: 13px;
  }
}