/* ============================================================
   Teste de QI — tema sunset.
   ============================================================ */

.sj-game-host:has(.qi) {
  --sj-text:           #2d2438;
  --sj-text-dim:       #5d5468;
  --sj-text-mute:      rgba(45, 36, 56, 0.42);
  --sj-bg-card:        rgba(255, 255, 255, 0.85);
  --sj-bg-elev:        rgba(255, 255, 255, 0.7);
  --sj-bg-card-hover:  rgba(255, 255, 255, 0.95);
  --sj-border:         rgba(255, 255, 255, 0.5);
  --sj-border-bright:  rgba(45, 36, 56, 0.18);
  --sj-accent:         #6b5bff;
  --sj-accent-hover:   #5347d6;
  --sj-accent-soft:    rgba(107, 91, 255, 0.12);
  --sj-gold:           #ffd93d;
  --sj-danger:         #ff3355;
  --sj-score-bg:       #fff;
}
.sj-game-host:has(.qi),
body:has(.sj-game-stage) .sj-game-host:has(.qi) {
  background:
    radial-gradient(circle at 15% 25%, rgba(255,255,255,0.18), transparent 35%),
    radial-gradient(circle at 85% 80%, rgba(107,91,255,0.20), transparent 40%),
    linear-gradient(135deg, #ff7e5f 0%, #feb47b 45%, #ff6b95 100%);
}
.sj-game-stage-frame:has(.qi) {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.25);
}

/* ============ Wrapper ============ */
.qi {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 12px;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
  overflow-y: auto;
}

/* ============ Stage card ============ */
.qi-stage {
  width: 100%;
  max-width: 640px;
  background: #fff;
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 12px 32px rgba(45, 36, 56, 0.18);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============ Progress ============ */
.qi-progress {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--sj-font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--sj-text-dim);
}
.qi-progress-type { color: var(--sj-accent); font-weight: 700; }
.qi-progress-bar {
  height: 4px;
  background: rgba(45, 36, 56, 0.12);
  border-radius: 2px;
  overflow: hidden;
}
.qi-progress-fill {
  height: 100%;
  background: var(--sj-accent);
  width: 0%;
  transition: width .3s;
}

/* ============ Prompt + display ============ */
.qi-prompt {
  font-family: var(--sj-font-display);
  font-weight: 700;
  font-size: 20px;
  line-height: 1.3;
  color: var(--sj-text);
  margin: 0;
}
.qi-display {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2px 0;
  min-height: 0;
}
.qi-display:empty { display: none; }

.qi-sequence {
  font-family: var(--sj-font-mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--sj-text);
  letter-spacing: 0.08em;
  text-align: center;
}
.qi-sequence .qi-blank {
  color: var(--sj-accent);
  font-weight: 900;
}

/* ============ Matrix (Raven's style) ============ */
.qi-matrix {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows:    repeat(3, 56px);
  gap: 5px;
  padding: 6px;
  background: rgba(107, 91, 255, 0.06);
  border-radius: 10px;
}
.qi-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  background: #fff;
  border: 1px solid rgba(45, 36, 56, 0.10);
  border-radius: 6px;
  line-height: 1;
  color: var(--sj-text);
  overflow: hidden;
  padding: 2px;
  box-sizing: border-box;
  letter-spacing: -1px;
}
.qi-cell span { display: inline-block; line-height: 1; }
/* Tamanho do glifo escala conforme len pra caber em 1 linha
   na célula 56×56 com letter-spacing negativo. */
.qi-cell[data-len="1"] span { font-size: 30px; }
.qi-cell[data-len="2"] span { font-size: 24px; }
.qi-cell[data-len="3"] span { font-size: 17px; }
.qi-cell[data-len="4"] span { font-size: 13px; }
.qi-cell[data-len="5"] span { font-size: 11px; }
.qi-cell[data-len="6"] span { font-size: 9px; }
.qi-cell[data-len="7"] span { font-size: 8px; }
.qi-cell.is-missing {
  color: var(--sj-accent);
  font-weight: 900;
  font-size: 26px;
  background: var(--sj-accent-soft);
  border-color: var(--sj-accent);
}

