*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d2018;
  --bg2: #163325;
  --orange: #f4820a;
  --orange-light: #ffb347;
  --green: #2ecc71;
  --red: #e74c3c;
  --white: #ffffff;
  --gray: #7a9080;
  --card: rgba(255, 255, 255, 0.06);
  --radius: 14px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--white);
}

/* ── Screens ── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  overflow-y: auto;
}

.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ── Start Screen ── */
#screen-start {
  justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #1f4a30 0%, var(--bg) 70%);
}

.start-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  text-align: center;
  padding: 40px 24px;
}

.logo {
  font-size: 5.5rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-12px) rotate(5deg); }
}

.start-content h1 {
  font-size: 3.2rem;
  font-weight: 900;
  color: var(--orange);
  letter-spacing: -1px;
  text-shadow: 0 0 40px rgba(244, 130, 10, 0.4);
}

.start-subtitle {
  color: var(--gray);
  font-size: 1.05rem;
}

/* ── Buttons ── */
.btn {
  padding: 18px 52px;
  border: none;
  border-radius: 50px;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.btn:active { transform: scale(0.95) !important; }

.btn-primary {
  background: var(--orange);
  color: var(--white);
  box-shadow: 0 8px 28px rgba(244, 130, 10, 0.45);
}

.btn-primary:hover {
  background: var(--orange-light);
  transform: translateY(-3px);
  box-shadow: 0 14px 36px rgba(244, 130, 10, 0.5);
}

/* ── Question Screen ── */
#screen-question {
  justify-content: flex-start;
  padding: 0 0 16px;
}

.question-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.progress {
  font-size: 0.95rem;
  color: var(--gray);
}

.progress .q-num {
  color: var(--orange);
  font-weight: 800;
  font-size: 1.25rem;
}

.score-display {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--orange);
}

/* ── Timer ── */
.timer-container {
  position: relative;
  width: 88px;
  height: 88px;
  margin: 14px auto 10px;
  flex-shrink: 0;
}

.timer-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 7;
}

.timer-fg {
  fill: none;
  stroke: var(--orange);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 339.29;
  stroke-dashoffset: 0;
}

.timer-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.65rem;
  font-weight: 900;
  color: var(--orange);
}

/* ── Question content ── */
.question-content {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 18px;
  text-align: center;
}

.question-image-container {
  display: flex;
  justify-content: center;
  margin: 10px auto 14px;
}

.question-image-container img {
  max-width: 260px;
  max-height: 180px;
  object-fit: contain;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: rgba(255,255,255,0.05);
}

#question-text {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.45;
  margin-bottom: 16px;
}

/* ── Options ── */
.options-container {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 16px;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

/* 3 or fewer text options → single column */
.options-container[data-type="text"][data-count="2"],
.options-container[data-type="text"][data-count="3"] {
  grid-template-columns: 1fr;
  max-width: 520px;
}

.option-btn {
  background: var(--card);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  color: var(--white);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
  min-height: 58px;
  line-height: 1.3;
}

.option-btn:hover:not(:disabled) {
  background: rgba(244, 130, 10, 0.14);
  border-color: rgba(244, 130, 10, 0.6);
  transform: translateY(-2px);
}

.option-btn:active:not(:disabled) { transform: translateY(0); }

.option-btn.correct {
  background: rgba(46, 204, 113, 0.22);
  border-color: var(--green);
  animation: pop 0.35s ease;
}

.option-btn.wrong {
  background: rgba(231, 76, 60, 0.22);
  border-color: var(--red);
  animation: shake 0.4s ease;
}

@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

.option-letter {
  min-width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  flex-shrink: 0;
}

.option-text {
  flex: 1;
}

/* ── Image option buttons ── */
.options-container[data-type="image"] .option-btn {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  min-height: 150px;
  position: relative;
}

.options-container[data-type="image"] .option-btn img {
  width: 100%;
  height: 130px;
  object-fit: contain;
  border-radius: 8px;
}

.option-num {
  position: absolute;
  top: 7px;
  left: 7px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 800;
}

.img-placeholder {
  font-size: 0.72rem;
  color: var(--gray);
  word-break: break-all;
  text-align: center;
  padding: 8px;
}

/* ── Feedback bar ── */
.feedback {
  width: 100%;
  max-width: 820px;
  margin: 12px auto 0;
  padding: 14px 20px;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  animation: slide-up 0.25s ease;
  /* keep inside padding for when inline */
  position: relative;
  left: 0;
}

/* We set margin via the wrapper, but since feedback is inside screen flex, need padding */
.feedback { margin-left: 16px; margin-right: 16px; max-width: calc(820px - 32px); }

.feedback.hidden { display: none; }

.feedback.correct {
  background: rgba(46, 204, 113, 0.18);
  border: 1px solid rgba(46, 204, 113, 0.5);
  color: var(--green);
}

.feedback.wrong {
  background: rgba(231, 76, 60, 0.18);
  border: 1px solid rgba(231, 76, 60, 0.5);
  color: var(--red);
}

.feedback.timeout {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--gray);
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Results Screen ── */
#screen-results {
  justify-content: center;
  background: radial-gradient(ellipse at 50% 50%, #1f4a30 0%, var(--bg) 65%);
}

#fireworks-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.results-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  text-align: center;
  padding: 40px 24px;
}

.results-content h1 {
  font-size: 2.6rem;
  font-weight: 900;
  color: var(--orange);
  text-shadow: 0 0 40px rgba(244, 130, 10, 0.5);
  animation: pop 0.5s ease 0.2s both;
}

.score-circle {
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: rgba(244, 130, 10, 0.1);
  border: 4px solid var(--orange);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 60px rgba(244, 130, 10, 0.3), inset 0 0 30px rgba(244, 130, 10, 0.05);
  animation: pop 0.6s ease 0.4s both;
}

.final-score {
  font-size: 3.2rem;
  font-weight: 900;
  color: var(--orange);
  line-height: 1;
}

.score-label {
  font-size: 0.85rem;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 4px;
}

.stats {
  display: flex;
  gap: 36px;
  animation: slide-up 0.5s ease 0.7s both;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat span {
  font-size: 2.1rem;
  font-weight: 900;
  color: var(--white);
}

.stat label {
  font-size: 0.78rem;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ── Responsive ── */
@media (max-width: 500px) {
  .start-content h1 { font-size: 2.4rem; }
  .logo { font-size: 4rem; }
  #question-text { font-size: 1.15rem; }
  .options-container { grid-template-columns: 1fr 1fr; gap: 8px; }
  .options-container[data-type="image"] .option-btn { min-height: 120px; }
  .options-container[data-type="image"] .option-btn img { height: 95px; }
  .option-btn { padding: 11px 12px; font-size: 0.92rem; }
  .results-content h1 { font-size: 2rem; }
  .score-circle { width: 160px; height: 160px; }
  .final-score { font-size: 2.6rem; }
  .stats { gap: 24px; }
  .stat span { font-size: 1.7rem; }
}
