﻿.quiz-content.gaming-mode {
  --game-score-border: rgba(255, 209, 102, 0.75);
  --game-score-color: #7c2d12;
  --game-score-bg: linear-gradient(135deg, #fff7d6, #fda4af);
  --game-score-shadow: rgba(239, 71, 111, 0.12);
  --game-card-border: rgba(255, 209, 102, 0.7);
  --game-card-shadow: rgba(93, 39, 61, 0.14);
  --game-card-glow-a: rgba(255, 209, 102, 0.34);
  --game-card-glow-b: rgba(56, 189, 248, 0.18);
  --game-mascot-border: rgba(239, 71, 111, 0.16);
  --game-mascot-face: linear-gradient(135deg, #ffd166, #ef476f);
  --game-mascot-shadow: rgba(239, 71, 111, 0.16);
  --game-message-color: #7a2547;
  --game-topic-bg: #fda4af;
  --game-topic-color: #7a2547;
  --game-result-bg: rgba(240, 253, 250, 0.94);
  --game-badge-bg: #fde047;
  --game-badge-color: #7c2d12;
  --game-score-big: #0f766e;
}

.quiz-content.gaming-mode[data-quiz-subject="english"] {
  --game-score-border: rgba(14, 165, 233, 0.45);
  --game-score-color: #0f3a5c;
  --game-score-bg: linear-gradient(135deg, #dff7ff, #bbf7d0);
  --game-score-shadow: rgba(14, 165, 233, 0.15);
  --game-card-border: rgba(14, 165, 233, 0.34);
  --game-card-shadow: rgba(14, 165, 233, 0.14);
  --game-card-glow-a: rgba(14, 165, 233, 0.22);
  --game-card-glow-b: rgba(34, 197, 94, 0.18);
  --game-mascot-border: rgba(14, 165, 233, 0.18);
  --game-mascot-face: linear-gradient(135deg, #0ea5e9, #22c55e);
  --game-mascot-shadow: rgba(14, 165, 233, 0.18);
  --game-message-color: #075985;
  --game-topic-bg: #e0f2fe;
  --game-topic-color: #075985;
  --game-score-big: #0284c7;
}

.quiz-content.gaming-mode[data-quiz-subject="sains"] {
  --game-score-border: rgba(20, 184, 166, 0.45);
  --game-score-color: #064e3b;
  --game-score-bg: linear-gradient(135deg, #bbf7d0, #99f6e4);
  --game-score-shadow: rgba(20, 184, 166, 0.16);
  --game-card-border: rgba(20, 184, 166, 0.36);
  --game-card-shadow: rgba(15, 118, 110, 0.14);
  --game-card-glow-a: rgba(34, 197, 94, 0.2);
  --game-card-glow-b: rgba(20, 184, 166, 0.2);
  --game-mascot-border: rgba(20, 184, 166, 0.2);
  --game-mascot-face: linear-gradient(135deg, #22c55e, #14b8a6);
  --game-mascot-shadow: rgba(20, 184, 166, 0.18);
  --game-message-color: #065f46;
  --game-topic-bg: #d1fae5;
  --game-topic-color: #065f46;
  --game-score-big: #0f766e;
}

.quiz-content.gaming-mode[data-quiz-subject="matematik"] {
  --game-score-border: rgba(250, 204, 21, 0.62);
  --game-score-color: #713f12;
  --game-score-bg: linear-gradient(135deg, #fef9c3, #bfdbfe);
  --game-score-shadow: rgba(37, 99, 235, 0.14);
  --game-card-border: rgba(37, 99, 235, 0.28);
  --game-card-shadow: rgba(37, 99, 235, 0.14);
  --game-card-glow-a: rgba(250, 204, 21, 0.26);
  --game-card-glow-b: rgba(37, 99, 235, 0.18);
  --game-mascot-border: rgba(37, 99, 235, 0.18);
  --game-mascot-face: linear-gradient(135deg, #eab308, #2563eb);
  --game-mascot-shadow: rgba(37, 99, 235, 0.16);
  --game-message-color: #1e3a8a;
  --game-topic-bg: #bfdbfe;
  --game-topic-color: #1e3a8a;
  --game-score-big: #2563eb;
}

.quiz-content.gaming-mode[data-quiz-subject="islam"] {
  --game-score-border: rgba(245, 158, 11, 0.55);
  --game-score-color: #713f12;
  --game-score-bg: linear-gradient(135deg, #fde047, #bbf7d0);
  --game-score-shadow: rgba(4, 120, 87, 0.14);
  --game-card-border: rgba(4, 120, 87, 0.28);
  --game-card-shadow: rgba(4, 120, 87, 0.14);
  --game-card-glow-a: rgba(245, 158, 11, 0.26);
  --game-card-glow-b: rgba(4, 120, 87, 0.18);
  --game-mascot-border: rgba(4, 120, 87, 0.18);
  --game-mascot-face: linear-gradient(135deg, #f59e0b, #047857);
  --game-mascot-shadow: rgba(4, 120, 87, 0.16);
  --game-message-color: #064e3b;
  --game-topic-bg: #ecfdf5;
  --game-topic-color: #064e3b;
  --game-score-big: #047857;
}

.quiz-content.gaming-mode[data-quiz-subject="sejarah"] {
  --game-score-border: rgba(234, 179, 8, 0.52);
  --game-score-color: #3730a3;
  --game-score-bg: linear-gradient(135deg, #fde047, #e0e7ff);
  --game-score-shadow: rgba(67, 56, 202, 0.14);
  --game-card-border: rgba(67, 56, 202, 0.28);
  --game-card-shadow: rgba(67, 56, 202, 0.14);
  --game-card-glow-a: rgba(234, 179, 8, 0.24);
  --game-card-glow-b: rgba(99, 102, 241, 0.18);
  --game-mascot-border: rgba(67, 56, 202, 0.18);
  --game-mascot-face: linear-gradient(135deg, #eab308, #4f46e5);
  --game-mascot-shadow: rgba(67, 56, 202, 0.16);
  --game-message-color: #3730a3;
  --game-topic-bg: #e0e7ff;
  --game-topic-color: #3730a3;
  --game-score-big: #4f46e5;
}

.quiz-content.gaming-mode[data-quiz-subject="rbt"] {
  --game-score-border: rgba(249, 115, 22, 0.45);
  --game-score-color: #0f766e;
  --game-score-bg: linear-gradient(135deg, #99f6e4, #fed7aa);
  --game-score-shadow: rgba(15, 118, 110, 0.14);
  --game-card-border: rgba(15, 118, 110, 0.30);
  --game-card-shadow: rgba(15, 118, 110, 0.14);
  --game-card-glow-a: rgba(249, 115, 22, 0.20);
  --game-card-glow-b: rgba(20, 184, 166, 0.20);
  --game-mascot-border: rgba(15, 118, 110, 0.18);
  --game-mascot-face: linear-gradient(135deg, #fb923c, #14b8a6);
  --game-mascot-shadow: rgba(15, 118, 110, 0.16);
  --game-message-color: #115e59;
  --game-topic-bg: #99f6e4;
  --game-topic-color: #115e59;
  --game-score-big: #0f766e;
}

.quiz-content.gaming-mode[data-quiz-subject="arab"] {
  --game-score-border: rgba(217, 119, 6, 0.48);
  --game-score-color: #713f12;
  --game-score-bg: linear-gradient(135deg, #fef3c7, #ffedd5);
  --game-score-shadow: rgba(180, 83, 9, 0.14);
  --game-card-border: rgba(180, 83, 9, 0.30);
  --game-card-shadow: rgba(180, 83, 9, 0.14);
  --game-card-glow-a: rgba(245, 158, 11, 0.22);
  --game-card-glow-b: rgba(20, 184, 166, 0.16);
  --game-mascot-border: rgba(180, 83, 9, 0.18);
  --game-mascot-face: linear-gradient(135deg, #f59e0b, #0f766e);
  --game-mascot-shadow: rgba(180, 83, 9, 0.16);
  --game-message-color: #713f12;
  --game-topic-bg: #fef3c7;
  --game-topic-color: #713f12;
  --game-score-big: #b45309;
}

.quiz-content.gaming-mode .score-pill {
  position: relative;
  border-color: var(--game-score-border);
  color: var(--game-score-color);
  background: var(--game-score-bg);
  box-shadow: 0 8px 18px var(--game-score-shadow);
}

.quiz-content.gaming-mode .score-pill.score-pop {
  animation: scorePop 320ms ease;
}

@keyframes scorePop {
  0% { transform: scale(1); }
  45% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

.quiz-content.gaming-mode .question-card {
  position: relative;
  overflow: hidden;
  border: 2px solid var(--game-card-border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 249, 252, 0.96)),
    radial-gradient(circle at 94% 12%, var(--game-card-glow-a), transparent 24%),
    radial-gradient(circle at 8% 88%, var(--game-card-glow-b), transparent 28%);
  box-shadow: 0 18px 40px var(--game-card-shadow);
}

.quiz-content.gaming-mode .question-card.question-enter {
  animation: questionEnter 260ms ease;
}

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

.quiz-mascot {
  display: none;
}

.quiz-content.gaming-mode .quiz-mascot {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  padding: 10px;
  border: 1px solid var(--game-mascot-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
}

.mascot-face {
  display: grid;
  width: 52px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 16px;
  background: var(--game-mascot-face);
  font-size: 1.85rem;
  box-shadow: 0 10px 20px var(--game-mascot-shadow);
}

.mascot-message {
  margin: 0;
  color: var(--game-message-color);
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1.35;
}

.quiz-mascot.is-happy .mascot-face {
  animation: mascotBounce 420ms ease;
}

.quiz-mascot.is-try .mascot-face {
  animation: mascotNudge 420ms ease;
}

@keyframes mascotBounce {
  0%, 100% { transform: translateY(0); }
  35% { transform: translateY(-6px) rotate(-4deg); }
  70% { transform: translateY(2px) rotate(3deg); }
}

@keyframes mascotNudge {
  0%, 100% { transform: rotate(0); }
  35% { transform: rotate(-6deg); }
  70% { transform: rotate(5deg); }
}

.quiz-content.gaming-mode .topic {
  color: var(--game-topic-color);
  background: var(--game-topic-bg);
}

/* Keep passages, tables and data visuals readable on every subject theme. */
.quiz-content .source-card,
.quiz-content .passage-card,
.quiz-content .visual-card,
.quiz-content .data-visual,
.quiz-content .question-visual,
.quiz-content .math-visual-card,
.quiz-content .mini-visual {
  color: #17324d;
  background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
}

.quiz-content .source-card .source-label,
.quiz-content .passage-card .passage-label,
.quiz-content .visual-card h3,
.quiz-content .data-visual h3,
.quiz-content .question-visual h3 {
  color: #075985;
}

.quiz-content .science-table,
.quiz-content .data-table,
.quiz-content .source-table,
.quiz-content .coord-table {
  color: #17324d;
  background: #ffffff;
}

.quiz-content .science-table th,
.quiz-content .data-table th,
.quiz-content .source-table th,
.quiz-content .coord-table th {
  color: #0f4c81;
  background: #e0f2fe;
}

.quiz-content .science-table td,
.quiz-content .data-table td,
.quiz-content .source-table td,
.quiz-content .coord-table td {
  color: #17324d;
  background: #ffffff;
}

.quiz-content.gaming-mode .question,
.quiz-content.gaming-mode .question-text,
.quiz-content.gaming-mode #questionText {
  position: relative;
}

.quiz-content.gaming-mode .question[data-question-icon]::before,
.quiz-content.gaming-mode .question-text[data-question-icon]::before,
.quiz-content.gaming-mode #questionText[data-question-icon]::before {
  content: attr(data-question-icon);
  display: inline-block;
  margin: 0 8px 0 0;
  font-size: 1.18em;
  line-height: 1;
  vertical-align: -0.08em;
}

.quiz-content.gaming-mode .answer-btn {
  position: relative;
  overflow: hidden;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.quiz-content.gaming-mode .answer-btn.correct,
.quiz-content.gaming-mode .answer-btn.is-correct {
  border-color: rgba(22, 163, 74, 0.55);
  background:
    linear-gradient(135deg, rgba(220, 252, 231, 0.96), rgba(187, 247, 208, 0.96));
  animation: answerCorrectPop 560ms cubic-bezier(0.2, 1.35, 0.35, 1), answerSuccessRing 920ms ease-out;
  box-shadow:
    0 0 0 4px rgba(15, 143, 95, 0.14),
    0 0 24px rgba(34, 197, 94, 0.42);
}

.quiz-content.gaming-mode .answer-btn.wrong,
.quiz-content.gaming-mode .answer-btn.is-wrong {
  border-color: rgba(201, 74, 58, 0.45);
  color: #7a241b;
  background: #fff0ed;
  animation: answerWrongStrong 420ms ease;
  box-shadow: 0 0 0 4px rgba(201, 74, 58, 0.12);
}

.answer-result-emoji {
  float: right;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-left: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.1);
  font-size: 1.18rem;
  line-height: 1;
  animation: emojiPop 420ms cubic-bezier(0.2, 1.35, 0.35, 1);
}

.mega-confetti {
  position: fixed;
  z-index: 9999;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  pointer-events: none;
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.88),
    0 10px 18px rgba(15, 23, 42, 0.14);
  animation: megaConfettiBlast 1050ms cubic-bezier(0.16, 0.9, 0.25, 1) forwards;
}

.mega-confetti.is-star {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  clip-path: polygon(50% 0%, 61% 34%, 98% 35%, 68% 56%, 79% 91%, 50% 69%, 21% 91%, 32% 56%, 2% 35%, 39% 34%);
}

.mega-confetti.is-spark {
  width: 12px;
  height: 30px;
  border-radius: 999px;
  transform-origin: center;
}

.mega-confetti.is-word {
  width: auto;
  height: auto;
  min-width: 108px;
  padding: 12px 18px;
  border: 4px solid rgba(255, 255, 255, 0.98);
  border-radius: 999px;
  color: #ffffff;
  background: linear-gradient(135deg, #15803d, #16a34a 42%, #0ea5e9);
  box-shadow:
    0 18px 34px rgba(15, 118, 110, 0.28),
    0 0 0 7px rgba(187, 247, 208, 0.42),
    0 0 28px rgba(34, 197, 94, 0.48);
  font-size: 1.28rem;
  font-weight: 950;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  animation: successWordBlast 1120ms cubic-bezier(0.18, 1.2, 0.25, 1) forwards;
}

@keyframes answerCorrectPop {
  0% { transform: scale(1); }
  34% { transform: scale(1.035) translateY(-2px); }
  68% { transform: scale(0.992) translateY(0); }
  100% { transform: scale(1); }
}

@keyframes answerSuccessRing {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.38), 0 0 0 4px rgba(15, 143, 95, 0.14), 0 0 24px rgba(34, 197, 94, 0.42); }
  72% { box-shadow: 0 0 0 16px rgba(34, 197, 94, 0), 0 0 0 4px rgba(15, 143, 95, 0.14), 0 0 28px rgba(34, 197, 94, 0.5); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0), 0 0 0 4px rgba(15, 143, 95, 0.14), 0 0 24px rgba(34, 197, 94, 0.42); }
}

@keyframes answerWrongStrong {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px) rotate(-0.6deg); }
  30% { transform: translateX(8px) rotate(0.6deg); }
  45% { transform: translateX(-6px) rotate(-0.4deg); }
  60% { transform: translateX(6px) rotate(0.4deg); }
  75% { transform: translateX(-3px); }
}

@keyframes emojiPop {
  0% { opacity: 0; transform: scale(0.45) rotate(-12deg); }
  72% { opacity: 1; transform: scale(1.14) rotate(6deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

@keyframes megaConfettiBlast {
  0% {
    opacity: 0;
    transform: translate(0, 0) rotate(0deg) scale(0.35);
  }
  16% {
    opacity: 1;
    transform: translate(calc(var(--confetti-x) * 0.2), calc(var(--confetti-y) * 0.2)) rotate(70deg) scale(1.35);
  }
  72% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(var(--confetti-x), var(--confetti-y)) rotate(var(--confetti-rotate)) scale(0.58);
  }
}

@keyframes successWordBlast {
  0% {
    opacity: 0;
    transform: translate(0, 0) rotate(0deg) scale(0.35);
  }
  18% {
    opacity: 1;
    transform: translate(calc(var(--confetti-x) * 0.16), calc(var(--confetti-y) * 0.16)) rotate(0deg) scale(1.18);
  }
  70% {
    opacity: 1;
    transform: translate(calc(var(--confetti-x) * 0.78), calc(var(--confetti-y) * 0.78)) rotate(var(--confetti-rotate)) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--confetti-x), var(--confetti-y)) rotate(var(--confetti-rotate)) scale(0.82);
  }
}

.quiz-content.gaming-mode .result-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(20, 184, 166, 0.22);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), var(--game-result-bg)),
    radial-gradient(circle at 18% 10%, var(--game-card-glow-a), transparent 28%);
  box-shadow: 0 20px 42px rgba(15, 23, 42, 0.10);
}

.quiz-content.gaming-mode .result-panel.is-visible {
  animation: questionEnter 360ms ease;
}

.quiz-content.gaming-mode .result-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  margin-bottom: 12px;
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--game-badge-color);
  background: var(--game-badge-bg);
  font-weight: 900;
}

.quiz-content.gaming-mode .big-score {
  color: var(--game-score-big);
  text-shadow: 0 8px 18px var(--game-mascot-shadow);
}
