/* ============================================================
   迷宮模組
   螢幕模式（列印 + 互動共用）
   ============================================================ */

/* ----------------------------------------------------------
   列印版：maze-content / maze-svg
   ---------------------------------------------------------- */

.maze-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  padding: 8px 0;
}

.maze-instruction {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 16px;
  align-self: flex-start;
}

.maze-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.maze-svg {
  width: 100%;
  max-width: 500px;
  height: auto;
}

/* ----------------------------------------------------------
   互動版
   ---------------------------------------------------------- */

/* --- 遊戲主區域 --- */
.maze-play-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 16px;
  position: relative;
}

.maze-grid-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}

.maze-question-text {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--color-text);
  text-align: center;
}

/* --- Grid --- */
.maze-grid-container {
  display: inline-grid;
  background: #fff;
  border: 3px solid var(--color-primary, #7C3AED);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.15);
  touch-action: none; /* 防止瀏覽器攔截滑動 */
}

/* --- 格子 --- */
.maze-cell {
  width: var(--cell-size, 60px);
  height: var(--cell-size, 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-sizing: border-box;
}

.maze-cell.wall-top    { border-top: 3px solid #1F2937; }
.maze-cell.wall-right  { border-right: 3px solid #1F2937; }
.maze-cell.wall-bottom { border-bottom: 3px solid #1F2937; }
.maze-cell.wall-left   { border-left: 3px solid #1F2937; }

.maze-cell.is-start {
  background: #DCFCE7;
}

.maze-cell.is-end {
  background: #FEF3C7;
}

/* --- 角色 & 目標 --- */
.maze-player {
  font-size: 56px;
  transition: all 200ms ease-out;
  z-index: 10;
  line-height: 1;
}

.maze-player.bump {
  animation: mazeBump 200ms ease-out;
}

.maze-goal {
  font-size: 56px;
  line-height: 1;
}

/* --- 提示脈衝 --- */
.maze-cell-hint {
  animation: mazeHintPulse 1.5s ease-in-out infinite;
}

/* --- D-pad（備用，右側欄） --- */
.maze-sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.maze-dpad {
  display: grid;
  grid-template-areas:
    '.     up    .'
    'left  center right'
    '.     down  .';
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  gap: 3px;
  opacity: 0.35;
}

.maze-dir-btn {
  width: 44px;
  height: 44px;
  border: 2px solid #E5E7EB;
  border-radius: 12px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: transform 100ms ease-out, background 100ms;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.maze-dir-btn:active {
  transform: scale(0.9);
  background: var(--color-secondary, #E9D5FF);
}

.maze-dir-btn[data-dir="up"]    { grid-area: up; }
.maze-dir-btn[data-dir="left"]  { grid-area: left; }
.maze-dir-btn[data-dir="right"] { grid-area: right; }
.maze-dir-btn[data-dir="down"]  { grid-area: down; }

.maze-dpad-center {
  grid-area: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--color-gray-100, #F3F4F6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--color-gray-400, #9CA3AF);
}

/* --- 滑動提示文字 --- */
.maze-swipe-hint {
  text-align: center;
  font-size: 13px;
  color: #9CA3AF;
  padding: 8px;
}

/* === 角落裝飾 === */

.maze-deco {
  position: absolute;
  width: 80px;
  height: 80px;
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}

.maze-deco-tl { top: 8px; left: 8px; }
.maze-deco-tr { top: 8px; right: 8px; }
.maze-deco-bl { bottom: 48px; left: 8px; }
.maze-deco-br { bottom: 48px; right: 8px; }

/* === 動畫 === */

@keyframes mazeBump {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
}

@keyframes mazeHintPulse {
  0%, 100% { background: rgba(168, 85, 247, 0.08); }
  50% { background: rgba(168, 85, 247, 0.25); }
}

@media (prefers-reduced-motion: reduce) {
  .maze-player,
  .maze-cell-hint {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ----------------------------------------------------------
   列印模式
   ---------------------------------------------------------- */
@media print {
  .maze-content {
    padding: 2mm 0;
  }

  .maze-instruction {
    font-size: 14pt;
    margin: 0 0 4mm;
  }

  .maze-svg {
    max-width: 140mm;
  }
}
