/* === Unit 10 game: kill site header offset (empty top band) === */
.arcade-header-bar,
.arcade-nav,
.nav-profile,
.profile-fab,
[data-theme-toggle],
.theme-toggle,
body > header,
.site-footer {
  display: none !important;
}
html, body {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin: 0 !important;
}
body.game-page,
body[data-type="game"] {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

html, body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0 !important;
  overflow: hidden !important;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body {
  background: #f4f6fb !important;
  color: #1e293b !important;
}
html[data-theme="dark"] body {
  background: #0f1117 !important;
  color: #f1f5f9 !important;
}

.mc-game {
  position: relative;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 10px 14px 12px;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
}

.mc-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  flex-shrink: 0;
}
.mc-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid #d0d5dd;
  background: #fff;
  color: #334155;
  font-size: 16px;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  flex-shrink: 0;
}
html[data-theme="dark"] .mc-back {
  border-color: rgba(148,163,184,0.25);
  background: rgba(255,255,255,0.06);
  color: #e2e8f0;
}
.mc-title {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html[data-theme="dark"] .mc-title { color: #94a3b8; }
.mc-badge, .mc-progress {
  font-size: 12px;
  font-weight: 800;
  color: #6d28d9;
  background: rgba(124, 92, 255, 0.12);
  padding: 5px 10px;
  border-radius: 999px;
  flex-shrink: 0;
}
html[data-theme="dark"] .mc-badge,
html[data-theme="dark"] .mc-progress {
  color: #c4b5fd;
  background: rgba(167, 139, 250, 0.18);
}

.mc-start, .mc-done {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 0;
  overflow: auto;
  padding: 8px 4px;
}
.mc-hero {
  width: 72px; height: 72px;
  border-radius: 20px;
  background: linear-gradient(145deg, #34d399, #6366f1);
  display: flex; align-items: center; justify-content: center;
  font-size: 34px;
  margin-bottom: 12px;
  box-shadow: 0 10px 28px rgba(99,102,241,0.3);
}
.mc-start h1, .mc-done h1 {
  margin: 0 0 6px;
  font-size: 1.45rem;
  font-weight: 900;
}
.mc-desc {
  margin: 0 0 14px;
  color: #64748b;
  font-weight: 600;
  font-size: 0.95rem;
}
html[data-theme="dark"] .mc-desc { color: #94a3b8; }

.mc-mode-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}
.mc-mode-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px 14px;
}
button.mc-mode-btn {
  appearance: none;
  width: 100%;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}
button.mc-mode-btn:active { transform: scale(0.98); }
button.mc-mode-btn:hover {
  border-color: #6366f1;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.15);
}
html[data-theme="dark"] .mc-mode-card {
  background: rgba(255,255,255,0.05);
  border-color: rgba(148,163,184,0.2);
}
.mc-mode-num {
  width: 28px; height: 28px;
  border-radius: 9px;
  background: linear-gradient(145deg, #818cf8, #6366f1);
  color: #fff;
  font-weight: 900;
  font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.mc-mode-card strong { display: block; font-size: 0.92rem; }
.mc-mode-card p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: #64748b;
  font-weight: 600;
}
html[data-theme="dark"] .mc-mode-card p { color: #94a3b8; }

.mc-stars { display: flex; gap: 6px; font-size: 1.5rem; margin-bottom: 8px; }
.mc-trophy { font-size: 2.4rem; margin-bottom: 6px; }

.mc-instruction {
  margin: 0 0 8px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
  flex-shrink: 0;
}
html[data-theme="dark"] .mc-instruction { color: #94a3b8; }
.mc-hint-warn { color: #dc2626 !important; }

.mc-board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  overflow: hidden;
}
.mc-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.mc-col > * {
  flex: 1 1 0;
  min-height: 56px;
}

/* Shared card shell */
.mc-left-item, .mc-right-item {
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  user-select: none;
  -webkit-user-select: none;
}
html[data-theme="dark"] .mc-left-item,
html[data-theme="dark"] .mc-right-item {
  background: rgba(255,255,255,0.05);
  border-color: rgba(148,163,184,0.22);
}
.mc-left-item {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 4px;
}
.mc-left-item.is-selected,
.mc-right-item.is-selected {
  border-color: #6366f1 !important;
  border-width: 3px !important;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.28);
  outline: 2px solid rgba(99, 102, 241, 0.5);
  outline-offset: 2px;
}
html[data-theme="dark"] .mc-left-item.is-selected,
html[data-theme="dark"] .mc-right-item.is-selected {
  border-color: #a5b4fc !important;
  box-shadow: 0 0 0 4px rgba(165, 180, 252, 0.3);
  outline-color: rgba(165, 180, 252, 0.55);
}
.mc-left-item.is-correct,
.mc-right-item.is-correct {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.1);
}
html[data-theme="dark"] .mc-left-item.is-correct,
html[data-theme="dark"] .mc-right-item.is-correct {
  border-color: #34d399;
  background: rgba(52, 211, 153, 0.12);
}
.mc-left-item.is-wrong,
.mc-right-item.is-wrong {
  border-color: #ef4444;
  animation: mc-shake 0.4s ease;
}
@keyframes mc-shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Pictures – fit fully inside the button */
.mc-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  border-radius: 10px;
  display: block;
  pointer-events: none;
  padding: 6px;
  box-sizing: border-box;
}
.mc-pic-flag {
  position: absolute;
  right: 6px;
  bottom: 6px;
  font-size: 1.15rem;
  line-height: 1;
  background: rgba(15, 23, 42, 0.55);
  border-radius: 8px;
  padding: 3px 5px;
  backdrop-filter: blur(4px);
  z-index: 2;
}
.mc-pic-cell, .mc-pic-btn {
  position: relative;
  padding: 4px;
  overflow: hidden;
}
.mc-pic-btn {
  appearance: none;
  width: 100%;
  height: 100%;
  cursor: pointer;
  font: inherit;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #fff;
}
html[data-theme="dark"] .mc-pic-btn {
  background: rgba(255,255,255,0.05);
}

/* Words */
.mc-word {
  appearance: none;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 10px 14px;
  font: inherit;
  font-weight: 800;
  font-size: 1.15rem;
  color: #1e293b;
  cursor: pointer;
  text-align: center;
}
html[data-theme="dark"] .mc-word { color: #f1f5f9; }
.mc-word-label {
  min-width: 0;
  line-height: 1.25;
  font-size: 1.15rem;
  font-weight: 800;
}

/* Play button – AEF 1 U3A style */
.mc-play {
  position: relative;
  overflow: visible;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
  transition: transform 0.15s, box-shadow 0.2s;
}
.mc-play:hover { transform: scale(1.05); }
.mc-play:disabled { opacity: 0.5; cursor: default; transform: none; }
.mc-play.playing { box-shadow: 0 0 0 5px rgba(99, 102, 241, 0.25); }
.mc-play svg {
  position: relative;
  z-index: 2;
  transition: opacity 0.2s, transform 0.2s;
}
.mc-play .wave {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid #6366f1;
  opacity: 0;
  pointer-events: none;
}
.mc-play.playing .wave { animation: mc-ripple 1.25s ease-out infinite; }
.mc-play.playing .wave:nth-child(2) { animation-delay: 0.3s; }
.mc-play.playing .wave:nth-child(3) { animation-delay: 0.6s; }
@keyframes mc-ripple {
  0% { transform: scale(0.85); opacity: 0.65; }
  100% { transform: scale(1.55); opacity: 0; }
}
.mc-play .eq {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}
.mc-play .eq span {
  width: 3px;
  height: 12px;
  background: #fff;
  border-radius: 2px;
}
.mc-play.playing svg { opacity: 0; transform: scale(0.5); }
.mc-play.playing .eq { opacity: 1; }
.mc-play.playing .eq span:nth-child(1) { animation: mc-eq 0.55s ease-in-out infinite; }
.mc-play.playing .eq span:nth-child(2) { animation: mc-eq 0.55s ease-in-out infinite 0.1s; }
.mc-play.playing .eq span:nth-child(3) { animation: mc-eq 0.55s ease-in-out infinite 0.2s; }
.mc-play.playing .eq span:nth-child(4) { animation: mc-eq 0.55s ease-in-out infinite 0.15s; }
@keyframes mc-eq {
  0%,100% { transform: scaleY(0.45); }
  50% { transform: scaleY(1.15); }
}

.mc-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-shrink: 0;
  padding-bottom: max(4px, env(safe-area-inset-bottom, 0px));
}
.mc-btn {
  appearance: none;
  border: none;
  flex: 0 0 auto;
  background: linear-gradient(145deg, #818cf8, #6366f1);
  color: #fff;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  padding: 12px 28px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
  text-align: center;
  text-decoration: none;
  min-width: 160px;
  align-self: center;
}
.mc-actions .mc-btn {
  flex: 1;
  min-width: 0;
}
.mc-btn.secondary {
  background: #fff;
  color: #4338ca;
  border: 2px solid #c7d2fe;
  box-shadow: none;
}
html[data-theme="dark"] .mc-btn.secondary {
  background: rgba(255,255,255,0.06);
  color: #c4b5fd;
  border-color: rgba(167, 139, 250, 0.35);
}
.mc-btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.mc-done .mc-btn { margin-top: 8px; width: min(220px, 100%); flex: none; }

@media (max-width: 400px) {
  .mc-word, .mc-word-label, .mc-word-left, .mc-word-left .mc-word-label { font-size: 1.05rem; }
  .mc-word { padding: 8px 10px; }
  .mc-play { width: 50px; height: 50px; }
  .mc-pic-flag { font-size: 1rem; }
}
@media (max-height: 680px) {
  .mc-col > * { min-height: 48px; }
  .mc-play { width: 46px; height: 46px; }
}

/* ===== Match visual effects ===== */
.mc-left-item,
.mc-right-item {
  position: relative;
  overflow: visible;
}
.mc-pic-cell,
.mc-pic-btn {
  overflow: hidden; /* keep image clipped; sparks on outer item */
}
.mc-left-item.mc-pic-cell,
.mc-right-item.mc-pic-btn {
  overflow: visible;
}
.mc-left-item.mc-pic-cell .mc-thumb,
.mc-right-item.mc-pic-btn .mc-thumb {
  border-radius: 10px;
}

.mc-match-pop {
  animation: mc-pop 0.5s cubic-bezier(0.22, 1.2, 0.36, 1);
  border-color: #10b981 !important;
  box-shadow:
    0 0 0 4px rgba(16, 185, 129, 0.35),
    0 8px 24px rgba(16, 185, 129, 0.25) !important;
  z-index: 5;
}
html[data-theme="dark"] .mc-match-pop {
  box-shadow:
    0 0 0 4px rgba(52, 211, 153, 0.4),
    0 8px 24px rgba(52, 211, 153, 0.3) !important;
}

@keyframes mc-pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.mc-spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: radial-gradient(circle, #fde68a 0%, #34d399 45%, #6366f1 100%);
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  animation: mc-spark 0.65s ease-out forwards;
  animation-delay: var(--delay, 0s);
}
@keyframes mc-spark {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0.2);
  }
}

.mc-match-flash {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 30;
  background: radial-gradient(circle at center, rgba(52, 211, 153, 0.18), transparent 55%);
  animation: mc-flash 0.45s ease-out forwards;
}
@keyframes mc-flash {
  0% { opacity: 0; }
  30% { opacity: 1; }
  100% { opacity: 0; }
}

/* Checkmark badge on correct tiles */
.mc-left-item.is-correct::after,
.mc-right-item.is-correct::after {
  content: "✓";
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #10b981;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.45);
  animation: mc-check-in 0.35s cubic-bezier(0.22, 1.2, 0.36, 1);
  z-index: 6;
}
@keyframes mc-check-in {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Wrong: stronger red pulse */
.mc-left-item.is-wrong,
.mc-right-item.is-wrong {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.35);
}

/* Country name on left – same font/size as nationality words on right */
.mc-word-left {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 10px 14px;
  font: inherit;
  font-weight: 800;
  font-size: 1.15rem;
  color: #1e293b;
  cursor: pointer;
  text-align: center;
  position: relative;
}
html[data-theme="dark"] .mc-word-left {
  color: #f1f5f9;
}
.mc-word-left .mc-word-label {
  min-width: 0;
  line-height: 1.25;
  font-size: 1.15rem;
  font-weight: 800;
  color: inherit;
  text-align: center;
}
.mc-word-left.is-selected {
  border-color: #7c5cff;
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.25);
}

