:root {
  --bg: #081019;
  --panel: #111c2b;
  --ink: #d9f7ff;
  --teal: #54f2d2;
  --amber: #ffc657;
  --magenta: #ff4ab8;
  --wall: #2a3142;
  --floor: #172130;
  --target: #2f2c61;
  --crate: #d88f32;
  --crate-edge: #6f3a0e;
  --player: #8dfbff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 15%, #12364f 0, transparent 28%),
    radial-gradient(circle at 80% 5%, #2b124c 0, transparent 34%),
    linear-gradient(180deg, #070c14, #06080f 60%, #04050a);
  display: flex;
  justify-content: center;
  padding: 22px;
}

.app {
  width: min(900px, 100%);
}

.back-link {
  display: inline-block;
  margin-bottom: 12px;
  color: #9ad4ff;
  text-decoration: none;
}

.back-link:hover { color: #d9f7ff; }

.hero {
  background: linear-gradient(180deg, rgba(22, 40, 60, 0.9), rgba(9, 16, 29, 0.95));
  border: 1px solid rgba(130, 182, 255, 0.3);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.kicker {
  margin: 0;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal);
  font-size: 0.78rem;
}

.hero h1 {
  margin: 6px 0;
  font-size: clamp(1.6rem, 4vw, 2.3rem);
}

.hero p {
  margin: 0;
  color: #b8cbe4;
}

.panel {
  margin-top: 16px;
  background: rgba(12, 19, 31, 0.96);
  border-radius: 14px;
  border: 1px solid rgba(140, 181, 255, 0.22);
  padding: 16px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.stat {
  background: linear-gradient(180deg, #18263a, #101927);
  border: 1px solid rgba(101, 136, 177, 0.45);
  border-radius: 10px;
  padding: 8px 10px;
  display: grid;
  gap: 4px;
}

.stat span {
  color: #9db2ce;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat strong {
  color: var(--ink);
  font-size: 1rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

button {
  border: 1px solid rgba(135, 177, 238, 0.5);
  background: linear-gradient(180deg, #253b57, #1a2a40);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
}

button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }

.board {
  --size: min(56px, 12vw);
  --cols: 8;
  --rows: 8;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--size));
  grid-template-rows: repeat(var(--rows), var(--size));
  width: fit-content;
  margin: 0 auto;
  border: 2px solid rgba(124, 174, 255, 0.65);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 0 24px rgba(88, 146, 255, 0.25);
}

.cell {
  position: relative;
  background: var(--floor);
  border: 1px solid rgba(0, 0, 0, 0.28);
}

.cell.wall {
  background:
    repeating-linear-gradient(135deg, #2f3750 0 6px, #263045 6px 12px),
    var(--wall);
}

.cell.target {
  background:
    radial-gradient(circle at 50% 50%, rgba(138, 120, 255, 0.6) 0 25%, transparent 26%),
    var(--target);
}

.cell.player::after,
.cell.crate::after {
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 6px;
}

.cell.player::after {
  background:
    radial-gradient(circle at 30% 30%, #f1ffff 0 16%, transparent 17%),
    linear-gradient(180deg, #6be7f4, #2bbecf);
  border: 2px solid #0f6d78;
  box-shadow: 0 0 12px rgba(100, 252, 255, 0.65);
}

.cell.crate::after {
  background:
    linear-gradient(145deg, #f0be63, #b56a1f);
  border: 3px solid var(--crate-edge);
  box-shadow: inset 0 0 0 2px rgba(255, 236, 176, 0.3);
}

.cell.crate.target::after {
  box-shadow:
    inset 0 0 0 2px rgba(255, 236, 176, 0.3),
    0 0 16px rgba(132, 109, 255, 0.7);
}

.pad {
  margin: 14px auto 0;
  width: fit-content;
  text-align: center;
}

.pad .row { display: flex; gap: 8px; margin-top: 8px; }

.pad button {
  min-width: 56px;
  min-height: 44px;
  font-size: 1.1rem;
}

.hint {
  margin-top: 12px;
  color: #8ea8ca;
  text-align: center;
  font-size: 0.9rem;
}

.win {
  margin-top: 16px;
  background: linear-gradient(180deg, rgba(23, 55, 39, 0.95), rgba(14, 34, 24, 0.95));
  border: 1px solid rgba(92, 244, 181, 0.5);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
}

.win h2 {
  margin: 0 0 6px;
  color: var(--teal);
}

.win p {
  margin: 0 0 10px;
  color: #daf7ef;
}

.hidden { display: none; }

@media (max-width: 640px) {
  body { padding: 12px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
