/* =========================================================
  MoleLab Interaktif - assets/css/game.css
  ---------------------------------------------------------
  Tampilan dan animasi Mode Game:
  - menu level
  - kartu level
  - status bar game
  - visual soal
  - panel tantangan
  - pilihan jawaban
  - input angka
  - feedback benar/salah
  - hasil akhir
  - sistem bintang
========================================================= */

/* =========================================================
  Game Menu
========================================================= */

.game-menu {
  position: relative;
  overflow: hidden;
}

.game-menu::before,
.game-menu::after {
  content: "";
  position: absolute;
  pointer-events: none;
  border-radius: var(--radius-full);
  z-index: 0;
}

.game-menu::before {
  width: 460px;
  height: 460px;
  left: -170px;
  top: -130px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.15), transparent 70%);
}

.game-menu::after {
  width: 380px;
  height: 380px;
  right: -150px;
  bottom: -150px;
  background: radial-gradient(circle, rgba(250, 204, 21, 0.18), transparent 72%);
}

.game-menu-content {
  position: relative;
  z-index: 1;
}

.game-menu-content h2 {
  color: var(--text-main);
  font-size: clamp(var(--text-4xl), 6vw, 4.8rem);
  letter-spacing: -0.075em;
}

.game-menu-content .section-description {
  color: var(--text-muted);
  font-size: var(--text-lg);
}

.level-card {
  min-height: 292px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5);
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: var(--radius-3xl);
  color: var(--text-main);
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.78), transparent 36%),
    linear-gradient(135deg, #fef3c7 0%, #dbeafe 54%, #f5d0fe 100%);
  box-shadow: var(--shadow-lg);
  text-align: center;
  position: relative;
  overflow: hidden;
  transition:
    transform var(--duration-slow) var(--ease-out),
    box-shadow var(--duration-slow) var(--ease-out),
    filter var(--duration-slow) var(--ease-out),
    border-color var(--duration-slow) var(--ease-out);
}

.level-card::before {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  top: -78px;
  right: -78px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.35);
}

.level-card::after {
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  left: -50px;
  bottom: -50px;
  border-radius: var(--radius-full);
  background: rgba(37, 99, 235, 0.12);
}

.level-card:hover,
.level-card:focus-visible {
  transform: translateY(-8px) scale(1.01);
  border-color: rgba(37, 99, 235, 0.26);
  box-shadow: var(--shadow-xl);
  filter: saturate(1.08);
}

.level-card > * {
  position: relative;
  z-index: 1;
}

.level-card strong {
  color: var(--text-main);
  font-size: var(--text-3xl);
  line-height: var(--leading-tight);
  letter-spacing: -0.05em;
}

.level-card span:not(.level-preview):not(.level-stars) {
  color: var(--color-slate-700);
  font-weight: 850;
}

.level-preview {
  width: 128px;
  height: 128px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-3xl);
  color: var(--primary);
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow:
    inset 0 0 0 1px rgba(15, 23, 42, 0.08),
    var(--shadow-md);
  font-family: var(--font-mono);
  font-size: var(--text-4xl);
  font-weight: 950;
  letter-spacing: -0.08em;
  line-height: 1;
}

.level-card:nth-child(2) .level-preview {
  color: var(--success);
}

.level-card:nth-child(3) .level-preview {
  color: var(--accent-purple);
}

.level-card:nth-child(4) .level-preview,
.level-card:nth-child(5) .level-preview {
  color: var(--accent-orange);
}

.level-stars {
  width: 100%;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-xl);
  color: var(--color-slate-300);
  background: rgba(255, 255, 255, 0.82);
  font-size: var(--text-xl);
  letter-spacing: 0.08em;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06);
}

.level-stars .star-earned,
.level-stars.is-earned,
#gameStarValue .star-earned {
  color: var(--warning);
  text-shadow: 0 2px 8px rgba(250, 204, 21, 0.4);
}

.level-stars .star-empty,
#gameStarValue .star-empty {
  color: var(--color-slate-300);
}

/* =========================================================
  Game Play Status Bar
========================================================= */

.game-play {
  animation: gamePlayEnter var(--duration-slow) var(--ease-out);
}

@keyframes gamePlayEnter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.game-status-bar {
  position: relative;
  overflow: hidden;
}

