/* ==========================================================================
 * MEMORY MAZE (记忆迷宫) — Electrifying 7×7 Obsidian Laser Floor Matrix
 * ========================================================================== */

.mm-arena {
  width: 100%;
  max-width: 1020px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 18px;
  align-items: start;
}

.mm-stage-card {
  position: relative;
  padding: 18px;
  border-radius: var(--tg-radius-lg);
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(34, 211, 238, 0.1), transparent 65%),
    linear-gradient(165deg, rgba(16, 20, 34, 0.96), rgba(7, 9, 15, 0.98));
  border: 1px solid var(--tg-border-strong);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.mm-stage-card.is-siren {
  animation: mm-shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97);
  border-color: var(--tg-garnet-bright);
  box-shadow:
    0 0 55px rgba(255, 46, 84, 0.45),
    inset 0 0 42px rgba(217, 27, 58, 0.3);
}

@keyframes mm-shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  15% { transform: translate3d(-7px, 2px, 0); }
  30% { transform: translate3d(7px, -3px, 0); }
  45% { transform: translate3d(-5px, 3px, 0); }
  65% { transform: translate3d(5px, -1px, 0); }
  85% { transform: translate3d(-2px, 0, 0); }
}

.mm-top-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.mm-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--tg-border-strong);
  background: rgba(14, 18, 30, 0.92);
}

.mm-status-pill.is-cyan {
  border-color: rgba(34, 211, 238, 0.65);
  color: #a5f3fc;
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.22);
}

.mm-status-pill.is-garnet {
  border-color: rgba(255, 46, 84, 0.72);
  color: #ffb3c1;
  box-shadow: 0 0 18px rgba(255, 46, 84, 0.28);
}

.mm-status-pill.is-siren {
  background: linear-gradient(135deg, rgba(217, 27, 58, 0.48), rgba(110, 8, 28, 0.72));
  border-color: #ff4f70;
  color: #fff;
  animation: tg-pulse-urgent 0.6s infinite;
}

