/* Math4Kids — playful but tidy */
:root {
  --sky-50: #F0F8FF;
  --sky-100: #DCEEFB;
  --sky-200: #B6DDF5;
  --sky-300: #7CC5F5;
  --sky-500: #4DA8E8;
  --sky-700: #2A6FAE;
  --ink-900: #1F2D4A;
  --ink-700: #3B4C73;
  --ink-500: #6B7A99;
  --ink-300: #B6C0D6;
  --cloud: #FFFFFF;
  --cream: #FFF9EC;
  --sun: #FFD93D;
  --sun-deep: #F4B71A;
  --grass: #7BD389;
  --grass-deep: #4FB561;
  --pink: #FFB3D9;
  --pink-deep: #FF7AB8;
  --lavender: #C9A8FF;
  --lavender-deep: #9B72E8;
  --coral: #FF9B7A;
  --mint: #9DE8C8;
  --shadow-soft: 0 8px 24px rgba(43, 78, 130, 0.08), 0 2px 6px rgba(43, 78, 130, 0.06);
  --shadow-card: 0 12px 28px rgba(43, 78, 130, 0.10), 0 4px 10px rgba(43, 78, 130, 0.06);
  --shadow-pop: 0 18px 40px rgba(43, 78, 130, 0.16), 0 6px 14px rgba(43, 78, 130, 0.10);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --radius-xl: 36px;
  --radius-pill: 999px;
}

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

