/* ============================================================
   MAENLA HTML5 GAME ENGINE - CSS STYLING & CLASSROOM MODE
   ============================================================ */

/* ---------- Game Modal Overlay ---------- */
.game-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(15, 40, 50, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.game-modal-overlay.is-active {
  display: flex;
}

.game-modal-container {
  position: relative;
  width: 100%;
  max-width: 720px;
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  border: 4px solid var(--teal);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalPop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.game-modal-container.class-mode-modal {
  max-width: 1080px;
}

@keyframes modalPop {
  0% { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.game-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
  width: 36px;
  height: 36px;
  background: #ffffff;
  border: 2px solid var(--line);
  border-radius: 50%;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.game-modal-close:hover {
  background: var(--coral);
  border-color: var(--coral);
  color: #fff;
  transform: rotate(90deg);
}

/* ---------- Standalone / In-Modal Engine Wrapper ---------- */
.game-app-wrapper {
  width: 100%;
  background: #f4fafb;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

/* ---------- Top Control Bar ---------- */
.ge-top-bar {
  width: 100%;
  max-width: 600px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.ge-logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--teal);
  letter-spacing: -0.5px;
}

.ge-logo span {
  color: var(--magenta);
}

.ge-progress-wrap {
  flex: 1 1 auto;
  height: 12px;
  background: #e1edf0;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid #d0e4e8;
}

.ge-progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #18849c, #3fa34d);
  border-radius: 10px;
  transition: width 0.3s ease;
}

.ge-score-chip {
  flex: 0 0 auto;
  background: #fff;
  border: 2.5px solid var(--amber);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  padding: 5px 14px;
  border-radius: var(--radius-full);
  box-shadow: 0 2px 0 rgba(232, 144, 26, 0.2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Classroom Mode Toggle Button */
.ge-class-toggle {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  cursor: pointer;
  background: #ffffff;
  color: var(--teal);
  border: 2.5px solid var(--teal);
  box-shadow: 0 2px 0 rgba(24, 132, 156, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.ge-class-toggle svg {
  width: 22px;
  height: 22px;
}

.ge-class-toggle:hover {
  background: var(--teal-light);
}

.ge-class-toggle.is-active {
  background: var(--magenta);
  color: #ffffff;
  border-color: var(--magenta);
  box-shadow: 0 2px 0 rgba(228, 24, 108, 0.3);
}

/* ---------- Game Stage Box ---------- */
.ge-stage {
  width: 100%;
  max-width: 600px;
  background: #ffffff;
  border: 3.5px solid var(--teal);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 0 rgba(24, 132, 156, 0.15);
  display: flex;
  flex-direction: column;
  padding: 20px;
  min-height: 480px;
  transition: max-width var(--transition-normal);
}

.ge-topic-bar {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.ge-instruction {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.15rem, 3.5vw, 1.45rem);
  text-align: center;
  color: var(--teal-deep);
  margin-bottom: 14px;
  line-height: 1.3;
}

/* Audio Player Widget */
.ge-player-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 18px;
}

.ge-btn-listen {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1rem;
  color: #ffffff;
  background: var(--magenta);
  border: 3px solid var(--magenta);
  border-radius: var(--radius-full);
  padding: 8px 22px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(228, 24, 108, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

.ge-btn-listen:hover {
  background: #c8125c;
  border-color: #c8125c;
}

.ge-btn-listen.is-playing {
  background: var(--teal);
  border-color: var(--teal);
}

/* Waveform Animation */
.ge-wave {
  display: inline-flex;
  gap: 3px;
  align-items: flex-end;
  height: 16px;
}

.ge-wave span {
  width: 3.5px;
  background: #ffffff;
  border-radius: 2px;
  height: 5px;
}

.ge-btn-listen.is-playing .ge-wave span {
  animation: waveAnim 0.7s ease-in-out infinite;
}

.ge-btn-listen.is-playing .ge-wave span:nth-child(2) { animation-delay: 0.15s; }
.ge-btn-listen.is-playing .ge-wave span:nth-child(3) { animation-delay: 0.3s; }
.ge-btn-listen.is-playing .ge-wave span:nth-child(4) { animation-delay: 0.45s; }

@keyframes waveAnim {
  0%, 100% { height: 4px; }
  50% { height: 16px; }
}

.ge-btn-restart {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  background: #ffffff;
  color: var(--teal-deep);
  border: 2.5px solid var(--teal);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 0 rgba(24, 132, 156, 0.2);
  transition: all var(--transition-fast);
}

.ge-btn-restart:hover {
  background: var(--teal-light);
  transform: rotate(-45deg);
}

/* Card Content Area */
.ge-card-area {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Form Fill Header */
.ge-form-header {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--magenta);
  text-align: center;
  padding: 6px 12px;
  background: #fdf2f7;
  border: 1.5px dashed var(--magenta);
  border-radius: 10px;
  letter-spacing: 0.5px;
}

/* Question Rows */
.ge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #ffffff;
  border: 2.5px solid var(--teal);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(24, 132, 156, 0.15);
  transition: all var(--transition-fast);
}

.ge-row:hover {
  background: #f9fdfd;
}

.ge-row.is-selected {
  border-color: var(--magenta);
  background: #fdf0f6;
  transform: translateX(4px);
}

.ge-row.is-done {
  border-color: var(--leaf);
  background: var(--leaf-light);
  cursor: default;
}

.ge-row.is-shown {
  border-color: var(--amber);
  background: var(--amber-light);
  cursor: default;
}

.ge-row.is-wrong-shake {
  animation: shakeAnim 0.35s ease-in-out;
  border-color: var(--coral);
}

@keyframes shakeAnim {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.ge-rlabel {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.98rem;
  color: var(--teal-deep);
  flex: 0 0 45%;
}

.ge-rval {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--magenta);
  border-bottom: 2.5px dashed var(--teal);
  padding: 2px 6px;
  flex: 1 1 auto;
  text-align: right;
  min-height: 26px;
}

.ge-row.is-done .ge-rval {
  color: var(--leaf);
  border-bottom-style: solid;
  border-bottom-color: var(--leaf);
}

.ge-row.is-shown .ge-rval {
  color: var(--amber);
  border-bottom-style: solid;
  border-bottom-color: var(--amber);
}

/* Options Palette (Multiple Choice) */
.ge-options-box {
  background: var(--paper);
  border: 2px solid #dcebee;
  border-radius: 12px;
  padding: 12px;
  margin-top: 10px;
}

.ge-options-label {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-align: center;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.ge-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ge-opt-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 2px solid var(--teal);
  border-radius: 10px;
  padding: 8px 12px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--teal-deep);
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(24, 132, 156, 0.15);
  transition: all var(--transition-fast);
  text-align: left;
}

.ge-opt-btn:hover {
  background: var(--teal-light);
  transform: translateY(-2px);
}

.ge-opt-letter {
  background: var(--teal);
  color: #fff;
  border-radius: 6px;
  padding: 1px 7px;
  font-weight: 800;
  font-size: 0.8rem;
}

.ge-opt-btn.is-used {
  opacity: 0.35;
  pointer-events: none;
  filter: grayscale(0.5);
}

.ge-opt-btn.is-wrong {
  background: #fdecec;
  border-color: var(--coral);
  color: var(--coral);
  animation: shakeAnim 0.35s ease;
}

.ge-opt-btn.is-wrong .ge-opt-letter {
  background: var(--coral);
}

/* Feedback Line (Fixed height to prevent jumping) */
.ge-feedback-line {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1rem;
  text-align: center;
  margin-top: 8px;
}

.ge-feedback-line.good { color: var(--leaf); }
.ge-feedback-line.bad { color: var(--coral); }
.ge-feedback-line.part { color: var(--amber); }

/* Bottom Action Bar */
.ge-actions-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* ---------- End Game Screen ---------- */
.ge-end-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px 20px;
}

.ge-end-screen.is-active {
  display: flex;
}

.ge-end-stars {
  font-size: 3.5rem;
  letter-spacing: 6px;
  margin-bottom: 10px;
  animation: bounceStars 0.6s ease;
}

@keyframes bounceStars {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.ge-end-score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 3.8rem;
  color: var(--magenta);
  line-height: 1;
  margin-bottom: 10px;
}

.ge-end-title {
  font-size: 2rem;
  color: var(--teal-deep);
  margin-bottom: 6px;
}

.ge-end-sub {
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin-bottom: 24px;
}

/* ============================================================
   CLASSROOM MODE (CHẾ ĐỘ CHIẾU LỚP - DÀNH CHO MÁY CHIẾU & TV)
   ============================================================ */
.class-mode .ge-top-bar,
.class-mode .ge-stage {
  max-width: 1000px;
}

.class-mode .ge-stage {
  padding: 28px 36px;
  border-width: 5px;
}

.class-mode .ge-instruction {
  font-size: clamp(1.8rem, 2.5vw, 2.2rem);
  margin-bottom: 18px;
}

.class-mode .ge-topic-bar {
  font-size: 1.1rem;
}

.class-mode .ge-score-chip {
  font-size: 1.35rem;
  padding: 8px 20px;
}

.class-mode .ge-btn-listen {
  font-size: 1.25rem;
  padding: 12px 30px;
}

.class-mode .ge-form-header {
  font-size: 1.45rem;
  padding: 10px 18px;
}

.class-mode .ge-row {
  padding: 14px 20px;
}

.class-mode .ge-rlabel {
  font-size: 1.35rem;
}

.class-mode .ge-rval {
  font-size: 1.45rem;
}

.class-mode .ge-opt-btn {
  font-size: 1.3rem;
  padding: 12px 18px;
}

.class-mode .ge-opt-letter {
  font-size: 1.05rem;
  padding: 2px 10px;
}

.class-mode .ge-feedback-line {
  font-size: 1.3rem;
  min-height: 44px;
}

.class-mode .btn {
  font-size: 1.15rem;
  padding: 14px 32px;
}

/* Play Guide Modal */
.ge-guide-modal {
  position: fixed;
  inset: 0;
  z-index: 2500;
  background: rgba(15, 30, 40, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.ge-guide-modal.is-active {
  display: flex;
}

.ge-guide-content {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 3px solid var(--teal);
  max-width: 560px;
  width: 100%;
  padding: 26px 30px;
  box-shadow: var(--shadow-lg);
  line-height: 1.7;
}

.ge-guide-content h3 {
  color: var(--teal-deep);
  font-size: 1.4rem;
  margin-bottom: 12px;
}

.ge-guide-content ul {
  padding-left: 20px;
  margin-bottom: 20px;
  color: var(--ink);
}

.ge-guide-content li {
  margin-bottom: 8px;
}
