/* ============================================================
   Maths Star Garden — shared design tokens & components
   Used by: index.html (hub), subtraction.html, future game pages
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Quicksand', system-ui, sans-serif;
  background: linear-gradient(135deg, #ffe5f1 0%, #e5f4ff 50%, #fff5e5 100%);
  color: #4a3858;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app {
  height: 100vh;
  width: 100vw;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

.screen {
  min-height: 100vh;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeIn 0.4s ease-out;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px);} to { opacity: 1; transform: none;} }

/* ---------- Hero / mascot ---------- */
.title-hero { text-align: center; margin: 24px 0 10px; }
.title-hero h1 {
  font-size: 44px;
  background: linear-gradient(90deg, #ff7eb9, #ff9472, #ffd86b, #7afcff, #c47aff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 0 rgba(255,255,255,0.5);
  letter-spacing: 1px;
}
.mascot {
  font-size: 90px;
  display: inline-block;
  animation: bobble 2.6s ease-in-out infinite;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,0.12));
}
@keyframes bobble {
  0%,100% { transform: translateY(0) rotate(-3deg);}
  50% { transform: translateY(-10px) rotate(3deg);}
}

/* ---------- Speech bubble & greeting ---------- */
.greeting {
  background: white;
  padding: 14px 22px;
  border-radius: 26px;
  font-size: 22px;
  box-shadow: 0 6px 0 #ffd1e7;
  margin: 8px 0 18px;
  max-width: 90%;
  text-align: center;
}
.speech-bubble {
  background: white;
  padding: 10px 18px;
  border-radius: 24px;
  margin: 8px 0;
  font-size: 17px;
  box-shadow: 0 3px 0 #ffd1e7;
  position: relative;
  text-align: center;
  max-width: 480px;
}

