/* Sokoban — own styles, theme variables only. Tiles are CSS-drawn, crate and player are inline SVG. */

.sk {
  width: 100%;
  max-width: 640px;
}

.sk-frame {
  padding: 10px;
  background: var(--gm-surface, #1b2740);
  border: 1px solid var(--gm-line, rgba(255, 255, 255, 0.09));
  border-radius: var(--gm-radius, 12px);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.5);
}

.sk-board {
  --cols: 8;
  --rows: 6;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  width: min(100%, calc(var(--cols) * 56px));
  aspect-ratio: var(--cols) / var(--rows);
  margin: 0 auto;
  border-radius: 6px;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.sk-board:focus-visible {
  box-shadow: 0 0 0 3px var(--gm-accent-bright, #e0584a);
}

.sk-tile {
  position: relative;
  min-width: 0;
  min-height: 0;
}

.sk-floor {
  background: var(--gm-sq-light, #e9e0cc);
  box-shadow: inset 0 0 0 1px var(--gm-line, rgba(0, 0, 0, 0.08));
}

.sk-wall {
  background: var(--gm-sq-dark, #6b3a44);
  box-shadow: inset 0 0 0 1px var(--gm-board-edge, rgba(0, 0, 0, 0.35)), inset 0 3px 0 rgba(255, 255, 255, 0.14), inset 0 -3px 0 rgba(0, 0, 0, 0.22);
  border-radius: 3px;
}

.sk-target::after {
  content: "";
  position: absolute;
  inset: 30%;
  border-radius: 50%;
  border: 3px solid var(--gm-accent, #c0392b);
  background: var(--gm-accent-soft, rgba(192, 57, 43, 0.3));
  box-sizing: border-box;
}

.sk-obj {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(100% / var(--cols));
  height: calc(100% / var(--rows));
  pointer-events: none;
  transition: transform 0.12s ease-out;
  will-change: transform;
}

.sk-obj svg {
  position: absolute;
  inset: 8%;
  width: 84%;
  height: 84%;
}

.sk-crate .sk-box {
  fill: var(--gm-sq-dark, #6b3a44);
  stroke: var(--gm-board-edge, rgba(0, 0, 0, 0.45));
  stroke-width: 1.5;
}

.sk-crate .sk-plank {
  stroke: var(--gm-text, #f2eee6);
  stroke-width: 1.6;
  opacity: 0.55;
  fill: none;
}

.sk-crate.is-on .sk-box {
  fill: var(--gm-accent, #c0392b);
}

.sk-crate.is-on .sk-plank {
  opacity: 0.85;
  stroke: #fff;
}

.sk-player .sk-body {
  fill: var(--gm-accent-bright, #e0584a);
  stroke: var(--gm-board-edge, rgba(0, 0, 0, 0.45));
  stroke-width: 1.2;
}

.sk-player .sk-face {
  fill: var(--gm-sq-light, #f7f3ea);
}

.sk-player.is-bump svg {
  animation: sk-bump 0.25s ease;
}

@keyframes sk-bump {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.88); }
}

.sk-board.is-done .sk-crate .sk-box {
  fill: var(--gm-accent-bright, #e0584a);
}

#gm-sokoban .gm-status { margin-top: 12px; }

/* on-screen direction pad */
.sk-dpad {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  gap: 6px;
  justify-content: center;
  margin: 14px auto 0;
}

.sk-key {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--gm-line-2, rgba(255, 255, 255, 0.16));
  border-radius: 12px;
  background: var(--gm-surface, #1b2740);
  color: var(--gm-text, #f2eee6);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.sk-key:hover,
.sk-key:active {
  border-color: var(--gm-accent-bright, #e0584a);
  color: var(--gm-accent-bright, #e0584a);
}

.sk-key:focus-visible {
  outline: 3px solid var(--gm-accent-bright, #e0584a);
  outline-offset: 2px;
}

.sk-key svg {
  width: 40%;
  height: 40%;
  fill: currentColor;
}

.sk-key-up { grid-column: 2; grid-row: 1; }
.sk-key-left { grid-column: 1; grid-row: 2; }
.sk-key-right { grid-column: 3; grid-row: 2; }
.sk-key-down { grid-column: 2; grid-row: 3; }

/* level picker */
.sk-levels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px;
}

.sk-levels button {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  min-height: 44px;
  margin: 0;
  padding: 0;
  font: 600 0.9rem/1 var(--gm-body, "DM Sans", system-ui, sans-serif);
  font-variant-numeric: tabular-nums;
  color: var(--gm-muted, rgba(242, 238, 230, 0.66));
  background: var(--gm-bg-2, #131c2b);
  border: 1px solid var(--gm-line, rgba(255, 255, 255, 0.09));
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.sk-levels button:hover {
  border-color: var(--gm-accent-bright, #e0584a);
  color: var(--gm-text, #f2eee6);
}

.sk-levels button:focus-visible {
  outline: 3px solid var(--gm-accent-bright, #e0584a);
  outline-offset: 1px;
}

.sk-levels button.is-solved {
  color: var(--gm-text, #f2eee6);
  background: var(--gm-accent-soft, rgba(192, 57, 43, 0.3));
  border-color: var(--gm-accent-line, rgba(192, 57, 43, 0.42));
}

.sk-levels button.is-solved::after {
  content: "";
  position: absolute;
  right: 5px;
  top: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gm-accent-bright, #e0584a);
}

.sk-levels button[aria-pressed="true"] {
  color: #fff;
  background: var(--gm-accent, #c0392b);
  border-color: var(--gm-accent, #c0392b);
}

.sk-levels button[aria-pressed="true"]::after {
  background: #fff;
}

@media (hover: none) {
  .sk-dpad { display: grid; }
}

@media (max-width: 480px) {
  .sk-frame { padding: 6px; }
  .sk-dpad { grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 52px); }
  .gm-actions .gm-btn { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .sk-obj { transition: none; }
  .sk-player.is-bump svg { animation: none; }
}

.sk-player .sk-mouth {
  fill: none;
  stroke: var(--gm-sq-light, #f7f3ea);
  stroke-width: 1.6;
  stroke-linecap: round;
}
