button, 
input[type="button"], 
input[type="submit"], 
input[type="reset"],
.role-btn,
.floating-qa-btn {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

memory-match-card {
  display: flex;
  justify-content: center;
  flex: 0 1 auto;
}

memory-match-card .game-card {
  width: 100%;
  max-width: 460px;
  box-sizing: border-box;
  background-color: var(--bg-card-body);
  border-radius: 20px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  position: relative;
  overflow: hidden;
}

memory-match-card .game-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 520px;
  padding: 20px;
  box-sizing: border-box;
  gap: 10px;
}

.mem-title {
  font-size: 0.95rem;
}

.mem-mb-0 {
  margin-bottom: 0 !important;
}

.mem-help-flex-row {
  justify-content: center;
  gap: 12px;
}

.mem-preview-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
}

.mem-preview-box {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mem-flipped-card {
  background-color: #9CAF88;
  color: #1a1a1a;
  font-size: 1.1rem;
  font-weight: bold;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.mem-preview-arrow {
  font-size: 1.1rem;
  color: var(--color-accent);
}

.memory-grid {
  --mem-grid-size: 6;
  --mem-grid-gap: 8px;
  --mem-icon-size: 1.1rem;
  display: grid;
  grid-template-columns: repeat(var(--mem-grid-size), 1fr);
  grid-template-rows: repeat(var(--mem-grid-size), 1fr);
  gap: var(--mem-grid-gap);
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1 / 1;
  margin: 4px auto 2px auto;
  perspective: 1000px;
  box-sizing: border-box;
}

.memory-card {
  width: 100%;
  height: 100%;
  background-color: transparent;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.memory-card:focus-visible .memory-card-front {
  outline: 2px solid var(--color-accent, #d1db9e);
  outline-offset: 2px;
}

.memory-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
  border-radius: 8px;
}

.memory-card.flipped .memory-card-inner {
  transform: rotateY(180deg);
}

.memory-card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: var(--mem-icon-size, 1.4rem);
  box-sizing: border-box;
}

.memory-card-front {
  background-color: var(--color-control, rgba(255, 255, 255, 0.08));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.2);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.memory-card:hover .memory-card-front {
  border-color: var(--color-accent, #d1db9e);
  box-shadow: 0 0 10px rgba(181, 190, 138, 0.25), inset 0 0 6px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

.memory-card-back {
  background-color: #b5be8a;
  color: #1e2319;
  border: 1.5px solid var(--color-accent-hover);
  transform: rotateY(180deg);
}

.card-icon {
  display: inline-block;
  line-height: 1;
  filter: drop-shadow(0px 2px 4px rgba(0, 0, 0, 0.5));
}

.memory-card.matched .memory-card-back {
  box-shadow: 0 0 12px rgba(57, 255, 20, 0.3);
}

.mem-controls-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 420px;
  align-items: center;
  margin-top: 20px;
}

.mem-custom-dropdown-container.mem-size-dropdown {
  flex: 0 0 120px;
  width: 120px;
  min-width: 120px;
}

.mem-custom-dropdown-container {
  position: relative;
  display: block;
  font-family: inherit;
  font-size: 0.85rem;
  flex: 1;
  min-width: 0;
}

.mem-size-dropdown {
  flex: 1;
  width: 100%;
  min-width: 0;
}

.mem-custom-select-trigger {
  background: var(--bg-dark, #141812);
  color: var(--color-accent, #d1db9e);
  border: 1px solid var(--color-accent, #d1db9e);
  border-radius: 8px;
  padding: 0 8px;
  height: 40px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.mem-custom-select-trigger:hover:not(.disabled) {
  border-color: var(--color-accent, #d1db9e);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.mem-custom-select-arrow {
  font-size: 0.65rem;
  margin-left: 4px;
  transition: transform 0.25s ease;
}

.mem-custom-select-options {
  position: absolute;
  bottom: 100%;
  left: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-bottom: 6px;
  background: var(--bg-dark, #141812);
  border: 1px solid var(--color-accent, #d1db9e);
  border-radius: 8px;
  box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.4);
  box-sizing: border-box;
  max-height: 160px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--color-accent, #d1db9e) var(--bg-dark, #141812);
}

.mem-custom-select-options::-webkit-scrollbar {
  width: 5px;
}

.mem-custom-select-options::-webkit-scrollbar-track {
  background: var(--bg-dark, #141812);
  border-radius: 0 8px 8px 0;
}

.mem-custom-select-options::-webkit-scrollbar-thumb {
  background: var(--color-accent, #d1db9e);
  border-radius: 3px;
}

.mem-custom-select-options::-webkit-scrollbar-thumb:hover {
  background: rgba(209, 219, 158, 0.8);
}

.mem-custom-select-options.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.mem-custom-select-options.closing {
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
}

.mem-custom-option {
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  color: var(--color-accent, #d1db9e);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.mem-custom-option:hover {
  background-color: var(--color-accent, #d1db9e);
  color: var(--bg-dark, #141812);
}

.mem-custom-option.selected {
  background-color: color-mix(in srgb, var(--color-accent, #d1db9e) 20%, transparent);
  color: var(--color-accent, #d1db9e);
  font-weight: bold;
}

#restartMemBtn {
  flex: 0 0 120px;
  box-sizing: border-box;
  margin-top: 0;
  width: 120px;
}

.mem-help-label {
  font-size: 0.8rem;
  font-weight: bold;
  margin-top: 10px;
  margin-bottom: 6px;
  color: var(--color-accent, #d1db9e);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mem-items-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  background: rgba(30, 35, 25, 0.6);
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.mem-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

memory-match-card .action-btn {
  margin-left: 2px;
}

memory-match-card .game-help-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-card-body);
  border-radius: 20px;
  z-index: 50;
  padding: 20px;
  display: flex;
  overflow-y: auto;
  overflow-x: hidden;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

memory-match-card .game-help-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* RETRO LED SCREEN */
memory-match-card .arcade-marquee-screen {
  background-color: #0d1109;
  border: 2px solid #3b4432;
  border-radius: 6px;
  padding: 6px 0;
  width: 100%;
  max-width: 320px;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.8), 0 0 5px rgba(181, 190, 138, 0.2);
  text-align: center;
  box-sizing: border-box;
  margin-top: -10px;
  margin-bottom: 6px;
  overflow: hidden;
  position: relative;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

/* Base Text */
memory-match-card .arcade-marquee-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.65rem;
  color: #ff4d4d;
  text-shadow: 0 0 8px #ff0000, 0 0 15px #ff0000, 0 0 25px #ff0000;
  letter-spacing: 0.5px;
  white-space: nowrap;
  display: block;
  width: 100%;
  animation: marqueeScroll 6s linear infinite;
}

/* 🏆 Win State */
memory-match-card .arcade-marquee-screen.win-state .arcade-marquee-text {
  color: #ffd700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.9);
  animation: retroRiseIn 0.8s ease-out forwards, goldGlowPulse 1.5s infinite alternate ease-in-out 0.8s;
}

/* Active Gameplay State */
memory-match-card .arcade-marquee-screen.active-state .arcade-marquee-text {
  animation: none;
  color: #39ff14;
  transform: none;
}

/* --- Keyframe Animations --- */
@keyframes marqueeScroll {
  0% { 
    transform: translate3d(100%, 0, 0); 
  }
  100% { 
    transform: translate3d(-100%, 0, 0); 
  }
}

@keyframes retroRiseIn {
  0% {
    opacity: 0;
    transform: translate3d(0, 120%, 0);
  }
  60% {
    opacity: 0.8;
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes goldGlowPulse {
  0% { text-shadow: 0 0 5px rgba(255, 215, 0, 0.6); }
  100% { text-shadow: 0 0 12px rgba(255, 215, 0, 1); }
}