/* ============================================================
   Shared stylesheet — md_GameWorld
   All games link to this file. Per-game :root overrides and
   game-specific rules live in each page's local <style> tag.
   ============================================================ */

/* ── Variables ── */
:root {
  --red:    #FF6B6B;
  --blue:   #4ECDC4;
  --purple: #A78BFA;
  --orange: #FFB347;
  --pink:   #FF8DC7;
  --correct:#5DBB63;
  --sun:    #FFD700;

  /* Per-game theme overrides */
  --bg-sky-top:    #87CEEB;
  --bg-sky-mid:    #B0E0FF;
  --bg-split:      58%;
  --theme-primary: #A78BFA;
  --theme-secondary: #7c3aed;
}

/* ── Reset ── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; height: 100dvh; overflow: hidden; }
body { font-family: 'Nunito', sans-serif; display: flex; flex-direction: column; position: relative; }

/* ── Animated background ── */
.bg-scene {
  position: fixed; inset: 0;
  background: linear-gradient(180deg,
    var(--bg-sky-top) 0%,
    var(--bg-sky-mid) var(--bg-split),
    #5DBB63 var(--bg-split),
    #4aaa50 100%);
  z-index: -2;
}

/* ── Sun ── */
.sun {
  position: fixed; top: 22px; right: 52px;
  width: 74px; height: 74px;
  background: radial-gradient(circle at 36% 36%, #FFE566, var(--sun));
  border-radius: 50%;
  box-shadow: 0 0 0 14px rgba(255,215,0,.28), 0 0 0 28px rgba(255,215,0,.1);
  animation: pulse 3.2s ease-in-out infinite;
  z-index: -1;
}
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.08)} }

/* ── Clouds ── */
.cloud {
  position: fixed; background: rgba(255,255,255,.9); border-radius: 50px;
  z-index: -1; animation: drift linear infinite;
}
.cloud::before, .cloud::after {
  content: ''; position: absolute; background: rgba(255,255,255,.9); border-radius: 50%;
}
.c1{width:120px;height:40px;top:55px;left:-140px;animation-duration:26s}
.c1::before{width:60px;height:60px;top:-25px;left:15px}
.c1::after{width:44px;height:44px;top:-15px;left:52px}
.c2{width:88px;height:28px;top:100px;left:-110px;animation-duration:36s;animation-delay:-16s}
.c2::before{width:42px;height:42px;top:-18px;left:8px}
.c2::after{width:34px;height:34px;top:-10px;left:35px}
.c3{width:150px;height:48px;top:36px;left:-175px;animation-duration:44s;animation-delay:-26s}
.c3::before{width:68px;height:68px;top:-30px;left:20px}
.c3::after{width:52px;height:52px;top:-18px;left:64px}
@keyframes drift { from{left:-210px} to{left:110%} }

/* ── Header ── */
header { text-align: center; padding: 8px 20px 2px; flex-shrink: 0; }
header h1 {
  font-family: 'Baloo 2', sans-serif;
  font-size: clamp(1.4rem,5vw,2.2rem);
  color: #fff;
  text-shadow: 3px 3px 0 var(--red), 6px 6px 0 rgba(0,0,0,.12);
  letter-spacing: 2px; line-height: 1.1;
}
.subtitle {
  font-size: .8rem; color: rgba(255,255,255,.9);
  font-weight: 700; margin-top: 2px;
  text-shadow: 1px 1px 2px rgba(0,0,0,.2);
}

/* ── Score area ── */
.score-area {
  display: flex; justify-content: center; align-items: center;
  gap: 12px; padding: 4px 20px;
  color: white; font-weight: 800; font-size: .9rem;
  text-shadow: 1px 1px 2px rgba(0,0,0,.2); flex-shrink: 0;
}
.score-pill {
  background: rgba(255,255,255,.28); border-radius: 20px;
  padding: 4px 14px; backdrop-filter: blur(4px);
}

