:root {
  --bg: #090d18;
  --panel: #0f1730;
  --ink: #e9f0ff;
  --accent: #ff5a3d;
  --wall: #2f6dff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 20%, #15264a 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: "Trebuchet MS", "Verdana", sans-serif;
}

.game-wrap {
  width: min(95vw, 540px);
  padding: 18px;
  background: color-mix(in srgb, var(--panel) 85%, black 15%);
  border: 2px solid color-mix(in srgb, var(--wall) 60%, white 10%);
  border-radius: 14px;
  box-shadow: 0 14px 45px rgba(0, 0, 0, 0.4);
  text-align: center;
}

h1 {
  margin: 0 0 8px;
  letter-spacing: 1px;
}

.hint {
  margin: 0 0 10px;
  opacity: 0.9;
  font-size: 0.92rem;
}

canvas {
  width: 100%;
  height: auto;
  background: #000;
  border: 2px solid #1f2f58;
  border-radius: 8px;
  image-rendering: auto;
}

.hud {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  font-size: 0.95rem;
}

.status {
  margin: 10px 0 8px;
  color: var(--accent);
  min-height: 1.4rem;
}

.touch-controls {
  display: none;
  margin-top: 8px;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  gap: 8px;
  grid-template-areas:
    ". up ."
    "left . right"
    ". down .";
}

.ctrl-btn {
  border: 1px solid #4e679f;
  background: #13203d;
  color: #dce8ff;
  border-radius: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  touch-action: manipulation;
  user-select: none;
}

.ctrl-btn:active {
  transform: translateY(1px);
  background: #1a2e57;
}

.ctrl-btn.up { grid-area: up; }
.ctrl-btn.left { grid-area: left; }
.ctrl-btn.right { grid-area: right; }
.ctrl-btn.down { grid-area: down; }

.ctrl-btn.restart {
  height: 44px;
  padding: 0 14px;
  font-size: 0.9rem;
}

@media (max-width: 900px), (hover: none) and (pointer: coarse) {
  .game-wrap {
    width: min(100vw, 560px);
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    padding-bottom: 14px;
  }

  .touch-controls {
    display: flex;
  }
}
