/* ═══════════════════════════════════════════════════════
   COLOR MAZE — scoped to #colormaze-game  prefix: .cm-
═══════════════════════════════════════════════════════ */

/* ── Loading ─────────────────────────────────────────── */
#colormaze-game .cm-loading {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 400px; gap: var(--space-md);
  color: var(--clr-text-muted); font-family: var(--font-body);
}
#colormaze-game .cm-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--clr-border);
  border-top-color: var(--clr-accent);
  border-radius: 50%;
  animation: cm-spin 0.8s linear infinite;
}
@keyframes cm-spin { to { transform: rotate(360deg); } }

/* ── Setup / Win shells ──────────────────────────────── */
#colormaze-game .cm-setup,
#colormaze-game .cm-win {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 520px; gap: var(--space-lg);
  text-align: center; padding: var(--space-xl) var(--space-md);
}
#colormaze-game .cm-logo { font-size: 4rem; line-height: 1; }
#colormaze-game .cm-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3.5rem);
  color: var(--clr-text); margin: 0; letter-spacing: 0.04em;
}
#colormaze-game .cm-sub {
  color: var(--clr-text-muted); font-family: var(--font-body);
  font-size: 1rem; margin: 0; max-width: 360px;
}
#colormaze-game .cm-saved {
  font-family: var(--font-body);
  font-size: 0.85rem; color: var(--clr-accent); margin: 0;
}
#colormaze-game .cm-hint {
  font-family: var(--font-body);
  font-size: 0.8rem; color: var(--clr-text-dim); margin: 0;
}
#colormaze-game .cm-setup-btns {
  display: flex; flex-direction: column;
  gap: var(--space-sm); width: 100%; max-width: 280px;
}
#colormaze-game .cm-setup-btns .btn {
  width: 100%; min-height: 50px;
  font-family: var(--font-display);
  font-size: 1.1rem; letter-spacing: 0.05em;
}
#colormaze-game .cm-win-icon {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--clr-accent); color: var(--clr-bg);
  font-size: 2.2rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--glow-cyan);
  animation: cm-pop 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
#colormaze-game .cm-trophy {
  background: transparent; font-size: 4rem;
  box-shadow: none; width: auto; height: auto;
}
#colormaze-game .cm-win-stars {
  font-size: 2.5rem; letter-spacing: 0.15em; color: var(--clr-accent-3);
  animation: cm-pop 0.5s 0.2s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes cm-pop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ══════════════════════════════════════════════════════
   GAME UI
══════════════════════════════════════════════════════ */
#colormaze-game .cm-ui {
  display: flex; flex-direction: column;
  align-items: center; gap: var(--space-md);
  padding: var(--space-md) 0; width: 100%;
}

/* ── Topbar ──────────────────────────────────────────── */
#colormaze-game .cm-topbar {
  display: flex; align-items: center; gap: var(--space-md);
  width: 100%; max-width: 520px;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--border-radius-lg);
  padding: var(--space-sm) var(--space-md);
}
#colormaze-game .cm-stat {
  display: flex; flex-direction: column; align-items: center; min-width: 52px;
}
#colormaze-game .cm-stat-label {
  font-family: var(--font-display); font-size: 0.65rem;
  letter-spacing: 0.1em; color: var(--clr-text-muted);
}
#colormaze-game .cm-stat-val {
  font-family: var(--font-display); font-size: 1.4rem;
  color: var(--clr-text); line-height: 1;
}
#colormaze-game .cm-stat-of { font-size: 0.75rem; color: var(--clr-text-muted); }
#colormaze-game .cm-fill-wrap {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
#colormaze-game .cm-fill-bar {
  width: 100%; height: 8px; background: var(--clr-surface-2);
  border-radius: 99px; overflow: hidden;
}
#colormaze-game .cm-fill-inner {
  height: 100%; background: var(--clr-accent); border-radius: 99px;
  transition: width 60ms linear; box-shadow: var(--glow-cyan);
}
#colormaze-game .cm-fill-pct {
  font-family: var(--font-display); font-size: 0.75rem;
  color: var(--clr-accent); letter-spacing: 0.05em;
}

/* ══════════════════════════════════════════════════════
   BOARD — zero gap, seamless tiles
══════════════════════════════════════════════════════ */
#colormaze-game .cm-board-wrap {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1;
  background: #1e1830;
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7),
              inset 0 1px 0 rgba(255,255,255,0.07);
  overflow: hidden;
  box-sizing: border-box;
}

