/* Korean Explorer - Kid-friendly styles */

:root {
  --primary: #FF6B6B;
  --secondary: #4ECDC4;
  --accent: #FFE66D;
  --purple: #A855F7;
  --green: #4ADE80;
  --orange: #FB923C;
  --blue: #60A5FA;
  --pink: #F472B6;
  --bg: #FFF9F0;
  --card-bg: #FFFFFF;
  --text: #2D2D2D;
  --shadow: 0 4px 15px rgba(0,0,0,0.12);
  --radius: 20px;
  --radius-sm: 12px;
}

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

body {
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Arial Rounded MT Bold', cursive, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── HEADER ─────────────────────────────────── */
header {
  background: linear-gradient(135deg, var(--primary), var(--purple));
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

header .logo-icon {
  font-size: 2rem;
}

header .logo-text {
  font-size: 1.4rem;
  font-weight: bold;
  color: #fff;
  text-shadow: 2px 2px 0px rgba(0,0,0,0.2);
}

nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

nav a {
  background: rgba(255,255,255,0.25);
  color: #fff;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: bold;
  transition: background 0.2s, transform 0.2s;
  border: 2px solid rgba(255,255,255,0.4);
}

nav a:hover, nav a.active {
  background: rgba(255,255,255,0.5);
  transform: translateY(-2px);
}

/* ─── MAIN CONTENT ────────────────────────────── */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 30px 20px 100px;
}

/* ─── HERO (index) ────────────────────────────── */
.hero {
  text-align: center;
  padding: 40px 20px;
}

.hero-emoji {
  font-size: 5rem;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

.hero h1 {
  font-size: 3rem;
  color: var(--primary);
  text-shadow: 3px 3px 0px rgba(255,107,107,0.3);
  margin: 10px 0;
}

.hero p {
  font-size: 1.4rem;
  color: #666;
  margin-bottom: 30px;
}

/* ─── PROGRESS BAR ────────────────────────────── */
.progress-widget {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.level-badge {
  background: linear-gradient(135deg, var(--accent), var(--orange));
  color: #000;
  font-weight: bold;
  padding: 8px 18px;
  border-radius: 30px;
  font-size: 1.1rem;
  white-space: nowrap;
}

.progress-bar-wrap {
  flex: 1;
  min-width: 120px;
  background: #eee;
  border-radius: 20px;
  height: 20px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--secondary), var(--blue));
  border-radius: 20px;
  transition: width 0.5s ease;
}

.points-display {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--purple);
  white-space: nowrap;
}

.stars-display {
  font-size: 1.3rem;
  white-space: nowrap;
}

/* ─── MODULE CARDS ────────────────────────────── */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 30px;
}

.module-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s;
  text-decoration: none;
  color: var(--text);
  border: 3px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.module-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 8px 25px rgba(0,0,0,0.18);
}

.module-card .card-emoji {
  font-size: 3.5rem;
}

.module-card h2 {
  font-size: 1.3rem;
  color: var(--primary);
}

.module-card p {
  font-size: 0.95rem;
  color: #888;
}

.module-card.hangul  { border-color: var(--primary); }
.module-card.words   { border-color: var(--secondary); }
.module-card.numbers { border-color: var(--accent); }
.module-card.phrases { border-color: var(--purple); }
.module-card.games   { border-color: var(--green); }

/* ─── PAGE TITLE ──────────────────────────────── */
.page-title {
  text-align: center;
  padding: 20px 0 10px;
}

.page-title .page-emoji {
  font-size: 3rem;
}

.page-title h1 {
  font-size: 2.2rem;
  color: var(--primary);
  text-shadow: 2px 2px 0 rgba(255,107,107,0.2);
}

.page-title p {
  font-size: 1.1rem;
  color: #888;
  margin-top: 4px;
}

/* ─── TABS ────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0;
  justify-content: center;
}

.tab-btn {
  background: #fff;
  border: 3px solid var(--primary);
  color: var(--primary);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.2s;
  font-family: inherit;
}

.tab-btn:hover, .tab-btn.active {
  background: var(--primary);
  color: #fff;
  transform: translateY(-2px);
}

/* ─── CARDS ───────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* ─── LETTER CARD ─────────────────────────────── */
.letter-showcase {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  flex-wrap: wrap;
  margin: 20px 0;
}