html, body {
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  color: var(--ink-900);
  background: linear-gradient(180deg, #EAF5FF 0%, #F5F0FF 60%, #FFF4F9 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

h1, h2, h3, h4, .display {
  font-family: 'Fredoka', 'Nunito', system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* Floating cloud decorations */
.bg-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.bg-cloud {
  position: absolute;
  opacity: 0.55;
  filter: blur(0.3px);
  animation: float 18s ease-in-out infinite;
}
.bg-cloud.c2 { animation-duration: 24s; animation-delay: -6s; }
.bg-cloud.c3 { animation-duration: 30s; animation-delay: -12s; }
.bg-cloud.c4 { animation-duration: 22s; animation-delay: -3s; }

@keyframes float {
  0%, 100% { transform: translateY(0) translateX(0); }
  50% { transform: translateY(-18px) translateX(10px); }
}

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

@keyframes wiggle {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(2deg); }
}

@keyframes sparkle {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}

@keyframes pop-in {
  0% { transform: scale(0.85); opacity: 0; }
  60% { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* Layout */
.app {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 28px 80px;
}

/* HEADER */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 14px;
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, rgba(234,245,255,0.92) 0%, rgba(234,245,255,0.7) 80%, rgba(234,245,255,0) 100%);
  backdrop-filter: blur(8px);
  z-index: 50;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
}
.brand-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  animation: bob 4s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(155, 114, 232, 0.25));
}
.brand-name {
  font-family: 'Fredoka', sans-serif;
  font-size: 28px;
  font-weight: 600;
  color: var(--ink-900);
  line-height: 1;
}
.brand-name span { color: var(--lavender-deep); }
.brand-tag {
  font-size: 13px;
  color: var(--ink-500);
  font-weight: 600;
  margin-top: 2px;
}
.nav {
  display: flex;
  gap: 6px;
  align-items: center;
  background: var(--cloud);
  padding: 6px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-soft);
}
.nav a {
  text-decoration: none;
  color: var(--ink-700);
  font-weight: 700;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  transition: all 0.2s;
}
.nav a:hover { background: var(--sky-100); color: var(--ink-900); }
.nav a.cta {
  background: linear-gradient(135deg, var(--sun) 0%, var(--sun-deep) 100%);
  color: var(--ink-900);
  box-shadow: 0 4px 0 #C99410;
}
.nav a.cta:hover { transform: translateY(-1px); box-shadow: 0 5px 0 #C99410; }

/* HERO */
.hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 40px;
  align-items: center;
  padding: 40px 0 30px;
}
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--cloud);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-700);
  box-shadow: var(--shadow-soft);
  margin-bottom: 18px;
}
.hero-eyebrow .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--grass-deep);
  box-shadow: 0 0 0 4px rgba(123, 211, 137, 0.3);
}
.hero h1 {
  font-size: clamp(40px, 5.2vw, 64px);
  line-height: 1.02;
  color: var(--ink-900);
  margin-bottom: 18px;
}
.hero h1 .accent-1 { color: var(--sky-500); }
.hero h1 .accent-2 { color: var(--pink-deep); }
.hero h1 .accent-3 { color: var(--sun-deep); }
.hero p.lede {
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink-700);
  max-width: 520px;
  margin-bottom: 28px;
}
.hero-stats {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.hero-stat {
  background: var(--cloud);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  gap: 12px;
}
.hero-stat-icon {
  width: 44px; height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.hero-stat-num {
  font-family: 'Fredoka', sans-serif;
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
  color: var(--ink-900);
}
.hero-stat-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Hero visual */
.hero-visual {
  position: relative;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
}
.hero-cube-stack {
  position: relative;
  width: 90%;
  max-width: 420px;
  aspect-ratio: 1 / 1;
}
.hero-cube {
  position: absolute;
  border-radius: 22px;
  display: grid;
  place-items: center;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  color: white;
  box-shadow: var(--shadow-pop), inset 0 -8px 0 rgba(0,0,0,0.08), inset 0 4px 0 rgba(255,255,255,0.3);
  animation: bob 5s ease-in-out infinite;
}
.hero-cube.c1 { left: 4%; top: 18%; width: 38%; aspect-ratio: 1; background: linear-gradient(135deg, #FFE066, var(--sun-deep)); font-size: 76px; color: #6B4A00; animation-delay: 0s; }
.hero-cube.c2 { right: 6%; top: 8%; width: 34%; aspect-ratio: 1; background: linear-gradient(135deg, #95D5FF, var(--sky-500)); font-size: 64px; animation-delay: -1.5s; }
.hero-cube.c3 { left: 24%; bottom: 6%; width: 36%; aspect-ratio: 1; background: linear-gradient(135deg, #FFC9E2, var(--pink-deep)); font-size: 70px; animation-delay: -3s; }
.hero-cube.c4 { right: 14%; bottom: 12%; width: 30%; aspect-ratio: 1; background: linear-gradient(135deg, #DCC8FF, var(--lavender-deep)); font-size: 56px; animation-delay: -2.2s; }

.hero-sparkle {
  position: absolute;
  font-size: 24px;
  animation: sparkle 2.4s ease-in-out infinite;
}

/* Section heading */
.section {
  padding: 56px 0 20px;
  position: relative;
}
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 26px;
  gap: 20px;
  flex-wrap: wrap;
}
.section-head-left { display: flex; align-items: center; gap: 18px; }
.section-icon {
  width: 64px; height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-card), inset 0 -6px 0 rgba(0,0,0,0.08), inset 0 3px 0 rgba(255,255,255,0.4);
  flex-shrink: 0;
}
.section h2 {
  font-size: clamp(28px, 3.4vw, 40px);
  line-height: 1.08;
  color: var(--ink-900);
}
.section-sub {
  font-size: 15px;
  color: var(--ink-500);
  font-weight: 600;
  margin-top: 6px;
}
.section-counter {
  background: var(--cloud);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-700);
  box-shadow: var(--shadow-soft);
}

/* Game grid */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px;
}
@media (max-width: 1000px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px) { .grid { grid-template-columns: repeat(2, 1fr); } }

/* Game card */
.game-card {
  position: relative;
  background: var(--cloud);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 260px;
  text-align: left;
  width: 100%;
}
.game-card:hover {
  transform: translateY(-6px) rotate(-0.5deg);
  box-shadow: var(--shadow-pop);
}
.game-card-tile {
  width: 100%;
  aspect-ratio: 1.4 / 1;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  margin-bottom: 16px;
  position: relative;
  box-shadow: inset 0 -8px 0 rgba(0,0,0,0.08), inset 0 4px 0 rgba(255,255,255,0.35);
  overflow: hidden;
}
.game-card-symbol {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 88px;
  color: white;
  text-shadow: 0 4px 0 rgba(0,0,0,0.08);
  line-height: 1;
}
.game-card-symbol.dark { color: #6B4A00; text-shadow: 0 3px 0 rgba(0,0,0,0.06); }
.game-card-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--ink-900);
  margin-bottom: 4px;
}
.game-card-desc {
  font-size: 13.5px;
  color: var(--ink-500);
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 14px;
}
.game-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--sky-100);
  color: var(--sky-700);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chip.reward {
  background: linear-gradient(135deg, #FFF1B8, #FFE066);
  color: #8A5A00;
}
.chip.diff-easy { background: #DFF7E4; color: #2D7A3E; }
.chip.diff-mid { background: #FFE9C7; color: #8A5A00; }
.chip.diff-hard { background: #FFD6E5; color: #A02A6B; }
.play-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 13px;
  color: var(--ink-700);
}
.play-btn-arrow {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--ink-900);
  color: white;
  display: grid;
  place-items: center;
  font-size: 14px;
  transition: transform 0.2s;
}
.game-card:hover .play-btn-arrow { transform: translateX(3px); }

.game-card-corner {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(255,255,255,0.9);
  border-radius: var(--radius-pill);
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-700);
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 2;
}

/* Random games — wider, alternating layout */
.random-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}
@media (max-width: 900px) { .random-list { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .random-list { grid-template-columns: 1fr; } }

.random-card {
  position: relative;
  background: var(--cloud);
  border-radius: var(--radius-lg);
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s;
  display: flex;
  flex-direction: column;
  min-height: 220px;
  text-align: left;
  width: 100%;
}
.random-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-pop); }
.random-card-art {
  flex: 1;
  display: grid;
  place-items: center;
  position: relative;
  min-height: 130px;
}
.random-card-body {
  background: var(--cloud);
  padding: 16px 18px 18px;
  border-top: 1px dashed rgba(43, 78, 130, 0.1);
}
.random-card-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 19px;
  font-weight: 600;
  margin-bottom: 4px;
}
.random-card-desc {
  font-size: 13px;
  color: var(--ink-500);
  font-weight: 600;
  line-height: 1.4;
}

/* REDEEM section */
.redeem {
  background: linear-gradient(135deg, #FFF4F9 0%, #F5EEFF 50%, #EAF5FF 100%);
  border-radius: var(--radius-xl);
  padding: 50px 48px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 50px;
  align-items: center;
}
@media (max-width: 880px) { .redeem { grid-template-columns: 1fr; padding: 36px 28px; } }

.redeem-deco {
  position: absolute;
  pointer-events: none;
}
.redeem-deco.d1 { top: 20px; right: 30px; font-size: 32px; animation: sparkle 3s ease-in-out infinite; }
.redeem-deco.d2 { bottom: 24px; left: 38px; font-size: 24px; animation: sparkle 2.5s ease-in-out infinite 0.5s; }
.redeem-deco.d3 { top: 40%; right: 12%; font-size: 18px; animation: sparkle 2.8s ease-in-out infinite 1s; }

.redeem-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--cloud);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 800;
  color: var(--pink-deep);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: var(--shadow-soft);
  margin-bottom: 16px;
}
.redeem h2 {
  font-size: clamp(30px, 3.6vw, 44px);
  line-height: 1.05;
  margin-bottom: 14px;
}
.redeem h2 .pink { color: var(--pink-deep); }
.redeem p {
  color: var(--ink-700);
  font-size: 16px;
  line-height: 1.55;
  margin-bottom: 22px;
  max-width: 480px;
}

.code-input-wrap {
  background: var(--cloud);
  border-radius: var(--radius-lg);
  padding: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  box-shadow: var(--shadow-card);
  border: 2px solid transparent;
  transition: border-color 0.2s;
}
.code-input-wrap:focus-within { border-color: var(--pink-deep); }
.code-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: 'Fredoka', sans-serif;
  font-size: 24px;
  font-weight: 500;
  color: var(--ink-900);
  padding: 14px 18px;
  letter-spacing: 0.05em;
}
.code-input::placeholder { color: var(--ink-300); font-weight: 500; }
.redeem-btn {
  background: linear-gradient(135deg, var(--pink) 0%, var(--pink-deep) 100%);
  color: white;
  font-family: 'Fredoka', sans-serif;
  font-size: 18px;
  font-weight: 600;
  padding: 14px 26px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 0 #C9558F, 0 8px 16px rgba(255, 122, 184, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.redeem-btn:hover { transform: translateY(-1px); box-shadow: 0 5px 0 #C9558F, 0 10px 18px rgba(255, 122, 184, 0.4); }
.redeem-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #C9558F, 0 4px 8px rgba(255, 122, 184, 0.35); }

.redeem-hint {
  font-size: 13px;
  color: var(--ink-500);
  font-weight: 700;
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.redeem-msg {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 14px;
  animation: pop-in 0.3s ease-out;
}
.redeem-msg.error { background: #FFE2E2; color: #B23636; }
.redeem-msg.success { background: #E2F7E5; color: #2D7A3E; }

/* Code preview card */
.code-preview {
  position: relative;
  background: var(--cloud);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-pop);
  transform: rotate(2deg);
  transition: transform 0.3s;
}
.code-preview:hover { transform: rotate(0deg) scale(1.02); }
.code-preview-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #FFE066, var(--sun));
  color: #6B4A00;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}
.code-preview-emojis {
  font-size: 56px;
  letter-spacing: 0.05em;
  text-align: center;
  padding: 24px 0;
  background: linear-gradient(180deg, #FFF9EC 0%, #FFEFD0 100%);
  border-radius: var(--radius-md);
  border: 2px dashed var(--sun-deep);
  margin-bottom: 14px;
}
.code-preview-label {
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.code-preview::before {
  content: '';
  position: absolute;
  top: -10px; left: 50%;
  transform: translateX(-50%);
  width: 80px; height: 16px;
  background: rgba(255,255,255,0.6);
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

/* Sticker collection */
.stickers-section {
  background: var(--cloud);
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
.stickers-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 14px;
  margin-top: 24px;
}
@media (max-width: 900px) { .stickers-grid { grid-template-columns: repeat(6, 1fr); } }
@media (max-width: 600px) { .stickers-grid { grid-template-columns: repeat(4, 1fr); } }

.sticker {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  font-size: 38px;
  position: relative;
  cursor: pointer;
  transition: transform 0.2s;
}
.sticker.unlocked {
  background: linear-gradient(135deg, #FFF9EC, #FFEFD0);
  box-shadow: var(--shadow-soft), inset 0 -4px 0 rgba(0,0,0,0.05);
  animation: pop-in 0.4s ease-out;
}
.sticker.unlocked:hover { transform: scale(1.08) rotate(-3deg); }
.sticker.locked {
  background: repeating-linear-gradient(45deg, #F0F4F8, #F0F4F8 6px, #E6ECF2 6px, #E6ECF2 12px);
  font-size: 22px;
  color: var(--ink-300);
}
.sticker-count-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--sun), var(--sun-deep));
  color: #6B4A00;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-weight: 800;
  font-size: 13px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 45, 74, 0.55);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 100;
  animation: fade-in 0.2s ease-out;
  padding: 20px;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--cloud);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  overflow: hidden;
  animation: pop-in 0.3s ease-out;
  box-shadow: 0 30px 80px rgba(0,0,0,0.3);
}
.modal-hero {
  padding: 36px;
  display: grid;
  place-items: center;
  position: relative;
  min-height: 200px;
}
/* Slim variant used when a math runner is mounted: gives the runner more
   vertical room so the numpad/choices fit above the fold on phones. */
.modal-hero.modal-hero-slim {
  padding: 12px 22px;
  min-height: 0;
  place-items: center start;
}
.modal-hero-slim-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Fredoka', sans-serif;
  font-size: 18px;
  font-weight: 600;
  text-shadow: 0 1px 0 rgba(0,0,0,0.08);
}
.modal-hero-slim-symbol { font-size: 28px; line-height: 1; }
.modal-hero-symbol {
  font-family: 'Fredoka', sans-serif;
  font-size: 120px;
  color: white;
  font-weight: 600;
  text-shadow: 0 6px 0 rgba(0,0,0,0.08);
  line-height: 1;
}
.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  display: grid;
  place-items: center;
  font-size: 20px;
  color: var(--ink-700);
  transition: transform 0.2s;
}
.modal-close:hover { transform: rotate(90deg); }
.modal-body { padding: 28px 32px 32px; }
.modal-body h3 {
  font-size: 28px;
  margin-bottom: 8px;
}
.modal-body p {
  color: var(--ink-700);
  font-size: 15px;
  line-height: 1.55;
  margin-bottom: 20px;
}
.modal-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.modal-actions {
  display: flex;
  gap: 12px;
}
.btn-primary {
  flex: 1;
  background: linear-gradient(135deg, var(--sky-300), var(--sky-500));
  color: white;
  font-family: 'Fredoka', sans-serif;
  font-size: 17px;
  font-weight: 600;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 0 var(--sky-700);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 5px 0 var(--sky-700); }
.btn-secondary {
  background: var(--sky-100);
  color: var(--ink-700);
  font-family: 'Fredoka', sans-serif;
  font-size: 17px;
  font-weight: 600;
  padding: 14px 20px;
  border-radius: var(--radius-md);
}
.btn-secondary:hover { background: var(--sky-200); }

/* Math game runner shared shell. Mounted inside the math game modal under the
   colored hero. Children render the question and pick an input style:
   Numpad (typed answer), ChoicePad (multiple choice), or NumberLine (drag). */
.runner {
  padding: 18px 24px 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  text-align: center;
  position: relative;
  min-height: 360px;
}
.runner.fb-correct { background: linear-gradient(180deg, rgba(123,211,137,0.10), transparent 60%); }
.runner.fb-wrong   { background: linear-gradient(180deg, rgba(255,123,184,0.12), transparent 60%); }

.runner-progress { display: flex; gap: 8px; }
.runner-progress .dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--ink-300);
  transition: transform 0.2s, background 0.2s;
}
.runner-progress .dot-ok { background: var(--grass-deep); }
.runner-progress .dot-no { background: var(--pink-deep); }
.runner-progress .dot-now { background: var(--sky-500); transform: scale(1.25); }