/* ---------- Name input ---------- */
.name-input-wrap {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  width: 100%;
  max-width: 380px;
}
.name-input {
  flex: 1;
  border: 4px solid #ffb6db;
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 22px;
  font-family: inherit;
  background: white;
  text-align: center;
  color: #4a3858;
  outline: none;
}
.name-input:focus { border-color: #ff7eb9; }

/* ---------- Stats / garden ---------- */
.stats-bar {
  display: flex;
  gap: 14px;
  margin: 12px 0;
  flex-wrap: wrap;
  justify-content: center;
}
.stat-pill {
  background: white;
  border-radius: 30px;
  padding: 8px 18px;
  font-size: 18px;
  box-shadow: 0 3px 0 #e0d0ee;
  display: flex;
  align-items: center;
  gap: 6px;
}

.garden-preview {
  background: rgba(255,255,255,0.6);
  border-radius: 20px;
  padding: 14px;
  margin-top: 16px;
  width: 100%;
  max-width: 460px;
  text-align: center;
}
.garden-preview h3 { font-size: 18px; margin-bottom: 8px; color: #6a5481; }
.garden-display {
  font-size: 30px;
  line-height: 1.5;
  min-height: 50px;
  word-wrap: break-word;
}
.garden-empty { color: #b0a0c0; font-size: 15px; font-family: inherit; }

/* ---------- Top bar / icon button ---------- */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 540px;
  margin-bottom: 8px;
}
.icon-btn {
  background: white;
  border: 3px solid #ffb6db;
  border-radius: 50%;
  width: 46px;
  height: 46px;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 3px 0 #ffb6db;
  font-family: inherit;
  color: #4a3858;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #ffb6db; }

/* ---------- Big buttons ---------- */
.big-btn {
  background: linear-gradient(135deg, #ff7eb9, #ff5c8a);
  color: white;
  border: none;
  border-radius: 22px;
  padding: 16px 30px;
  font-size: 22px;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 5px 0 #d94572;
  margin: 8px 4px;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #d94572; }
.big-btn.secondary {
  background: linear-gradient(135deg, #b8c8ff, #8ba0e8);
  box-shadow: 0 5px 0 #6477c2;
}
.big-btn.secondary:active { box-shadow: 0 2px 0 #6477c2; }

.footer-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
  justify-content: center;
}
.small-text { font-size: 13px; color: #8b7aa3; margin-top: 6px; text-align: center; }

/* ---------- User picker (multi-player support) ---------- */
.user-picker {
  background: rgba(255,255,255,0.7);
  border-radius: 22px;
  padding: 14px;
  width: 100%;
  max-width: 460px;
  text-align: center;
  margin-top: 6px;
}
.user-picker h3 { font-size: 18px; margin-bottom: 10px; color: #6a5481; }
.user-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.user-pick-btn {
  background: white;
  border: 4px solid #ffb6db;
  border-radius: 16px;
  padding: 12px 8px;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 0 #ffd1e7;
  color: #4a3858;
}
.user-pick-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #ffd1e7; }
.upb-name { font-size: 18px; font-weight: bold; word-break: break-word; }
.upb-stars { font-size: 13px; color: #8b7aa3; margin-top: 4px; }
.or-divider { font-size: 14px; color: #8b7aa3; margin: 10px 0 6px; }

/* ---------- Effects: sparkles, confetti, toast ---------- */
.sparkle-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  overflow: hidden;
}
.sparkle {
  position: absolute;
  font-size: 28px;
  animation: sparkleFly 1.4s ease-out forwards;
}
@keyframes sparkleFly {
  0% { transform: translate(0,0) scale(0) rotate(0); opacity: 1;}
  50% { opacity: 1;}
  100% { transform: translate(var(--dx), var(--dy)) scale(1.4) rotate(360deg); opacity: 0;}
}
.confetti-piece {
  position: absolute;
  width: 10px;
  height: 16px;
  top: -20px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(720deg); }
}
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: white;
  padding: 12px 22px;
  border-radius: 24px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  font-size: 18px;
  z-index: 300;
  transition: transform 0.4s cubic-bezier(.17,.67,.5,1.5);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ---------- Settings modal ---------- */
.settings-modal {
  position: fixed;
  inset: 0;
  background: rgba(74,56,88,0.55);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.settings-card {
  background: white;
  border-radius: 24px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
}
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f0e5f5;
}
.toggle {
  width: 50px;
  height: 28px;
  background: #d4c5e0;
  border-radius: 14px;
  position: relative;
  cursor: pointer;
  transition: background 0.3s;
}
.toggle.on { background: #ff7eb9; }
.toggle::after {
  content: '';
  position: absolute;
  width: 22px; height: 22px;
  background: white;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: left 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle.on::after { left: 25px; }

/* ---------- Reward screens ---------- */
.reward-screen-content {
  text-align: center;
  margin-top: 30px;
}
.reward-screen-content h2 {
  font-size: 38px;
  color: #ff5c8a;
  margin-bottom: 10px;
}
.reward-stars {
  font-size: 36px;
  margin: 16px auto;
  letter-spacing: 2px;
  animation: starGrow 0.6s ease-out;
  max-width: 90vw;
  line-height: 1.3;
  word-break: break-word;
}
@keyframes starGrow {
  from { transform: scale(0); opacity: 0;}
  to { transform: scale(1); opacity: 1;}
}
.reward-unlock {
  background: white;
  border-radius: 22px;
  padding: 20px;
  margin: 14px 0;
  box-shadow: 0 6px 0 #ffd1e7;
  max-width: 360px;
}
.reward-unlock .item {
  font-size: 70px;
  margin: 10px 0;
  animation: bounceIn 0.7s ease-out;
}
@keyframes bounceIn {
  0% { transform: scale(0) rotate(-180deg); }
  60% { transform: scale(1.3) rotate(20deg); }
  100% { transform: scale(1) rotate(0); }
}

/* ---------- Inkling mastery filters (used by the Inklings game) ---------- */
/* Apply these classes to the wrapper around an Inkling emoji to reflect
   its mastery state. Each escalates the visual richness. */
.ink-wild {
  filter: grayscale(0.95) brightness(0.7);
  opacity: 0.4;
}
.ink-captured {
  filter: grayscale(0.4);
  opacity: 0.85;
}
.ink-tame {
  /* full colour */
}
.ink-mastered {
  filter: drop-shadow(0 0 8px rgba(255, 216, 107, 0.9));
  animation: inkPulse 2.4s ease-in-out infinite;
}
.ink-eternal {
  filter: drop-shadow(0 0 12px gold) drop-shadow(0 0 4px #fff8c8);
  animation: inkGolden 3s ease-in-out infinite;
}
@keyframes inkPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}
@keyframes inkGolden {
  0%, 100% { filter: drop-shadow(0 0 8px gold) drop-shadow(0 0 3px #fff8c8); transform: rotate(-2deg); }
  50%      { filter: drop-shadow(0 0 16px gold) drop-shadow(0 0 6px #fffacd); transform: rotate(2deg); }
}
