/* ============================================
   National Day Quiz — Saudi national background
   (cream + sage Sadu) · MW robot accents
   ============================================ */

:root {
  /* National background palette */
  --cream: #f8e4cf;
  --cream-deep: #f0d4b8;
  --sage: #8fad86;
  --sage-deep: #6f8f68;
  --sage-soft: #a8c09f;
  --sage-ink: #4a6344;
  /* Robot / accent colors */
  --pink: #ff6bb5;
  --pink-soft: #ff8ec8;
  --pink-deep: #e84a9a;
  --purple: #9b5de5;
  --purple-soft: #c4b5fd;
  --purple-deep: #7b5cff;
  --sky: #5ec8ff;
  --sky-soft: #7dd3fc;
  --sky-deep: #38bdf8;
  --ink: #1a2e22;
  --ink-soft: #3d5a47;
  --white: #ffffff;
  --danger: #e11d48;
  --ok: #10b981;
  --radius: 28px;
  --shadow: 0 14px 36px rgba(74, 99, 68, 0.18);
  --font: "Segoe UI", "Tahoma", "Arial", sans-serif;
  --sadu-h: clamp(64px, 12vh, 110px);
  --violet: var(--purple-deep);
}

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

html { font-size: 16px; }

body {
  font-family: var(--font);
  color: var(--ink);
  min-height: 100vh;
  background: var(--cream);
  overflow-x: hidden;
}

.stage {
  position: relative;
  min-height: 100vh;
  background-color: var(--cream);
  display: flex;
  flex-direction: column;
}

/* National Sadu bands — sage green on cream */
.sadu-band {
  position: absolute;
  left: 0;
  right: 0;
  height: var(--sadu-h);
  pointer-events: none;
  z-index: 0;
  background-color: #b7c8a8;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='100' viewBox='0 0 160 100'%3E%3Crect width='160' height='100' fill='%23b7c8a8'/%3E%3Cg fill='none' stroke='%236a845f' stroke-width='2.2' stroke-linejoin='round'%3E%3Cpath d='M80 6 L140 50 L80 94 L20 50 Z'/%3E%3Cpath d='M80 22 L118 50 L80 78 L42 50 Z'/%3E%3Cpath d='M62 42 H98 M62 50 H98 M62 58 H98'/%3E%3Cpath d='M0 50 H20 M140 50 H160'/%3E%3Cpath d='M8 14 L22 28 L8 42 M152 14 L138 28 L152 42 M8 58 L22 72 L8 86 M152 58 L138 72 L152 86'/%3E%3Cpath d='M40 8 L48 18 L40 28 L32 18 Z M120 8 L128 18 L120 28 L112 18 Z M40 72 L48 82 L40 92 L32 82 Z M120 72 L128 82 L120 92 L112 82 Z'/%3E%3C/g%3E%3C/svg%3E");
  background-size: calc(var(--sadu-h) * 1.6) 100%;
  background-repeat: repeat-x;
  box-shadow: inset 0 0 0 1px rgba(106, 132, 95, 0.25);
}

.sadu-top { top: 0; }
.sadu-bottom { bottom: 0; }

/* Floating national balloons — rise bottom → top, loop */
.balloons-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.balloon {
  position: absolute;
  bottom: -160px;
  display: block;
  width: clamp(90px, 14vw, 140px);
  height: auto;
  opacity: 0.85;
  animation-name: balloonRise;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  will-change: transform;
  filter: drop-shadow(0 6px 10px rgba(0, 70, 40, 0.18));
  pointer-events: none;
}

.balloon.b1 { left: 4%;  animation-duration: 18s; animation-delay: 0s;   width: 130px; }
.balloon.b2 { left: 18%; animation-duration: 22s; animation-delay: -6s;  width: 95px; opacity: 0.65; }
.balloon.b3 { left: 36%; animation-duration: 16s; animation-delay: -11s; width: 145px; }
.balloon.b4 { left: 54%; animation-duration: 20s; animation-delay: -3s;  width: 110px; opacity: 0.7; }
.balloon.b5 { left: 70%; animation-duration: 24s; animation-delay: -14s; width: 90px; }
.balloon.b6 { left: 84%; animation-duration: 17s; animation-delay: -8s;  width: 125px; opacity: 0.75; }

