/* ===== K-Cult memory game — dark "stage" panel inside the light site theme =====
 *
 * Ported from projects/memory-cards-learning-game/css/style.css. Two rules of
 * the port, both non-negotiable since the game now lives inside a full page:
 *   1. no element selectors — the source's `*`, `html, body`, `body` and bare
 *      `dialog` rules would repaint the whole site;
 *   2. every selector is a descendant of #kcult-mg, which also beats the theme's
 *      global `:root :where(...)` styles (specificity 0,1,0).
 */

#kcult-mg {
  --mg-bg: #12101f;
  --mg-bg-soft: #1c1930;
  --mg-card: #262040;
  --mg-card-hover: #322a54;
  --mg-text: #f2eefc;
  --mg-text-dim: #a79fc4;
  --mg-accent: #a78bfa;
  --mg-accent-strong: #8b5cf6;
  --mg-ok: #34d399;
  --mg-ko: #f87171;
  --mg-short: #f87171;
  --mg-medium: #fbbf24;
  --mg-long: #34d399;
  --mg-radius: 16px;
  --mg-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);

  position: relative; /* anchors the OK/KO overlay to the game, not the viewport */
  max-width: 520px;
  margin-inline: auto;
  border-radius: 24px;
  overflow: hidden;
  background: radial-gradient(1200px 600px at 50% -10%, #2b2350 0%, var(--mg-bg) 60%);
  color: var(--mg-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* Reset bounded to the game: the source stylesheet's `*` rule would flatten the page. */
#kcult-mg *,
#kcult-mg *::before,
#kcult-mg *::after { margin: 0; padding: 0; box-sizing: border-box; }

#kcult-mg .mg-screen {
  min-height: min(78vh, 620px);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
}

#kcult-mg .mg-hidden { display: none !important; }

/* ===== Buttons ===== */
#kcult-mg .mg-btn {
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  padding: 14px 32px;
  min-height: 48px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
#kcult-mg .mg-btn:active { transform: scale(0.96); }

#kcult-mg .mg-btn-primary {
  background: linear-gradient(135deg, var(--mg-accent) 0%, var(--mg-accent-strong) 100%);
  color: #fff;
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.45);
}

#kcult-mg .mg-btn-ghost {
  background: transparent;
  color: var(--mg-accent);
  border: 2px solid var(--mg-accent);
}

#kcult-mg .mg-btn-icon {
  font: inherit;
  font-size: 20px;
  line-height: 1;
  background: var(--mg-card);
  color: var(--mg-text);
  border: none;
  border-radius: 12px;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  cursor: pointer;
}

/* ===== Home screen ===== */
#kcult-mg .mg-home-header { text-align: center; margin-bottom: 18px; position: relative; }

#kcult-mg .mg-home-settings { position: absolute; top: 0; right: 0; }

#kcult-mg .mg-logo {
  font-size: clamp(30px, 9vw, 42px);
  line-height: 1.1;
  letter-spacing: 4px;
  font-weight: 800;
  padding: 0 52px; /* keeps long names clear of the settings button */
  background: linear-gradient(135deg, #c4b5fd, #f0abfc, #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#kcult-mg .mg-tagline { color: var(--mg-text-dim); margin-top: 6px; font-size: 15px; }

#kcult-mg .mg-home-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 22px;
}

/* The ways to play, chosen here rather than buried in the settings. */
#kcult-mg .mg-modes {
  display: grid;
  gap: 10px;
}

/* Four buttons on two rows: Learn/Challenge across, Easy/Hard down. Single
   column on a narrow phone, where four side-by-side would be unreadable. */
#kcult-mg .mg-modes--grid {
  grid-template-columns: 1fr;
}

@media (min-width: 380px) {
  #kcult-mg .mg-modes--grid {
    grid-template-columns: 1fr 1fr;
  }
}

#kcult-mg .mg-mode-btn {
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 14px 18px;
  min-height: 64px;
  border: 2px solid transparent;
  border-radius: 18px;
  color: #fff;
  cursor: pointer;
  text-align: center;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