.game-status-bar::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 12% 50%, rgba(255, 255, 255, 0.24), transparent 28%),
    radial-gradient(circle at 80% 20%, rgba(250, 204, 21, 0.24), transparent 30%);
  pointer-events: none;
}

.game-status-bar > * {
  position: relative;
  z-index: 1;
}

#gameStarValue {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  color: var(--warning-soft);
  letter-spacing: 0.06em;
}

#gameStartOverButton {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: none;
}

#gameStartOverButton:hover {
  background: var(--color-white);
}

/* =========================================================
  Game Board
========================================================= */

.game-board {
  position: relative;
  overflow: hidden;
}

.game-board::before,
.game-board::after {
  content: "";
  position: absolute;
  pointer-events: none;
  border-radius: var(--radius-full);
}

.game-board::before {
  width: 420px;
  height: 420px;
  left: -180px;
  top: -140px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.12), transparent 68%);
}

.game-board::after {
  width: 360px;
  height: 360px;
  right: -150px;
  bottom: -150px;
  background: radial-gradient(circle, rgba(250, 204, 21, 0.18), transparent 70%);
}

.game-visual-panel,
.game-challenge-panel {
  z-index: 1;
}

.game-visual-panel::after {
  content: "Visual Soal";
  position: absolute;
  left: 50%;
  bottom: var(--space-4);
  transform: translateX(-50%);
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-full);
  color: var(--primary);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow-sm);
  font-size: var(--text-xs);
  font-weight: 950;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.game-visual-area {
  position: relative;
  overflow: hidden;
}

.game-visual-area::before {
  content: "";
  position: absolute;
  width: 260px;
  height: 260px;
  border-radius: var(--radius-full);
  background: radial-gradient(circle, rgba(96, 165, 250, 0.14), transparent 70%);
}

/* =========================================================
  Challenge Area
========================================================= */

.game-challenge-content {
  width: min(680px, 100%);
  display: grid;
  justify-items: center;
  gap: var(--space-5);
  animation: challengeFadeIn var(--duration-slow) var(--ease-out);
}

@keyframes challengeFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.challenge-kicker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-full);
  color: var(--primary);
  background: var(--color-blue-50);
  border: 1px solid var(--color-blue-100);
  font-size: var(--text-xs);
  font-weight: 950;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.challenge-title {
  color: var(--text-main);
  font-size: clamp(var(--text-3xl), 5vw, 3.4rem);
  font-weight: 900;
  line-height: var(--leading-tight);
  letter-spacing: -0.06em;
}

.challenge-description {
  max-width: 52ch;
  color: var(--text-muted);
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
}

.challenge-formula {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  min-height: 72px;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-2xl);
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.86);
  border: 2px solid rgba(15, 23, 42, 0.72);
  box-shadow: var(--shadow-md);
  font-family: var(--font-mono);
  font-size: var(--text-4xl);
  font-weight: 950;
  line-height: 1;
}

.challenge-formula sub {
  font-size: 0.56em;
}

.challenge-value-card {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  padding: var(--space-5);
  border-radius: var(--radius-2xl);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-md);
}

.challenge-value-card span {
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.challenge-value-card strong {
  color: var(--primary);
  font-size: var(--text-5xl);
  line-height: 1;
  letter-spacing: -0.07em;
}

/* =========================================================
  Answer Controls
========================================================= */

.answer-grid {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
}

.answer-button {
  min-width: 122px;
  min-height: 58px;
  padding: 0.75rem var(--space-5);
  border-radius: var(--radius-xl);
  color: var(--text-main);
  background: var(--color-white);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
  font-size: var(--text-xl);
  font-weight: 950;
  transition:
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.answer-button:hover,
.answer-button:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.28);
  background: var(--color-blue-50);
  box-shadow: var(--shadow-md);
}

.answer-button.is-correct {
  color: var(--color-white) !important;
  background: var(--success) !important;
  border-color: var(--success) !important;
  box-shadow: 0 14px 30px rgba(22, 163, 74, 0.28) !important;
}

.answer-button.is-wrong {
  color: var(--color-white) !important;
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  box-shadow: 0 14px 30px rgba(220, 38, 38, 0.24) !important;
}

