/* 미로 탈출 — 60초 동안 탈출 횟수 */

.board-wrap {
  position: relative;
  width: min(92vw, 420px);
  margin: 0 auto;
}

.mz-board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, #ffe6a0, #fcce5a);
  border-radius: 18px;
  padding: 10px;
  box-sizing: border-box;
  box-shadow: 0 10px 30px rgba(252, 206, 90, 0.25);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  outline: none;
}

.mz-board.cleared { animation: clearPop 0.4s ease; }
@keyframes clearPop {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.02); filter: brightness(1.08); }
}

.mz-cells {
  position: relative;
  margin: 0 auto;
  background: rgba(255,255,255,0.5);
  border-radius: 6px;
}

.mz-cell {
  position: absolute;
  box-sizing: border-box;
  background: transparent;
}

/* 벽: 외곽 보더 — 인접 셀과 합산되어 두 배 두께가 되지 않게 정밀 배치 */
.mz-cell.w-top    { border-top:    2px solid #6b3a0a; }
.mz-cell.w-right  { border-right:  2px solid #6b3a0a; }
.mz-cell.w-bottom { border-bottom: 2px solid #6b3a0a; }
.mz-cell.w-left   { border-left:   2px solid #6b3a0a; }

.mz-cell.mz-goal::after {
  content: "🏁";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  animation: goalPulse 1.2s ease-in-out infinite;
}
@keyframes goalPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.18); }
}

/* 플레이어 */
.mz-player {
  position: absolute;
  top: 10px; left: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ff8b6e, #d6422a);
  box-shadow: 0 4px 10px rgba(214, 66, 42, 0.35);
  transition: transform 0.14s ease-out;
  z-index: 2;
  pointer-events: none;
}

.mz-player.bump-top    { animation: bumpY -0.22s ease; animation-name: bumpUp; animation-duration: 0.22s; }
.mz-player.bump-bottom { animation: bumpDown   0.22s ease; }
.mz-player.bump-left   { animation: bumpLeft   0.22s ease; }
.mz-player.bump-right  { animation: bumpRight  0.22s ease; }
@keyframes bumpUp     { 0%,100%{margin-top:0}50%{margin-top:-3px} }
@keyframes bumpDown   { 0%,100%{margin-top:0}50%{margin-top:3px} }
@keyframes bumpLeft   { 0%,100%{margin-left:0}50%{margin-left:-3px} }
@keyframes bumpRight  { 0%,100%{margin-left:0}50%{margin-left:3px} }

/* D-pad (모바일/마우스용 보조 — 스와이프/키보드도 가능) */
.mz-pad {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  gap: 6px;
  width: 168px;
  margin-left: auto;
  margin-right: auto;
}
.mz-pad-btn {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 10px;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  height: 48px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.08s, background 0.15s;
}
.mz-pad-btn:active { transform: scale(0.94); }
.mz-pad-btn:hover  { background: var(--bg-soft); }
.mz-pad-btn[data-dir="top"]    { grid-column: 2; grid-row: 1; }
.mz-pad-btn[data-dir="left"]   { grid-column: 1; grid-row: 2; }
.mz-pad-btn[data-dir="right"]  { grid-column: 3; grid-row: 2; }
.mz-pad-btn[data-dir="bottom"] { grid-column: 2; grid-row: 3; }

/* ===== 시작 오버레이 ===== */

.mz-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 41, 0.78);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  z-index: 5;
  transition: opacity 0.2s;
}
.mz-overlay.hidden { opacity: 0; pointer-events: none; }

.overlay-content { text-align: center; padding: 24px; }
.overlay-icon { font-size: 3.5rem; margin-bottom: 12px; }
.overlay-content h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 6px; color: var(--text); }
.overlay-content p { color: var(--text-dim); margin-bottom: 18px; line-height: 1.5; }

.hint {
  text-align: center;
  margin-top: 18px;
  color: var(--text-dim);
  font-size: 0.88rem;
  padding: 0 16px;
}

/* ===== 결과 모달 ===== */

.result-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 41, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  animation: fadeIn 0.25s ease;
}
.result-modal.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.result-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px 28px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-emoji { font-size: 4rem; margin-bottom: 8px; }
.result-card h2 { font-size: 1.5rem; margin-bottom: 8px; }
.result-msg { color: var(--text-dim); margin-bottom: 24px; }

.result-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.result-stats > div {
  background: rgba(255,255,255,0.05);
  padding: 14px;
  border-radius: 12px;
}
.result-stats span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.result-stats strong {
  font-size: 1.6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.result-rank {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 8px 0 4px;
  color: var(--accent);
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}
.result-actions .btn {
  padding: 12px 16px;
  text-align: center;
  font-size: 0.95rem;
}