/* ========== Smooth animations (all modes) ========== */

/* Staggered entrance when a set loads */
.mc-board .mc-left-item,
.mc-board .mc-right-item {
  opacity: 1;
}
.mc-board.is-entering .mc-left-item,
.mc-board.is-entering .mc-right-item {
  animation: mc-card-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.mc-board .mc-left-item:nth-child(1),
.mc-board .mc-right-item:nth-child(1) { animation-delay: 0.04s; }
.mc-board .mc-left-item:nth-child(2),
.mc-board .mc-right-item:nth-child(2) { animation-delay: 0.08s; }
.mc-board .mc-left-item:nth-child(3),
.mc-board .mc-right-item:nth-child(3) { animation-delay: 0.12s; }
.mc-board .mc-left-item:nth-child(4),
.mc-board .mc-right-item:nth-child(4) { animation-delay: 0.16s; }
.mc-board .mc-left-item:nth-child(5),
.mc-board .mc-right-item:nth-child(5) { animation-delay: 0.20s; }

@keyframes mc-card-in {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Smoother base transitions on all cards */
.mc-left-item,
.mc-right-item {
  transition: border-color 0.22s ease,
    background 0.22s ease,
    box-shadow 0.22s ease,
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Soft lift on hover / selected */
.mc-left-item:not(.is-correct):hover,
.mc-right-item:not(.is-correct):not(.is-used):hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}
html[data-theme="dark"] .mc-left-item:not(.is-correct):hover,
html[data-theme="dark"] .mc-right-item:not(.is-correct):not(.is-used):hover {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.mc-left-item.is-selected {
  transform: translateY(-2px) scale(1.02);
  transition: border-color 0.2s ease, box-shadow 0.25s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Correct match – gentle settle */
.mc-left-item.is-correct,
.mc-right-item.is-correct {
  transition: border-color 0.3s ease,
    background 0.3s ease,
    box-shadow 0.3s ease,
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Wrong – smoother shake */
.mc-left-item.is-wrong,
.mc-right-item.is-wrong {
  animation: mc-shake-smooth 0.48s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
@keyframes mc-shake-smooth {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-5px); }
  30% { transform: translateX(5px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
}

/* Stronger but smoother pop on match */
.mc-match-pop {
  animation: mc-pop-smooth 0.55s cubic-bezier(0.22, 1.25, 0.36, 1);
}
@keyframes mc-pop-smooth {
  0% { transform: scale(1); }
  30% { transform: scale(1.1); }
  55% { transform: scale(0.97); }
  100% { transform: scale(1); }
}

/* Sparkles – slightly longer, softer fade */
.mc-spark {
  animation: mc-spark-smooth 0.75s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes mc-spark-smooth {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0.15);
  }
}

/* Flash ring – softer */
.mc-match-flash {
  animation: mc-flash-smooth 0.55s ease-out forwards;
}
@keyframes mc-flash-smooth {
  0% { opacity: 0.55; transform: scale(0.92); }
  100% { opacity: 0; transform: scale(1.08); }
}

/* Check mark – smoother bounce in */
.mc-left-item.is-correct::after,
.mc-right-item.is-correct::after {
  animation: mc-check-smooth 0.45s cubic-bezier(0.22, 1.3, 0.36, 1);
}
@keyframes mc-check-smooth {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* Menu mode cards – smooth entrance */
.mc-mode-list .mc-mode-card {
  opacity: 0;
  animation: mc-card-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.mc-mode-list .mc-mode-card:nth-child(1) { animation-delay: 0.06s; }
.mc-mode-list .mc-mode-card:nth-child(2) { animation-delay: 0.12s; }
.mc-mode-list .mc-mode-card:nth-child(3) { animation-delay: 0.18s; }

.mc-mode-card {
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.mc-mode-card:hover {
  transform: translateY(-3px);
}

/* Done screen – soft fade up */
.mc-done {
  animation: mc-card-in 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.mc-done .mc-trophy {
  animation: mc-check-smooth 0.55s cubic-bezier(0.22, 1.3, 0.36, 1) 0.1s both;
}
.mc-done .mc-stars span {
  display: inline-block;
  opacity: 0;
  animation: mc-card-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.mc-done .mc-stars span:nth-child(1) { animation-delay: 0.2s; }
.mc-done .mc-stars span:nth-child(2) { animation-delay: 0.3s; }
.mc-done .mc-stars span:nth-child(3) { animation-delay: 0.4s; }

/* Instruction / progress – subtle fade */
.mc-instruction,
.mc-progress {
  transition: color 0.2s ease, background 0.2s ease;
}
.mc-instruction.mc-hint-warn {
  animation: mc-hint-pulse 0.9s ease;
}
@keyframes mc-hint-pulse {
  0%, 100% { opacity: 1; }
  30% { opacity: 0.55; }
  60% { opacity: 1; }
}

/* Buttons */
.mc-btn {
  transition: background 0.2s ease, transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease;
}
.mc-btn:hover {
  transform: translateY(-1px);
}
.mc-btn:active {
  transform: scale(0.97);
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .mc-board .mc-left-item,
  .mc-board .mc-right-item,
  .mc-mode-list .mc-mode-card,
  .mc-done,
  .mc-done .mc-trophy,
  .mc-done .mc-stars span,
  .mc-match-pop,
  .mc-spark,
  .mc-match-flash,
  .mc-left-item.is-wrong,
  .mc-right-item.is-wrong,
  .mc-screen,
  .mc-screen.mc-screen-leave,
  .mc-game::before {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .mc-left-item,
  .mc-right-item,
  .mc-mode-card,
  .mc-btn,
  .mc-set-progress-fill {
    transition: none !important;
  }
}

/* ── Trophy win animation: stars orbit around the cup (behind → front) ── */
.trophy-scene {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 8px 0 16px;
  position: relative;
  width: 100%;
  min-height: 160px;
  perspective: 600px;
  perspective-origin: 50% 45%;
}

.orbit-system {
  position: relative;
  width: 200px;
  height: 150px;
  transform-style: preserve-3d;
}

/* Cup fixed in the center plane (translateZ 0) */
.trophy-float {
  position: absolute;
  left: 50%;
  top: 44%;
  font-size: 64px;
  line-height: 1;
  user-select: none;
  pointer-events: none;
  transform: translate(-50%, -50%) translateZ(0);
  filter: drop-shadow(0 8px 18px rgba(251, 191, 36, 0.4));
  animation: trophy-float 3s ease-in-out infinite;
  will-change: transform;
  /* solid-ish backdrop so stars disappear when behind */
  background: radial-gradient(circle at 50% 55%, rgba(15, 23, 42, 0.92) 0%, rgba(15, 23, 42, 0.6) 55%, transparent 72%);
  border-radius: 50%;
  padding: 8px 10px;
}

html:not([data-theme="dark"]) .trophy-float {
  background: radial-gradient(circle at 50% 55%, rgba(244, 246, 251, 0.95) 0%, rgba(244, 246, 251, 0.65) 55%, transparent 72%);
}

.trophy-scene.perfect .trophy-float {
  filter: drop-shadow(0 10px 24px rgba(251, 191, 36, 0.6));
  animation: trophy-float 2.6s ease-in-out infinite;
}

/* Orbital arms — 3 stars evenly spaced */
.star-orbit {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  animation: orbit-around 10s linear infinite;
}

.star-orbit:nth-child(2) { animation-delay: 0s; }
.star-orbit:nth-child(3) { animation-delay: -3.33s; }
.star-orbit:nth-child(4) { animation-delay: -6.66s; }

.star {
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  font-size: 26px;
  line-height: 28px;
  text-align: center;
  color: rgba(148, 163, 184, 0.35);
  /* radius of the orbit */
  transform: translateZ(70px);
  transform-origin: center center;
  pointer-events: none;
  backface-visibility: visible;
}

.star.filled {
  color: #fbbf24;
  filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.85));
  animation: star-self-spin 5.5s linear infinite;
}

/* Tilted Y-orbit so path is elliptical and clearly goes behind/front */
@keyframes orbit-around {
  from { transform: rotateX(22deg) rotateY(0deg); }
  to   { transform: rotateX(22deg) rotateY(360deg); }
}

/* Self-spin while keeping the orbital radius (translateZ) */
@keyframes star-self-spin {
  from { transform: translateZ(70px) rotate(0deg); }
  to   { transform: translateZ(70px) rotate(360deg); }
}

@keyframes trophy-float {
  0%, 100% { transform: translate(-50%, -50%) translateZ(0) translateY(0) rotate(-2deg); }
  50%      { transform: translate(-50%, -50%) translateZ(0) translateY(-10px) rotate(2deg); }
}

@media (prefers-reduced-motion: reduce) {
  .trophy-float,
  .star-orbit,
  .star.filled {
    animation: none !important;
  }
  .star-orbit:nth-child(2) { transform: rotateX(22deg) rotateY(0deg); }
  .star-orbit:nth-child(3) { transform: rotateX(22deg) rotateY(120deg); }
  .star-orbit:nth-child(4) { transform: rotateX(22deg) rotateY(240deg); }
  .star { transform: translateZ(70px); }
}


/* === Shared mismatch style (Units 1–2 match games) === */
.mc-left-item.is-wrong,
.mc-right-item.is-wrong,
.mc-card.is-wrong,
.sm-card.is-wrong,
.ms-item.is-wrong,
[class*="is-wrong"] {
  border-color: #ef4444 !important;
  background: #fee2e2 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.4) !important;
  opacity: 1 !important;
  visibility: visible !important;
  animation: mc-mismatch-shake 0.48s cubic-bezier(0.36, 0.07, 0.19, 0.97) !important;
}
html[data-theme="dark"] .mc-left-item.is-wrong,
html[data-theme="dark"] .mc-right-item.is-wrong,
html[data-theme="dark"] .mc-card.is-wrong,
html[data-theme="dark"] .sm-card.is-wrong,
html[data-theme="dark"] .ms-item.is-wrong,
html[data-theme="dark"] [class*="is-wrong"] {
  background: rgba(239, 68, 68, 0.22) !important;
  border-color: #f87171 !important;
}
@keyframes mc-mismatch-shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  15% { transform: translate3d(-5px, 0, 0); }
  30% { transform: translate3d(5px, 0, 0); }
  45% { transform: translate3d(-4px, 0, 0); }
  60% { transform: translate3d(3px, 0, 0); }
  75% { transform: translate3d(-2px, 0, 0); }
}

/* Sequential parts – start & between screens */
.mc-part-list {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  width: 100%;
  text-align: left;
}
.mc-part-list li {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  color: #334155;
}
html[data-theme="dark"] .mc-part-list li {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
.mc-part-list li strong {
  color: #6366f1;
}
html[data-theme="dark"] .mc-part-list li strong {
  color: #a5b4fc;
}
.mc-start-btn {
  width: min(240px, 100%);
  margin-top: 4px;
}
.mc-between .mc-next-label {
  margin: 12px 0 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
html[data-theme="dark"] .mc-between .mc-next-label {
  color: #94a3b8;
}
.mc-between .mc-next-title {
  margin: 0 0 18px;
  font-size: 1.05rem;
  color: #1e293b;
}
html[data-theme="dark"] .mc-between .mc-next-title {
  color: #f1f5f9;
}

/* ===== Lives hearts (from AEF Starter Food Match) ===== */
.mc-hearts {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  margin-left: auto;
  margin-right: 8px;
}
html[data-theme="dark"] .mc-hearts {
  background: rgba(255,255,255,0.06);
  border-color: rgba(148,163,184,0.25);
}
.mc-heart {
  font-size: 1.1rem;
  line-height: 1;
  display: inline-block;
  transform-origin: center;
}
.mc-heart.is-full {
  color: #ef4444;
  text-shadow: 0 1px 0 #b91c1c;
}
.mc-heart.is-broken {
  color: #cbd5e1;
  opacity: 0.85;
  transform: scale(0.95);
}
html[data-theme="dark"] .mc-heart.is-broken {
  color: #64748b;
}
.mc-heart.is-breaking {
  color: #ef4444;
  animation: mc-heartBreak 0.48s ease forwards;
}
@keyframes mc-heartBreak {
  0% { transform: scale(1) rotate(0deg); opacity: 1; filter: none; }
  25% { transform: scale(1.25) rotate(-12deg); }
  50% { transform: scale(1.1) rotate(10deg); filter: grayscale(0.3); }
  75% { transform: scale(0.9) rotate(-6deg); opacity: 0.7; filter: grayscale(0.7); }
  100% { transform: scale(0.95) rotate(0deg); opacity: 0.85; filter: grayscale(1); }
}
.mc-topbar .mc-progress {
  flex-shrink: 0;
}

/* ===== Phone: compact topbar (avoid truncated titles) ===== */
.mc-title-short,
.mc-prog-short {
  display: none;
}
.mc-title-full,
.mc-prog-full {
  display: inline;
}
@media (max-width: 420px) {
  .mc-topbar {
    gap: 6px;
  }
  .mc-title {
    font-size: 12px;
    min-width: 0;
  }
  .mc-title-full,
  .mc-prog-full {
    display: none;
  }
  .mc-title-short,
  .mc-prog-short {
    display: inline;
  }
  .mc-progress {
    font-size: 11px;
    padding: 4px 8px;
  }
  .mc-hearts {
    margin-right: 4px;
    padding: 3px 6px;
  }
  .mc-heart {
    font-size: 1rem;
  }
  .mc-instruction {
    font-size: 0.82rem;
    margin-bottom: 6px;
  }
  .mc-col {
    gap: 6px;
  }
  .mc-col > * {
    min-height: 48px;
  }
  .mc-thumb {
    padding: 4px;
  }
  .mc-word-label {
    font-size: 0.88rem;
  }
}
@media (max-width: 360px) {
  .mc-back {
    width: 34px;
    height: 34px;
  }
  .mc-progress {
    font-size: 10px;
    padding: 3px 6px;
  }
}

/* ══════════════════════════════════════════════════════════
   Polish pass: screen transitions, ambient backdrop,
   per-set progress bar, and finer responsive tuning.
   ══════════════════════════════════════════════════════════ */

/* Soft ambient glow behind the game card — subtle, static-friendly */
.mc-game {
  isolation: isolate;
}
.mc-game::before {
  content: "";
  position: fixed;
  inset: -10%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(38% 30% at 18% 12%, rgba(99, 102, 241, 0.16), transparent 60%),
    radial-gradient(42% 34% at 86% 88%, rgba(52, 211, 153, 0.14), transparent 60%);
  animation: mc-ambient-drift 16s ease-in-out infinite alternate;
}
html[data-theme="dark"] .mc-game::before {
  background:
    radial-gradient(38% 30% at 18% 12%, rgba(99, 102, 241, 0.22), transparent 60%),
    radial-gradient(42% 34% at 86% 88%, rgba(52, 211, 153, 0.16), transparent 60%);
}
@keyframes mc-ambient-drift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-2%, 2%) scale(1.05); }
}

/* Whole-screen swap: every render() paints a fresh .mc-screen, so the
   entrance animation just plays on insert — no JS coordination needed. */
.mc-screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  animation: mc-screen-in 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes mc-screen-in {
  0%   { opacity: 0; transform: translateY(10px) scale(0.985); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.mc-screen.mc-screen-leave {
  animation: mc-screen-out 0.19s cubic-bezier(0.4, 0, 1, 1) both;
  pointer-events: none;
}
@keyframes mc-screen-out {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-8px) scale(0.98); }
}

/* Per-set progress bar under the instruction line */
.mc-set-progress {
  flex-shrink: 0;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.15);
  overflow: hidden;
  margin: 0 0 10px;
}
html[data-theme="dark"] .mc-set-progress {
  background: rgba(148, 163, 184, 0.18);
}
.mc-set-progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6366f1, #34d399);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Buttons: crisper tactile feedback */
.mc-btn {
  will-change: transform;
}
.mc-btn:active {
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}
.mc-play:active { transform: scale(0.94); }
.mc-left-item:active:not(.is-correct),
.mc-right-item:active:not(.is-correct):not(.is-used) {
  transform: scale(0.97);
}

/* Keyboard focus visibility (mouse users unaffected) */
.mc-left-item:focus-visible,
.mc-right-item:focus-visible,
.mc-btn:focus-visible,
.mc-back:focus-visible,
.mc-play:focus-visible {
  outline: 3px solid #6366f1;
  outline-offset: 2px;
}
html[data-theme="dark"] .mc-left-item:focus-visible,
html[data-theme="dark"] .mc-right-item:focus-visible,
html[data-theme="dark"] .mc-btn:focus-visible,
html[data-theme="dark"] .mc-back:focus-visible,
html[data-theme="dark"] .mc-play:focus-visible {
  outline-color: #a5b4fc;
}

/* Short / landscape phones: keep everything reachable without scrolling */
@media (max-height: 560px) {
  .mc-hero { width: 56px; height: 56px; font-size: 26px; margin-bottom: 8px; }
  .mc-start h1, .mc-done h1 { font-size: 1.2rem; }
  .mc-desc { margin-bottom: 8px; }
  .mc-part-list li { padding: 7px 12px; margin-bottom: 6px; font-size: 0.85rem; }
  .mc-set-progress { margin-bottom: 6px; }
  .mc-instruction { margin-bottom: 4px; }
}
@media (max-height: 420px) {
  .mc-topbar { margin-bottom: 3px; }
  .mc-hero { display: none; }
  .mc-part-list li { padding: 5px 10px; margin-bottom: 4px; }
}

/* Very narrow phones: tighten card padding so labels never wrap awkwardly */
@media (max-width: 340px) {
  .mc-board { gap: 8px; }
  .mc-col { gap: 5px; }
}

/* ===== Arcade design refresh + polish (shared) ===== */
html:not([data-theme="dark"]){--bg:#f3f0ff;--bg-card:#ffffff;--bg-soft:#ede9fe;--border:#ddd6fe;--accent:#7c3aed;--accent-soft:#ede9fe;--accent-text:#6d28d9;--text:#1e1b4b;--muted:#64748b;--ps-bg:#f3f0ff;--ps-card:#ffffff;--ps-purple:#7c3aed;--ps-purple-soft:rgba(124,58,237,.12);--ps-text:#1e1b4b}
html:not([data-theme="dark"]) body{background:radial-gradient(900px 520px at 8% -8%,rgba(251,207,232,.85),transparent 60%),radial-gradient(800px 480px at 100% 0,rgba(191,219,254,.8),transparent 58%),radial-gradient(700px 500px at 50% 110%,rgba(221,214,254,.9),transparent 60%),#f5f3ff!important;background-attachment:fixed!important}
html[data-theme="dark"] body{background:radial-gradient(800px 480px at 0 -10%,rgba(124,58,237,.30),transparent 60%),radial-gradient(700px 420px at 100% 0,rgba(236,72,153,.16),transparent 55%),#0f1220!important;background-attachment:fixed!important}
[class*="-chip"]:not([class*="-chips"]),[class*="-choice"]:not([class*="-choices"]),[class*="-opt"]:not([class*="-options"]):not([class*="-opts"]){border-radius:14px;border:2px solid rgba(124,58,237,.22);box-shadow:0 4px 0 rgba(124,58,237,.18),0 8px 18px rgba(30,27,75,.08);font-weight:700;transition:transform .14s cubic-bezier(.22,.9,.3,1),box-shadow .14s,border-color .2s,background-color .2s}
[class*="-chip"]:not([class*="-chips"]):not(:disabled):hover,[class*="-choice"]:not([class*="-choices"]):not(:disabled):hover,[class*="-opt"]:not([class*="-options"]):not([class*="-opts"]):not(:disabled):hover{transform:translateY(-2px);box-shadow:0 6px 0 rgba(124,58,237,.2),0 12px 22px rgba(30,27,75,.12)}
[class*="-chip"]:not([class*="-chips"]):not(:disabled):active,[class*="-choice"]:not([class*="-choices"]):not(:disabled):active,[class*="-opt"]:not([class*="-options"]):not([class*="-opts"]):not(:disabled):active{transform:translateY(3px);box-shadow:0 1px 0 rgba(124,58,237,.2)}
[class*="-btn"]{border-radius:14px;font-weight:800;letter-spacing:.01em}
[class*="-card"]:not([class*="-cards"]),[class*="-panel"]:not([class*="-panels"]){border-radius:22px;box-shadow:0 14px 36px rgba(30,27,75,.10)}
html[data-theme="dark"] [class*="-chip"]:not([class*="-chips"]),html[data-theme="dark"] [class*="-choice"]:not([class*="-choices"]),html[data-theme="dark"] [class*="-opt"]:not([class*="-options"]):not([class*="-opts"]){border-color:rgba(167,139,250,.3);box-shadow:0 4px 0 rgba(0,0,0,.35)}
input,textarea{border-radius:14px}
@keyframes ap-in{from{opacity:0;transform:translateY(10px) scale(.985)}to{opacity:1;transform:none}}
@keyframes ap-pop{0%{transform:scale(.6);opacity:0}70%{transform:scale(1.12)}100%{transform:scale(1);opacity:1}}
.screen:not(.hidden),#game-app>section,#game-app>main,#game-app>div{animation:ap-in .38s cubic-bezier(.22,.9,.3,1) both}
button{cursor:pointer;touch-action:manipulation;-webkit-user-select:none;user-select:none;transition:transform .16s cubic-bezier(.22,.9,.3,1),box-shadow .2s,background-color .2s,opacity .2s}
button:not(:disabled):active{transform:scale(.96)}
button:focus-visible,a:focus-visible,input:focus-visible{outline:3px solid rgba(124,58,237,.55);outline-offset:3px}
[class*="-star"]{animation:ap-pop .55s cubic-bezier(.34,1.56,.64,1) both}
[class*="-star"]:nth-child(2){animation-delay:.15s}[class*="-star"]:nth-child(3){animation-delay:.3s}
@media (max-width:480px){button{min-height:44px}}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
/* progress bar, combo, celebration */
.afx-bar{height:12px;border-radius:999px;background:rgba(139,92,246,.16);overflow:hidden;margin:8px 0 10px}
.afx-bar i{display:block;height:100%;border-radius:999px;background:linear-gradient(90deg,#8b5cf6,#ec4899,#f59e0b);background-size:200% 100%;animation:afx-shine 2.4s linear infinite;transition:width .6s cubic-bezier(.22,.9,.3,1);box-shadow:0 0 12px rgba(139,92,246,.55)}
@keyframes afx-shine{to{background-position:-200% 0}}
.afx-combo{position:fixed;right:14px;top:68px;z-index:900;font-weight:800;font-size:15px;padding:6px 14px;border-radius:999px;opacity:0;transform:scale(.7);pointer-events:none;transition:opacity .2s,transform .3s;white-space:nowrap}
.afx-combo em{font-style:normal;font-size:11px;letter-spacing:.08em;margin-left:4px;opacity:.9}
.afx-combo.is-on{opacity:1;transform:none;background:linear-gradient(135deg,#fb923c,#f59e0b);color:#fff;box-shadow:0 6px 16px rgba(245,158,11,.4)}
.afx-combo.is-hot{background:linear-gradient(135deg,#ef4444,#f97316);box-shadow:0 6px 20px rgba(239,68,68,.5)}
.afx-combo.is-bump{animation:afx-bump .45s cubic-bezier(.34,1.56,.64,1)}
.afx-combo.is-lost{opacity:1;transform:none;background:#e2e8f0;color:#64748b;font-size:13px;animation:afx-shake .4s}
.afx-fire{display:inline-block;animation:afx-flick .7s ease-in-out infinite alternate}
@keyframes afx-bump{0%{transform:scale(.8)}55%{transform:scale(1.28) rotate(-3deg)}100%{transform:scale(1)}}
@keyframes afx-flick{to{transform:scale(1.2) rotate(8deg)}}
@keyframes afx-shake{25%{transform:translateX(-6px)}75%{transform:translateX(6px)}}
.afx-burst{position:fixed;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:radial-gradient(circle,rgba(139,92,246,.35),rgba(15,18,32,.55));overflow:hidden;pointer-events:none;animation:afx-fin .25s both}
.afx-burst.is-out{animation:afx-fout .4s both}
@keyframes afx-fin{from{opacity:0}}@keyframes afx-fout{to{opacity:0}}
.afx-burst i{position:absolute;top:-16px;width:10px;height:16px;border-radius:2px;animation:afx-fall linear both}
@keyframes afx-fall{to{transform:translateY(110vh) rotate(720deg)}}
.afx-card{text-align:center;padding:28px 40px;border-radius:28px;background:#fff;color:#1e1b4b;box-shadow:0 24px 60px rgba(0,0,0,.4);animation:afx-zoom .7s cubic-bezier(.34,1.56,.64,1) both;max-width:88vw}
html[data-theme="dark"] .afx-card{background:#1a1f35;color:#f1f5f9}
.afx-emoji{font-size:76px;line-height:1;animation:afx-spin 1s cubic-bezier(.34,1.56,.64,1) both}
.afx-title{font-size:30px;font-weight:900;margin-top:8px;background:linear-gradient(90deg,#8b5cf6,#ec4899,#f59e0b);-webkit-background-clip:text;background-clip:text;color:transparent}
.afx-sub{margin-top:6px;font-weight:600;opacity:.75}
@keyframes afx-zoom{from{transform:scale(.2) rotate(-8deg);opacity:0}}
@keyframes afx-spin{from{transform:scale(0) rotate(-360deg)}}
@media (prefers-reduced-motion:reduce){#game-app *,#game-app,.afx-burst i,.afx-fire,.afx-bar i{animation:none!important;transition:none!important}}

/* existing progress bars → same animated gradient bar */
.fc-progress,.clf-bar,.cw-bar,.wt-bar{height:12px!important;border-radius:999px;background:rgba(139,92,246,.16)!important;overflow:hidden}
.fc-progress-fill,.clf-bar-fill,.cw-bar-fill,.wt-bar-fill{border-radius:999px;background:linear-gradient(90deg,#8b5cf6,#ec4899,#f59e0b)!important;background-size:200% 100%;animation:afx-shine 2.4s linear infinite;transition:width .6s cubic-bezier(.22,.9,.3,1)!important;box-shadow:0 0 12px rgba(139,92,246,.55)}

/* existing bars of this batch */
.lw-progress,.progress,.mc-set-progress{height:12px!important;border-radius:999px;background:rgba(139,92,246,.16)!important;overflow:hidden}
.lw-progress-fill,.progress-fill,.mc-set-progress-fill{border-radius:999px;background:linear-gradient(90deg,#8b5cf6,#ec4899,#f59e0b)!important;background-size:200% 100%;animation:afx-shine 2.4s linear infinite;transition:width .6s cubic-bezier(.22,.9,.3,1)!important;box-shadow:0 0 12px rgba(139,92,246,.55)}


/* Emoji fallback when no image */
.mc-emoji-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  width: 100%;
  height: 100%;
  min-height: 72px;
}