.number-answer-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.number-answer-row input {
  width: 150px;
  height: 64px;
  border: 2px solid var(--text-main);
  border-radius: var(--radius-xl);
  background: var(--color-white);
  box-shadow: var(--shadow-sm);
  font-size: var(--text-3xl);
  font-weight: 950;
  text-align: center;
}

.number-answer-row input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.16), var(--shadow-sm);
}

.number-answer-row .btn {
  min-height: 64px;
  padding-inline: var(--space-6);
  font-size: var(--text-lg);
}

.game-feedback {
  width: min(560px, 100%);
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  border-radius: var(--radius-xl);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
  font-size: var(--text-base);
  font-weight: 850;
  line-height: var(--leading-normal);
}

.game-feedback.is-correct {
  color: var(--color-green-700);
  background: var(--success-soft);
  border-color: rgba(22, 163, 74, 0.24);
}

.game-feedback.is-wrong {
  color: var(--color-red-700);
  background: var(--danger-soft);
  border-color: rgba(220, 38, 38, 0.24);
}

.game-feedback.is-finished {
  color: var(--primary);
  background: var(--color-blue-50);
  border-color: rgba(37, 99, 235, 0.2);
}

/* =========================================================
  Game Visual Objects
========================================================= */

.game-mini-molecule {
  width: 340px;
  height: 260px;
  position: relative;
  display: block;
}

.game-mini-atom {
  position: absolute;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  color: var(--color-white);
  border: 3px solid rgba(255, 255, 255, 0.74);
  box-shadow:
    inset -8px -8px 12px rgba(0, 0, 0, 0.24),
    inset 7px 7px 12px rgba(255, 255, 255, 0.28),
    var(--shadow-md);
  font-size: var(--text-xl);
  font-weight: 950;
  transform: translate(-50%, -50%);
  animation: atomEnter 520ms var(--ease-bounce) both;
}

.game-mini-atom.is-h {
  width: 62px;
  height: 62px;
  background: radial-gradient(circle at 32% 28%, #dbeafe, var(--atom-h) 50%, #1d4ed8 100%);
}

.game-mini-atom.is-o {
  width: 86px;
  height: 86px;
  background: radial-gradient(circle at 32% 28%, #fecaca, var(--atom-o) 50%, #991b1b 100%);
}

.game-mini-atom.is-c {
  width: 84px;
  height: 84px;
  background: radial-gradient(circle at 32% 28%, #d1d5db, var(--atom-c) 54%, #020617 100%);
}

.game-mini-bond {
  position: absolute;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--molecule-bond);
  transform-origin: left center;
}

.game-scale-visual,
.game-particle-visual,
.game-gas-visual,
.game-beaker-visual,
.game-percent-visual {
  width: 320px;
  height: 320px;
  position: relative;
  display: grid;
  place-items: center;
}

.game-particle-pack {
  width: 180px;
  height: 150px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-3xl);
  color: var(--color-white);
  background: var(--gradient-warning);
  box-shadow: var(--shadow-xl), var(--shadow-glow-yellow);
  font-size: var(--text-3xl);
  font-weight: 950;
}

.game-gas-tube {
  width: 150px;
  height: 250px;
  position: relative;
  overflow: hidden;
  border: 5px solid rgba(30, 64, 175, 0.86);
  border-radius: 32px 32px 46px 46px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: var(--shadow-lg), var(--shadow-glow-blue);
}

.game-gas-tube span {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 58%;
  background: linear-gradient(180deg, rgba(96, 165, 250, 0.5), rgba(37, 99, 235, 0.72));
  animation: gasPulse 3.2s ease-in-out infinite;
}

.game-beaker-mini {
  width: 170px;
  height: 230px;
  position: relative;
  overflow: hidden;
  border: 5px solid rgba(15, 23, 42, 0.74);
  border-top: 0;
  border-radius: 0 0 42px 42px;
  background: rgba(255, 255, 255, 0.48);
  box-shadow: var(--shadow-lg), var(--shadow-glow-blue);
}

.game-beaker-mini span {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 56%;
  background: linear-gradient(180deg, var(--solution-cyan), var(--solution-blue));
  animation: solutionWave 3.4s ease-in-out infinite;
}

.game-percent-ring {
  width: 190px;
  height: 190px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: conic-gradient(var(--primary) 0 35%, var(--accent-purple) 35% 72%, var(--warning) 72% 100%);
  box-shadow: var(--shadow-xl), var(--shadow-glow-purple);
}

.game-percent-ring span {
  width: 104px;
  height: 104px;
  display: grid;
  place-items: center;
  border-radius: inherit;
  color: var(--accent-purple);
  background: rgba(255, 255, 255, 0.92);
  font-size: var(--text-4xl);
  font-weight: 950;
}

/* =========================================================
  Final Result
========================================================= */

.game-result-card {
  width: min(620px, 100%);
  display: grid;
  justify-items: center;
  gap: var(--space-5);
  padding: var(--space-8);
  border-radius: var(--radius-3xl);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-xl);
  animation: resultPop 620ms var(--ease-bounce) both;
}