@keyframes balloonRise {
  0% {
    transform: translateY(0) translateX(0) rotate(-5deg);
  }
  25% {
    transform: translateY(-30vh) translateX(14px) rotate(4deg);
  }
  50% {
    transform: translateY(-60vh) translateX(-12px) rotate(-3deg);
  }
  75% {
    transform: translateY(-90vh) translateX(16px) rotate(5deg);
  }
  100% {
    transform: translateY(-125vh) translateX(-8px) rotate(-4deg);
  }
}

#app {
  position: relative;
  z-index: 1;
  flex: 1;
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: calc(var(--sadu-h) + 0.75rem) 1.25rem calc(var(--sadu-h) + 0.75rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.settings-btn {
  position: absolute;
  top: calc(var(--sadu-h) + 0.35rem);
  left: clamp(0.75rem, 3vw, 1.75rem);
  z-index: 20;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  line-height: 0;
  transition: transform 0.2s ease;
  filter: drop-shadow(0 4px 12px rgba(123, 92, 255, 0.35));
}

.settings-btn:hover { transform: rotate(-25deg) scale(1.06); }

.screen { display: none; animation: rise 0.4s ease; }
.screen.active { display: block; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.welcome-card {
  text-align: center;
  max-width: 420px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.welcome-card .girl-character {
  width: 160px;
  height: 230px;
  margin: 0 auto 1rem;
}

.welcome-line {
  font-size: clamp(1.25rem, 3.5vw, 1.7rem);
  font-weight: 800;
  color: var(--sage-ink);
  margin-bottom: 0.5rem;
}

.welcome-hint {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin-bottom: 1.25rem;
}

.btn-welcome {
  min-width: 200px;
  margin: 0.35rem;
}

.robot-enter {
  animation: robotPopIn 0.9s cubic-bezier(0.22, 1.2, 0.36, 1) both;
}

@keyframes robotPopIn {
  0% {
    opacity: 0;
    transform: translateY(80px) scale(0.5);
  }
  60% {
    opacity: 1;
    transform: translateY(-12px) scale(1.08);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.start-head { text-align: center; margin-bottom: 1.5rem; }

.eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--sage-ink);
  background: rgba(143, 173, 134, 0.35);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  margin-bottom: 0.55rem;
}

.start-head h1 {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  color: var(--ink);
  font-weight: 800;
}

.start-head .sub {
  margin-top: 0.4rem;
  color: var(--ink-soft);
  font-size: 0.98rem;
}

.mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  max-width: 900px;
  margin: 0 auto;
}

.mode-card {
  position: relative;
  border: none;
  cursor: pointer;
  background: linear-gradient(145deg, #c4a574 0%, #a67c52 45%, #8b6914 100%);
  border-radius: var(--radius);
  min-height: 240px;
  padding: 1.25rem 1rem 1.1rem;
  box-shadow: 0 14px 36px rgba(107, 74, 40, 0.28);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
  color: var(--ink);
  overflow: visible;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}

.mode-card-alt {
  background: linear-gradient(145deg, #d4b896 0%, #b8956c 40%, #8b6914 100%);
}

.mode-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 3px solid transparent;
  pointer-events: none;
  transition: border-color 0.2s;
}

.mode-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 18px 40px rgba(107, 74, 40, 0.38);
}

.mode-card:hover::after,
.mode-card.selected::after {
  border-color: #5c3d1e;
}

.mode-pill {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  background: var(--cream);
  color: #5c3d1e;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  z-index: 2;
  box-shadow: 0 4px 12px rgba(92, 61, 30, 0.15);
}

.mode-art {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1;
  min-height: 130px;
  margin-top: 1.5rem;
  overflow: visible;
}

.team-svg {
  width: 100%;
  max-width: 320px;
  height: 130px;
  overflow: visible;
}

.team-svg use {
  width: 100px;
  height: 120px;
}

.mode-hint {
  display: block;
  margin-top: 0.35rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff8ef;
  text-shadow: 0 1px 2px rgba(60, 35, 15, 0.35);
}

.mascot-dock {
  position: absolute;
  bottom: calc(var(--sadu-h) + 0.5rem);
  right: clamp(0.5rem, 4vw, 2rem);
  pointer-events: none;
}

.mascot-dock .girl-character {
  width: 120px;
  height: 170px;
}

.btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  border: none;
  border-radius: 999px;
  padding: 0.8rem 1.5rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn:hover { transform: translateY(-2px); }

.btn-primary {
  background: linear-gradient(90deg, var(--pink), var(--purple-deep));
  color: #fff;
  box-shadow: 0 8px 22px rgba(255, 107, 181, 0.4);
}

.btn-secondary {
  background: linear-gradient(90deg, var(--purple), var(--sky));
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--purple-deep);
  border: 2px solid var(--purple-soft);
}

.btn-danger {
  background: #ffe4e6;
  color: var(--danger);
}

.icon-close {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--cream-deep);
  color: var(--ink);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  font-weight: 700;
}

