*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1f2933, #020617);
  color: #f9fafb;
  display: flex;
  justify-content: center;
  align-items: stretch;
  min-height: 100vh;
}

.app {
  max-width: 1080px;
  width: 100%;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(30, 64, 175, 0.7));
  box-shadow: 0 12px 25px rgba(15, 23, 42, 0.7);
}

.header h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: 0.08em;
}

.header-info {
  display: flex;
  gap: 16px;
  font-size: 0.95rem;
}

.timer {
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(30, 64, 175, 0.5);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.7);
}

.main {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(240px, 1fr);
  gap: 16px;
}

.game-panel {
  background: rgba(15, 23, 42, 0.85);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
}

.board {
  display: grid;
  gap: 2px;
  padding: 10px;
  border-radius: 12px;
  background: radial-gradient(circle at top left, #111827, #020617);
  outline: none;
}

.cell {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: transform 0.1s ease-out, box-shadow 0.1s ease-out, background 0.1s;
}

.cell-wall {
  background: linear-gradient(145deg, #111827, #020617);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.7);
}

.cell-floor {
  background: radial-gradient(circle at top, #020617, #020617);
}

.cell-target {
  background: radial-gradient(circle at center, rgba(251, 191, 36, 0.9), rgba(120, 53, 15, 0.8));
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.7);
}

.cell-box {
  background: linear-gradient(145deg, #fbbf24, #b45309);
  box-shadow: 0 3px 0 #92400e;
}

.cell-box-on-target {
  background: linear-gradient(145deg, #4ade80, #15803d);
  box-shadow: 0 3px 0 #166534;
}

.cell-player {
  background: radial-gradient(circle at 30% 20%, #60a5fa, #1d4ed8);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.8);
}

.cell-player-on-target {
  background: radial-gradient(circle at 30% 20%, #a5b4fc, #4f46e5);
  box-shadow: 0 0 10px rgba(129, 140, 248, 0.9);
}

.cell-hint {
  box-shadow: 0 0 0 1px rgba(248, 250, 252, 0.8),
    0 0 16px rgba(248, 250, 252, 0.95);
  animation: cell-hint-pulse 0.9s ease-out infinite;
}

.player-sprite {
  width: 70%;
  height: 78%;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.player-sprite-body {
  width: 55%;
  height: 55%;
  border-radius: 8px;
  background: linear-gradient(180deg, #22c55e, #16a34a);
  box-shadow: 0 3px 0 rgba(21, 128, 61, 0.9);
  position: relative;
}

.player-sprite-head {
  width: 65%;
  height: 65%;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #fde68a, #f59e0b);
  box-shadow: 0 1px 0 rgba(180, 83, 9, 0.8);
  position: absolute;
  left: 50%;
  bottom: 75%;
  transform: translateX(-50%);
}

.player-sprite-head::before,
.player-sprite-head::after {
  content: "";
  position: absolute;
  top: 40%;
  width: 14%;
  height: 14%;
  border-radius: 999px;
  background: #1f2937;
}

.player-sprite-head::before {
  left: 25%;
}

.player-sprite-head::after {
  right: 25%;
}

.player-sprite-body::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 45%;
  width: 46%;
  height: 30%;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.95);
  transform: translateX(-50%);
}

.player-sprite.player-walk {
  animation: player-walk 180ms ease-out;
}

.player-sprite.player-push {
  animation: player-push 220ms ease-out;
}

@keyframes player-walk {
  0% {
    transform: translateY(2px);
  }
  60% {
    transform: translateY(-2px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes player-push {
  0% {
    transform: translateY(1px) scaleX(1);
  }
  40% {
    transform: translateY(-1px) scaleX(1.06);
  }
  100% {
    transform: translateY(0) scaleX(1);
  }
}

@keyframes cell-hint-pulse {
  0% {
    box-shadow: 0 0 0 1px rgba(248, 250, 252, 0.7),
      0 0 10px rgba(248, 250, 252, 0.6);
  }
  60% {
    box-shadow: 0 0 0 3px rgba(248, 250, 252, 1),
      0 0 22px rgba(248, 250, 252, 1);
  }
  100% {
    box-shadow: 0 0 0 1px rgba(248, 250, 252, 0.6),
      0 0 10px rgba(248, 250, 252, 0.4);
  }
}

.sidebar {
  background: rgba(15, 23, 42, 0.9);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.9);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.btn-wide {
  grid-column: 1 / -1;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(30, 64, 175, 0.2);
  color: #e5e7eb;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.8);
}

.btn:hover {
  background: rgba(37, 99, 235, 0.55);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.65);
}

.btn:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.7);
}

.btn-primary {
  background: linear-gradient(135deg, #f59e0b, #e11d48);
  color: #111827;
  font-weight: 600;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #f97316, #f97316);
}

.btn-secondary {
  background: rgba(55, 65, 81, 0.7);
}

.btn-secondary:hover {
  background: rgba(75, 85, 99, 0.95);
}

.level-select {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
}

.level-select select {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(55, 65, 81, 0.8);
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  outline: none;
}

.help {
  font-size: 0.9rem;
}

.help summary {
  cursor: pointer;
  font-weight: 600;
}

.help ul {
  padding-left: 18px;
  margin: 6px 0 0 0;
}

.hint-container {
  margin-top: -4px;
}

.hint-panel {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: radial-gradient(circle at top, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.85));
  border: 1px solid rgba(59, 130, 246, 0.7);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.9);
  font-size: 0.85rem;
  line-height: 1.5;
  display: none;
}

.hint-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  font-weight: 600;
}

.hint-close {
  appearance: none;
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
}

.hint-close:hover {
  color: #e5e7eb;
}

.hint-panel p {
  margin: 4px 0 0 0;
}

.toast {
  position: fixed;
  left: 50%;
  top: 18px;
  transform: translateX(-50%) translateY(-120%);
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #022c22;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: 0 14px 30px rgba(22, 163, 74, 0.75);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
  z-index: 30;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.modal.show {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(3px);
}

.modal-content {
  position: relative;
  background: radial-gradient(circle at top, #020617, #020617);
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.9);
  max-width: 320px;
  width: 90%;
  text-align: center;
  border: 1px solid rgba(248, 113, 113, 0.8);
}

.modal-content h2 {
  margin: 0 0 8px 0;
  font-size: 1.25rem;
  color: #fecaca;
}

.modal-content p {
  margin: 0 0 14px 0;
  font-size: 0.95rem;
  color: #e5e7eb;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

@media (max-width: 800px) {
  .main {
    grid-template-columns: minmax(0, 1fr);
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .header-info {
    font-size: 0.85rem;
  }

  .game-panel {
    order: 1;
  }

  .sidebar {
    order: 2;
  }

  .cell {
    width: 32px;
    height: 32px;
  }
}


