/* NeoCoder — quiz sahifalari (Coding Quiz, English Quiz, Translation) uchun yagona dizayn.
   site.css ustiga ulanadi; JS ishlatadigan id va klasslar o'zgarmagan. */

html { scrollbar-gutter: stable; }
body { display: flex; flex-direction: column; min-height: 100vh; }
.quiz-page { flex: 1; padding: clamp(18px, 4vw, 36px) 0 48px; }

/* ---------- Asosiy karta ---------- */
.game-container {
  display: flex; flex-direction: column; gap: 18px;
  width: min(860px, 100% - 32px); margin: 0 auto; padding: clamp(20px, 4vw, 34px);
  text-align: center;
  background: linear-gradient(160deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .025));
  border: 1px solid var(--border); border-radius: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .06);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.game-title {
  order: 0; font-size: clamp(1.5rem, 4vw, 2.2rem); font-weight: 900; line-height: 1.15; letter-spacing: -.3px;
  background: linear-gradient(90deg, #fff, #c7d2fe 45%, #facc15);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.quiz-sub { order: 0; margin-top: -10px; color: var(--muted); font-size: .95rem; }

/* ---------- Rejim tanlash (avval markazdagi suzuvchi oyna edi — endi karta ichida) ---------- */
.difficulty-modal {
  order: 1; display: none; flex-direction: column; gap: 10px;
  width: min(460px, 100%); margin: 4px auto 0; animation: quizIn .3s ease-out;
}
.difficulty-modal.show { display: flex; }
.difficulty-modal h2 {
  font-size: .8rem !important; font-weight: 700; margin: 0 0 4px !important; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px; text-shadow: none !important;
}
.difficulty-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 18px; border-radius: 14px; cursor: pointer;
  font: 700 1.02rem 'Inter', system-ui, sans-serif; color: var(--text); text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  transition: transform .15s, border-color .15s, background .15s;
}
.difficulty-btn::after { content: '\2192'; margin-left: auto; color: var(--muted); transition: transform .15s, color .15s; }
.difficulty-btn:hover, .difficulty-btn:focus-visible {
  outline: none; transform: translateY(-2px); border-color: rgba(129, 140, 248, .7);
  background: rgba(99, 102, 241, .14);
}
.difficulty-btn:hover::after { color: var(--gold); transform: translateX(3px); }

/* ---------- O'yin paytidagi HUD ---------- */
.score-board {
  order: 2; display: none; justify-content: center; flex-wrap: wrap; gap: 10px;
  font-size: .9rem; color: var(--muted);
}
.score-board > span {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 8px 16px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
}
.score-board > span > span, .score-board b { color: var(--text); font-weight: 800; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
#score { color: var(--gold); }

.timer-bar-container {
  order: 3; display: none; position: relative; width: 100%; height: 28px; overflow: hidden;
  border-radius: 999px; background: rgba(0, 0, 0, .35); border: 1px solid var(--border);
}
.timer-bar {
  height: 100%; width: 100%; border-radius: inherit;
  background: linear-gradient(90deg, #22c55e, #6366f1 60%, #8b5cf6);
  transition: width .2s linear;
}
.timer-text {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 800 .9rem var(--mono); color: #fff; text-shadow: 0 1px 4px rgba(0, 0, 0, .7);
}

.progress-bar { order: 4; display: flex; gap: clamp(2px, .5vw, 4px); width: 100%; }
.progress-bar:empty { display: none; }
.progress-circle {
  flex: 1; min-width: 0; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .1);
  transition: background .25s, box-shadow .25s;
}
.progress-circle.correct { background: var(--ok); box-shadow: 0 0 8px rgba(34, 197, 94, .5); }
.progress-circle.incorrect { background: var(--bad); box-shadow: 0 0 8px rgba(239, 68, 68, .5); }

/* ---------- Savol ---------- */
.word-container, .question-container {
  order: 5; padding: clamp(18px, 3.5vw, 28px); border-radius: 18px;
  font-size: clamp(1.15rem, 2.8vw, 1.6rem); font-weight: 700; line-height: 1.45; overflow-wrap: anywhere;
  background: linear-gradient(135deg, rgba(99, 102, 241, .22), rgba(139, 92, 246, .12));
  border: 1px solid rgba(129, 140, 248, .35);
  animation: quizIn .3s ease-out;
}
.word-container:empty, .question-container:empty { display: none; }
.word-container.incorrect, .question-container.incorrect {
  background: linear-gradient(135deg, rgba(239, 68, 68, .22), rgba(239, 68, 68, .08)); border-color: rgba(239, 68, 68, .5);
}
.word-container code, .quiz-review code {
  font-family: var(--mono); font-size: .9em; padding: 2px 8px; border-radius: 6px; background: rgba(0, 0, 0, .3);
}

/* ---------- Javob variantlari ---------- */
.options-container { order: 6; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.options-container:empty { display: none; }
.option-btn {
  position: relative; min-height: 56px; padding: 14px 16px 14px 52px; border-radius: 14px; cursor: pointer;
  font: 600 1rem 'Inter', system-ui, sans-serif; color: var(--text); text-align: left; line-height: 1.4; overflow-wrap: anywhere;
  background: var(--surface); border: 1px solid var(--border);
  transition: transform .15s, border-color .15s, background .15s;
}
.option-btn::before {
  content: attr(data-key); position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px;
  font: 700 .8rem var(--mono); color: var(--accent);
  background: rgba(255, 255, 255, .06); border: 1px solid var(--border); border-bottom-width: 2px;
}
.option-btn:hover:not(:disabled) { transform: translateY(-2px); border-color: rgba(129, 140, 248, .7); background: rgba(99, 102, 241, .14); }
.option-btn:disabled { cursor: default; opacity: .55; }
.option-btn.correct { opacity: 1; background: rgba(34, 197, 94, .18); border-color: rgba(34, 197, 94, .7); color: #dcfce7; }
.option-btn.correct::before { content: '\2713'; color: #22c55e; border-color: rgba(34, 197, 94, .5); }
.option-btn.incorrect { opacity: 1; background: rgba(239, 68, 68, .16); border-color: rgba(239, 68, 68, .7); color: #fee2e2; animation: shake .25s; }
.option-btn.incorrect::before { content: '\2715'; color: #ef4444; border-color: rgba(239, 68, 68, .5); }
.code-font .option-btn { font-family: var(--mono); font-size: .95rem; }

/* ---------- Tarjima: javob kiritish ---------- */
.input-container { order: 6; display: flex; gap: 10px; width: 100%; }
.game-container:has(.difficulty-modal.show) .input-container,
.game-container:has(#gameOverModal.show) .input-container { display: none; }
.answer-input {
  flex: 1; min-width: 0; padding: 14px 18px; border-radius: 14px; outline: none;
  border: 2px solid var(--border); background: rgba(0, 0, 0, .35); color: var(--text);
  font: 600 1.1rem 'Inter', system-ui, sans-serif; transition: border-color .2s, box-shadow .2s;
}
.answer-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99, 102, 241, .2); }
.answer-input.correct { border-color: var(--ok); box-shadow: 0 0 0 4px rgba(34, 197, 94, .2); }
.answer-input.incorrect { border-color: var(--bad); box-shadow: 0 0 0 4px rgba(239, 68, 68, .2); animation: shake .25s; }

/* ---------- Tugmalar ---------- */
.submit-btn, #restartButton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border: 0; border-radius: 14px; cursor: pointer; white-space: nowrap;
  font: 700 1rem 'Inter', system-ui, sans-serif; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 8px 22px rgba(99, 102, 241, .35); transition: transform .15s, box-shadow .15s;
}
.submit-btn:hover, #restartButton:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(99, 102, 241, .5); }

/* ---------- Natija ---------- */
#gameOverModal { order: 7; display: none; animation: quizIn .35s ease-out; }
#gameOverModal.show { display: block; }
#gameOverText {
  margin-bottom: 18px; font-size: clamp(1.05rem, 2.6vw, 1.3rem); font-weight: 700; line-height: 1.5;
  white-space: pre-line; color: var(--text);
}
.quiz-review {
  margin-top: 16px; padding: 16px 18px; border-radius: 16px; text-align: left; white-space: normal;
  font-size: .95rem; font-weight: 500; line-height: 1.5;
  background: rgba(0, 0, 0, .22); border: 1px solid var(--border);
  max-height: 46vh; overflow: auto;
}
.quiz-review > p { font-weight: 700; }
.quiz-review h3 { margin: 12px 0 8px; font-size: 1rem; color: var(--accent); }
.quiz-review ol { padding-left: 22px; }
.quiz-review li { margin-bottom: 10px; }
.quiz-review .ok { color: #4ade80; }
.quiz-review .bad { color: #f87171; }

/* ---------- Footer ---------- */
footer.footer { position: static !important; width: 100%; text-align: center; }
footer.footer a { margin: 0 8px; text-decoration: none; }

@keyframes quizIn { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  .difficulty-modal, .word-container, .question-container, #gameOverModal { animation: none; }
}

@media (max-width: 600px) {
  .game-container { width: calc(100% - 20px); border-radius: 20px; gap: 14px; }
  .options-container { grid-template-columns: 1fr; gap: 10px; }
  .option-btn { min-height: 50px; padding: 12px 14px 12px 48px; }
  .input-container { flex-direction: column; }
  .submit-btn { width: 100%; }
  .score-board > span { padding: 6px 12px; }
}
