:root {
  --ink-900: #0f1d30;
  --ink-700: #1d3557;
  --ink-500: #457b9d;
  --sand-100: #f5efe1;
  --sand-200: #e8d9bc;
  --orange-500: #f4a261;
  --orange-700: #c47d33;
  --mint-500: #00b894;
  --red-500: #e63946;
  --panel: rgba(250, 244, 231, 0.88);
  --line: rgba(29, 53, 87, 0.22);
  --shadow: 0 18px 40px rgba(13, 27, 42, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Chakra Petch", sans-serif;
  color: var(--ink-900);
  background:
    radial-gradient(circle at 16% 12%, rgba(0, 184, 148, 0.34), transparent 28%),
    radial-gradient(circle at 82% 10%, rgba(244, 162, 97, 0.45), transparent 34%),
    linear-gradient(145deg, #d7ecec, #f7ebd1 52%, #ffd5ab);
  overflow-x: hidden;
}

.page-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to right, rgba(29, 53, 87, 0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(29, 53, 87, 0.06) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), transparent 84%);
}

.game-shell {
  width: min(1200px, 94vw);
  margin: 20px auto 36px;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 2.1fr) minmax(280px, 1fr);
  position: relative;
  z-index: 1;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(5px);
  animation: rise-in 0.5s ease both;
}

.top-panel,
.stats-panel {
  grid-column: 1 / -1;
}

.top-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
}

.kicker {
  margin: 0;
  color: var(--ink-500);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 0.78rem;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Bungee", cursive;
  letter-spacing: 0.02em;
}

h1 {
  margin-top: 4px;
  font-size: clamp(1.45rem, 2.7vw, 2.1rem);
  line-height: 1.1;
}

.subtitle {
  margin: 8px 0 0;
  max-width: 58ch;
  color: #254262;
  font-weight: 500;
}

.action-btn {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(95deg, var(--orange-700), var(--orange-500));
  color: #fff9f0;
  font-family: "Bungee", cursive;
  padding: 11px 18px;
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease;
}

.action-btn:hover {
  transform: translateY(-1px);
  filter: saturate(1.12);
}

.stats-panel {
  padding: 10px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.stat {
  border: 1px solid rgba(29, 53, 87, 0.12);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.55);
}

.stat span {
  display: block;
  font-size: 0.74rem;
  color: #35577d;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 1.08rem;
}

.arena-panel {
  position: relative;
  overflow: hidden;
  padding: 12px;
}

#gameCanvas {
  display: block;
  width: 100%;
  max-height: 72vh;
  margin: 0 auto;
  border-radius: 12px;
  border: 1px solid rgba(29, 53, 87, 0.22);
  background: #f3ebdc;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.overlay {
  position: absolute;
  inset: 12px;
  border-radius: 12px;
  background: rgba(18, 39, 60, 0.72);
  color: #fff8ea;
  display: none;
  place-items: center;
  text-align: center;
  padding: 20px;
}

.overlay h2 {
  font-size: clamp(1.25rem, 2.9vw, 1.9rem);
}

.overlay p {
  margin-top: 8px;
  font-size: 1.02rem;
  max-width: 40ch;
}

.overlay.show {
  display: grid;
}

.side-panel {
  padding: 16px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.side-copy {
  margin: 8px 0 0;
  color: #2f4e71;
  line-height: 1.35;
}

#mapImage {
  display: block;
  width: 100%;
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid rgba(29, 53, 87, 0.22);
  background: #ffffff;
  image-rendering: pixelated;
}

.legend p {
  margin: 8px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #234061;
}

.swatch {
  width: 17px;
  height: 17px;
  border-radius: 5px;
  border: 1px solid rgba(18, 39, 60, 0.22);
}

.swatch.floor {
  background: #f5efe1;
}

.swatch.wall {
  background: #1f2937;
}

.swatch.crate {
  background: #c47d33;
}

.swatch.player {
  background: #00b894;
}

.swatch.player-two {
  background: #3b82f6;
}

.swatch.enemy {
  background: #e63946;
}

.touch-controls {
  display: none;
  border-top: 1px solid rgba(29, 53, 87, 0.18);
  padding-top: 14px;
}

.touch-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.touch-btn,
.bomb-btn {
  border: 0;
  border-radius: 10px;
  padding: 11px;
  font-family: "Chakra Petch", sans-serif;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  color: #123;
}

.touch-btn {
  background: #dceaf4;
}

.bomb-btn {
  margin-top: 10px;
  width: 100%;
  background: linear-gradient(120deg, var(--red-500), #ff8b96);
  color: #fff;
}

@keyframes rise-in {
  from {
    transform: translateY(10px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 1020px) {
  .game-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-row: 4;
  }
}

@media (max-width: 860px) {
  .top-panel {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .touch-controls {
    display: block;
  }

  #gameCanvas {
    max-height: none;
  }
}
