:root {
  --bg: #090712;
  --panel: rgba(12, 12, 24, 0.82);
  --line: rgba(255, 255, 255, 0.12);
  --neon-pink: #ff4da6;
  --neon-cyan: #4de9ff;
  --neon-gold: #ffc94d;
  --text: #f7f7fb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #23113a 0%, #090712 60%, #040308 100%);
  overflow-x: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

.page-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 77, 166, 0.18), transparent 0 28%),
    radial-gradient(circle at 80% 15%, rgba(77, 233, 255, 0.16), transparent 0 24%),
    linear-gradient(180deg, #170d23 0%, #0a0914 55%, #040308 100%);
  z-index: -1;
}

.game-page {
  width: min(1400px, 96vw);
  margin: 0 auto;
  padding: 18px 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 14px;
}

.title-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
}

.title-logo {
  width: min(360px, 60vw);
  max-height: 96px;
  object-fit: contain;
  filter: drop-shadow(0 0 18px rgba(255, 255, 255, 0.22));
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--neon-cyan);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 12px;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 46px);
  letter-spacing: 0.05em;
}

.mini-brand img {
  width: 120px;
  max-width: 30vw;
  filter: drop-shadow(0 0 18px rgba(255, 255, 255, 0.25));
}

.game-shell {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 14px 14px 96px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
}

.hud {
  position: absolute;
  left: 50%;
  bottom: 10px;
  z-index: 4;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 0;
  pointer-events: none;
}

.hud-card {
  min-width: 120px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}

.hud-card span {
  display: block;
  font-size: 12px;
  opacity: 0.8;
}

.hud-card strong {
  font-size: 24px;
}

.canvas-wrap {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 150px);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #0b0913;
  touch-action: none;
}

.touch-controls {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  justify-content: space-between;
  align-items: flex-end;
  gap: clamp(6px, 2vw, 12px);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(8, 8, 18, 0), rgba(8, 8, 18, 0.68));
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.touch-controls.ui-hidden {
  opacity: 0;
  pointer-events: none;
}

.touch-pad {
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.8vw, 10px);
}

.touch-btn {
  width: clamp(42px, 12vw, 58px);
  height: clamp(42px, 12vw, 58px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: clamp(12px, 3vw, 18px);
  padding: 0;
  background: linear-gradient(135deg, rgba(255, 77, 166, 0.95), rgba(77, 233, 255, 0.85));
  color: #140b15;
  font-size: clamp(16px, 4.2vw, 22px);
  font-weight: 900;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
  opacity: 0.9;
}

.touch-btn.pressed {
  transform: scale(0.96);
  opacity: 1;
}

.shoot-btn {
  width: clamp(58px, 17vw, 78px);
  font-size: clamp(11px, 2.8vw, 14px);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  background: linear-gradient(rgba(6, 6, 14, 0.54), rgba(6, 6, 14, 0.8));
  padding: clamp(10px, 2vw, 18px);
  overflow-y: auto;
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(520px, 94%);
  max-height: min(86vh, 560px);
  overflow-y: auto;
  padding: 24px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 8, 18, 0.86);
  box-shadow: 0 0 30px rgba(255, 77, 166, 0.18);
  text-align: center;
}

.panel h2 {
  margin: 6px 0 10px;
  font-size: clamp(24px, 3vw, 34px);
}

.alert-panel {
  max-width: 560px;
  box-shadow: 0 0 34px rgba(255, 60, 60, 0.28);
}

.graffiti-warning {
  margin: 0 0 12px;
  color: #ff5050;
  font-size: clamp(34px, 5vw, 56px);
  letter-spacing: 0.06em;
  text-shadow:
    0 2px 0 #1a0303,
    0 0 12px rgba(255, 80, 80, 0.45),
    3px 3px 0 rgba(0, 0, 0, 0.45);
  transform: rotate(-2deg);
}

.panel p {
  line-height: 1.5;
  opacity: 0.95;
}

.rules-box {
  margin: 16px auto 20px;
  max-width: 390px;
  text-align: left;
}

.rule-callout {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.controls-guide {
  display: grid;
  gap: 10px;
}

.control-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.key-chip {
  min-width: 104px;
  padding: 8px 10px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255, 77, 166, 0.24), rgba(77, 233, 255, 0.2));
  border: 1px solid rgba(255, 255, 255, 0.12);
  text-align: center;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.hero-logo {
  width: min(220px, 60vw);
  margin-bottom: 8px;
}

.end-art {
  width: min(220px, 58vw);
  margin-bottom: 6px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: clamp(10px, 2.2vw, 14px) clamp(16px, 4vw, 24px);
  background: linear-gradient(135deg, var(--neon-pink), var(--neon-gold));
  color: #170d0d;
  font-weight: 800;
  font-size: clamp(12px, 3vw, 16px);
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(255, 77, 166, 0.35);
}

button:hover {
  transform: translateY(-1px);
}

@media (max-width: 1024px), (hover: none), (pointer: coarse) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel {
    padding: 18px;
  }

  .hud-card {
    min-width: 88px;
    padding: 8px 10px;
    background: rgba(8, 8, 18, 0.78);
    backdrop-filter: blur(6px);
  }

  .hud-card strong {
    font-size: 18px;
  }

  .touch-controls {
    display: flex;
  }

  .touch-pad {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .game-page {
    width: min(100vw, 100%);
    padding: 8px 0 18px;
  }

  .game-shell {
    border-radius: 16px;
    padding: 10px 10px 80px;
  }

  .canvas-wrap {
    max-height: calc(100vh - 120px);
  }

  .panel {
    width: min(94vw, 420px);
    max-height: 82vh;
    padding: 14px;
  }

  .control-item {
    gap: 8px;
  }

  .key-chip {
    min-width: 82px;
    padding: 6px 8px;
    font-size: 11px;
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  .game-page {
    padding: 4px 0 10px;
  }

  .topbar {
    margin-bottom: 6px;
  }

  .title-logo {
    max-height: 52px;
  }

  .game-shell {
    padding: 8px 8px 66px;
    border-radius: 14px;
  }

  .canvas-wrap {
    max-height: calc(100vh - 82px);
  }

  .panel {
    width: min(88vw, 420px);
    max-height: 78vh;
    padding: 12px;
  }

  .panel h2 {
    margin: 4px 0 8px;
    font-size: clamp(18px, 3vw, 24px);
  }

  .rules-box {
    margin: 8px auto 12px;
  }

  .controls-guide {
    gap: 6px;
  }

  .key-chip {
    min-width: 76px;
    font-size: 10px;
  }
}
