/* Maze game-specific styles */

.maze-shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 22px 18px 96px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.maze-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.maze-back {
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
}

.maze-back:hover { color: var(--accent-deep); }

.maze-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 900;
}

.maze-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--ink-soft);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.stat-value {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.maze-canvas-wrap {
  position: relative;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
}

#mazeCanvas {
  display: block;
  width: 100%;
  height: auto;
  max-width: 600px;
  border-radius: var(--radius-sm);
  background: #fff8ec;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: pixelated;
  touch-action: none;
}

.maze-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  padding: 10px 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 0.9rem;
  background: var(--accent);
  color: #fff;
  transition: transform 0.12s ease, box-shadow 0.18s ease;
  box-shadow: 0 6px 16px rgba(217, 122, 60, 0.32);
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn.ghost {
  background: var(--bg-soft);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: none;
}

.dpad {
  display: none;
  grid-template-columns: repeat(3, 64px);
  grid-template-rows: repeat(3, 64px);
  gap: 6px;
  justify-content: center;
  margin-top: 4px;
}

.dpad-btn {
  border: none;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 1.5rem;
  font-weight: 900;
  border-radius: 14px;
  display: grid;
  place-items: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  box-shadow: 0 4px 10px rgba(217, 122, 60, 0.18);
}

.dpad-btn:active { background: var(--accent); color: #fff; }
.dpad-btn[data-dir="up"]    { grid-column: 2; grid-row: 1; }
.dpad-btn[data-dir="left"]  { grid-column: 1; grid-row: 2; }
.dpad-btn[data-dir="right"] { grid-column: 3; grid-row: 2; }
.dpad-btn[data-dir="down"]  { grid-column: 2; grid-row: 3; }

@media (pointer: coarse) {
  .dpad { display: grid; }
}

/* Modal — used for both stage clear and run complete */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(58, 36, 24, 0.55);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 10;
  padding: 20px;
  animation: fade-in 0.25s ease;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(420px, 100%);
  background: linear-gradient(160deg, #fff5e1, #ffe0bd);
  border-radius: 24px;
  padding: 28px 26px 22px;
  box-shadow: 0 28px 60px rgba(58, 36, 24, 0.32);
  text-align: center;
  border: 1px solid rgba(217, 122, 60, 0.24);
}

.modal h3 {
  margin: 0 0 6px;
  font-size: 1.4rem;
  font-weight: 900;
}

.modal p { margin: 6px 0; color: var(--ink-soft); }

.modal .score-row {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin: 14px 0 18px;
}

.score-row .stat-value { font-size: 1.4rem; }

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hidden { display: none !important; }

@media (max-width: 480px) {
  .maze-shell { padding: 16px 12px 72px; }
  .maze-stats { grid-template-columns: repeat(2, 1fr); }
}
