/* مكتبة ورد — Shared Storybook Kids' Games Design System */
@import url('https://fonts.googleapis.com/css2?family=Baloo+Bhaijaan+2:wght@500;600;700;800&family=Tajawal:wght@400;500;700;800&display=swap');

:root {
  --cream: #FFFBF4;
  --cream-2: #FFF4E2;
  --blush: #FCEAF1;
  --blush-deep: #F6CADB;
  --teal: #145B59;
  --teal-mid: #1E7E7B;
  --teal-light: #2A9D8F;
  --mint: #DDF3EC;
  --coral: #E86F51;
  --coral-dark: #C85235;
  --gold: #F4B942;
  --gold-dark: #D4941A;
  --gold-soft: #FFF4D2;
  --ink: #2B1D12;
  --ink-soft: #6F5A4B;
  --rose: #9E2A55;
  --white: #FFFFFF;
  --shadow-soft: 0 10px 28px rgba(43, 29, 18, 0.09);
  --shadow-card: 0 8px 20px rgba(43, 29, 18, 0.08), 0 4px 0 #EEDCC6;
  --font-display: 'Baloo Bhaijaan 2', 'Tajawal', -apple-system, 'Segoe UI', Tahoma, Arial, sans-serif;
  --font-body: 'Tajawal', 'Baloo Bhaijaan 2', -apple-system, 'Segoe UI', Tahoma, Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.ward-game-body {
  height: 100dvh;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
@supports (height: 100dvh) {
  body.ward-game-body { height: 100dvh; }
}

h1, h2, h3, .ward-title, .ward-btn {
  font-family: var(--font-display);
}

/* ---------- Chunky 3D Tactile Buttons ---------- */
.ward-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: none;
  border-radius: 22px;
  padding: 14px 32px;
  font-size: clamp(19px, 4.6vw, 24px);
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s cubic-bezier(.34,1.56,.64,1), box-shadow 0.12s ease, filter 0.12s ease;
  line-height: 1.25;
  position: relative;
}
.ward-btn:active {
  transform: translateY(4px) scale(0.98);
}

.ward-btn-primary {
  background: linear-gradient(180deg, #F58567 0%, var(--coral) 100%);
  color: #fff;
  box-shadow: 0 6px 0 var(--coral-dark), 0 12px 24px rgba(232, 111, 81, 0.32);
}
.ward-btn-primary:active {
  box-shadow: 0 2px 0 var(--coral-dark), 0 4px 10px rgba(232, 111, 81, 0.25);
}

.ward-btn-teal {
  background: linear-gradient(180deg, #1E7E7B 0%, var(--teal) 100%);
  color: #fff;
  box-shadow: 0 6px 0 #0D3F3D, 0 10px 22px rgba(20, 91, 89, 0.28);
}
.ward-btn-teal:active {
  box-shadow: 0 2px 0 #0D3F3D, 0 4px 10px rgba(20, 91, 89, 0.2);
}

.ward-btn-gold {
  background: linear-gradient(180deg, #FFD05B 0%, var(--gold) 100%);
  color: var(--ink);
  box-shadow: 0 6px 0 var(--gold-dark), 0 10px 20px rgba(244, 185, 66, 0.34);
}
.ward-btn-gold:active {
  box-shadow: 0 2px 0 var(--gold-dark), 0 4px 10px rgba(244, 185, 66, 0.2);
}

.ward-btn-soft {
  background: #fff;
  color: var(--teal);
  border: 2.5px solid #CBE8DF;
  box-shadow: 0 5px 0 #CBE8DF, 0 8px 16px rgba(20, 91, 89, 0.08);
}
.ward-btn-soft:active {
  box-shadow: 0 1px 0 #CBE8DF;
}

/* ---------- Top Game HUD ---------- */
.ward-hud {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(10px + var(--safe-top)) 14px 8px;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  flex-shrink: 0;
}

.ward-hud-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ward-icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  border: 2.5px solid #F0DFC8;
  background: #fff;
  color: var(--teal);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 0 #E5CEB1, 0 6px 14px rgba(43,29,18,0.08);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  flex-shrink: 0;
  font-size: 20px;
  padding: 0;
}
.ward-icon-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #E5CEB1;
}
.ward-icon-btn.muted {
  opacity: 0.65;
  background: #F6EFE6;
}

.ward-speak-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid #FFF7DF;
  background: linear-gradient(180deg, #FFD05B 0%, var(--gold) 100%);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--gold-dark), 0 8px 18px rgba(244,185,66,0.4);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  flex-shrink: 0;
  padding: 0;
  animation: wardPulseGlow 2.4s ease-in-out infinite;
}
.ward-speak-btn:active {
  transform: translateY(3px) scale(0.95);
  box-shadow: 0 2px 0 var(--gold-dark);
}
@keyframes wardPulseGlow {
  0%, 100% { box-shadow: 0 5px 0 var(--gold-dark), 0 0 0 0 rgba(244,185,66,0.45); }
  50% { box-shadow: 0 5px 0 var(--gold-dark), 0 0 0 10px rgba(244,185,66,0); }
}

.ward-star-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 2.5px solid #F7D88B;
  border-radius: 999px;
  padding: 6px 14px 6px 12px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(17px, 4vw, 22px);
  color: var(--ink);
  box-shadow: 0 4px 0 #EBD08A, 0 6px 14px rgba(43,29,18,0.08);
  transition: transform 0.2s cubic-bezier(.34,1.56,.64,1);
}
.ward-star-pill.pop {
  transform: scale(1.22);
}

.ward-progress-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.86);
  border: 2px solid #F0DFC8;
  border-radius: 999px;
  padding: 6px 10px;
  box-shadow: 0 3px 10px rgba(43,29,18,0.06);
}
.ward-prog-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #E9D9C3;
  transition: transform 0.28s cubic-bezier(.34,1.56,.64,1), background 0.25s ease;
}
.ward-prog-dot.done {
  background: var(--gold);
  box-shadow: 0 0 0 2px #FFF4D2;
  transform: scale(1.18);
}
.ward-prog-dot.active {
  background: var(--coral);
  transform: scale(1.25);
}