#colormaze-game .cm-board {
  display: grid;
  grid-template-columns: repeat(var(--cm-cols), 1fr);
  grid-template-rows:    repeat(var(--cm-rows), 1fr);
  width: 100%;
  height: 100%;
  /* ZERO gap — seamless. Shape comes from border-radius per cell */
  gap: 0;
  background: #3a3060; /* board floor colour shown in the gaps between shapes */
  border-radius: 10px;
  overflow: hidden;
}

/* ── Base cell ───────────────────────────────────────── */
#colormaze-game .cm-cell {
  /* Same as board floor — cells are invisible until painted/obstacle */
  background: #3a3060;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  /* border-radius set per-cell by JS */
  border-radius: 0;
  /* no transition on background — instant colour change, shape animates */
  transition: border-radius 60ms ease;
  overflow: visible;
  z-index: 1;
}

/* ── Painted cell ────────────────────────────────────── */
#colormaze-game .cm-cell.cm-painted {
  background: #00c8e0;
  z-index: 2;
}

/* ── Ball cell ───────────────────────────────────────── */
#colormaze-game .cm-cell.cm-ball-cell {
  background: #00c8e0;
  z-index: 3;
  overflow: visible;
}

/* ── Obstacle ─────────────────────────────────────────
   Raised white pill shape — JS sets border-radius
   so touching obstacles merge into one blob           */
#colormaze-game .cm-cell.cm-obs {
  background: #ccc8e8;
  z-index: 2;
}

/* ── Ball — no pop animation, just appears ───────────── */
#colormaze-game .cm-ball {
  width: 76%;
  height: 76%;
  border-radius: 50%;
  background: radial-gradient(circle at 33% 28%,
    #f6f6ff 0%,
    #b4b4cc 44%,
    #3c3c58 100%
  );
  box-shadow:
    0 4px 12px rgba(0,0,0,0.75),
    inset 0 1px 4px rgba(255,255,255,0.6);
  position: relative;
  z-index: 10;
  /* NO animation — ball just moves, no size bounce */
}

/* ── Ripple only on .cm-new (freshly painted) ────────── */
#colormaze-game .cm-cell.cm-new::before {
  content: '';
  position: absolute; inset: 0;
  background: rgba(0, 229, 255, 0.45);
  animation: cm-ripple 0.28s ease forwards;
  pointer-events: none;
  z-index: 5;
  border-radius: inherit;
}
@keyframes cm-ripple {
  0%   { opacity: 1; transform: scale(0.3); }
  100% { opacity: 0; transform: scale(1.3); }
}

/* ══════════════════════════════════════════════════════
   D-PAD
══════════════════════════════════════════════════════ */
#colormaze-game .cm-dpad {
  display: flex; flex-direction: column;
  align-items: center; gap: 4px; margin-top: var(--space-sm);
}
#colormaze-game .cm-dpad-row {
  display: flex; align-items: center; gap: 4px;
}
#colormaze-game .cm-dpad-center {
  width: 54px; height: 54px;
  background: var(--clr-surface); border-radius: var(--border-radius);
  border: 1px solid var(--clr-border);
}
#colormaze-game .cm-dpad-btn {
  width: 54px; height: 54px; min-height: 54px;
  background: var(--clr-surface); border: 1px solid var(--clr-border);
  border-radius: var(--border-radius); color: var(--clr-text);
  font-size: 1.1rem; cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  display: flex; align-items: center; justify-content: center;
  user-select: none; -webkit-user-select: none;
}
#colormaze-game .cm-dpad-btn:hover {
  background: var(--clr-surface-2);
  border-color: var(--clr-accent); color: var(--clr-accent);
}
#colormaze-game .cm-dpad-btn:active {
  transform: scale(0.9);
  background: color-mix(in srgb, var(--clr-accent) 15%, var(--clr-surface));
}
#colormaze-game .cm-actions {
  display: flex; gap: var(--space-sm); margin-top: var(--space-xs);
}
#colormaze-game .cm-actions .btn {
  min-height: 44px; font-size: 0.85rem; padding: 0 var(--space-md);
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════ */
@media (max-width: 560px) {
  #colormaze-game .cm-board-wrap { max-width: 100%; padding: 8px; }
  #colormaze-game .cm-topbar { max-width: 100%; }
  #colormaze-game .cm-dpad-btn { width: 60px; height: 60px; min-height: 60px; font-size: 1.3rem; }
  #colormaze-game .cm-dpad-center { width: 60px; height: 60px; }
}
@media (max-width: 360px) {
  #colormaze-game .cm-dpad-btn { width: 52px; height: 52px; min-height: 52px; }
  #colormaze-game .cm-dpad-center { width: 52px; height: 52px; }
  #colormaze-game .cm-actions { flex-direction: column; width: 100%; padding: 0 var(--space-sm); }
  #colormaze-game .cm-actions .btn { width: 100%; text-align: center; }
}