.srmg-game {
  --srmg-surface: #ffffff;
  --srmg-ink: #203044;
  --srmg-soft-blue: #edf5ff;
  --srmg-soft-gold: #fff6df;
  --srmg-border: rgba(26, 55, 93, 0.12);
  --srmg-shadow: 0 14px 34px rgba(31, 53, 86, 0.12);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--srmg-ink);
  margin: 24px 0;
  position: relative;
}

.srmg-shell {
  background: linear-gradient(180deg, #f6fbff 0%, #ffffff 100%);
  border: 1px solid var(--srmg-border);
  border-radius: 28px;
  box-shadow: var(--srmg-shadow);
  padding: 24px;
}

.srmg-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.srmg-title-group {
  flex: 1 1 auto;
}

.srmg-title {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 2vw, 2rem);
  line-height: 1.2;
}

.srmg-intro {
  margin: 0;
  font-size: 1rem;
  line-height: 1.55;
  max-width: 58ch;
}

.srmg-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.srmg-stat-box {
  min-width: 110px;
  background: var(--srmg-surface);
  border: 1px solid var(--srmg-border);
  border-radius: 18px;
  padding: 12px 16px;
  text-align: center;
}

.srmg-stat-label {
  display: block;
  font-size: 0.82rem;
  opacity: 0.82;
  margin-bottom: 4px;
}

.srmg-stat-value {
  font-size: 1.2rem;
}

.srmg-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding: 14px 16px;
  background: var(--srmg-soft-gold);
  border: 1px solid rgba(151, 118, 29, 0.14);
  border-radius: 20px;
}

.srmg-message {
  margin: 0;
  font-weight: 600;
}

.srmg-button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  background: #2457a6;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
  box-shadow: 0 8px 18px rgba(36, 87, 166, 0.24);
}

.srmg-button:hover,
.srmg-button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(36, 87, 166, 0.28);
}

.srmg-button:focus-visible,
.srmg-card:focus-visible {
  outline: 3px solid #1f6feb;
  outline-offset: 3px;
}

.srmg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 16px;
}

.srmg-card {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  position: relative;
  perspective: 1000px;
  min-height: 188px;
}

.srmg-card[disabled] {
  cursor: default;
}

.srmg-card-inner {
  position: relative;
  display: block;
  min-height: 188px;
  transform-style: preserve-3d;
  transition: transform 0.45s ease;
}

.srmg-card.is-open .srmg-card-inner,
.srmg-card.is-matched .srmg-card-inner {
  transform: rotateY(180deg);
}

.srmg-card-face {
  position: absolute;
  inset: 0;
  border-radius: 22px;
  backface-visibility: hidden;
  overflow: hidden;
}

.srmg-card-front {
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 255, 255, 0.85) 0 10%, transparent 10.5%),
    radial-gradient(circle at 82% 22%, rgba(255, 255, 255, 0.65) 0 8%, transparent 8.5%),
    linear-gradient(160deg, #7cc7ff 0%, #4f8be8 50%, #4f66d0 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 10px 22px rgba(43, 87, 162, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px;
  text-align: center;
}

.srmg-front-star {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 10px;
}

.srmg-front-text {
  font-weight: 800;
  letter-spacing: 0.02em;
}

.srmg-front-subtext {
  display: block;
  font-size: 0.85rem;
  margin-top: 6px;
  opacity: 0.92;
}

.srmg-card-back {
  transform: rotateY(180deg);
  background: var(--srmg-soft, #eef7ff);
  border: 2px solid var(--srmg-accent, #5d7aa4);
  box-shadow: 0 14px 26px rgba(24, 41, 71, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 16px;
  text-align: center;
}

.srmg-card-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 82px;
  width: 100%;
}

.srmg-card-badge img {
  max-width: 92px;
  max-height: 92px;
  width: auto;
  height: auto;
  display: block;
}

.srmg-card-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #10304d;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(16, 48, 77, 0.08);
  margin-bottom: 10px;
}

.srmg-card-name {
  display: block;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 6px;
}

.srmg-card-era {
  display: block;
  font-size: 0.86rem;
  line-height: 1.3;
  opacity: 0.82;
}

.srmg-card.is-matched .srmg-card-back {
  box-shadow: 0 16px 30px rgba(31, 128, 65, 0.16);
}

.srmg-card.is-matched::after {
  content: "✓";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #ffffff;
  background: #2f9651;
  box-shadow: 0 8px 16px rgba(47, 150, 81, 0.3);
  z-index: 3;
}

.srmg-fact-panel {
  margin-top: 22px;
  padding: 18px 20px;
  background: var(--srmg-soft-blue);
  border: 1px solid rgba(44, 89, 158, 0.12);
  border-radius: 22px;
}

.srmg-fact-panel.is-hidden {
  display: none;
}

.srmg-fact-title {
  margin: 0 0 6px;
  font-size: 1rem;
}

.srmg-fact-text,
.srmg-note {
  margin: 0;
  line-height: 1.55;
}

.srmg-note {
  margin-top: 16px;
  font-size: 0.92rem;
  opacity: 0.8;
}

.srmg-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 640px) {
  .srmg-shell {
    padding: 18px;
    border-radius: 24px;
  }

  .srmg-header {
    flex-direction: column;
  }

  .srmg-stats {
    width: 100%;
  }

  .srmg-stat-box {
    flex: 1 1 120px;
  }

  .srmg-card,
  .srmg-card-inner {
    min-height: 170px;
  }

  .srmg-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .srmg-card-inner,
  .srmg-button {
    transition: none;
  }
}