/* ---------- Mascot Companion Bar (دبدوب ورد) ---------- */
.ward-bear-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 4px 14px;
  position: relative;
  z-index: 20;
  flex-shrink: 0;
}

.ward-bear-avatar {
  width: clamp(64px, 16vw, 84px);
  height: clamp(64px, 16vw, 84px);
  flex-shrink: 0;
  filter: drop-shadow(0 6px 10px rgba(43,29,18,0.12));
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1);
}
.ward-bear-avatar.state-idle {
  animation: bearBob 3.2s ease-in-out infinite;
}
.ward-bear-avatar.state-celebrate {
  animation: bearJump 0.55s cubic-bezier(.34,1.56,.64,1) infinite alternate;
}
.ward-bear-avatar.state-encourage {
  animation: bearTilt 0.6s ease-in-out;
}
@keyframes bearBob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-4px) rotate(1.5deg); }
}
@keyframes bearJump {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-10px) scale(1.07); }
}
@keyframes bearTilt {
  0%, 100% { transform: rotate(0deg); }
  30% { transform: rotate(-7deg); }
  70% { transform: rotate(6deg); }
}

.ward-speech-bubble {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fff;
  border: 3px solid #F2DEC4;
  border-radius: 24px;
  padding: 10px 14px 10px 10px;
  box-shadow: 0 5px 0 #EED7B9, 0 10px 22px rgba(43,29,18,0.08);
  position: relative;
}
.ward-speech-bubble::before {
  content: '';
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
  width: 16px;
  height: 16px;
  background: #fff;
  border-top: 3px solid #F2DEC4;
  border-right: 3px solid #F2DEC4;
  border-radius: 2px;
}
.ward-speech-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(18px, 4.7vw, 25px);
  color: var(--ink);
  line-height: 1.3;
  flex: 1;
}
.ward-speech-text .hl {
  color: var(--coral);
  background: var(--blush);
  padding: 1px 10px;
  border-radius: 12px;
  display: inline-block;
}
.ward-speech-sub {
  display: block;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: clamp(13px, 3.2vw, 15px);
  color: var(--teal);
  margin-top: 2px;
}