/* ── Toggles ── */
.toggles-area {
  display: flex; justify-content: center; align-items: center;
  gap: 6px; padding: 3px 12px 2px; flex-shrink: 0; flex-wrap: wrap;
}
.mode-btn {
  padding: 4px 11px; border: 2px solid rgba(255,255,255,.5);
  border-radius: 20px; background: rgba(255,255,255,.2); color: white;
  font-family: 'Baloo 2', sans-serif; font-size: .72rem; font-weight: 700;
  cursor: pointer; transition: all .2s; backdrop-filter: blur(4px); white-space: nowrap;
}
.mode-btn.active {
  background: white; color: var(--theme-secondary);
  border-color: white; box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.settings-btn {
  padding: 4px 13px; border: 2px solid rgba(255,255,255,.5);
  border-radius: 20px; background: rgba(255,255,255,.2); color: white;
  font-family: 'Baloo 2', sans-serif; font-size: .78rem; font-weight: 700;
  cursor: pointer; transition: all .2s; backdrop-filter: blur(4px);
}
.settings-btn:hover { background: rgba(255,255,255,.35); }

/* ── Stars bar ── */
.stars-bar { display: flex; justify-content: center; gap: 5px; padding: 4px 0 2px; flex-shrink: 0; }
.star { font-size: 20px; filter: grayscale(1); transition: all .3s; }
.star.lit { filter: none; animation: starPop .4s ease; }
@keyframes starPop { 0%{transform:scale(0)} 70%{transform:scale(1.3)} 100%{transform:scale(1)} }

/* ── Game container ── */
.game-container {
  width: 100%; margin: 0 auto;
  padding: 4px 16px 8px;
  flex: 1 1 0; display: flex; flex-direction: column; min-height: 0;
}

/* ── Question card ── */
.question-card {
  background: white; border-radius: 24px; padding: 12px 16px 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.08);
  text-align: center; position: relative; overflow: hidden;
  flex: 1 1 0; display: flex; flex-direction: column; min-height: 0;
}
.question-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 8px;
  background: linear-gradient(90deg,var(--red),var(--orange),var(--sun),var(--correct),var(--blue),var(--purple));
}
.progress-text {
  font-size: .72rem; color: #aaa; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase; margin-bottom: 4px; flex-shrink: 0;
}
.progress-bar-wrap {
  background: #f0f0f0; border-radius: 20px; height: 8px;
  margin: 0 0 6px; overflow: hidden; flex-shrink: 0;
}
.progress-bar-fill {
  height: 100%; background: linear-gradient(90deg,var(--blue),var(--purple));
  border-radius: 20px; transition: width .4s ease;
}

