:root {
  --ink: #090414;
  --purple: #8b5cf6;
  --cyan: #23e6ff;
  --pink: #ff3cac;
  --orange: #ff8a00;
  --white: #f8f7ff;
}

* { box-sizing: border-box; }

html {
  background: var(--ink);
  display: flex;
  height: 100%;
}

body {
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 60, 172, 0.28), transparent 31%),
    radial-gradient(circle at 88% 78%, rgba(35, 230, 255, 0.22), transparent 34%),
    linear-gradient(145deg, #17052f 0%, #090414 48%, #07192a 100%);
  display: flex;
  flex: 1;
  justify-content: center;
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
}

body::before,
body::after {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  content: '';
  pointer-events: none;
  position: fixed;
}

body::before {
  box-shadow: 0 0 80px rgba(139, 92, 246, 0.28);
  height: 42vw;
  left: -18vw;
  top: -20vw;
  width: 42vw;
}

body::after {
  bottom: -25vw;
  box-shadow: 0 0 90px rgba(35, 230, 255, 0.2);
  height: 48vw;
  right: -18vw;
  width: 48vw;
}

.game-shell {
  align-items: center;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  justify-content: center;
  position: relative;
  width: 100%;
  z-index: 1;
}

.brand-bar {
  align-items: center;
  color: var(--white);
  display: none;
  flex: 0 0 54px;
  font-family: Arial Black, Arial, sans-serif;
  gap: 9px;
  letter-spacing: -1px;
  padding: 7px 18px 2px;
  width: 100%;
}

.brand-mark {
  align-items: center;
  background: linear-gradient(135deg, var(--pink), var(--orange));
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 12px 4px 12px 4px;
  box-shadow: 0 0 18px rgba(255, 60, 172, 0.55);
  display: flex;
  font-size: 18px;
  height: 34px;
  justify-content: center;
  transform: rotate(-5deg);
  width: 34px;
}

.brand-name { font-size: 20px; font-style: italic; }

.brand-name strong {
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(35, 230, 255, 0.65);
}

.brand-badge {
  background: rgba(139, 92, 246, 0.28);
  border: 1px solid rgba(139, 92, 246, 0.62);
  border-radius: 999px;
  color: #d8c9ff;
  font-family: Arial, sans-serif;
  font-size: 9px;
  letter-spacing: 1.5px;
  margin-left: auto;
  padding: 5px 8px;
}

.game-stage {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 0;
  position: relative;
}

.game-stage canvas {
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 14px;
  box-shadow: 0 0 0 4px rgba(15, 7, 31, 0.82), 0 18px 55px rgba(0, 0, 0, 0.55), 0 0 34px rgba(139, 92, 246, 0.2);
  display: block;
  height: auto;
  image-rendering: pixelated;
  max-height: calc(100dvh - 16px);
  max-width: calc(100vw - 16px);
  width: auto;
}

.loading {
  align-items: center;
  color: var(--cyan);
  display: flex;
  font-family: Lucida Console, Courier, monospace;
  font-size: 24px;
  text-shadow: 0 0 18px rgba(35, 230, 255, 0.75);
}

.touch-controls { display: none; }

