/*
 * Bear's Sokoban: Push the Crates (games/box-pusher/style.css)
 * Cozy wooden warehouse grid, crates, star spots, helper bear, and tactile D-Pad.
 */

:root {
  --game-bg: linear-gradient(180deg, #fef3c7 0%, #fde68a 52%, #fed7aa 100%);
  --game-ink: #292524;
  --game-accent: #b45309;
  --game-banner-bg: rgba(255, 255, 255, 0.88);
}

.sokoban-workspace {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 10px;
  overflow: hidden;
  outline: none;
}

/* --- Status Bar --------------------------------------------------------- */

.sokoban-status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  width: 100%;
  max-width: 720px;
  z-index: 2;
}

.soko-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid rgba(217, 119, 6, 0.45);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.96rem;
  font-weight: 700;
  color: #451a03;
  box-shadow: 0 3px 10px rgba(180, 83, 9, 0.1);
  font-variant-numeric: tabular-nums;
}

.pill-accent {
  color: #b45309;
  font-weight: 900;
}

.pill-sep {
  color: #78716c;
}

.level-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.level-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  border: 2px solid #a8a29e;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.level-dot.done {
  background: #22c55e;
  border-color: #15803d;
}

.level-dot.current {
  background: #f59e0b;
  border-color: #b45309;
  transform: scale(1.25);
}

/* --- Warehouse Board Stage ---------------------------------------------- */

.board-stage {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  z-index: 2;
}

.sokoban-board {
  --cols: 7;
  --rows: 6;
  --cell-size: clamp(42px, min(11.5vw, 9.2vh), 64px);
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell-size));
  grid-template-rows: repeat(var(--rows), var(--cell-size));
  gap: 4px;
  padding: 10px;
  background: #78350f;
  border: 4px solid #451a03;
  border-radius: 22px;
  box-shadow:
    0 14px 30px rgba(69, 26, 3, 0.26),
    inset 0 2px 6px rgba(254, 243, 199, 0.35);
  touch-action: none;
}

.soko-cell {
  position: relative;
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: 11px;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell-size) * 0.58);
  line-height: 1;
  cursor: pointer;
  transition: transform 0.14s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.soko-cell:focus-visible {
  outline: 3px solid #38bdf8;
  outline-offset: 2px;
  z-index: 5;
}

/* Wall Tile */
.cell-wall {
  background: linear-gradient(180deg, #a8a29e 0%, #78716c 60%, #57534e 100%);
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.45), 0 2px 4px rgba(0, 0, 0, 0.25);
  cursor: default;
}

