/* CCM — cute card loading screen */

#ccmLoadingScreen {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: "VT323", "Orbitron", monospace;
  color: var(--secondary-color, #98fb98);
  background: linear-gradient(165deg, #000102 0%, #020408 48%, #000101 100%);
  transition: opacity 0.65s ease-in-out;
  overflow: hidden;
  isolation: isolate;
  contain: layout paint;
}

/* Fine dot field under the domino tiles — gentle drift (no rotation = no moiré flicker) */
#ccmLoadingScreen::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  opacity: 0.2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='5' height='5' viewBox='0 0 5 5'%3E%3Ccircle cx='1.4' cy='1.4' r='1.25' fill='rgba(100,220,200,0.55)'/%3E%3C/svg%3E");
  background-size: 5px 5px;
  background-repeat: repeat;
  animation: ccmLoaderDotsDrift 90s linear infinite;
  pointer-events: none;
  will-change: background-position;
  backface-visibility: hidden;
}

/* Domino tiles — dense 5×8 pip grid per card */
#ccmLoadingScreen::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  opacity: 0.36;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='76' viewBox='0 0 56 76'%3E%3Crect x='1' y='1' width='54' height='74' rx='7' fill='rgba(4,8,12,0.82)' stroke='rgba(100,200,180,0.16)' stroke-width='1'/%3E%3Ccircle cx='9' cy='10' r='1.35' fill='rgba(100,220,200,0.24)'/%3E%3Ccircle cx='18' cy='10' r='1.35' fill='rgba(100,220,200,0.18)'/%3E%3Ccircle cx='27' cy='10' r='1.35' fill='rgba(100,220,200,0.22)'/%3E%3Ccircle cx='36' cy='10' r='1.35' fill='rgba(100,220,200,0.17)'/%3E%3Ccircle cx='45' cy='10' r='1.35' fill='rgba(100,220,200,0.23)'/%3E%3Ccircle cx='9' cy='18' r='1.35' fill='rgba(100,220,200,0.19)'/%3E%3Ccircle cx='18' cy='18' r='1.35' fill='rgba(100,220,200,0.21)'/%3E%3Ccircle cx='27' cy='18' r='1.35' fill='rgba(100,220,200,0.16)'/%3E%3Ccircle cx='36' cy='18' r='1.35' fill='rgba(100,220,200,0.2)'/%3E%3Ccircle cx='45' cy='18' r='1.35' fill='rgba(100,220,200,0.18)'/%3E%3Ccircle cx='9' cy='26' r='1.35' fill='rgba(100,220,200,0.22)'/%3E%3Ccircle cx='18' cy='26' r='1.35' fill='rgba(100,220,200,0.17)'/%3E%3Ccircle cx='27' cy='26' r='1.35' fill='rgba(100,220,200,0.23)'/%3E%3Ccircle cx='36' cy='26' r='1.35' fill='rgba(100,220,200,0.18)'/%3E%3Ccircle cx='45' cy='26' r='1.35' fill='rgba(100,220,200,0.21)'/%3E%3Ccircle cx='9' cy='34' r='1.35' fill='rgba(100,220,200,0.18)'/%3E%3Ccircle cx='18' cy='34' r='1.35' fill='rgba(100,220,200,0.2)'/%3E%3Ccircle cx='27' cy='34' r='1.35' fill='rgba(100,220,200,0.15)'/%3E%3Ccircle cx='36' cy='34' r='1.35' fill='rgba(100,220,200,0.19)'/%3E%3Ccircle cx='45' cy='34' r='1.35' fill='rgba(100,220,200,0.17)'/%3E%3Ccircle cx='9' cy='42' r='1.35' fill='rgba(100,220,200,0.21)'/%3E%3Ccircle cx='18' cy='42' r='1.35' fill='rgba(100,220,200,0.16)'/%3E%3Ccircle cx='27' cy='42' r='1.35' fill='rgba(100,220,200,0.22)'/%3E%3Ccircle cx='36' cy='42' r='1.35' fill='rgba(100,220,200,0.18)'/%3E%3Ccircle cx='45' cy='42' r='1.35' fill='rgba(100,220,200,0.2)'/%3E%3Ccircle cx='9' cy='50' r='1.35' fill='rgba(100,220,200,0.17)'/%3E%3Ccircle cx='18' cy='50' r='1.35' fill='rgba(100,220,200,0.19)'/%3E%3Ccircle cx='27' cy='50' r='1.35' fill='rgba(100,220,200,0.14)'/%3E%3Ccircle cx='36' cy='50' r='1.35' fill='rgba(100,220,200,0.18)'/%3E%3Ccircle cx='45' cy='50' r='1.35' fill='rgba(100,220,200,0.16)'/%3E%3Ccircle cx='9' cy='58' r='1.35' fill='rgba(100,220,200,0.2)'/%3E%3Ccircle cx='18' cy='58' r='1.35' fill='rgba(100,220,200,0.15)'/%3E%3Ccircle cx='27' cy='58' r='1.35' fill='rgba(100,220,200,0.21)'/%3E%3Ccircle cx='36' cy='58' r='1.35' fill='rgba(100,220,200,0.17)'/%3E%3Ccircle cx='45' cy='58' r='1.35' fill='rgba(100,220,200,0.19)'/%3E%3Ccircle cx='9' cy='66' r='1.35' fill='rgba(100,220,200,0.18)'/%3E%3Ccircle cx='18' cy='66' r='1.35' fill='rgba(100,220,200,0.2)'/%3E%3Ccircle cx='27' cy='66' r='1.35' fill='rgba(100,220,200,0.16)'/%3E%3Ccircle cx='36' cy='66' r='1.35' fill='rgba(100,220,200,0.19)'/%3E%3Ccircle cx='45' cy='66' r='1.35' fill='rgba(100,220,200,0.17)'/%3E%3C/svg%3E");
  background-size: 56px 76px;
  background-repeat: repeat;
  animation: ccmLoaderDominoDrift 60s linear infinite;
  pointer-events: none;
  will-change: background-position;
  backface-visibility: hidden;
}