@keyframes resultPop {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.86);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.game-result-icon {
  width: 104px;
  height: 104px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  color: var(--color-white);
  background: var(--gradient-success);
  box-shadow: var(--shadow-md), 0 0 34px rgba(22, 163, 74, 0.26);
  font-size: var(--text-5xl);
  line-height: 1;
}

.game-result-title {
  color: var(--text-main);
  font-size: clamp(var(--text-3xl), 5vw, var(--text-5xl));
  font-weight: 950;
  letter-spacing: -0.06em;
}

.game-result-score {
  color: var(--primary);
  font-size: clamp(var(--text-4xl), 7vw, 5rem);
  font-weight: 950;
  line-height: 1;
  letter-spacing: -0.08em;
}

.game-result-message {
  max-width: 46ch;
  color: var(--text-muted);
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
}

.game-result-stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  color: var(--warning);
  font-size: var(--text-4xl);
  letter-spacing: 0.08em;
  text-shadow: 0 3px 12px rgba(250, 204, 21, 0.38);
}

.game-result-stars .star-empty {
  color: var(--color-slate-300);
  text-shadow: none;
}

/* =========================================================
  Game States & Flash Animations
========================================================= */

.game-play.is-answer-locked .answer-button,
.game-play.is-answer-locked .number-answer-row input,
.game-play.is-answer-locked .number-answer-row button {
  pointer-events: none;
}

.game-play.is-correct-flash .game-board {
  animation: correctFlash 520ms ease-out;
}

.game-play.is-wrong-flash .game-board {
  animation: wrongFlash 520ms ease-out;
}

@keyframes correctFlash {
  0%, 100% {
    box-shadow: var(--shadow-lg);
  }
  45% {
    box-shadow: 0 0 0 7px rgba(22, 163, 74, 0.18), var(--shadow-xl);
  }
}

@keyframes wrongFlash {
  0%, 100% {
    box-shadow: var(--shadow-lg);
  }
  45% {
    box-shadow: 0 0 0 7px rgba(220, 38, 38, 0.18), var(--shadow-xl);
  }
}

.answer-button.is-correct::after,
.answer-button.is-wrong::after {
  margin-left: var(--space-2);
  font-weight: 950;
}

.answer-button.is-correct::after {
  content: "✓";
}

.answer-button.is-wrong::after {
  content: "×";
}

/* =========================================================
  Confetti / Reward Effects
========================================================= */

.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 16px;
  border-radius: 3px;
  background: var(--warning);
  animation: confettiFall 1.8s ease-in forwards;
}

.confetti-piece.is-blue { background: var(--primary); }
.confetti-piece.is-green { background: var(--success); }
.confetti-piece.is-purple { background: var(--accent-purple); }
.confetti-piece.is-pink { background: var(--accent-pink); }

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(-20px) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(100vh) rotate(720deg);
  }
}

/* =========================================================
  Responsive Lock Friendly
========================================================= */

@media (max-width: 1120px) {
  .game-board {
    grid-template-columns: 460px minmax(0, 1fr);
  }

  .level-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .level-card {
    min-height: 292px;
  }

  .level-preview {
    width: 128px;
    height: 128px;
  }

  .game-status-bar {
    display: flex;
    text-align: left;
  }

  .game-board {
    grid-template-columns: 460px minmax(0, 1fr);
  }
}

@media (max-width: 520px) {
  .answer-button {
    min-width: 122px;
    min-height: 58px;
  }

  .number-answer-row {
    width: auto;
  }

  .number-answer-row input {
    width: 150px;
  }

  .game-result-card {
    padding: var(--space-8);
  }
}