#kcult-mg .mg-mode-btn:active { transform: scale(0.975); }
@media (hover: hover) {
  #kcult-mg .mg-mode-btn:hover { filter: brightness(1.08); }
}

#kcult-mg .mg-mode-btn--learn {
  background: linear-gradient(135deg, var(--mg-accent) 0%, var(--mg-accent-strong) 100%);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.45);
}
#kcult-mg .mg-mode-btn--challenge {
  background: linear-gradient(135deg, #fb7185 0%, #e11d48 100%);
  box-shadow: 0 6px 20px rgba(225, 29, 72, 0.4);
}

#kcult-mg .mg-mode-btn__label {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
#kcult-mg .mg-mode-btn__hint {
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.3;
  opacity: 0.92;
}

/* One row per member: name on the left, photos scrolling on the right. */
#kcult-mg .mg-roster { display: flex; flex-direction: column; gap: 10px; }

#kcult-mg .mg-roster-row {
  display: grid;
  grid-template-columns: minmax(4.5rem, 22%) 1fr;
  align-items: center;
  gap: 10px;
  background: var(--mg-card);
  border-radius: var(--mg-radius);
  padding: 8px 10px;
  animation: mg-pop-in 0.35s ease both;
  animation-delay: calc(var(--i, 0) * 0.04s);
}

#kcult-mg .mg-roster-name {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

#kcult-mg .mg-roster-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--mg-accent) transparent;
  padding-bottom: 2px;
  /* fades the right edge to signal there is more to scroll */
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent 100%);
  mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent 100%);
}
#kcult-mg .mg-roster-strip::-webkit-scrollbar { height: 5px; }
#kcult-mg .mg-roster-strip::-webkit-scrollbar-thumb {
  background: var(--mg-accent);
  border-radius: 999px;
}

#kcult-mg .mg-roster-img {
  height: 64px;
  width: auto;
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: cover;
  background: var(--mg-bg-soft);
  scroll-snap-align: start;
  display: block;
}

/* The thumbnail is a button now (it opens the photo), so it must not look like
   one: no chrome, just the image and a focus ring. */
#kcult-mg .mg-roster-shot {
  padding: 0;
  border: 0;
  background: none;
  flex: 0 0 auto;
  line-height: 0;
  cursor: zoom-in;
  border-radius: 8px;
  scroll-snap-align: start;
  transition: transform 0.12s ease;
}
#kcult-mg .mg-roster-shot:active { transform: scale(0.96); }
@media (hover: hover) {
  #kcult-mg .mg-roster-shot:hover { transform: translateY(-2px); }
}
#kcult-mg .mg-roster-shot:focus-visible {
  outline: 3px solid var(--mg-accent);
  outline-offset: 2px;
}

/* ===== Roster photo viewer ===== */
#kcult-mg .mg-lightbox {
  padding: 0;
  border: 0;
  max-width: min(92vw, 400px); /* 400px = the CDN ceiling; never upscale */
  max-height: 92vh;
  overflow: visible;
  background: none;
  cursor: zoom-out;
}
#kcult-mg .mg-lightbox::backdrop {
  background: rgba(9, 7, 18, 0.82);
}

#kcult-mg .mg-lightbox__figure {
  margin: 0;
  border-radius: 18px;
  overflow: hidden;
  background: var(--mg-bg-soft);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

#kcult-mg .mg-lightbox img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
  background: var(--mg-bg-soft);
}

#kcult-mg .mg-lightbox__caption {
  padding: 10px 14px 12px;
  color: var(--mg-text);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}

/* Indicative only: a click anywhere closes. */
#kcult-mg .mg-lightbox__close {
  position: absolute;
  top: -14px;
  right: -14px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--mg-card);
  color: var(--mg-text);
  font: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
#kcult-mg .mg-lightbox__close:focus-visible {
  outline: 3px solid var(--mg-accent);
  outline-offset: 2px;
}