/* ---------- Floating Praise Toast ---------- */
.ward-toast {
  position: fixed;
  top: 18%;
  left: 50%;
  transform: translateX(-50%) scale(0.6);
  z-index: 80;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(180deg, #FFFDF8 0%, #FFF4D2 100%);
  border: 3.5px solid var(--gold);
  border-radius: 999px;
  padding: 10px 26px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(22px, 6vw, 34px);
  color: var(--teal);
  box-shadow: 0 8px 0 rgba(212,148,26,0.35), 0 14px 32px rgba(43,29,18,0.18);
  white-space: nowrap;
  max-width: 92vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ward-toast.warn {
  background: linear-gradient(180deg, #FFFDF8 0%, var(--blush) 100%);
  border-color: var(--coral);
  color: var(--rose);
  box-shadow: 0 8px 0 rgba(200,82,53,0.22), 0 14px 32px rgba(43,29,18,0.14);
}
.ward-toast.show {
  animation: wardToastPop 1.25s cubic-bezier(.22,1,.36,1) forwards;
}
@keyframes wardToastPop {
  0% { opacity: 0; transform: translateX(-50%) translateY(16px) scale(0.6); }
  18% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.08); }
  32% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  78% { opacity: 1; transform: translateX(-50%) translateY(-4px) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-18px) scale(0.95); }
}

/* ---------- Overlays (Start / Stage / Victory) ---------- */
.ward-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 35%, rgba(255, 251, 244, 0.88), rgba(20, 91, 89, 0.62));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: wardFadeIn 0.25s ease;
}
.ward-overlay.hidden { display: none !important; }

@keyframes wardFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ward-modal {
  background: linear-gradient(180deg, #FFFFFF 0%, #FFFBF4 100%);
  border: 4px solid #F5DFC2;
  border-radius: 34px;
  padding: 26px 24px 24px;
  width: 100%;
  max-width: 410px;
  text-align: center;
  box-shadow: 0 10px 0 #E7CCAA, 0 24px 56px rgba(43, 29, 18, 0.26);
  position: relative;
  animation: wardModalPop 0.36s cubic-bezier(.34,1.56,.64,1);
}
@keyframes wardModalPop {
  from { transform: scale(0.84) translateY(16px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.ward-modal-mascot {
  width: 112px;
  height: 112px;
  margin: -10px auto 6px;
}

.ward-modal h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 7vw, 34px);
  font-weight: 800;
  color: var(--teal);
  line-height: 1.2;
}
.ward-modal p {
  margin: 0 0 20px;
  font-size: clamp(16px, 4.2vw, 19px);
  color: var(--ink-soft);
  line-height: 1.55;
  font-weight: 500;
}

.ward-modal-stars {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 4px 0 12px;
}
.ward-modal-stars svg {
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 4px 6px rgba(244,185,66,0.45));
  animation: starPopIn 0.5s cubic-bezier(.34,1.56,.64,1) backwards;
}
.ward-modal-stars svg:nth-child(2) { width: 56px; height: 56px; margin-top: -8px; animation-delay: 0.12s; }
.ward-modal-stars svg:nth-child(3) { animation-delay: 0.24s; }
@keyframes starPopIn {
  from { transform: scale(0) rotate(-40deg); opacity: 0; }
  to { transform: scale(1) rotate(0deg); opacity: 1; }
}

.ward-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.ward-modal-actions .ward-btn {
  width: 100%;
}

/* ---------- Confetti & Sparkle Particles ---------- */
.ward-confetti {
  position: fixed;
  pointer-events: none;
  z-index: 120;
  animation: wardConfettiFall var(--dur, 1.3s) cubic-bezier(.2,.7,.4,1) forwards;
}
@keyframes wardConfettiFall {
  0% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(0.7); }
  20% { opacity: 1; transform: translate(calc(var(--dx) * 0.45), calc(var(--dy) * 0.6)) rotate(120deg) scale(1.1); }
  100% { opacity: 0; transform: translate(var(--dx), calc(var(--dy) + 120px)) rotate(540deg) scale(0.6); }
}