@keyframes ccmLoaderDominoDrift {
  from { background-position: 0 0; }
  to { background-position: 336px 456px; }
}

@keyframes ccmLoaderDotsDrift {
  from { background-position: 0 0; }
  to { background-position: 250px 250px; }
}

#ccmLoadingScreen .ccm-loader-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    transparent 0%,
    transparent 36%,
    rgba(0, 0, 0, 0.62) 65%,
    rgba(0, 0, 0, 0.94) 100%
  );
  z-index: 1;
}

#ccmLoadingScreen .ccm-loader-content {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 420px;
  padding: 20px;
}

#ccmLoadingScreen.ccm-loader-fading::before,
#ccmLoadingScreen.ccm-loader-fading::after,
#ccmLoadingScreen.ccm-loader-fading .ccm-loader-card,
#ccmLoadingScreen.ccm-loader-fading .ccm-loader-card-inner,
#ccmLoadingScreen.ccm-loader-fading .ccm-loader-match-burst,
#ccmLoadingScreen.ccm-loader-fading .ccm-loader-title,
#ccmLoadingScreen.ccm-loader-fading #ccmLoadingProgressBar {
  animation-play-state: paused;
}

/* --- Cute flipping card trio --- */
.ccm-loader-stage {
  position: relative;
  width: 168px;
  height: 118px;
  margin: 0 auto 28px;
  perspective: 520px;
}

.ccm-loader-card {
  position: absolute;
  width: 52px;
  height: 72px;
  transform-style: preserve-3d;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.45));
}

.ccm-loader-card--a,
.ccm-loader-card--b {
  z-index: 2;
}

.ccm-loader-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  border-radius: 7px;
}

.ccm-loader-face {
  position: absolute;
  inset: 0;
  border-radius: 7px;
  backface-visibility: hidden;
  border: 1px solid rgba(152, 251, 152, 0.45);
}

/* Solid face-down back — reads clearly when A/B flip back over */
.ccm-loader-back {
  background-color: #061018;
  background-image:
    linear-gradient(155deg, rgba(255, 255, 255, 0.07) 0%, transparent 38%),
    linear-gradient(168deg, #143038 0%, #0a1e28 52%, #040a12 100%);
  border: 2px solid rgba(152, 251, 152, 0.82);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -3px 10px rgba(0, 0, 0, 0.72),
    inset 0 0 0 3px rgba(4, 12, 18, 0.98),
    0 3px 14px rgba(0, 0, 0, 0.65),
    0 0 12px rgba(152, 251, 152, 0.22);
}

.ccm-loader-back::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 64%;
  height: 70%;
  transform: translate(-50%, -50%);
  border-radius: 5px;
  background: #0c222c;
  border: 1.5px solid rgba(152, 251, 152, 0.48);
  box-shadow:
    inset 0 0 14px rgba(0, 0, 0, 0.55),
    0 0 8px rgba(152, 251, 152, 0.12);
}