#screen-teacher.active {
  display: flex;
  justify-content: center;
}

.settings-sheet {
  width: min(640px, 100%);
  background: var(--white);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.35rem 1.5rem;
  border: 3px solid var(--sage);
  position: relative;
  max-height: calc(100vh - 2 * var(--sadu-h) - 2rem);
  overflow-y: auto;
}

.settings-sheet::before {
  content: "";
  display: block;
  height: 18px;
  margin: -1.35rem -1.35rem 1rem;
  border-radius: calc(var(--radius) + 4px) calc(var(--radius) + 4px) 0 0;
  background-color: var(--sage-soft);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='18' viewBox='0 0 80 18'%3E%3Cpath fill='none' stroke='%236f8f68' stroke-width='1.4' d='M0 9 L10 2 L20 9 L30 2 L40 9 L50 2 L60 9 L70 2 L80 9 M0 9 L10 16 L20 9 L30 16 L40 9 L50 16 L60 9 L70 16 L80 9'/%3E%3C/svg%3E");
  background-size: 80px 18px;
  background-repeat: repeat-x;
}

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.sheet-head h2 {
  color: var(--sage-ink);
  font-size: 1.35rem;
}

.question-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin-bottom: 0.8rem;
}

.question-form input,
.question-form textarea,
.question-form select {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  padding: 0.65rem 0.85rem;
  border: 2px solid #e9d5ff;
  border-radius: 14px;
  background: var(--cream);
  color: var(--ink);
}

.question-form input:focus,
.question-form textarea:focus,
.question-form select:focus {
  outline: none;
  border-color: var(--sky);
}

.answers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 0.85rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.questions-list-wrap {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 2px dashed #e9d5ff;
}

.questions-list-wrap h3 {
  color: var(--purple-deep);
  font-size: 1rem;
  margin-bottom: 0.65rem;
}

.questions-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
}

.questions-list li {
  background: var(--cream);
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
  display: flex;
  justify-content: space-between;
  gap: 0.65rem;
  align-items: flex-start;
  border: 1px solid #e9d5ff;
}

.q-item-text { flex: 1; font-size: 0.9rem; }
.q-item-meta {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.btn-delete-q {
  background: #ffe4e6;
  color: var(--danger);
  border: none;
  border-radius: 8px;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}

.empty-hint { color: var(--ink-soft); font-size: 0.88rem; }

.teacher-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

/* ---------- Robot character ---------- */
.girl-character {
  width: 130px;
  height: 190px;
  position: relative;
}

.girl-character .girl-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.girl-character.mood-idle .girl-svg { animation: idleBob 2.2s ease-in-out infinite; }
.girl-character.mood-smile .girl-svg { animation: happyBounce 0.55s ease; }
.girl-character.mood-sad .girl-svg { animation: sadShake 0.5s ease; }
.girl-character.mood-celebrate .girl-svg { animation: celebrateJump 0.65s ease infinite; }

.girl-character.mood-smile .antenna-ball,
.girl-character.mood-celebrate .antenna-ball {
  animation: antennaPulse 0.5s ease infinite;
}

@keyframes idleBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes happyBounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.08) translateY(-12px) rotate(-4deg); }
  70% { transform: scale(1.05) translateY(-6px) rotate(4deg); }
  100% { transform: scale(1); }
}
@keyframes sadShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px) rotate(-2deg); }
  75% { transform: translateX(5px) rotate(2deg); }
}
@keyframes celebrateJump {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-22px) rotate(-3deg); }
}
@keyframes antennaPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.35); }
}

.girl-speech {
  margin-top: 0.5rem;
  background: var(--white);
  color: var(--purple-deep);
  padding: 0.45rem 0.75rem;
  border-radius: 14px;
  font-size: 0.85rem;
  font-weight: 800;
  text-align: center;
  box-shadow: var(--shadow);
  border: 2px solid var(--sky-soft);
  max-width: 150px;
}

#girl-svg-template { display: none !important; }

