* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: #000;
}

body {
  color: #fff;
  font-family: Arial, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

.game-container {
  position: relative;
  width: 100vw;
  height: 100svh;
  min-height: 100vh;
  overflow: hidden;
  background: #000;
  touch-action: none;
}

#starCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#gameTitle {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  font-size: 20px;
  letter-spacing: 2px;
  z-index: 4;
  text-shadow: 0 0 8px #00ff00;
  white-space: nowrap;
}

#scope {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 260px;
  height: 260px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2;
}

#scope svg {
  width: 100%;
  height: 100%;
  display: block;
}

.enemy {
  position: absolute;
  width: 120px;
  height: 120px;
  z-index: 3;
  transform: translate(-50%, -50%) scale(0.2);
  transform-origin: center center;
  will-change: transform, left, top, opacity;
}

.enemy svg {
  width: 100%;
  height: 100%;
  stroke: #88d0ff;
  stroke-width: 1.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.explosion {
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(circle,
    rgba(255,255,255,1) 0%,
    rgba(255,230,150,1) 30%,
    rgba(255,120,0,0.9) 55%,
    rgba(255,0,0,0) 80%);
  box-shadow:
    0 0 10px rgba(255,255,255,0.9),
    0 0 25px rgba(255,180,0,0.8),
    0 0 45px rgba(255,120,0,0.75);
  transform: translate(-50%,-50%) scale(0.2);
  opacity: 1;
  animation: explosion-burst 0.5s ease-out forwards;
}

@keyframes explosion-burst {
  to {
    transform: translate(-50%,-50%) scale(2.7);
    opacity: 0;
  }
}

.bullet {
  position: absolute;
  width: 6px;
  height: 16px;
  background: yellow;
  border-radius: 3px;
  z-index: 3;
  pointer-events: none;
  will-change: transform, left, top, opacity;
}

#ui {
  position: absolute;
  top: calc(max(10px, env(safe-area-inset-top)) + 26px);
  left: 10px;
  font-size: 18px;
  z-index: 10;
  text-shadow: 0 0 4px #000, 0 0 8px #000;
}

#timer {
  margin-top: 4px;
}

#controlHint {
  position: absolute;
  right: 10px;
  top: calc(max(10px, env(safe-area-inset-top)) + 26px);
  z-index: 10;
  max-width: min(420px, 45vw);
  padding: 6px 8px;
  border: 1px solid rgba(0, 255, 120, 0.28);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.34);
  font-size: 12px;
  line-height: 1.45;
  color: rgba(220, 255, 220, 0.92);
  text-align: right;
  text-shadow: 0 0 4px #000;
}

.touch-controls {
  position: absolute;
  z-index: 14;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid rgba(0, 255, 120, 0.23);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.30);
  backdrop-filter: blur(2px);
}

.touch-controls-center {
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(50px + env(safe-area-inset-bottom));
  max-width: calc(100vw - 24px);
}

.touch-controls button {
  min-width: 52px;
  min-height: 38px;
  border: 1px solid rgba(0, 255, 120, 0.50);
  border-radius: 999px;
  background: rgba(0, 30, 10, 0.78);
  color: #d7ffd7;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(0, 255, 0, 0.14);
}

.touch-controls button:active {
  transform: translateY(1px);
  background: rgba(0, 70, 30, 0.92);
}

.touch-controls-center {
  justify-content: center;
}


.touch-controls .fire-button {
  min-width: 82px;
  color: #fff3b0;
  border-color: rgba(255, 230, 50, 0.75);
}

.touch-controls .restart-button {
  min-width: 84px;
  color: #bde3ff;
  border-color: rgba(80, 170, 255, 0.7);
}

.game-footer {
  position: absolute;
  left: 50%;
  bottom: calc(6px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 13;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(240, 246, 255, 0.86);
  border: 1px solid rgba(21, 101, 192, 0.25);
  color: #1565c0;
  font-size: 0.86rem;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.game-footer a {
  color: #1565c0;
  font-weight: 700;
}

.game-footer a:hover {
  color: #0d47a1;
}

.ad-intro-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 16px 64px;
  background: linear-gradient(to top, rgba(0,0,0,0.76), rgba(0,0,0,0.24));
}

.ad-intro-overlay[hidden] {
  display: none !important;
}

.ad-panel {
  width: min(920px, calc(100vw - 32px));
  border: 1px solid #d7e6f8;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 10px 32px rgba(0,0,0,0.35);
}

.ad-panel[hidden] {
  display: none !important;
}

.ad-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  background: #f4f8ff;
  border-bottom: 1px solid #d7e6f8;
}

.ad-label {
  font-size: 0.72rem;
  color: #4f6f91;
  line-height: 1;
  flex: 0 0 auto;
}

.ad-close-notice {
  flex: 1 1 auto;
  font-size: 0.74rem;
  color: #5b6f89;
  text-align: right;
}

.ad-close-btn {
  margin: 0 !important;
  padding: 3px 8px !important;
  min-height: 0;
  height: auto;
  line-height: 1.2;
  border: none;
  border-radius: 999px;
  background: #1565c0;
  color: #ffffff;
  font-size: 0.72rem !important;
  font-weight: 700;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
}

.ad-close-btn:hover {
  background: #0d47a1;
}

.ad-body {
  padding: 8px;
  background: #ffffff;
}

@media (max-width: 900px) and (orientation: landscape) {
  #scope {
    width: 220px;
    height: 220px;
  }

  #gameTitle {
    font-size: 18px;
  }
}

@media (max-width: 720px) {
  #controlHint {
    max-width: 58vw;
    font-size: 11px;
  }

  .touch-controls {
    padding: 6px 7px;
    gap: 6px;
  }

  .touch-controls button {
    min-width: 46px;
    min-height: 34px;
    font-size: 0.9rem;
  }

  .touch-controls .fire-button,
  .touch-controls .restart-button {
    min-width: 74px;
  }

  .game-footer {
    font-size: 0.8rem;
    padding: 6px 10px;
  }
}

@media (max-width: 520px) {
  #scope {
    width: 200px;
    height: 200px;
  }

  #controlHint {
    display: none;
  }

  #ui {
    top: calc(max(8px, env(safe-area-inset-top)) + 24px);
    font-size: 16px;
  }

  .touch-controls-center {
    bottom: calc(46px + env(safe-area-inset-bottom));
  }

  .ad-intro-overlay {
    padding: 12px 12px 60px;
  }

  .ad-panel-head {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .ad-close-notice {
    width: 100%;
    text-align: left;
    order: 3;
  }
}