/* ---------- Wiggle Animation for Gentle Retry ---------- */
@keyframes wardWiggle {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  20% { transform: translateX(-8px) rotate(-3deg); }
  40% { transform: translateX(8px) rotate(3deg); }
  60% { transform: translateX(-6px) rotate(-2deg); }
  80% { transform: translateX(5px) rotate(1.5deg); }
}
.ward-wiggle {
  animation: wardWiggle 0.42s ease-in-out !important;
}

@keyframes wardCorrectPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.13); }
  100% { transform: scale(1.04); }
}
.ward-correct-pop {
  animation: wardCorrectPop 0.45s cubic-bezier(.34,1.56,.64,1) forwards !important;
}

/* Blink animation for teddy bear SVG */
.ward-bear-eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: bearBlink 4.6s infinite;
}
@keyframes bearBlink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}

@media (max-width: 420px) {
  .ward-hud { padding: calc(8px + var(--safe-top)) 10px 6px; gap: 6px; }
  .ward-icon-btn { width: 42px; height: 42px; border-radius: 14px; }
  .ward-speak-btn { width: 46px; height: 46px; }
  .ward-progress-wrap { padding: 5px 8px; gap: 4px; }
  .ward-prog-dot { width: 9px; height: 9px; }
  .ward-bear-bar { gap: 9px; padding: 2px 10px; }
  .ward-speech-bubble { padding: 8px 12px 8px 8px; border-radius: 20px; }
}


/* ---------- Gentle Mom-Friendly Sales Bridge (Celebration Modal) ---------- */
.ward-modal {
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
}
.ward-sales-bridge {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 2px dashed #F1DEC5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
}
.ward-sales-note {
  margin: 0 !important;
  font-family: var(--font-body);
  font-size: clamp(13px, 3.4vw, 14.5px) !important;
  font-weight: 700 !important;
  color: var(--teal) !important;
  line-height: 1.4 !important;
}
.ward-sales-links {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  width: 100%;
  flex-wrap: wrap;
}
.ward-sales-btn {
  flex: 1 1 138px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 9px 11px;
  border-radius: 15px;
  font-family: var(--font-display);
  font-size: clamp(13px, 3.4vw, 14.5px);
  font-weight: 800;
  text-decoration: none;
  line-height: 1.25;
  white-space: nowrap;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
.ward-sales-btn:active {
  transform: translateY(2px) scale(0.98);
}
.ward-sales-btn.bundle {
  background: linear-gradient(180deg, #FFF5D6 0%, #FFE49E 100%);
  color: var(--ink);
  border: 2px solid #ECC460;
  box-shadow: 0 3px 0 #D8AD42;
}
.ward-sales-btn.store {
  background: linear-gradient(180deg, #FFF8FB 0%, var(--blush) 100%);
  color: var(--rose);
  border: 2px solid #F2C3D6;
  box-shadow: 0 3px 0 #E5AEC4;
}
@media (max-width: 420px) {
  .ward-overlay { padding: 12px; }
  .ward-modal { padding: 18px 16px 16px; border-radius: 28px; }
  .ward-modal-mascot { width: 88px; height: 88px; margin: -6px auto 4px; }
  .ward-modal h1 { font-size: 24px; margin-bottom: 5px; }
  .ward-modal p { font-size: 15px; margin-bottom: 13px; }
  .ward-modal-stars { margin: 2px 0 8px; }
  .ward-modal-stars svg { width: 36px; height: 36px; }
  .ward-modal-stars svg:nth-child(2) { width: 46px; height: 46px; margin-top: -6px; }
  .ward-modal-actions { gap: 8px; }
  .ward-modal-actions .ward-btn { padding: 11px 18px; font-size: 18px; border-radius: 18px; }
  .ward-sales-bridge { margin-top: 11px; padding-top: 10px; gap: 7px; }
  .ward-sales-btn { padding: 8px 9px; font-size: 13px; border-radius: 13px; }
}
