:root {
  --sokoban-tile-size: 44px;
  --sokoban-gap: 6px;
}

.sokoban-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

.sokoban-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  margin-top: 1.5rem;
}

@media (min-width: 900px) {
  .sokoban-layout {
    grid-template-columns: auto 320px;
    align-items: start;
  }
}

.sokoban-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sokoban-game {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  outline: none;
}

.sokoban-game:focus-visible {
  box-shadow:
    0 0 0 3px rgba(59, 130, 246, 0.45),
    0 0 0 6px rgba(15, 23, 42, 0.6);
  border-radius: 16px;
}

.sokoban-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sokoban-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: baseline;
}

.sokoban-stat {
  color: var(--color-text-light);
  font-weight: 600;
}

.sokoban-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.sokoban-buttons button {
  border: 1px solid var(--color-border);
  background: #ffffff;
  color: var(--color-text);
  padding: 0.55rem 0.9rem;
  border-radius: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease, border-color 0.15s ease;
}

.sokoban-buttons button:hover {
  background: #f8fafc;
  border-color: rgba(148, 163, 184, 0.85);
}

.sokoban-buttons button:active {
  transform: translateY(1px);
}

.sokoban-buttons button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.sokoban-grid {
  display: grid;
  gap: var(--sokoban-gap);
  justify-content: start;
  align-content: start;
  padding: 1rem;
  background: #0f172a;
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  touch-action: none;
}

.sokoban-dpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 0.5rem;
  max-width: 260px;
  margin: 0.5rem 0 0;
}

.dpad-btn {
  border: 1px solid var(--color-border);
  background: #ffffff;
  color: var(--color-text);
  border-radius: 14px;
  font-weight: 800;
  height: 54px;
  min-width: 54px;
  cursor: pointer;
  touch-action: manipulation;
}

.dpad-up {
  grid-column: 2;
  grid-row: 1;
}

.dpad-left {
  grid-column: 1;
  grid-row: 2;
}

.dpad-right {
  grid-column: 3;
  grid-row: 2;
}

.dpad-down {
  grid-column: 2;
  grid-row: 3;
}

@media (min-width: 900px) {
  .sokoban-dpad {
    display: none;
  }
}

.tile {
  width: var(--sokoban-tile-size);
  height: var(--sokoban-tile-size);
  border-radius: 10px;
  position: relative;
  background: #f3f4f6;
}

.tile.wall {
  background: #334155;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.tile.floor {
  background: #f3f4f6;
}

.tile.target {
  background: #eef2ff;
}

.tile.target::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 2px dashed rgba(79, 70, 229, 0.85);
  border-radius: 8px;
}

.tile.box::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 8px;
  background: linear-gradient(180deg, #d97706, #92400e);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.tile.player::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

.win-banner {
  padding: 0.9rem 1rem;
  border-radius: 12px;
  font-weight: 700;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #14532d;
}

.sokoban-help {
  background: var(--color-bg-light);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 1.25rem 1.25rem;
}

.sokoban-help h2 {
  margin-top: 0;
  font-size: 1.15rem;
}

.sokoban-help ul {
  margin-left: 1.2rem;
  color: var(--color-text-light);
  line-height: 1.6;
}

.legend {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--color-text-light);
}

.legend-swatch.tile {
  width: 32px;
  height: 32px;
  border-radius: 9px;
}