.letter-big {
  font-size: 8rem;
  color: var(--primary);
  text-shadow: 4px 4px 0 rgba(255,107,107,0.25);
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 160px;
  height: 160px;
  background: #fff0f0;
  border-radius: var(--radius);
  border: 4px solid var(--primary);
  user-select: none;
}

.letter-big:hover { transform: scale(1.05); }

.letter-info {
  text-align: center;
}

.letter-romanization {
  font-size: 2rem;
  font-weight: bold;
  color: var(--purple);
  margin-bottom: 6px;
}

.letter-name {
  font-size: 1.2rem;
  color: #888;
  margin-bottom: 16px;
}

.letter-nav {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}

/* ─── BUTTONS ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: 30px;
  border: none;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.btn:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(0,0,0,0.15); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary  { background: var(--primary); color: #fff; }
.btn-secondary{ background: var(--secondary); color: #fff; }
.btn-accent   { background: var(--accent); color: #333; }
.btn-purple   { background: var(--purple); color: #fff; }
.btn-green    { background: var(--green); color: #fff; }
.btn-orange   { background: var(--orange); color: #fff; }
.btn-blue     { background: var(--blue); color: #fff; }
.btn-white    { background: #fff; color: var(--primary); border: 3px solid var(--primary); }

.btn-sm { padding: 8px 16px; font-size: 0.95rem; }
.btn-lg { padding: 18px 32px; font-size: 1.3rem; }

/* ─── WORD GRID ───────────────────────────────── */
.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.word-card {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 3px solid transparent;
}

.word-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  border-color: var(--secondary);
}

.word-emoji {
  font-size: 2.8rem;
  margin-bottom: 8px;
}

.word-korean {
  font-size: 1.4rem;
  color: var(--primary);
  font-weight: bold;
  margin-bottom: 2px;
}

.word-english {
  font-size: 0.9rem;
  color: #888;
}

/* ─── NUMBERS ─────────────────────────────────── */
.number-display {
  text-align: center;
  padding: 30px;
}

.number-big {
  font-size: 6rem;
  font-weight: bold;
  color: var(--purple);
  line-height: 1;
}

.number-korean {
  font-size: 3rem;
  color: var(--primary);
  margin-top: 8px;
}

.number-english {
  font-size: 1.5rem;
  color: #888;
  margin-top: 4px;
}

.counting-objects {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 16px 0;
  font-size: 2.5rem;
}

/* ─── QUIZ ────────────────────────────────────── */
.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

.quiz-option {
  background: #fff;
  border: 3px solid #ddd;
  border-radius: var(--radius-sm);
  padding: 18px;
  font-size: 1.4rem;
  font-weight: bold;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  font-family: inherit;
}

.quiz-option:hover { border-color: var(--secondary); background: #f0fffe; transform: scale(1.03); }
.quiz-option.correct { border-color: var(--green); background: #f0fff4; }
.quiz-option.wrong { border-color: var(--primary); background: #fff0f0; }

/* ─── GAME CARDS ──────────────────────────────── */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.game-card {
  aspect-ratio: 1;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: bold;
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow);
  text-align: center;
  padding: 8px;
  user-select: none;
}

.game-card:hover { transform: scale(1.04); }
.game-card.flipped { background: #fff; color: var(--text); border: 3px solid var(--purple); }
.game-card.matched { background: linear-gradient(135deg, var(--green), var(--secondary)); pointer-events: none; }
.game-card .card-back { font-size: 2rem; }
.game-card .card-front { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.game-card .card-front .card-emoji { font-size: 2rem; }
.game-card .card-front .card-word  { font-size: 1rem; }

/* ─── FEEDBACK / TOAST ────────────────────────── */
#toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #333;
  color: #fff;
  padding: 14px 28px;
  border-radius: 30px;
  font-size: 1.1rem;
  font-weight: bold;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 999;
  pointer-events: none;
  text-align: center;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#toast.correct { background: #22c55e; }
#toast.wrong   { background: #ef4444; }
#toast.info    { background: #3b82f6; }
#toast.star    { background: #f59e0b; }

/* ─── CONFETTI ─────────────────────────────────── */
.confetti-piece {
  position: fixed;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  pointer-events: none;
  animation: confetti-fall 2.5s ease-in forwards;
  z-index: 9999;
}

@keyframes confetti-fall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ─── CORRECT ANIMATION ───────────────────────── */
@keyframes pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}
.pop-anim { animation: pop 0.4s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-8px); }
  75%       { transform: translateX(8px); }
}
.shake-anim { animation: shake 0.4s ease; }

/* ─── CANVAS (tracing) ────────────────────────── */
#tracing-canvas {
  border: 3px dashed var(--primary);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: crosshair;
  display: block;
  margin: 0 auto;
  max-width: 100%;
  touch-action: none;
}