@media (hover: none), (pointer: coarse), (max-width: 700px) {
  .game-shell {
    justify-content: flex-start;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .brand-bar { display: flex; }

  .game-stage {
    flex: 1 1 auto;
    padding: 3px 10px 5px;
    width: 100%;
  }

  .game-stage canvas {
    border-color: rgba(139, 92, 246, 0.62);
    max-height: calc(100dvh - 224px - env(safe-area-inset-bottom));
    max-width: calc(100vw - 20px);
  }

  .touch-controls {
    align-items: center;
    background: linear-gradient(180deg, rgba(16, 7, 36, 0.34), rgba(16, 7, 36, 0.88));
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    display: flex;
    flex: 0 0 170px;
    justify-content: space-between;
    padding: 7px max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left));
    width: 100%;
  }

  .touch-button {
    align-items: center;
    background: linear-gradient(145deg, rgba(73, 47, 126, 0.92), rgba(27, 13, 58, 0.96));
    border: 1px solid rgba(190, 167, 255, 0.72);
    border-radius: 16px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 7px 0 #13082c, 0 10px 22px rgba(0, 0, 0, 0.36);
    color: var(--white);
    display: flex;
    font-family: Arial Black, Arial, sans-serif;
    font-size: 18px;
    font-weight: 900;
    justify-content: center;
    padding: 0;
    position: relative;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.42);
    touch-action: none;
    transition: transform 70ms ease, box-shadow 70ms ease, filter 70ms ease;
  }

  .touch-button.is-pressed {
    box-shadow: inset 0 3px 10px rgba(0, 0, 0, 0.32), 0 2px 0 #13082c, 0 0 22px rgba(35, 230, 255, 0.35);
    filter: brightness(1.22);
    transform: translateY(5px) scale(0.97);
  }

  .d-pad {
    display: grid;
    gap: 4px;
    grid-template-columns: repeat(3, 49px);
    grid-template-rows: repeat(3, 49px);
    position: relative;
  }

  .d-pad::before {
    background: radial-gradient(circle, rgba(139, 92, 246, 0.42), transparent 68%);
    content: '';
    inset: -16px;
    pointer-events: none;
    position: absolute;
  }

  .d-pad .touch-button { height: 49px; width: 49px; }
  .d-pad__up { grid-column: 2; grid-row: 1; }
  .d-pad__left { grid-column: 1; grid-row: 2; }
  .d-pad__right { grid-column: 3; grid-row: 2; }
  .d-pad__down { grid-column: 2; grid-row: 3; }

  .d-pad__core {
    background: linear-gradient(145deg, #31176a, #16092f);
    border: 1px solid rgba(139, 92, 246, 0.55);
    border-radius: 12px;
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.5);
    grid-column: 2;
    grid-row: 2;
    margin: 5px;
  }

  .action-pad { align-items: center; display: flex; gap: 15px; }

  .fire-button {
    background: linear-gradient(145deg, #ff9c19, #ff3c7e 55%, #a51de0);
    border: 2px solid rgba(255, 240, 214, 0.9);
    border-radius: 50%;
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), 0 8px 0 #6b164b, 0 12px 30px rgba(255, 60, 172, 0.34);
    font-size: 16px;
    height: 88px;
    letter-spacing: 1px;
    width: 88px;
  }

  .fire-button.is-pressed {
    box-shadow: inset 0 4px 14px rgba(92, 10, 76, 0.42), 0 2px 0 #6b164b, 0 0 28px rgba(255, 138, 0, 0.48);
  }

  .pause-button {
    background: linear-gradient(145deg, #1ecfe8, #6d39d8);
    border-color: rgba(176, 249, 255, 0.85);
    height: 48px;
    width: 48px;
  }
}

@media (hover: none) and (orientation: landscape),
  (pointer: coarse) and (orientation: landscape),
  (max-width: 700px) and (orientation: landscape) {
  .game-shell { justify-content: center; }
  .brand-bar { display: none; }
  .game-stage { padding: 4px; }
  .game-stage canvas { max-height: calc(100dvh - 40px); }

  .touch-controls {
    background: none;
    border: 0;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 0;
    padding-left: max(6px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    pointer-events: none;
    position: fixed;
  }

  .touch-controls > * { pointer-events: auto; }

  .d-pad {
    gap: 3px;
    grid-template-columns: repeat(3, 43px);
    grid-template-rows: repeat(3, 43px);
  }

  .d-pad .touch-button {
    height: 43px;
    width: 43px;
  }

  .action-pad {
    flex-direction: column-reverse;
    gap: 10px;
  }

  .fire-button {
    height: 78px;
    width: 78px;
  }

  .pause-button {
    height: 42px;
    width: 42px;
  }
}

@media (max-height: 700px) and (orientation: portrait) {
  .brand-bar { flex-basis: 46px; padding-top: 5px; }
  .brand-mark { height: 30px; width: 30px; }
  .touch-controls { flex-basis: 158px; }
  .game-stage canvas { max-height: calc(100dvh - 204px - env(safe-area-inset-bottom)); }
}