/* Floor Tile */
.cell-floor {
  background: linear-gradient(180deg, #fef3c7 0%, #fde68a 100%);
  box-shadow: inset 0 1px 3px rgba(180, 83, 9, 0.15);
}

.cell-floor.is-adjacent-step {
  box-shadow: inset 0 0 0 2px rgba(217, 119, 6, 0.38);
}

/* Star Goal Tile */
.cell-goal {
  background: radial-gradient(circle, #fef08a 15%, #fde047 65%, #facc15 100%);
  box-shadow: inset 0 0 0 2px #eab308, 0 0 10px rgba(250, 204, 21, 0.45);
}

/* Crate on Floor */
.cell-crate {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 65%, #b45309 100%);
  box-shadow:
    inset 0 2px 4px rgba(254, 243, 199, 0.65),
    0 4px 8px rgba(69, 26, 3, 0.28);
}

/* Crate on Star Goal (Success!) */
.cell-crate-goal {
  background: linear-gradient(180deg, #4ade80 0%, #16a34a 70%, #15803d 100%);
  box-shadow:
    inset 0 2px 5px rgba(255, 255, 255, 0.7),
    0 0 0 3px #fde047,
    0 4px 12px rgba(22, 163, 74, 0.45);
}

.crate-star-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  font-size: calc(var(--cell-size) * 0.32);
  pointer-events: none;
}

/* Crate in a Deadlock Corner */
.cell-crate.is-corner-stuck {
  box-shadow: 0 0 0 3px #f97316, inset 0 0 8px rgba(239, 68, 68, 0.45);
}

/* Bear Helper Tile */
.cell-player {
  background: linear-gradient(180deg, #bae6fd 0%, #7dd3fc 100%);
  box-shadow: inset 0 0 0 2px #0284c7;
}

.cell-player.on-goal {
  background: linear-gradient(180deg, #fef08a 0%, #7dd3fc 100%);
  box-shadow: inset 0 0 0 3px #eab308;
}

/* Hint Highlight on Cell */
.soko-cell.is-hint-cell {
  box-shadow: 0 0 0 4px #38bdf8, 0 0 14px rgba(56, 189, 248, 0.75);
  z-index: 4;
}

/* --- Sparkle FX Layer --------------------------------------------------- */

.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 10;
}

.fx-particle {
  position: absolute;
  font-size: 1.55rem;
  pointer-events: none;
  animation: fx-rise 0.95s ease-out forwards;
}

.fx-pos-1 { left: 24%; top: 55%; }
.fx-pos-2 { left: 36%; top: 47%; }
.fx-pos-3 { left: 50%; top: 40%; }
.fx-pos-4 { left: 64%; top: 47%; }
.fx-pos-5 { left: 76%; top: 55%; }
.fx-pos-6 { left: 46%; top: 59%; }

@keyframes fx-rise {
  0% {
    opacity: 1;
    transform: translateY(0) scale(0.7);
  }
  100% {
    opacity: 0;
    transform: translateY(-64px) scale(1.25);
  }
}

/* --- Bottom Controls: Tactile D-Pad + Action Buttons -------------------- */

.sokoban-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 20px;
  width: 100%;
  max-width: 760px;
  z-index: 3;
}

.dpad-cluster {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.75);
  padding: 6px 10px;
  border-radius: 22px;
  border: 2px solid rgba(217, 119, 6, 0.35);
}

.dpad-vertical {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dpad-btn {
  width: 48px;
  height: 44px;
  border-radius: 14px;
  border: 2px solid #ffffff;
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  color: #ffffff;
  font-size: 1.25rem;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(180, 83, 9, 0.22);
  transition: transform 0.1s ease, box-shadow 0.15s ease;
  touch-action: manipulation;
}

.dpad-btn:active {
  transform: scale(0.92);
}

.dpad-btn:focus-visible {
  outline: 3px solid #0284c7;
  outline-offset: 2px;
}

.dpad-btn.is-hint-dir {
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.75), 0 6px 14px rgba(2, 132, 199, 0.35);
  animation: pulse-cta 0.7s ease-in-out infinite alternate;
}

.soko-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.soko-action-btn {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 3px solid #ffffff;
  font-size: 0.94rem;
  font-weight: 800;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
  transition: transform 0.12s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  touch-action: manipulation;
}

.soko-action-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.soko-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.soko-action-btn:focus-visible {
  outline: 4px solid #0284c7;
  outline-offset: 3px;
}

.undo-btn {
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
}

.undo-btn.is-hint-undo {
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.85), 0 6px 16px rgba(2, 132, 199, 0.38);
  animation: pulse-cta 0.75s ease-in-out infinite alternate;
}

.hint-btn {
  background: linear-gradient(180deg, #a855f7 0%, #7e22ce 100%);
}

.reset-btn {
  background: linear-gradient(180deg, #94a3b8 0%, #475569 100%);
}

.next-btn {
  background: linear-gradient(180deg, #4ade80 0%, #16a34a 100%);
  animation: pulse-cta 1.1s ease-in-out infinite alternate;
}

@keyframes pulse-cta {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

/* --- Finale Celebration Overlay ----------------------------------------- */

.celebration-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.celebration-card {
  background: #ffffff;
  border: 4px solid #f59e0b;
  border-radius: 28px;
  padding: 28px 24px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.28);
}

.celebration-emojis {
  font-size: 2.8rem;
  margin-bottom: 12px;
}

.celebration-text {
  margin: 0 0 20px;
  font-size: 1.22rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.4;
}

/* --- Responsive Adjustments --------------------------------------------- */

@media (max-height: 580px) {
  .sokoban-board {
    --cell-size: clamp(34px, 7.8vh, 48px);
    padding: 6px;
    gap: 3px;
  }

  .dpad-btn {
    width: 40px;
    height: 34px;
    font-size: 1.05rem;
  }

  .soko-action-btn {
    min-height: 36px;
    padding: 5px 12px;
    font-size: 0.84rem;
  }
}

/* --- Reduced Motion Support (TZ 5.4) ------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .soko-cell,
  .dpad-btn,
  .soko-action-btn,
  .level-dot {
    transition: none !important;
    animation: none !important;
  }
}