#kcult-mg .mg-rules {
  margin-top: 20px;
  color: var(--mg-text-dim);
  font-size: 14px;
  line-height: 1.5;
}
#kcult-mg .mg-rules summary { cursor: pointer; font-weight: 600; color: var(--mg-accent); }
#kcult-mg .mg-rules p { margin-top: 8px; }

#kcult-mg .mg-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: baseline;
}
#kcult-mg .mg-dot-short { background: var(--mg-short); }
#kcult-mg .mg-dot-medium { background: var(--mg-medium); }
#kcult-mg .mg-dot-long { background: var(--mg-long); }

/* ===== Portraits ===== */
#kcult-mg .mg-portrait {
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background: var(--mg-bg-soft);
}
#kcult-mg .mg-portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }

#kcult-mg .mg-avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.9);
}

/* ===== Game screen ===== */
#kcult-mg .mg-game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

#kcult-mg .mg-turn-counter {
  min-width: 40px;
  text-align: right;
  color: var(--mg-text-dim);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#kcult-mg .mg-progress-tokens { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; }

#kcult-mg .mg-token {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--mg-short);
  transition: background 0.4s ease, transform 0.25s ease;
}
#kcult-mg .mg-token.mg-box-1 { background: var(--mg-medium); }
#kcult-mg .mg-token.mg-box-2 { background: var(--mg-long); box-shadow: 0 0 8px rgba(52, 211, 153, 0.7); }
#kcult-mg .mg-token.mg-bump { transform: scale(1.5); }

/* ===== Victory meter ===== */
#kcult-mg .mg-victory-meter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

#kcult-mg .mg-victory-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--mg-bg-soft);
  overflow: hidden;
  position: relative;
}

/* Steps (members x gauge) marked on the bar; --steps set by game.js */
#kcult-mg .mg-victory-track::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent calc(100% / var(--steps, 21) - 1px),
    rgba(18, 16, 31, 0.55) calc(100% / var(--steps, 21) - 1px),
    rgba(18, 16, 31, 0.55) calc(100% / var(--steps, 21))
  );
  pointer-events: none;
}

#kcult-mg .mg-victory-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--mg-accent-strong), var(--mg-accent), var(--mg-long));
  transition: width 0.5s ease, filter 0.2s ease;
}

#kcult-mg .mg-victory-fill.mg-regress {
  background: linear-gradient(90deg, #b91c1c, var(--mg-ko));
  filter: brightness(1.15);
}

#kcult-mg .mg-victory-pct {
  min-width: 42px;
  text-align: right;
  font-size: 13px;
  font-weight: 800;
  color: var(--mg-text-dim);
  font-variant-numeric: tabular-nums;
}

/* Gain or loss shown on every answer: +8.3% / -16.7% */
#kcult-mg .mg-victory-delta {
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  opacity: 0;
}
#kcult-mg .mg-victory-delta.mg-gain { color: var(--mg-ok); }
#kcult-mg .mg-victory-delta.mg-loss { color: var(--mg-ko); }
#kcult-mg .mg-victory-delta.mg-show { animation: mg-delta-pop 1.4s ease both; }

@keyframes mg-delta-pop {
  0% { opacity: 0; transform: translateY(5px) scale(0.8); }
  18% { opacity: 1; transform: translateY(0) scale(1.15); }
  30% { transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== Mode 2: one vertical bar per member, photo below ===== */
#kcult-mg .mg-member-bars {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 6px;
}

#kcult-mg .mg-mbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  position: relative;
}

#kcult-mg .mg-mbar-track {
  width: 14px;
  height: 64px;
  border-radius: 999px;
  background: var(--mg-bg-soft);
  position: relative;
  overflow: hidden;
}

/* Graduated steps on each bar; --bar-steps set by game.js from the difficulty */
#kcult-mg .mg-mbar-track::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0,
    transparent calc(100% / var(--bar-steps, 4) - 1px),
    rgba(18, 16, 31, 0.55) calc(100% / var(--bar-steps, 4) - 1px),
    rgba(18, 16, 31, 0.55) calc(100% / var(--bar-steps, 4))
  );
  pointer-events: none;
}