.ccm-loader-back::after {
  content: "?";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "VT323", "Orbitron", monospace;
  font-size: 1.75rem;
  font-weight: bold;
  line-height: 1;
  color: rgba(152, 251, 152, 0.88);
  text-shadow:
    0 0 10px rgba(152, 251, 152, 0.55),
    0 1px 2px rgba(0, 0, 0, 0.85);
  pointer-events: none;
}

.ccm-loader-front {
  transform: rotateY(180deg);
  box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.25);
  transition: background-color 0.65s ease, box-shadow 0.65s ease;
}

.ccm-loader-front::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(126deg, rgba(255, 255, 255, 0.22) 0%, transparent 46%, rgba(0, 0, 0, 0.18) 100%);
  pointer-events: none;
}

.ccm-loader-card--a {
  left: 8px;
  top: 22px;
  animation: ccmLoaderCardBobA 2.8s ease-in-out infinite;
}

.ccm-loader-card--a .ccm-loader-card-inner {
  animation: ccmLoaderFlipA 2.4s cubic-bezier(0.45, 0.05, 0.2, 1) infinite;
}

.ccm-loader-card--b {
  right: 8px;
  top: 22px;
  animation: ccmLoaderCardBobB 2.8s ease-in-out infinite;
}

.ccm-loader-card--b .ccm-loader-card-inner {
  animation: ccmLoaderFlipB 2.4s cubic-bezier(0.45, 0.05, 0.2, 1) infinite;
}

.ccm-loader-card--c {
  left: 50%;
  top: 0;
  margin-left: -26px;
  opacity: 0.72;
  transform: scale(0.88);
  animation: ccmLoaderCardShuffle 1.6s ease-in-out infinite;
  z-index: -1;
}

.ccm-loader-card--c .ccm-loader-card-inner {
  animation: ccmLoaderFlipC 3.2s ease-in-out infinite;
}

.ccm-loader-match-burst {
  position: absolute;
  left: 50%;
  top: 58px;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  animation: ccmLoaderMatchBurst 2.4s ease-out infinite;
}

.ccm-loader-match-burst::before,
.ccm-loader-match-burst::after {
  content: "✦";
  position: absolute;
  font-size: 14px;
  color: var(--ccm-burst-color, #98fb98);
  text-shadow: 0 0 10px var(--ccm-burst-color, #98fb98);
}

.ccm-loader-match-burst::before {
  left: -18px;
  top: -6px;
  animation: ccmLoaderSparkLeft 2.4s ease-out infinite;
}

.ccm-loader-match-burst::after {
  right: -18px;
  top: -6px;
  animation: ccmLoaderSparkRight 2.4s ease-out infinite;
}

@keyframes ccmLoaderFlipA {
  0%, 18% { transform: rotateY(0deg); }
  38%, 58% { transform: rotateY(180deg); }
  78%, 100% { transform: rotateY(360deg); }
}

@keyframes ccmLoaderFlipB {
  0%, 18% { transform: rotateY(0deg); }
  38%, 58% { transform: rotateY(-180deg); }
  78%, 100% { transform: rotateY(-360deg); }
}

@keyframes ccmLoaderFlipC {
  0%, 100% { transform: rotateY(0deg) rotateZ(-6deg); }
  50% { transform: rotateY(180deg) rotateZ(6deg); }
}

@keyframes ccmLoaderCardBobA {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-3px) rotate(-2deg); }
}

@keyframes ccmLoaderCardBobB {
  0%, 100% { transform: translateY(0) rotate(4deg); }
  50% { transform: translateY(-3px) rotate(2deg); }
}

@keyframes ccmLoaderCardShuffle {
  0%, 100% { transform: scale(0.88) translateX(0); }
  25% { transform: scale(0.88) translateX(-6px) rotate(-3deg); }
  75% { transform: scale(0.88) translateX(6px) rotate(3deg); }
}

@keyframes ccmLoaderMatchBurst {
  0%, 34% { opacity: 0; transform: scale(0.2); }
  42% { opacity: 1; transform: scale(1.2); }
  58% { opacity: 0.85; transform: scale(1.6); }
  72%, 100% { opacity: 0; transform: scale(2.2); }
}

@keyframes ccmLoaderSparkLeft {
  0%, 38% { opacity: 0; transform: translate(8px, 4px) scale(0.4); }
  46% { opacity: 1; transform: translate(-6px, -10px) scale(1); }
  62%, 100% { opacity: 0; transform: translate(-14px, -18px) scale(0.3); }
}