.mm-step-pips {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mm-step-pip {
  width: 24px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: all 0.22s var(--tg-ease);
}

.mm-step-pip.is-available {
  background: linear-gradient(90deg, var(--tg-cyan), #7dd3fc);
  border-color: #a5f3fc;
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.55);
}

.mm-step-pip.is-available.is-double {
  background: linear-gradient(90deg, var(--tg-gold), var(--tg-gold-bright));
  border-color: #fff6d9;
  box-shadow: 0 0 12px rgba(228, 185, 91, 0.68);
}

.mm-step-pip.is-used {
  background: rgba(228, 185, 91, 0.28);
  border-color: rgba(228, 185, 91, 0.4);
}

/* 7x7 Obsidian Board Wrapper */
.mm-board-wrap {
  position: relative;
  width: min(100%, 540px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  padding: 10px;
  border-radius: 16px;
  background:
    linear-gradient(155deg, #111626 0%, #070910 100%);
  border: 1px solid rgba(228, 185, 91, 0.35);
  box-shadow:
    inset 0 0 36px rgba(0, 0, 0, 0.85),
    0 18px 46px rgba(0, 0, 0, 0.7);
}

.mm-grid {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: 6px;
}

.mm-cell {
  position: relative;
  border-radius: 9px;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.045), transparent 70%),
    linear-gradient(175deg, #171d31 0%, #0d111e 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s var(--tg-ease), border-color 0.18s, box-shadow 0.18s, background 0.18s;
  user-select: none;
}

.mm-cell.is-alt {
  background:
    radial-gradient(circle at 50% 30%, rgba(228, 185, 91, 0.03), transparent 70%),
    linear-gradient(175deg, #131829 0%, #090c16 100%);
}

.mm-cell-coord {
  position: absolute;
  top: 3px;
  left: 5px;
  font-family: var(--tg-font-mono);
  font-size: 9px;
  color: rgba(162, 168, 188, 0.32);
  pointer-events: none;
}

/* Corner Beacons: Start & Goal */
.mm-cell.is-start-cyan {
  border-color: rgba(34, 211, 238, 0.42);
  background: radial-gradient(circle at center, rgba(34, 211, 238, 0.16), #0b1322 80%);
}
.mm-cell.is-start-garnet {
  border-color: rgba(255, 46, 84, 0.45);
  background: radial-gradient(circle at center, rgba(217, 27, 58, 0.18), #190b14 80%);
}

.mm-cell.is-goal-cyan {
  border-color: var(--tg-cyan);
  background:
    radial-gradient(circle at center, rgba(34, 211, 238, 0.35), rgba(10, 26, 38, 0.92) 72%);
  box-shadow: inset 0 0 18px rgba(34, 211, 238, 0.35), 0 0 16px rgba(34, 211, 238, 0.25);
}
.mm-cell.is-goal-garnet {
  border-color: var(--tg-garnet-bright);
  background:
    radial-gradient(circle at center, rgba(255, 46, 84, 0.36), rgba(38, 10, 18, 0.92) 72%);
  box-shadow: inset 0 0 18px rgba(255, 46, 84, 0.35), 0 0 16px rgba(255, 46, 84, 0.28);
}

.mm-corner-tag {
  position: absolute;
  bottom: 3px;
  right: 4px;
  font-family: var(--tg-font-mono);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.85;
  pointer-events: none;
}
.mm-corner-tag.is-cyan { color: #67e8f9; }
.mm-corner-tag.is-garnet { color: #ff8ba0; }

/* Sonar trail ripple for current turn's walked squares */
.mm-cell.is-trail-cyan {
  border-color: rgba(34, 211, 238, 0.48);
  box-shadow: inset 0 0 14px rgba(34, 211, 238, 0.22);
}
.mm-cell.is-trail-garnet {
  border-color: rgba(255, 46, 84, 0.5);
  box-shadow: inset 0 0 14px rgba(255, 46, 84, 0.24);
}

/* Interactive Adjacent Cells */
.mm-cell.is-reachable {
  cursor: pointer;
  border-color: rgba(228, 185, 91, 0.72);
  box-shadow:
    inset 0 0 18px rgba(228, 185, 91, 0.16),
    0 0 14px rgba(228, 185, 91, 0.22);
}

.mm-cell.is-reachable:hover {
  transform: scale(1.04);
  border-color: var(--tg-gold-bright);
  background: radial-gradient(circle at center, rgba(228, 185, 91, 0.25), #181d32 80%);
  box-shadow: 0 0 22px rgba(228, 185, 91, 0.48);
  z-index: 3;
}

.mm-step-hint {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--tg-gold-bright);
  box-shadow: 0 0 12px var(--tg-gold);
  opacity: 0.75;
  animation: mm-dot-pulse 1.2s ease-in-out infinite;
}

@keyframes mm-dot-pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.55; }
  50% { transform: scale(1.2); opacity: 1; }
}

/* Player Tokens */
.mm-tokens {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.mm-token {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  border: 2px solid #fff;
  transition: transform 0.22s var(--tg-ease);
}

.mm-tokens.is-shared .mm-token {
  width: 24px;
  height: 24px;
  font-size: 11px;
}

.mm-token.is-cyan {
  background: radial-gradient(circle at 30% 25%, #cffafe, #06b6d4 58%, #0e7490 100%);
  color: #03151c;
  border-color: #a5f3fc;
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.75), 0 4px 10px rgba(0, 0, 0, 0.6);
}

.mm-token.is-garnet {
  background: radial-gradient(circle at 30% 25%, #ffd1db, #ff2e54 55%, #8f0820 100%);
  color: #fff;
  border-color: #ff9eb0;
  box-shadow: 0 0 20px rgba(255, 46, 84, 0.78), 0 4px 10px rgba(0, 0, 0, 0.6);
}

.mm-token.is-active {
  animation: mm-token-glow 1.3s ease-in-out infinite;
}

@keyframes mm-token-glow {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* SVG Laser Wall Overlay (flashes struck wall OR reveals all 32 walls post-game) */
.mm-wall-overlay {
  position: absolute;
  inset: 10px;
  width: calc(100% - 20px);
  height: calc(100% - 20px);
  pointer-events: none;
  z-index: 6;
}

.mm-laser-hit {
  stroke: #ff2e54;
  stroke-width: 11;
  stroke-linecap: round;
  filter: drop-shadow(0 0 10px #ff2e54) drop-shadow(0 0 22px #ff8598);
  animation: mm-laser-zap 0.35s ease-in-out infinite alternate;
}

.mm-laser-core {
  stroke: #fff5f7;
  stroke-width: 4;
  stroke-linecap: round;
}

@keyframes mm-laser-zap {
  0% { opacity: 0.72; stroke-width: 9; }
  100% { opacity: 1; stroke-width: 13; }
}

.mm-wall-revealed {
  stroke: rgba(255, 68, 102, 0.82);
  stroke-width: 5.5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgba(255, 46, 84, 0.7));
}

/* Right Control Column */
.mm-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mm-panel {
  padding: 15px;
  border-radius: var(--tg-radius-md);
  background: var(--tg-glass);
  border: 1px solid var(--tg-border);
  box-shadow: var(--tg-shadow-card);
}

.mm-section-label {
  font-family: var(--tg-font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tg-gold);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mm-player-stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(10, 12, 22, 0.76);
  border: 1px solid var(--tg-border-subtle);
  margin-bottom: 8px;
}

.mm-player-stat:last-child {
  margin-bottom: 0;
}

.mm-player-stat.is-active-cyan {
  border-color: rgba(34, 211, 238, 0.65);
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.14);
}
.mm-player-stat.is-active-garnet {
  border-color: rgba(255, 46, 84, 0.68);
  box-shadow: 0 0 18px rgba(255, 46, 84, 0.16);
}

.mm-stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 13.5px;
}

.mm-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--tg-ink-muted);
  font-family: var(--tg-font-mono);
}

/* Tactile Directional Pad */
.mm-dpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 210px;
  margin: 0 auto 12px;
}

.mm-dpad-btn {
  height: 50px;
  border-radius: 10px;
  background: linear-gradient(180deg, #212840 0%, #111524 100%);
  border: 1px solid var(--tg-border);
  color: var(--tg-ink);
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 #070910;
  transition: transform 0.12s var(--tg-ease), border-color 0.14s, box-shadow 0.14s;
}

.mm-dpad-btn:hover:not(:disabled) {
  border-color: var(--tg-gold-bright);
  color: var(--tg-gold-bright);
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #070910, 0 0 16px var(--tg-gold-glow);
}

.mm-dpad-btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 2px 0 #070910;
}

.mm-dpad-center {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--tg-font-mono);
  font-size: 11px;
  color: var(--tg-ink-faint);
}

.mm-action-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mm-kbd-hint {
  text-align: center;
  font-size: 11px;
  color: var(--tg-ink-faint);
  font-family: var(--tg-font-mono);
  margin-top: 6px;
}

.mm-siren-banner {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(217, 27, 58, 0.34), rgba(90, 8, 22, 0.65));
  border: 1px solid rgba(255, 46, 84, 0.72);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #ffe2e8;
}

@media (max-width: 860px) {
  .mm-arena {
    grid-template-columns: 1fr;
  }
  .mm-board-wrap {
    width: min(100%, 440px);
  }
  .mm-token {
    width: 26px;
    height: 26px;
    font-size: 12px;
  }
}