#kcult-mg .mg-mbar-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: var(--mg-short);
  transition: height 0.5s ease, background 0.4s ease;
}

/* The cursor: bright line at the top of the fill */
#kcult-mg .mg-mbar-fill::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 2px;
}

#kcult-mg .mg-mbar-fill.mg-box-1 { background: var(--mg-medium); }
#kcult-mg .mg-mbar-fill.mg-box-2 { background: var(--mg-long); }
#kcult-mg .mg-mbar-fill.mg-regress { background: var(--mg-ko); filter: brightness(1.25); }
#kcult-mg .mg-mbar-fill.mg-gain-glow { filter: brightness(1.3) drop-shadow(0 0 6px rgba(52, 211, 153, 0.9)); }

#kcult-mg .mg-mbar-photo {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.35);
}
#kcult-mg .mg-mbar-photo .mg-portrait { width: 100%; height: 100%; border-radius: 50%; }
#kcult-mg .mg-mbar-photo .mg-avatar-fallback { font-size: 16px; }
/* Square crop of a bust shot: bias upwards so the top of the head survives. */
#kcult-mg .mg-mbar-photo .mg-portrait img { object-position: center 20%; }

#kcult-mg .mg-mbar.mg-bump { animation: mg-bar-bump 0.5s ease; }

@keyframes mg-bar-bump {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.22); }
}

/* '+1' / '-N' badge flying up above the member's bar */
#kcult-mg .mg-mbar-badge {
  position: absolute;
  top: -8px;
  left: 50%;
  font-size: 15px;
  font-weight: 900;
  color: var(--mg-ok);
  text-shadow: 0 0 8px rgba(18, 16, 31, 0.9);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}
#kcult-mg .mg-mbar-badge.mg-loss { color: var(--mg-ko); }
#kcult-mg .mg-mbar-badge.mg-show { animation: mg-badge-fly 1.1s ease both; }

@keyframes mg-badge-fly {
  0% { opacity: 0; transform: translate(-50%, 6px) scale(0.7); }
  20% { opacity: 1; transform: translate(-50%, -4px) scale(1.25); }
  40% { transform: translate(-50%, -8px) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -18px); }
}

/* ===== Photo / question zone ===== */

/* Stacked on mobile; becomes two columns on a wide screen (see the desktop
 * block at the end of this file). */
#kcult-mg .mg-play-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#kcult-mg .mg-photo-zone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 0;
}

/* The Next button takes the prompt's place; the slot keeps its height so the
 * answer grid never jumps. */
#kcult-mg .mg-prompt-slot {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#kcult-mg .mg-btn-next {
  padding: 12px 30px;
  min-height: 44px;
  font-size: 15px;
  animation: mg-pop-in 0.25s ease both;
}

/* The gallery holds everything from full-body shots (ratio 0.43) to landscape
 * crops (1.41), so ANY fixed frame either cuts a head off or wastes half the
 * card. Instead: the height is fixed — so nothing below ever moves — and the
 * width follows the photo's own ratio (--mg-card-ratio, set per question by
 * game.js). For almost every photo the frame then matches it exactly and
 * nothing is cropped at all; only the few ratios outside the clamp differ, and
 * those are trimmed from the BOTTOM (see object-position below). */
#kcult-mg .mg-photo-card {
  height: min(74vw, 310px);
  width: auto;
  max-width: 100%;
  aspect-ratio: var(--mg-card-ratio, 0.75);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--mg-shadow), 0 0 0 3px rgba(167, 139, 250, 0.35);
  background: var(--mg-bg-soft);
}
#kcult-mg .mg-photo-card .mg-portrait { width: 100%; height: 100%; border-radius: 0; }
/* Anchored to the top: when a photo is taller than its frame (a full-body shot
 * past the clamp) the excess is taken off the BOTTOM, so the head is always
 * kept — never bars, never a decapitated idol. */