.runner-label {
  font-family: 'Fredoka', sans-serif;
  font-size: 18px;
  color: var(--ink-700);
  font-weight: 600;
}
.runner-question {
  font-family: 'Fredoka', sans-serif;
  font-size: 56px;
  font-weight: 600;
  color: var(--ink-900);
  letter-spacing: 0.02em;
  line-height: 1;
}
.runner-stage {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  width: 100%;
}
.runner-flash {
  position: absolute;
  inset: auto 0 14px;
  text-align: center;
  font-family: 'Fredoka', sans-serif;
  font-size: 22px;
  font-weight: 600;
  pointer-events: none;
  animation: pop-in 0.25s ease-out;
}
.runner-flash.ok { color: var(--grass-deep); }
.runner-flash.no { color: var(--pink-deep); }

/* Numpad: typed numeric answer. */
.numpad {
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.numpad-display {
  background: var(--sky-100);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-family: 'Fredoka', sans-serif;
  font-size: 32px;
  font-weight: 600;
  color: var(--ink-900);
  text-align: center;
  min-height: 56px;
}
.numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.numpad-key {
  background: var(--cloud);
  font-family: 'Fredoka', sans-serif;
  font-size: 24px;
  font-weight: 600;
  color: var(--ink-900);
  padding: 16px 0;
  border-radius: var(--radius-md);
  box-shadow: 0 3px 0 var(--ink-300);
  transition: transform 0.1s, box-shadow 0.1s;
}
.numpad-key:hover  { transform: translateY(-1px); box-shadow: 0 4px 0 var(--ink-300); }
.numpad-key:active { transform: translateY(2px);  box-shadow: 0 1px 0 var(--ink-300); }
.numpad-key.numpad-clear { background: #FFE2E2; color: #C13F6E; box-shadow: 0 3px 0 #E8A5BA; }
.numpad-key.numpad-ok    { background: linear-gradient(135deg, var(--grass), var(--grass-deep)); color: white; box-shadow: 0 3px 0 #2E8C42; }
.numpad-key.numpad-ok:disabled {
  background: var(--ink-300);
  box-shadow: 0 3px 0 var(--ink-500);
  opacity: 0.7;
  cursor: not-allowed;
}

/* ChoicePad: 4 colored bubble buttons (Multiplikasjon, Klokka, Former, Telling). */
.choicepad {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 360px;
}
.choice {
  font-family: 'Fredoka', sans-serif;
  font-size: 24px;
  font-weight: 600;
  color: white;
  padding: 18px 12px;
  border-radius: var(--radius-md);
  transition: transform 0.1s, box-shadow 0.1s;
}
.choice-0 { background: linear-gradient(135deg, #95D5FF, #4DA8E8); box-shadow: 0 4px 0 #2A6FAE; }
.choice-1 { background: linear-gradient(135deg, #FFC9E2, #FF7AB8); box-shadow: 0 4px 0 #C14A8E; }
.choice-2 { background: linear-gradient(135deg, #DCC8FF, #9B72E8); box-shadow: 0 4px 0 #6B45BD; }
.choice-3 { background: linear-gradient(135deg, #FFE066, #F4B71A); box-shadow: 0 4px 0 #C99410; color: var(--ink-900); }
.choice:hover  { transform: translateY(-2px); }
.choice:active { transform: translateY(2px);  }

/* Klokka: analog clock face. */
.clock-face { filter: drop-shadow(0 6px 14px rgba(31,45,74,0.18)); }

/* Former: large shape display. */
.shape-display { filter: drop-shadow(0 6px 14px rgba(31,45,74,0.18)); }

/* Telling: cluster of countable objects. */
.count-board {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 10px;
  max-width: 380px;
  background: var(--sky-100);
  border-radius: var(--radius-md);
  padding: 14px;
}
.count-item { font-size: 28px; line-height: 1; }

/* Tallinje: drag a marker to a value. */
.numline {
  position: relative;
  width: 100%;
  max-width: 380px;
  height: 80px;
  touch-action: none;
  cursor: grab;
}
.numline:active { cursor: grabbing; }
.numline-track {
  position: absolute;
  top: 38px;
  left: 8px;
  right: 8px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sky-200), var(--lavender));
}
.numline-tick {
  position: absolute;
  top: 30px;
  width: 0;
  text-align: center;
}
.numline-tick::before {
  content: '';
  position: absolute;
  left: -1px; top: 8px;
  width: 2px; height: 12px;
  background: var(--ink-500);
  border-radius: 1px;
}
.numline-tick span {
  display: inline-block;
  transform: translate(-50%, 28px);
  font-size: 11px;
  color: var(--ink-500);
  font-weight: 700;
  white-space: nowrap;
}
.numline-marker {
  position: absolute;
  top: 24px;
  width: 36px; height: 36px;
  margin-left: -18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  box-shadow: 0 4px 10px rgba(255,122,184,0.45);
  display: grid;
  place-items: center;
  color: white;
  font-family: 'Fredoka', sans-serif;
  font-size: 13px;
  font-weight: 600;
  user-select: none;
  transition: transform 0.05s;
}
.numline-marker:active { transform: scale(1.1); }

/* Age picker grid: shown on first visit before any math game starts. */
.age-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 6px;
}
.age-btn {
  font-family: 'Fredoka', sans-serif;
  font-size: 28px;
  font-weight: 600;
  padding: 16px 0;
  background: linear-gradient(135deg, var(--sky-100), var(--sky-200));
  color: var(--ink-900);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 0 var(--sky-300);
  transition: transform 0.12s, box-shadow 0.12s;
  cursor: pointer;
}
.age-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--sky-300); }
.age-btn:active { transform: translateY(1px); box-shadow: 0 2px 0 var(--sky-300); }

/* Iframe modal for standalone games in Other Games/ */
.modal.modal-iframe {
  max-width: min(960px, 96vw);
  width: 96vw;
  height: 92vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
}
.modal-iframe-bar {
  position: relative;
  padding: 14px 60px 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-iframe-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink-900);
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}
.modal-iframe-bar .modal-close {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
}
.modal-iframe-bar .modal-close:hover { transform: translateY(-50%) rotate(90deg); }
.modal-iframe-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #000;
  display: block;
}

/* Reward reveal modal */
.reveal-art {
  background: linear-gradient(135deg, #FFE9F4, #FFF4E5, #E8F5FF);
  padding: 40px 30px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.reveal-art-emojis {
  font-size: 80px;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}
.reveal-art-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 30px;
  color: var(--ink-900);
  margin-bottom: 6px;
}
.reveal-art-sub {
  font-size: 14px;
  color: var(--ink-500);
  font-weight: 700;
}
.reveal-media {
  background: #1F2D4A;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  color: rgba(255,255,255,0.5);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  position: relative;
  overflow: hidden;
  background-image: 
    repeating-linear-gradient(45deg, rgba(255,255,255,0.04) 0 8px, transparent 8px 16px);
  margin: 20px;
}
.reveal-media::before {
  content: '▶';
  position: absolute;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: grid;
  place-items: center;
  font-size: 24px;
  color: white;
}
.reveal-media-label {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.5);
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* Real media reveal: rendered when a reward has a usable url. */
.reveal-media-frame {
  margin: 20px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  box-shadow: 0 8px 24px rgba(31, 45, 74, 0.18);
}
.reveal-media-frame iframe,
.reveal-media-frame img,
.reveal-media-frame video {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  object-fit: contain;
}

/* Footer */
.footer {
  text-align: center;
  padding: 60px 0 0;
  color: var(--ink-500);
  font-size: 13px;
  font-weight: 700;
}
.footer-mark {
  font-family: 'Fredoka', sans-serif;
  font-size: 16px;
  color: var(--ink-700);
  margin-bottom: 6px;
}

/* Responsive */
@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; gap: 30px; }
  .hero-visual { max-width: 380px; margin: 0 auto; }
  .nav { display: none; }
}

/* Tweaks Panel sits above */
.tweaks-toggle-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 60;
}

/* Respect users who have asked for reduced motion. We keep the look but
   strip the floating clouds, sticker bobs, and pop animations that can
   trigger motion sensitivity. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Phone tweaks: the modal pulls in tight, numpad tiles grow, choice grid stays usable. */
@media (max-width: 520px) {
  .modal { max-width: 100%; border-radius: 22px 22px 0 0; align-self: end; }
  .modal-backdrop { padding: 0; align-items: end; }
  .runner-question { font-size: 44px; }
  .numpad-key { font-size: 22px; padding: 14px 0; }
  .choice { font-size: 20px; padding: 14px 10px; }
  .age-grid { grid-template-columns: repeat(4, 1fr); }
  .age-btn { font-size: 22px; padding: 14px 0; }
  .modal.modal-iframe { width: 100vw; height: 100vh; max-width: 100vw; border-radius: 0; }
}