/* ============ Choices ============ */
.qi-choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.qi-choice {
  background: #fff;
  border: 1.5px solid rgba(45, 36, 56, 0.12);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: var(--sj-font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--sj-text);
  cursor: pointer;
  transition: all .15s;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
.qi-choice:hover:not(:disabled) {
  border-color: var(--sj-accent);
  background: var(--sj-accent-soft);
  transform: translateY(-1px);
}
.qi-choice-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(45, 36, 56, 0.08);
  color: var(--sj-text-dim);
  font-family: var(--sj-font-mono);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.qi-choice.is-right {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.10);
  color: var(--sj-text);
}
.qi-choice.is-right .qi-choice-letter {
  background: #22c55e;
  color: #fff;
}
.qi-choice.is-wrong {
  border-color: var(--sj-danger);
  background: rgba(255, 51, 85, 0.10);
}
.qi-choice.is-wrong .qi-choice-letter {
  background: var(--sj-danger);
  color: #fff;
}
.qi-choice:disabled { cursor: default; transform: none; }

/* Botão "Pular" — mostra a resposta certa e avança sem pontuar */
.qi-skip {
  align-self: center;
  margin-top: 4px;
  padding: 8px 20px;
  border: 1.5px solid rgba(45, 36, 56, 0.25);
  border-radius: 9999px;
  background: transparent;
  color: var(--sj-text-dim);
  font-family: var(--sj-font-display);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  touch-action: manipulation;
}
@media (hover: hover) {
  .qi-skip:hover:not(:disabled) {
    background: rgba(45, 36, 56, 0.06);
    color: var(--sj-text);
    border-color: rgba(45, 36, 56, 0.4);
  }
}
.qi-skip:active:not(:disabled) { transform: scale(0.96); }
.qi-skip:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============ End screen ============ */
.qi-end {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 8px 16px 16px;
  text-align: center;
}
.qi-end-label {
  font-family: var(--sj-font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--sj-text-dim);
}
.qi-end-iq {
  font-family: var(--sj-font-display);
  font-weight: 900;
  font-size: 64px;
  line-height: 1;
  color: var(--sj-accent);
}
.qi-end-band {
  font-family: var(--sj-font-display);
  font-weight: 700;
  font-size: 20px;
  color: var(--sj-text);
}
.qi-end-detail {
  font-family: var(--sj-font-mono);
  font-size: 13px;
  color: var(--sj-text-dim);
}

/* ============ Mobile ============ */
@media (max-width: 600px) {
  .qi { padding: 8px; gap: 8px; }
  .qi-stage { padding: 12px; gap: 10px; }
  .qi-prompt { font-size: 16px; }
  .qi-sequence { font-size: 20px; }
  .qi-matrix {
    grid-template-columns: repeat(3, 50px);
    grid-template-rows:    repeat(3, 50px);
    gap: 4px;
  }
  .qi-cell[data-len="1"] span { font-size: 26px; }
  .qi-cell[data-len="2"] span { font-size: 20px; }
  .qi-cell[data-len="3"] span { font-size: 14px; }
  .qi-cell[data-len="4"] span { font-size: 11px; }
  .qi-cell[data-len="5"] span { font-size: 10px; }
  .qi-cell[data-len="6"] span { font-size: 8px; }
  .qi-cell[data-len="7"] span { font-size: 7px; }
  .qi-cell.is-missing { font-size: 22px; }
  .qi-choices { grid-template-columns: 1fr; gap: 6px; }
  .qi-choice { padding: 9px 12px; font-size: 14px; min-height: 40px; }
  .qi-end-iq { font-size: 52px; }
}

/* ============ Landscape mobile compact ============ */
@media (max-width: 900px) and (orientation: landscape) {
  body:has(.sj-game-stage) .qi { padding: 6px; gap: 6px; }
  body:has(.sj-game-stage) .qi-stage { padding: 10px 12px; gap: 6px; }
  body:has(.sj-game-stage) .qi-prompt { font-size: 14px; }
  body:has(.sj-game-stage) .qi-sequence { font-size: 18px; }
  body:has(.sj-game-stage) .qi-matrix {
    grid-template-columns: repeat(3, 42px);
    grid-template-rows:    repeat(3, 42px);
    gap: 3px;
    padding: 4px;
  }
  body:has(.sj-game-stage) .qi-cell[data-len="1"] span { font-size: 20px; }
  body:has(.sj-game-stage) .qi-cell[data-len="2"] span { font-size: 14px; }
  body:has(.sj-game-stage) .qi-cell[data-len="3"] span { font-size: 11px; }
  body:has(.sj-game-stage) .qi-cell[data-len="4"] span,
  body:has(.sj-game-stage) .qi-cell[data-len="5"] span { font-size: 9px; }
  body:has(.sj-game-stage) .qi-cell.is-missing { font-size: 18px; }
  body:has(.sj-game-stage) .qi-choices { grid-template-columns: 1fr 1fr; gap: 5px; }
  body:has(.sj-game-stage) .qi-choice {
    padding: 6px 10px; font-size: 13px; min-height: 36px;
  }
}