/* ── Answer buttons ── */
.answers { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.answer-btn {
  display: block; width: 100%; padding: 10px 16px;
  border: 3px solid transparent; border-radius: 14px;
  font-family: 'Baloo 2', sans-serif; font-size: 1.15rem; font-weight: 800;
  cursor: pointer; transition: all .2s; outline: none;
}
.answer-btn:nth-child(1) { background: #FFF0F0; border-color: #FFD0D0; color: #CC4444; }
.answer-btn:nth-child(2) { background: #F0F8FF; border-color: #C0E0FF; color: #2266BB; }
.answer-btn:nth-child(3) { background: #F0FFF4; border-color: #C0F0D0; color: #226633; }
.answer-btn:hover:not(:disabled) { transform: translateY(-3px) scale(1.02); box-shadow: 0 6px 20px rgba(0,0,0,.1); }
.answer-btn:active:not(:disabled) { transform: scale(.97); }
.answer-btn.correct {
  background: #d4f5dc!important; border-color: #5DBB63!important;
  color: #226633!important; animation: correctPop .4s ease;
}
.answer-btn.wrong {
  background: #ffe0e0!important; border-color: #FF6B6B!important;
  color: #cc2222!important; animation: wrongShake .4s ease;
}
.answer-btn:disabled { cursor: default; }

/* ── Feedback ── */
.feedback {
  font-size: 1rem; font-weight: 800; text-align: center;
  padding: 6px; border-radius: 12px; margin-top: 5px;
  opacity: 0; transition: opacity .3s; flex-shrink: 0;
}
.feedback.show { opacity: 1; }
.feedback.good { background: #d4f5dc; color: #226633; }
.feedback.bad  { background: #ffe0e0; color: #cc2222; }

/* ── Next button ── */
.next-btn {
  display: none; margin: 7px auto 0; padding: 9px 30px;
  background: linear-gradient(135deg,var(--sun),var(--orange));
  border: none; border-radius: 50px;
  font-family: 'Baloo 2', sans-serif; font-size: 1.1rem; font-weight: 700;
  color: white; cursor: pointer;
  box-shadow: 0 4px 16px rgba(255,179,71,.5); transition: all .2s; flex-shrink: 0;
}
.next-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(255,179,71,.6); }
.next-btn.show { display: block; animation: popIn .3s ease; }

/* ── End screen ── */
.end-screen {
  display: none; text-align: center;
  flex-direction: column; align-items: center; justify-content: center; flex: 1;
}
.end-screen.show { display: flex; }
.end-screen h2 {
  font-family: 'Baloo 2', sans-serif; font-size: 2.2rem;
  color: var(--red); text-shadow: 3px 3px 0 rgba(0,0,0,.1); margin-bottom: 8px;
}
.end-score { font-size: 1.2rem; font-weight: 800; color: #555; margin-bottom: 18px; line-height: 1.5; }
.play-again-btn {
  padding: 13px 42px;
  background: linear-gradient(135deg,var(--theme-primary),var(--theme-secondary));
  border: none; border-radius: 50px;
  font-family: 'Baloo 2', sans-serif; font-size: 1.3rem; color: white;
  cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.2); transition: all .2s; margin-bottom: 10px;
}
.play-again-btn:hover { transform: scale(1.05); }

/* ── Settings overlay ── */
.settings-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.55); z-index: 500;
  align-items: center; justify-content: center;
}
.settings-overlay.show { display: flex; }
.settings-box {
  background: white; border-radius: 28px; padding: 22px 20px 18px;
  max-width: 340px; width: 92%;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: popIn .25s ease;
}
.settings-box h2 {
  font-family: 'Baloo 2', sans-serif; font-size: 1.3rem;
  color: #333; margin-bottom: 14px; text-align: center;
}
.s-section { margin-bottom: 12px; }
.s-label {
  font-size: .7rem; font-weight: 800; color: #bbb;
  letter-spacing: 1px; text-transform: uppercase; margin-bottom: 6px;
}
.s-row { display: flex; gap: 7px; flex-wrap: wrap; }
.s-opt {
  padding: 6px 14px; border: 2px solid #e5e5e5; border-radius: 20px;
  background: #fafafa; color: #555;
  font-family: 'Baloo 2', sans-serif; font-size: .85rem; font-weight: 700;
  cursor: pointer; transition: all .2s;
}
.s-opt:hover { border-color: var(--theme-primary); color: var(--theme-secondary); }
.s-opt.active { background: var(--theme-primary); border-color: var(--theme-primary); color: white; }
.s-close {
  display: block; width: 100%; margin-top: 14px; padding: 10px;
  background: linear-gradient(135deg,var(--theme-primary),var(--theme-secondary));
  border: none; border-radius: 50px;
  font-family: 'Baloo 2', sans-serif; font-size: 1rem; font-weight: 700;
  color: white; cursor: pointer;
}

/* ── Confetti ── */
.confetti-piece {
  position: fixed; width: 12px; height: 12px; border-radius: 2px;
  animation: confettiFall linear forwards; pointer-events: none; z-index: 999;
}
@keyframes confettiFall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ── Footer ── */
footer {
  text-align: center; padding: 5px 0 8px;
  font-size: .7rem; color: rgba(255,255,255,.6);
  font-weight: 700; letter-spacing: .5px; flex-shrink: 0;
}
footer a { color: rgba(255,255,255,.6); text-decoration: none; }

/* ── Common keyframes ── */
@keyframes popIn {
  0%   { transform: scale(.8); opacity: 0; }
  80%  { transform: scale(1.04); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes wrongShake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-8px); }
  60%     { transform: translateX(8px); }
}
@keyframes correctPop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.07); }
  100% { transform: scale(1); }
}
