/* BibleLingo – Fun panel, games, header Fun button (loaded after style.css) */

/* Fun button (header) – cyan/teal, next to Quests */
.fun-btn-header.icon-btn-with-label,
#funBtnHeader.fun-btn-header {
  min-width: 72px;
  padding-left: var(--space-3);
  padding-right: var(--space-3);
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.28) 0%, rgba(8, 145, 178, 0.18) 100%);
  border: 1px solid rgba(6, 182, 212, 0.55);
  color: #fff;
  box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.25);
}

.fun-btn-header:hover,
#funBtnHeader.fun-btn-header:hover {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.4) 0%, rgba(8, 145, 178, 0.3) 100%);
  border-color: #06b6d4;
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.4);
  color: #fff;
}

#funBtnHeader .fun-btn-label {
  font-weight: 600;
  font-size: var(--text-sm);
  letter-spacing: 0.02em;
}

.fun-btn-label {
  white-space: nowrap;
  overflow: visible;
}


/* Phone / narrow: hide Fun in header row (available in side menu) */
body.phone-mode .header-row-1 .fun-btn-header {
  display: none !important;
}

@media (max-width: 768px) {
  .header-row-1 .fun-btn-header {
    display: none !important;
  }
}

/* Fun panel */
.fun-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.fun-panel.open {
  pointer-events: auto;
  opacity: 1;
}

.fun-panel .panel-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.fun-panel.open .panel-backdrop {
  opacity: 1;
}

.fun-panel .fun-panel-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 90vh;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.2);
  transform: translateY(100%);
  transition: transform var(--transition-normal);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.fun-panel.open .fun-panel-content {
  transform: translateY(0);
}

.fun-panel .panel-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.fun-panel-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-md);
}

.fun-panel-back:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.fun-panel-back[hidden] {
  display: none;
}

.fun-panel .panel-title {
  flex: 1;
  margin: 0;
  font-size: var(--text-lg);
}

.fun-panel .panel-body {
  overflow-y: auto;
  padding: var(--space-4);
}

.fun-hub-intro {
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}

.fun-game-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.fun-game-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: left;
  transition: var(--transition-fast);
}

.fun-game-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.fun-game-card i {
  width: 24px;
  height: 24px;
  color: var(--accent-primary);
}

.fun-game-card-title {
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--text-primary);
}

.fun-game-card-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.fun-game-view {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.fun-game1-target {
  font-size: var(--native-text-size);
  font-family: var(--font-script);
  line-height: 1.5;
  color: var(--text-primary);
  padding: var(--space-3);
  background: var(--bg-card);
  border-radius: var(--radius-md);
}

.fun-game1-progress {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.fun-game1-stopwatch {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--accent-primary);
}

.fun-game1-slowdown {
  min-height: 1.5em;
  color: var(--warning-color);
  font-weight: 600;
}

.fun-game1-input {
  width: 100%;
  padding: var(--space-3);
  font-size: var(--text-lg);
  font-family: var(--font-script);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.fun-game1-input:focus {
  border-color: var(--accent-primary);
  outline: none;
}

.fun-game1-done {
  padding: var(--space-3);
  background: var(--success-color);
  color: white;
  border-radius: var(--radius-md);
  font-weight: 600;
}

.fun-game2-monster-bar-wrap {
  height: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.fun-game2-monster-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--success-color), var(--warning-color), #ef4444);
  border-radius: var(--radius-full);
  transition: width 0.2s ease;
}

.fun-game2-segment {
  font-size: var(--text-xl);
  font-family: var(--font-script);
  color: var(--text-primary);
  text-align: center;
  padding: var(--space-3);
}

.fun-game2-input {
  width: 100%;
  padding: var(--space-3);
  font-size: var(--text-lg);
  font-family: var(--font-script);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.fun-game2-timer {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--accent-primary);
}

.fun-game2-gameover {
  text-align: center;
  padding: var(--space-4);
}

.fun-game2-gameover p {
  margin: 0 0 var(--space-2);
  font-size: var(--text-lg);
  color: var(--text-primary);
}

.fun-game2-score {
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: var(--space-4);
}

.fun-game3-lives {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
}

.fun-game3-word {
  font-size: var(--text-3xl);
  font-family: var(--font-script);
  color: var(--text-primary);
  text-align: center;
  padding: var(--space-4);
}

.fun-game3-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.fun-game3-option-btn {
  padding: var(--space-3);
  text-align: left;
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.fun-game3-option-btn:hover {
  border-color: var(--accent-primary);
  background: var(--bg-card-hover);
}

.fun-game3-option-btn.correct {
  border-color: var(--success-color);
  background: rgba(34, 197, 94, 0.2);
}

.fun-game3-option-btn.wrong {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.2);
}

.fun-game3-score-line {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.fun-game3-gameover {
  text-align: center;
  padding: var(--space-4);
}

.fun-game3-gameover p {
  margin: 0 0 var(--space-2);
  color: var(--text-primary);
}

.fun-game3-final-score {
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: var(--space-4);
}

/* Fun panel: when one game is active, only that game view is visible (no stacked timers/inputs) */
.fun-panel-body .fun-game-view[hidden] {
  display: none !important;
}

/* Game 4: Alphabet Flashcard */
.fun-game4-wrap {
  max-width: 420px;
  margin: 0 auto;
}

.fun-game4-score-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2) 0%, rgba(139, 92, 246, 0.15) 100%);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(6, 182, 212, 0.4);
}