/* ─── PHRASE CARD ─────────────────────────────── */
.phrase-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  border-left: 6px solid var(--purple);
  cursor: pointer;
  transition: transform 0.2s;
}
.phrase-card:hover { transform: translateY(-3px); }
.phrase-korean { font-size: 1.8rem; color: var(--primary); font-weight: bold; }
.phrase-roman  { font-size: 1rem; color: #999; }
.phrase-english{ font-size: 1.1rem; color: #555; }
.phrase-emoji  { font-size: 2.5rem; }

/* ─── AD BANNER ───────────────────────────────── */
#ad-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  padding: 2px 0;
  text-align: center;
  display: none;
  z-index: 90;
  max-height: 60px;
  overflow: hidden;
}

#ad-banner.ad-visible { display: block; }

/* Push page content above the fixed ad banner */
body.ad-visible { padding-bottom: 60px; }

/* ─── FOOTER ──────────────────────────────────── */
footer {
  text-align: center;
  padding: 20px;
  color: #aaa;
  font-size: 0.9rem;
}

footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: bold;
}

footer a:hover { text-decoration: underline; }

/* ─── LETTER GRID (hangul) ────────────────────── */
.letter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.letter-tile {
  background: #fff;
  border: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.letter-tile:hover { background: #fff0f0; transform: scale(1.08); }
.letter-tile.selected { background: var(--primary); color: #fff; }

.letter-tile .lt-char  { font-size: 1.8rem; font-weight: bold; }
.letter-tile .lt-roman { font-size: 0.8rem; color: #888; }
.letter-tile.selected .lt-roman { color: #ffd; }

/* ─── MATCH GAME ──────────────────────────────── */
.match-area {
  display: flex;
  gap: 30px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 20px 0;
}

.match-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.match-item {
  background: #fff;
  border: 3px solid #ddd;
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  font-size: 1.3rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  min-width: 130px;
  user-select: none;
}

.match-item:hover { border-color: var(--secondary); background: #f0fffe; }
.match-item.selected { border-color: var(--purple); background: #f5f0ff; }
.match-item.matched  { border-color: var(--green);  background: #f0fff4; pointer-events: none; }
.match-item.wrong    { border-color: var(--primary); background: #fff0f0; }

/* ─── DRAG & DROP ─────────────────────────────── */
.drag-target {
  background: #f8f9fa;
  border: 3px dashed #ccc;
  border-radius: var(--radius-sm);
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: border-color 0.2s, background 0.2s;
  padding: 10px;
}

.drag-target.drag-over { border-color: var(--purple); background: #f5f0ff; }
.drag-target.correct   { border-color: var(--green);  background: #f0fff4; }
.drag-target.wrong     { border-color: var(--primary); background: #fff0f0; }

.drag-item {
  background: var(--purple);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 1.2rem;
  cursor: grab;
  user-select: none;
  transition: transform 0.15s;
  display: inline-block;
}

.drag-item:active { cursor: grabbing; transform: scale(1.05); }

/* ─── SCORE BOARD ─────────────────────────────── */
.scoreboard {
  text-align: center;
  padding: 20px;
}

.score-big {
  font-size: 4rem;
  font-weight: bold;
  color: var(--purple);
}

.score-label { font-size: 1.1rem; color: #888; }

.stars-row {
  font-size: 2.5rem;
  margin: 10px 0;
}

/* ─── SECTION HEADER ──────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 1.5rem;
  color: var(--primary);
}

/* ─── RESPONSIVE ──────────────────────────────── */
@media (max-width: 640px) {
  header { flex-direction: column; gap: 10px; }
  nav { justify-content: center; }
  .hero h1 { font-size: 2rem; }
  .letter-big { font-size: 6rem; width: 120px; height: 120px; }
  .quiz-options { grid-template-columns: 1fr; }
  .match-area { flex-direction: column; align-items: center; }
}
