:root {
  --bg-0: #071018;
  --bg-1: #11232f;
  --line: #1f3b4d;
  --ink: #dff4ff;
  --muted: #8fb3c8;
  --accent: #ff6f3c;
  --accent-2: #33c3a9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 111, 60, 0.18), transparent 30%),
    radial-gradient(circle at 82% 84%, rgba(51, 195, 169, 0.2), transparent 36%),
    linear-gradient(145deg, var(--bg-0), var(--bg-1));
  color: var(--ink);
  font-family: "Lucida Console", "Courier New", monospace;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  justify-items: center;
  align-items: center;
  padding: 20px;
}

.game-shell {
  width: min(100%, 560px);
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(6, 14, 20, 0.78);
  backdrop-filter: blur(4px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  padding: 14px;
}

.game-header h1 {
  font-size: 1rem;
  margin: 0;
  letter-spacing: 1px;
}

.game-header p {
  margin: 6px 0 14px;
  color: var(--muted);
  font-size: 0.75rem;
}

.game-stage {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

#game {
  width: 100%;
  aspect-ratio: 3 / 4;
  display: block;
  border: 1px solid #28485c;
  border-radius: 8px;
  background: #060e14;
}

.action-button {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: 140px;
  padding: 12px 20px;
  border: 1px solid #35596f;
  border-radius: 10px;
  color: var(--ink);
  background: rgba(7, 22, 30, 0.95);
  font: inherit;
  letter-spacing: 1px;
  z-index: 3;
}

.action-button[hidden] {
  display: none;
}

.mobile-controls {
  display: none;
  width: 100%;
}

.mobile-move-controls {
  flex: 1;
  display: flex;
  gap: 10px;
}

.control-button {
  flex: 1;
  border: 1px solid #35596f;
  border-bottom-width: 2px;
  border-radius: 10px;
  padding: 12px 10px;
  color: var(--ink);
  background: rgba(9, 25, 34, 0.94);
  font: inherit;
  letter-spacing: 0.7px;
}

.control-button-shoot {
  flex: 0 0 32%;
  min-width: 32%;
}

.control-button.is-active,
.control-button:active {
  transform: translateY(1px);
  background: rgba(18, 45, 58, 0.98);
  border-color: #4d7f98;
}

.action-button:active {
  transform: translate(-50%, calc(-50% + 1px));
  background: rgba(18, 45, 58, 0.98);
  border-color: #4d7f98;
}

.help-panel {
  width: min(100%, 560px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(8, 19, 26, 0.78);
  padding: 14px;
}

.help-panel h2 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.help-panel ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.help-panel p {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.8rem;
}

kbd {
  border: 1px solid #35596f;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--accent-2);
  background: rgba(51, 195, 169, 0.07);
}

@media (min-width: 960px) {
  .layout {
    grid-template-columns: minmax(520px, 560px) minmax(240px, 320px);
    align-items: start;
  }

  .help-panel {
    margin-top: 52px;
  }
}

@media (max-width: 959px) and (hover: none) and (pointer: coarse) {
  .layout {
    align-items: start;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
    gap: 12px;
  }

  .game-shell {
    width: 100%;
    padding: 10px;
  }

  .game-header p {
    margin-bottom: 10px;
  }

  #game,
  .control-button,
  .action-button {
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
  }

  .action-button {
    display: block;
    top: 65%;
  }

  .mobile-controls {
    margin-top: 12px;
    display: flex;
    gap: 10px;
    align-items: stretch;
  }

  .help-panel {
    margin-bottom: max(8px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 959px) and (hover: none) and (pointer: coarse) and (orientation: landscape) {
  .mobile-controls {
    display: none;
  }

  .action-button {
    display: none;
  }

  .game-shell::after {
    content: "Rotate to portrait for touch play.";
    display: block;
    color: var(--muted);
    font-size: 0.75rem;
    margin-top: 10px;
    text-align: center;
  }
}
