* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  font-family: "Baloo 2", "Comic Sans MS", system-ui, sans-serif;
  background: #fdf6e9;
  color: #22384a;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---------- header ---------- */
.site-header {
  width: 100%;
  max-width: 640px;
  padding: 10px 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #22384a;
}
.brand-logo { height: 48px; width: auto; display: block; }

/* ---------- game layout ---------- */
.game {
  width: 100%;
  max-width: 640px;
  padding: 8px 16px 24px;
  text-align: center;
  flex: 1;
}
.game-title {
  font-size: 40px;
  font-weight: 800;
  margin: 6px 0 4px;
  line-height: 1.1;
}
.hint {
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 10px;
  color: #41528a;
}
.progress {
  font-size: 21px;
  font-weight: 700;
  margin: 6px 0 12px;
}

/* ---------- operation toggles ---------- */
.operations {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 14px;
}
.op-btn {
  font-family: inherit;
  font-size: 18px;
  font-weight: 800;
  border-radius: 999px;
  padding: 9px 20px;
  cursor: pointer;
  background: #ffffff;
  color: #1e8a49;
  border: 3px solid #1e8a49;
  -webkit-tap-highlight-color: transparent;
}
.op-btn.on {
  background: linear-gradient(180deg, #79c94e, #1e8a49);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(30, 138, 73, 0.35);
}
.op-btn:active { transform: scale(0.97); }

/* ---------- flash card ---------- */
.card-scene {
  width: 100%;
  max-width: 420px;
  height: 300px;
  margin: 0 auto;
  perspective: 1200px;
  touch-action: pan-y; /* vertical page scroll ok; horizontal swipes captured by JS */
}
.card {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0.15, 0.3, 1);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.card.flipped { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border-radius: 28px;
  box-shadow: 0 10px 28px rgba(34, 56, 74, 0.22);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  padding: 20px;
}
.card-front { background: #e9f5ec; border: 4px solid #79c94e; }
.card-back {
  background: #ffedb8;
  border: 4px solid #f2b234;
  transform: rotateY(180deg);
}
.problem, .answer {
  font-size: 64px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 1px;
}
.answer { color: #166534; }
.tap-hint {
  font-size: 18px;
  font-weight: 700;
  color: #41528a;
  opacity: 0.85;
}

/* ---------- buttons ---------- */
.controls {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.btn {
  font-family: inherit;
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(180deg, #79c94e, #1e8a49);
  border: none;
  border-radius: 999px;
  padding: 14px 34px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(30, 138, 73, 0.35);
  min-width: 140px;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: linear-gradient(180deg, #6cb843, #166534); }
.btn:active { transform: scale(0.97); }
.btn-shuffle { min-width: 240px; }
.btn-sound {
  font-size: 16px;
  padding: 9px 18px;
  min-width: 0;
  flex-shrink: 0;
}

/* ---------- footer ---------- */
.site-footer {
  width: 100%;
  max-width: 640px;
  padding: 14px 16px 22px;
  text-align: center;
}
.credit { font-size: 14px; margin: 0 0 4px; }
.aco-credit { font-size: 14px; margin: 0; }
.aco-credit a { color: #1e8a49; font-weight: 700; text-decoration: none; }

/* ---------- small phones ---------- */
@media (max-width: 480px) {
  .game-title { font-size: 34px; }
  .card-scene { height: 270px; }
  .problem, .answer { font-size: 54px; }
  .btn { font-size: 20px; padding: 13px 26px; min-width: 126px; }
  .brand-logo { height: 40px; }
}