@keyframes ccmLoaderSparkRight {
  0%, 38% { opacity: 0; transform: translate(-8px, 4px) scale(0.4); }
  46% { opacity: 1; transform: translate(6px, -10px) scale(1); }
  62%, 100% { opacity: 0; transform: translate(14px, -18px) scale(0.3); }
}

/* --- Typography --- */
#ccmLoadingScreen .ccm-loader-title {
  font-size: 1.55em;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
  text-shadow: 0 0 18px rgba(152, 251, 152, 0.55);
  animation: ccmLoaderTitlePulse 2.2s ease-in-out infinite;
}

#ccmLoadingScreen .ccm-loader-subtitle {
  font-size: 0.92em;
  color: rgba(152, 251, 152, 0.78);
  margin-bottom: 28px;
  min-height: 2.4em;
  line-height: 1.25;
  padding: 0 8%;
}

@keyframes ccmLoaderTitlePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

/* --- Memory-charge progress bar --- */
#ccmLoadingProgressTrack {
  width: min(320px, 72vw);
  height: 22px;
  margin: 0 auto 14px;
  position: relative;
  border-radius: 8px;
  border: 2px solid rgba(152, 251, 152, 0.55);
  background: rgba(0, 0, 0, 0.45);
  box-shadow: 0 0 16px rgba(99, 197, 218, 0.25);
  overflow: hidden;
  box-sizing: border-box;
}

#ccmLoadingProgressBar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: 5px;
  background: linear-gradient(90deg, #63c5da 0%, #98fb98 55%, gold 100%);
  box-shadow: 0 0 14px rgba(152, 251, 152, 0.45);
  transition: width 0.32s ease-out;
}

#ccmLoadingProgressBar.ccm-progress-pulse {
  width: 48% !important;
  transform-origin: left center;
  animation: ccmLoaderBarPulse 1.35s ease-in-out infinite;
  transition: none;
}

#ccmLoadingProgressBar.ccm-progress-finish {
  animation: none;
  transform: none;
  transition: width 0.48s ease-out;
}

#ccmLoadingProgressText {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95em;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 6px #000;
  letter-spacing: 0.08em;
  z-index: 2;
  pointer-events: none;
}

@keyframes ccmLoaderBarPulse {
  0%, 100% { transform: scaleX(0.82); opacity: 0.85; }
  50% { transform: scaleX(1.15); opacity: 1; }
}

#ccmLoadingStatus {
  font-size: 0.88em;
  color: rgba(152, 251, 152, 0.88);
  min-height: 1.2em;
}

#ccmLoadingDetails {
  font-size: 0.82em;
  color: rgba(99, 197, 218, 0.72);
  min-height: 1.1em;
  margin-top: 4px;
}

body.ccm-booting > main,
body.ccm-booting > aside,
body.ccm-booting > div:not(#ccmLoadingScreen):not(#game-bg) {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body.ccm-booting #welcome-screen,
body.ccm-booting #welcome-screen .overlay-content,
body.ccm-booting #welcome-screen .how-to-overlay-content {
  transition: none !important;
}

body.ccm-boot-handoff-ready > main,
body.ccm-boot-handoff-ready > aside,
body.ccm-boot-handoff-ready #welcome-screen,
body.ccm-boot-handoff-ready #welcome-screen .overlay-content,
body.ccm-boot-handoff-ready #welcome-screen .how-to-overlay-content,
body.ccm-boot-handoff-ready #game-container {
  transition: none !important;
}

body.ccm-boot-handoff-ready.welcome-active #game-container {
  opacity: 0.42;
  transform: scale(0.982);
  filter: brightness(0.72);
}

@media (prefers-reduced-motion: reduce) {
  #ccmLoadingScreen::before,
  #ccmLoadingScreen::after {
    animation: none;
  }
}
.ccm-music-prompt {
  font-family: 'Orbitron', 'Share Tech Mono', monospace;
  font-size: 0.95rem;
  color: #00f3ff;
  text-transform: uppercase;
  letter-spacing: 2px;
  display: none;
  pointer-events: none;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  text-align: center;
  text-shadow: 0 0 10px rgba(0, 243, 255, 0.6);
}
.ccm-music-prompt.show {
  display: block;
  animation: fadePulsePrompt 1.4s ease-in-out infinite;
}
@keyframes fadePulsePrompt {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
`r`n