#kcult-mg .mg-photo-card .mg-portrait img {
  object-position: center top;
}
#kcult-mg .mg-photo-card .mg-avatar-fallback { font-size: 84px; }

/* Interference card: mini quiz between two faces */
#kcult-mg .mg-photo-card.mg-math { box-shadow: var(--mg-shadow), 0 0 0 3px rgba(96, 165, 250, 0.4); }

#kcult-mg .mg-math-op {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 46px;
  font-weight: 800;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  color: var(--mg-text);
  background: linear-gradient(160deg, #1d2a4d 0%, var(--mg-bg-soft) 90%);
}

#kcult-mg .mg-math-op.mg-hangul { font-size: 62px; letter-spacing: 6px; }

/* Romanization revealed with the answer, italic below the hangul */
#kcult-mg .mg-math-op .mg-romaja {
  font-size: 22px;
  font-style: italic;
  font-weight: 600;
  letter-spacing: 3px;
  color: var(--mg-text-dim);
  animation: mg-pop-in 0.3s ease both;
}

#kcult-mg .mg-romaja-inline { font-style: italic; font-weight: 600; opacity: 0.85; }

/* Lives on the left, interleaved-card score on the right. Reserved height so
 * the layout does not shift when either one appears mid-game. */
#kcult-mg .mg-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 26px;
  margin-top: 6px;
}

#kcult-mg .mg-lives {
  font-size: 17px;
  line-height: 1;
  letter-spacing: 2px;
  color: var(--mg-ko);
  font-variant-numeric: tabular-nums;
}
#kcult-mg .mg-heart { transition: opacity 0.3s ease; }
#kcult-mg .mg-heart-lost { opacity: 0.35; }

/* Interleaved-card score pill: '🧮 3/4' or '한 3/4' */
#kcult-mg .mg-filler-score {
  margin-left: auto;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--mg-text-dim);
  background: var(--mg-bg-soft);
  border-radius: 999px;
  padding: 3px 12px;
}

#kcult-mg .mg-photo-card.mg-slide-in { animation: mg-slide-in 0.3s ease both; }
#kcult-mg .mg-photo-card.mg-shake { animation: mg-shake 0.45s ease; }

#kcult-mg .mg-prompt { color: var(--mg-text-dim); font-weight: 600; }

/* ===== Name grid ===== */
#kcult-mg .mg-names-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding-bottom: 4px;
}

#kcult-mg .mg-name-btn {
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  color: var(--mg-text);
  background: var(--mg-card);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 14px 8px;
  min-height: 48px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
@media (hover: hover) {
  #kcult-mg .mg-name-btn:hover:not(:disabled) { background: var(--mg-card-hover); }
}
#kcult-mg .mg-name-btn:active:not(:disabled) { transform: scale(0.96); }
#kcult-mg .mg-name-btn:disabled { cursor: default; opacity: 0.85; }

#kcult-mg .mg-name-btn.mg-correct {
  background: rgba(52, 211, 153, 0.18);
  border-color: var(--mg-ok);
  color: var(--mg-ok);
}
#kcult-mg .mg-name-btn.mg-wrong {
  background: rgba(248, 113, 113, 0.18);
  border-color: var(--mg-ko);
  color: var(--mg-ko);
}
#kcult-mg .mg-name-btn.mg-reveal { animation: mg-pulse-reveal 0.6s ease 2; }

/* ===== OK / KO feedback =====
 * absolute, not fixed: the source's `position: fixed` would cover the whole
 * page — site header, ads and all — on every answer. */
#kcult-mg .mg-feedback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
}