/* ---------- Game ---------- */
.game-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.scoreboard {
  background: var(--white);
  border-radius: 16px;
  padding: 0.55rem 1rem;
  text-align: center;
  box-shadow: var(--shadow);
  border: 2px solid var(--purple-soft);
  min-width: 90px;
}

.scoreboard .team-name {
  display: block;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--ink-soft);
}

.scoreboard .team-score {
  display: block;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--purple-deep);
  line-height: 1.15;
}

.scoreboards-two {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.scoreboard.active-turn {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(255, 107, 181, 0.3), var(--shadow);
  transform: scale(1.04);
}

.turn-badge {
  background: linear-gradient(90deg, var(--pink), var(--sky));
  color: #fff;
  font-weight: 800;
  font-size: 0.75rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
}

.progress-chip {
  background: linear-gradient(90deg, var(--purple), var(--sky));
  color: #fff;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.85rem;
}

.hidden { display: none !important; }

.game-main {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 1rem;
  align-items: start;
}

.girl-aside {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.quiz-card {
  background: var(--white);
  border-radius: calc(var(--radius) + 2px);
  padding: 1.35rem;
  box-shadow: var(--shadow);
  border: 3px solid var(--purple-soft);
  position: relative;
}

.timer-wrap {
  width: 68px;
  height: 68px;
  position: absolute;
  top: 0.9rem;
  left: 0.9rem;
}

.timer-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-bg {
  fill: none;
  stroke: #e9d5ff;
  stroke-width: 8;
}

.timer-fg {
  fill: none;
  stroke: var(--sky-deep);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 264;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.2s linear, stroke 0.3s;
}

.timer-fg.urgent { stroke: var(--danger); }

.timer-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--purple-deep);
}

.question-text {
  text-align: center;
  color: var(--ink);
  font-size: clamp(1.1rem, 2.8vw, 1.4rem);
  margin: 2.4rem 0.5rem 1.25rem;
  line-height: 1.5;
  padding: 0 2.5rem;
}

.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.answer-btn {
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 700;
  text-align: right;
  padding: 0.9rem 1rem;
  border: 3px solid #e9d5ff;
  border-radius: 16px;
  background: var(--cream);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.answer-btn:hover:not(:disabled) {
  border-color: var(--sky);
  transform: translateY(-2px);
  background: #eef9ff;
}

.answer-btn:disabled { cursor: default; }

.answer-letter {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.answer-btn.correct {
  background: #d1fae5;
  border-color: var(--ok);
  color: var(--ok);
}

.answer-btn.wrong {
  background: #ffe4e6;
  border-color: var(--danger);
  color: var(--danger);
}

.answer-btn.dim { opacity: 0.45; }

.game-bar {
  margin-top: 1rem;
  text-align: center;
}

#screen-result.active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  position: relative;
}

.result-card {
  background: var(--white);
  border-radius: calc(var(--radius) + 6px);
  padding: 1.75rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 460px;
  width: 100%;
  position: relative;
  z-index: 2;
  border: 3px solid var(--purple-soft);
}

.result-card .girl-character { margin: 0 auto 0.85rem; }

.result-card h2 {
  color: var(--purple-deep);
  font-size: 1.6rem;
  margin-bottom: 0.4rem;
}

.result-message {
  color: var(--ink-soft);
  font-size: 1.05rem;
  margin-bottom: 0.85rem;
  line-height: 1.5;
}

.result-scores {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.result-scores .winner-board {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(255, 107, 181, 0.3);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 14px;
  top: -20px;
  animation: confettiFall linear forwards;
  border-radius: 2px;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0.85; }
}

@media (max-width: 780px) {
  .mode-row { grid-template-columns: 1fr; }
  .mascot-dock { display: none; }
  .game-main { grid-template-columns: 1fr; }
  .girl-aside {
    flex-direction: row;
    justify-content: center;
    gap: 0.75rem;
  }
  .girl-aside .girl-character {
    width: 90px;
    height: 130px;
  }
  .girl-speech { margin-top: 0; }
  .answers { grid-template-columns: 1fr; }
  .answers-grid,
  .form-row { grid-template-columns: 1fr; }
  .question-text {
    padding: 0;
    margin-top: 3.2rem;
  }
  .timer-wrap {
    left: 50%;
    transform: translateX(-50%);
  }
  .settings-btn svg {
    width: 42px;
    height: 42px;
  }
}