.fun-game4-score-label {
  font-weight: 700;
  color: var(--text-secondary);
}

.fun-game4-score-value {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--accent-secondary);
}

.fun-game4-practice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.fun-game4-practice-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  width: 100%;
}

.fun-game4-filter-btn {
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.fun-game4-filter-btn:hover,
.fun-game4-filter-btn.active {
  border-color: var(--accent-primary);
  background: rgba(139, 92, 246, 0.15);
  color: var(--text-primary);
}

.fun-game4-flashcard-wrap {
  perspective: 1200px;
  min-height: 320px;
}

.fun-game4-flashcard {
  width: 100%;
  min-height: 280px;
  cursor: pointer;
  perspective: 1200px;
}

.fun-game4-flashcard-inner {
  position: relative;
  width: 100%;
  min-height: 280px;
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.fun-game4-flashcard.flipped .fun-game4-flashcard-inner {
  transform: rotateY(180deg);
}

.fun-game4-front,
.fun-game4-back {
  position: absolute;
  width: 100%;
  min-height: 280px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.fun-game4-front {
  background: linear-gradient(160deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
  border: 2px solid var(--border-subtle);
}

.fun-game4-back {
  background: linear-gradient(160deg, var(--bg-secondary) 0%, var(--bg-card) 100%);
  border: 2px solid var(--accent-primary);
  transform: rotateY(180deg);
}

.fun-game4-timer {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.fun-game4-hint-btn {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--accent-secondary);
  background: rgba(6, 182, 212, 0.2);
  color: var(--accent-secondary);
  cursor: pointer;
  font-weight: 600;
  font-size: var(--text-sm);
  transition: var(--transition-fast);
}

.fun-game4-hint-btn:hover {
  background: rgba(6, 182, 212, 0.35);
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.3);
}

.fun-game4-hint-btn i {
  width: 18px;
  height: 18px;
}

.fun-game4-char {
  font-size: 4rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-script);
  line-height: 1.2;
  margin: var(--space-4) 0;
}

.fun-game4-tap-hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0;
}

.fun-game4-char-fonts {
  font-size: var(--text-2xl);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: center;
  align-items: center;
}

.fun-game4-char-font {
  padding: var(--space-2) var(--space-3);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.fun-game4-font-noto-sans { font-family: var(--font-thai-noto-sans); }
.fun-game4-font-noto-serif { font-family: var(--font-thai-noto-serif); }
.fun-game4-font-sarabun { font-family: var(--font-thai-sarabun); }
.fun-game4-font-prompt { font-family: var(--font-thai-prompt); }
.fun-game4-font-kanit { font-family: var(--font-thai-kanit); }
.fun-game4-font-mitr { font-family: var(--font-thai-mitr); }
.fun-game4-font-zh-sans { font-family: var(--font-zh-noto-sans); }
.fun-game4-font-zh-serif { font-family: var(--font-zh-noto-serif); }

.fun-game4-phonetic-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.fun-game4-phonetic {
  font-size: var(--text-lg);
  color: var(--accent-secondary);
  font-weight: 600;
}

.fun-game4-namethai-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.fun-game4-namethai-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.fun-game4-namethai {
  font-size: var(--text-lg);
  color: var(--text-primary);
  font-family: var(--font-thai);
}

.fun-game4-back-listen {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--accent-secondary);
  background: rgba(6, 182, 212, 0.2);
  color: var(--accent-secondary);
  cursor: pointer;
  font-weight: 600;
  font-size: var(--text-sm);
  transition: var(--transition-fast);
}

.fun-game4-back-listen:hover {
  background: rgba(6, 182, 212, 0.35);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.3);
}

.fun-game4-back-listen i {
  width: 18px;
  height: 18px;
}

.fun-game4-meaning {
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
  text-align: center;
}

.fun-game4-answer-btns {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
}

.fun-game4-answer-btn {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 2px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: center;
}

.fun-game4-answer-btn.instant {
  border-color: var(--success-color);
  background: rgba(34, 197, 94, 0.15);
  color: var(--success-color);
}

.fun-game4-answer-btn.instant:hover {
  background: rgba(34, 197, 94, 0.3);
}

.fun-game4-answer-btn.slow {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.fun-game4-answer-btn.slow:hover {
  background: rgba(59, 130, 246, 0.3);
}

.fun-game4-answer-btn.hint {
  border-color: var(--warning-color);
  background: rgba(234, 179, 8, 0.15);
  color: var(--warning-color);
}

.fun-game4-answer-btn.hint:hover {
  background: rgba(234, 179, 8, 0.3);
}

.fun-game4-answer-btn.incorrect {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.fun-game4-answer-btn.incorrect:hover {
  background: rgba(239, 68, 68, 0.3);
}

.fun-game4-empty {
  text-align: center;
  padding: var(--space-6);
  color: var(--text-secondary);
}