#kcult-mg .mg-stamp {
  font-size: clamp(64px, 20vw, 88px);
  font-weight: 900;
  letter-spacing: 4px;
  padding: 10px 34px;
  border-radius: 20px;
  transform: rotate(-8deg);
  animation: mg-stamp 0.9s ease both;
}
#kcult-mg .mg-stamp.mg-ok {
  color: var(--mg-ok);
  border: 6px solid var(--mg-ok);
  background: rgba(18, 16, 31, 0.85);
  text-shadow: 0 0 24px rgba(52, 211, 153, 0.6);
}
#kcult-mg .mg-stamp.mg-ko {
  color: var(--mg-ko);
  border: 6px solid var(--mg-ko);
  background: rgba(18, 16, 31, 0.85);
  text-shadow: 0 0 24px rgba(248, 113, 113, 0.6);
}

/* ===== Victory screen ===== */
#kcult-mg #mg-screen-win { justify-content: center; align-items: center; text-align: center; }

#kcult-mg .mg-win-box {
  background: var(--mg-card);
  border-radius: 24px;
  padding: 32px 26px;
  box-shadow: var(--mg-shadow);
  animation: mg-pop-in 0.45s ease both;
  width: 100%;
  max-width: 380px;
}

#kcult-mg .mg-win-emoji { font-size: 64px; margin-bottom: 8px; }
#kcult-mg .mg-win-box h2 { font-size: 32px; margin-bottom: 8px; color: var(--mg-text); }
#kcult-mg .mg-win-text { color: var(--mg-text-dim); margin-bottom: 22px; }

#kcult-mg .mg-win-stats {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 22px;
}
#kcult-mg .mg-win-stats dt { color: var(--mg-text-dim); font-size: 13px; }
#kcult-mg .mg-win-stats dd { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }

#kcult-mg .mg-win-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 22px;
}
#kcult-mg .mg-win-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}

#kcult-mg .mg-win-links a {
  font-size: 14px;
  font-weight: 700;
  color: var(--mg-accent);
  text-decoration: underline;
  background: var(--mg-bg-soft);
  border-radius: 999px;
  padding: 6px 12px;
}

/* ===== Settings dialog ===== */
#kcult-mg dialog {
  margin: auto;
  border: none;
  border-radius: 20px;
  background: var(--mg-card);
  color: var(--mg-text);
  padding: 24px;
  width: min(90vw, 360px);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--mg-shadow);
}
#kcult-mg dialog::backdrop {
  background: rgba(10, 8, 20, 0.65);
  backdrop-filter: blur(3px);
}
#kcult-mg dialog h3 { font-size: 22px; margin-bottom: 14px; color: var(--mg-text); }
#kcult-mg .mg-dialog-sub {
  color: var(--mg-text-dim);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* Each setting is one block so the dialog can go two-column on desktop. */
#kcult-mg .mg-setting { margin-bottom: 20px; }
#kcult-mg .mg-setting:last-child { margin-bottom: 0; }

#kcult-mg .mg-mode-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--mg-bg-soft);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  font-size: 15px;
}
#kcult-mg .mg-mode-option:has(input:checked) { border-color: var(--mg-accent); }
#kcult-mg .mg-mode-option input { accent-color: var(--mg-accent); margin-top: 3px; }
#kcult-mg .mg-mode-option small { display: block; color: var(--mg-text-dim); margin-top: 2px; line-height: 1.35; }

#kcult-mg .mg-difficulty-row { display: flex; gap: 8px; margin-bottom: 8px; }

#kcult-mg .mg-diff-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--mg-bg-soft);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 10px 4px;
  cursor: pointer;
  text-align: center;
  font-size: 15px;
}
#kcult-mg .mg-diff-option:has(input:checked) { border-color: var(--mg-accent); }
#kcult-mg .mg-diff-option input { accent-color: var(--mg-accent); }
#kcult-mg .mg-diff-option strong { display: block; }
#kcult-mg .mg-diff-option small { display: block; color: var(--mg-text-dim); font-size: 12px; }

#kcult-mg .mg-dialog-hint { color: var(--mg-text-dim); font-size: 12px; line-height: 1.35; margin-bottom: 14px; }

#kcult-mg dialog form { text-align: center; margin-top: 8px; }

/* ===== Breadcrumb back to the group ===== */
.kcult-mg-back {
  max-width: 520px;
  margin: 0 auto 12px;
  font-size: 14px;
  font-weight: 700;
}

/* ===== Animations ===== */
@keyframes mg-pop-in {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes mg-slide-in {
  from { opacity: 0; transform: translateX(46px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes mg-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-9px); }
  40%, 80% { transform: translateX(9px); }
}

@keyframes mg-stamp {
  0% { opacity: 0; transform: rotate(-8deg) scale(2.2); }
  20% { opacity: 1; transform: rotate(-8deg) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: rotate(-8deg) scale(1.05); }
}

@keyframes mg-pulse-reveal {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
  50% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0.35); }
}

@media (prefers-reduced-motion: reduce) {
  #kcult-mg *, #kcult-mg *::before, #kcult-mg *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 380px) {
  #kcult-mg .mg-screen { padding: 18px 14px; }
  #kcult-mg .mg-roster-row { grid-template-columns: minmax(4rem, 26%) 1fr; }
}

/* Tablets and small laptops: keep the single-column layout, just stop wasting
 * the extra width. Also softens the jump to the two-column desktop layout. */
@media (min-width: 620px) and (max-width: 899px) {
  #kcult-mg { max-width: 600px; }
  #kcult-mg .mg-photo-card { height: min(52vw, 380px); }
  #kcult-mg .mg-roster-img { height: 78px; }
  #kcult-mg .mg-name-btn { font-size: 18px; min-height: 52px; }
  .kcult-mg-back { max-width: 600px; }
}

/* ===== Desktop: use the width instead of stretching the mobile column =====
 * The page's <main> is --grigri-wide (up to 1140px), so the panel can grow.
 * Photo and answers go side by side, everything scales up, and the whole game
 * fits without scrolling. Mobile rules above are untouched. */
@media (min-width: 900px) {
  #kcult-mg { max-width: 880px; }

  #kcult-mg .mg-screen {
    padding: 30px 34px;
    min-height: min(82vh, 680px);
  }

  #kcult-mg .mg-logo { font-size: 52px; letter-spacing: 6px; }
  #kcult-mg .mg-tagline { font-size: 16px; }

  /* Home keeps one row per member — a wider row simply shows more photos
   * before the strip needs scrolling, which is the point. */
  #kcult-mg .mg-roster-row {
    grid-template-columns: minmax(6rem, 15%) 1fr;
    padding: 10px 14px;
  }
  #kcult-mg .mg-roster-name { font-size: 17px; }
  #kcult-mg .mg-roster-img { height: 96px; border-radius: 10px; }
  #kcult-mg .mg-rules { font-size: 15px; }

  /* Game: photo left, answers right, both centred on the taller of the two. */
  #kcult-mg .mg-play-area {
    display: grid;
    grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
    gap: 36px;
    align-items: center;
  }
  #kcult-mg .mg-photo-zone { padding: 0; }
  #kcult-mg .mg-photo-card { height: min(48vh, 440px); max-width: 100%; }
  #kcult-mg .mg-photo-card .mg-avatar-fallback { font-size: 108px; }
  #kcult-mg .mg-math-op { font-size: 58px; }
  #kcult-mg .mg-math-op.mg-hangul { font-size: 82px; }
  #kcult-mg .mg-prompt { font-size: 16px; }

  #kcult-mg .mg-names-grid { gap: 12px; }
  #kcult-mg .mg-name-btn { font-size: 18px; padding: 16px 10px; min-height: 56px; }

  /* Score widgets get the extra room too. */
  #kcult-mg .mg-victory-track { height: 10px; }
  #kcult-mg .mg-token { width: 15px; height: 15px; }
  #kcult-mg .mg-member-bars { gap: 24px; }
  #kcult-mg .mg-mbar-track { width: 16px; height: 88px; }
  #kcult-mg .mg-mbar-photo { width: 46px; height: 46px; }

  #kcult-mg .mg-win-box { max-width: 460px; padding: 40px 34px; }
  #kcult-mg .mg-modes { grid-template-columns: 1fr 1fr; gap: 14px; }
  #kcult-mg .mg-mode-btn { min-height: 78px; }
  #kcult-mg .mg-win-actions { flex-direction: row; justify-content: center; }

  .kcult-mg-back { max-width: 880px; }
}

/* Settings dialog on a wider screen: four sections in one column means a long
 * scroll, so spread them over two. Its own breakpoint — a modal is sized by the
 * viewport, not by the game panel. */
@media (min-width: 760px) {
  #kcult-mg dialog {
    width: min(92vw, 700px);
    padding: 30px 34px;
  }
  #kcult-mg dialog h3 { font-size: 26px; margin-bottom: 20px; }

  #kcult-mg .mg-settings-body {
    columns: 2;
    column-gap: 32px;
  }
  #kcult-mg .mg-setting {
    break-inside: avoid;
    margin-bottom: 24px;
  }
  #kcult-mg .mg-setting:last-child { margin-bottom: 0; }

  #kcult-mg dialog form { margin-top: 20px; }
}

/* ===== Page furniture (outside the game panel) ===== */

/* <main> is the wide container, so keep the editorial text readable. */
.kcult-memory-game .entry-content {
  max-width: 68ch;
  margin-inline: auto;
}

.kcult-mg-empty {
  max-width: 68ch;
  margin-inline: auto;
}

/* Intro on the group picker (the canonical, indexed URL).
   No block margin: these blocks are grid items of .biography-page, whose 2rem
   gap already separates them, and grid gaps do not collapse with margins. */
.kcult-mg-intro {
  max-width: 68ch;
  margin-inline: auto;
  font-size: clamp(1.03rem, 0.8vw + 0.95rem, 1.12rem);
  line-height: 1.62;
}
.kcult-mg-intro p { margin: 0 0 1.15rem; }

.kcult-mg-lede {
  font-size: 1.14em;
  font-weight: 600;
}

.kcult-mg-points {
  list-style: none;
  margin: 0 0 1.15rem;
  padding: 0;
  display: grid;
  gap: 0.7rem;
}
.kcult-mg-points li {
  padding-left: 1.35rem;
  position: relative;
}
.kcult-mg-points li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--grigri-accent-dark, #a2431f);
}
.kcult-mg-points strong { font-weight: 800; }

.kcult-mg-free { font-weight: 700; }

/* ===== Group picker ===== */
.kcult-mg-picker {
  max-width: 68ch;
  margin-inline: auto;
}

.kcult-mg-picker__title {
  font-family: var(--grigri-display-font, Georgia, serif);
  font-size: clamp(1.35rem, 3vw, 1.7rem);
  margin: 0 0 1rem;
}

.kcult-mg-groups {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}

.kcult-mg-group {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.15rem 1.25rem 1.25rem;
  background: var(--grigri-surface-strong, #fff);
  border: 1px solid var(--grigri-line, #decfba);
  border-radius: var(--grigri-radius, 20px);
  box-shadow: var(--grigri-shadow, 0 18px 54px rgba(41, 30, 19, 0.09));
}

.kcult-mg-group__head {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.kcult-mg-group__name {
  font-family: var(--grigri-display-font, Georgia, serif);
  font-size: clamp(1.25rem, 4vw, 1.5rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--grigri-ink, #171411);
}

.kcult-mg-group__meta {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--grigri-muted, #675f55);
}

/* .kcult-mg-faces and .kcult-mg-play live in the theme's main.css: the group
 * profile uses them too, and that page does not load this stylesheet. */

/* Roomier once there is space. auto-FIT, not auto-fill: with a single playable
 * group the card spans the full width instead of hugging an empty column. */
@media (min-width: 700px) {
  .kcult-mg-groups {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    gap: 1.35rem;
  }
  .kcult-mg-group { padding: 1.4rem 1.5rem 1.5rem; }
}
