* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  overflow: hidden;
  background: #000;
  font-family: 'Segoe UI', Arial, sans-serif;
  color: #fff;
}

canvas {
  display: block;
}

/* Crosshair */
#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  color: rgba(255, 255, 255, 0.8);
  pointer-events: none;
  z-index: 10;
  text-shadow: 0 0 2px #000;
}

/* Player HP */
#player-hp-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 10;
}

#player-hp-container span {
  font-size: 14px;
  font-weight: bold;
}

#player-hp-bar {
  width: 200px;
  height: 16px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  margin-top: 4px;
}

#player-hp-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, #44ff44, #22cc22);
  border-radius: 2px;
  transition: width 0.3s;
}

/* Money */
#money-display {
  position: fixed;
  bottom: 80px;
  left: 20px;
  font-size: 20px;
  font-weight: bold;
  color: #ffd700;
  z-index: 10;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}

/* Core HP */
#core-hp-container {
  position: fixed;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 10;
}

#core-hp-container span {
  font-size: 12px;
  font-weight: bold;
  color: #88aaff;
}

#core-hp-bar {
  width: 300px;
  height: 12px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(100, 150, 255, 0.5);
  border-radius: 3px;
  margin-top: 2px;
}

#core-hp-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, #4488ff, #2266cc);
  border-radius: 2px;
  transition: width 0.3s;
}

/* Stage/Level display */
#stage-level-display {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
  font-weight: bold;
  z-index: 10;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}

/* Enemies remaining */
#enemies-remaining {
  position: fixed;
  top: 20px;
  right: 20px;
  font-size: 16px;
  font-weight: bold;
  z-index: 10;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}

/* Weapon display (hidden - replaced by weapon bar) */
#weapon-display {
  display: none;
}

/* Ammo display (hidden - replaced by weapon bar) */

/* Weapon bar — Minecraft style hotbar */
#weapon-bar {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  z-index: 10;
  pointer-events: auto;
}

#weapon-bar .weapon-slot {
  width: 56px;
  height: 56px;
  background: rgba(30, 30, 30, 0.65);
  border: 2px solid rgba(180, 180, 180, 0.3);
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

#weapon-bar .weapon-slot.active {
  border-color: #ffffff;
  border-width: 3px;
  background: rgba(60, 60, 60, 0.7);
}

#weapon-bar .weapon-slot.empty {
  background: rgba(20, 20, 20, 0.5);
  border-color: rgba(100, 100, 100, 0.2);
}

#weapon-bar .weapon-slot .slot-key {
  position: absolute;
  top: 1px;
  left: 3px;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.4);
  font-weight: bold;
}

#weapon-bar .weapon-slot .slot-icon {
  font-size: 20px;
  line-height: 1;
  margin-bottom: 1px;
}

#weapon-bar .weapon-slot .slot-ammo {
  font-size: 8px;
  color: rgba(255, 255, 255, 0.6);
  font-family: 'Courier New', monospace;
  position: absolute;
  bottom: 2px;
  right: 3px;
}

#weapon-bar .weapon-slot.active .slot-ammo {
  color: #fff;
}

#weapon-bar .weapon-slot.future {
  border-color: rgba(0, 255, 200, 0.4);
  background: rgba(0, 80, 60, 0.5);
}

#weapon-bar .weapon-slot.future.active {
  border-color: #00ffcc;
  background: rgba(0, 100, 80, 0.6);
  box-shadow: 0 0 10px rgba(0, 255, 200, 0.3);
}

/* Minimap */
#minimap {
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 15;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  pointer-events: none;
}

#ammo-display {
  display: none;
}

#ammo-display.reloading {
  display: block !important;
  position: fixed;
  bottom: 68px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
  font-weight: bold;
  z-index: 11;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.9);
  font-family: 'Courier New', monospace;
  color: #ff8800;
  background: rgba(0, 0, 0, 0.5);
  padding: 4px 16px;
  border-radius: 4px;
  border: 1px solid rgba(255, 136, 0, 0.4);
  animation: reloadBlink 0.5s ease-in-out infinite alternate;
}

@keyframes reloadBlink {
  0% { opacity: 1; }
  100% { opacity: 0.4; }
}

/* Damage overlay */
#damage-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
  border: 0px solid transparent;
  transition: border 0.1s;
}

#damage-overlay.active {
  border: 8px solid rgba(255, 0, 0, 0.5);
}

/* Game Over screen */
#game-over-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

#game-over-screen h1 {
  font-size: 64px;
  color: #ff3333;
  margin-bottom: 20px;
  text-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
}

#game-over-screen p {
  font-size: 24px;
  margin-bottom: 40px;
}

#retry-button {
  padding: 15px 40px;
  font-size: 20px;
  background: #ff3333;
  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

#retry-button:hover {
  background: #ff5555;
}

/* ===== 説明書画面 ===== */
#tutorial-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 110;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

#tutorial-scroll {
  width: 100%;
  max-width: 700px;
  height: 100%;
  overflow-y: auto;
  padding: 30px 24px 40px;
  -webkit-overflow-scrolling: touch;
}

#tutorial-scroll h1 {
  font-size: 36px;
  color: #4488ff;
  text-align: center;
  margin-bottom: 4px;
  text-shadow: 0 0 20px rgba(68, 136, 255, 0.5);
}

#tutorial-scroll h2 {
  font-size: 20px;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
  margin-bottom: 24px;
  font-weight: normal;
}

.tutorial-section {
  margin-bottom: 22px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 16px 18px;
}

.tutorial-section h3 {
  font-size: 17px;
  color: #4488ff;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(68, 136, 255, 0.3);
  padding-bottom: 6px;
}

.tutorial-section p {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.7;
  margin-bottom: 6px;
}

.tutorial-section ul {
  margin: 6px 0 4px 20px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.8;
}

.tutorial-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.tutorial-table td {
  padding: 5px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.tutorial-table td:first-child {
  color: #ffd700;
  font-weight: bold;
  white-space: nowrap;
  width: 40%;
}

.tutorial-table td:last-child {
  color: rgba(255, 255, 255, 0.8);
}

#tutorial-bottom {
  text-align: center;
  padding: 20px 0 30px;
}

#tutorial-ok-btn {
  padding: 14px 50px;
  font-size: 20px;
  font-weight: bold;
  background: #4488ff;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

@media (max-width: 768px) {
  #tutorial-scroll {
    padding: 20px 16px 30px;
  }
  #tutorial-scroll h1 {
    font-size: 26px;
  }
  #tutorial-scroll h2 {
    font-size: 16px;
  }
  .tutorial-section {
    padding: 12px 14px;
  }
  .tutorial-section h3 {
    font-size: 15px;
  }
  .tutorial-section p,
  .tutorial-section ul,
  .tutorial-table {
    font-size: 13px;
  }
  #tutorial-ok-btn {
    font-size: 18px;
    padding: 12px 40px;
  }
}

/* ===== 言語選択画面 ===== */
#lang-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 115;
  display: flex;
  justify-content: center;
  align-items: center;
}

#lang-content {
  text-align: center;
}

#lang-buttons {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.lang-btn {
  padding: 18px 50px;
  font-size: 22px;
  font-weight: bold;
  background: rgba(68, 136, 255, 0.15);
  color: #fff;
  border: 2px solid rgba(68, 136, 255, 0.5);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.lang-btn:hover, .lang-btn:active {
  background: rgba(68, 136, 255, 0.4);
  border-color: #4488ff;
}

@media (max-width: 768px) {
  .lang-btn {
    padding: 14px 36px;
    font-size: 18px;
  }
}

/* Start overlay */
#start-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  cursor: pointer;
}

#start-overlay h1 {
  font-size: 48px;
  color: #4488ff;
  margin-bottom: 20px;
  text-shadow: 0 0 20px rgba(68, 136, 255, 0.5);
}

#start-overlay p {
  font-size: 24px;
  color: rgba(255, 255, 255, 0.7);
}

/* Message display */
#message-display {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 32px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

/* Floating money text */
.floating-money {
  position: fixed;
  font-size: 18px;
  font-weight: bold;
  color: #ffd700;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 30;
  animation: floatUp 1s ease-out forwards;
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-60px); }
}

/* ===== スナイパースコープオーバーレイ ===== */
#scope-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9;
}

#scope-vignette {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, transparent 30%, rgba(0,0,0,0.95) 60%);
}

#scope-circle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(60vw, 60vh);
  height: min(60vw, 60vh);
  transform: translate(-50%, -50%);
  border: 2px solid rgba(0, 0, 0, 0.8);
  border-radius: 50%;
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.92);
}

#scope-crosshair-h {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
  background: rgba(0, 0, 0, 0.6);
  transform: translateY(-0.5px);
}

#scope-crosshair-v {
  position: absolute;
  top: 0;
  left: 50%;
  width: 1px;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  transform: translateX(-0.5px);
}

/* ===== 縦画面警告オーバーレイ ===== */
#rotate-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

#rotate-content {
  text-align: center;
  color: #fff;
}

#rotate-phone {
  margin-bottom: 20px;
}

/* スマホ本体の回転アニメーション */
#rotate-phone-g {
  transform-origin: 60px 60px;
  animation: phoneRotate 2.5s ease-in-out infinite;
}

@keyframes phoneRotate {
  0%, 15% { transform: rotate(0deg); }
  40%, 60% { transform: rotate(-90deg); }
  85%, 100% { transform: rotate(0deg); }
}

/* 矢印の点滅 */
#rotate-arrow {
  animation: arrowPulse 2.5s ease-in-out infinite;
}

@keyframes arrowPulse {
  0%, 15% { opacity: 0.8; }
  40%, 60% { opacity: 0; }
  85%, 100% { opacity: 0.8; }
}

#rotate-device-name {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 8px;
}

#rotate-msg {
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 4px;
}

#rotate-ok-btn {
  margin-top: 24px;
  padding: 12px 32px;
  font-size: 16px;
  font-weight: bold;
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  cursor: pointer;
}

/* モバイルデバイスの縦画面のときだけ警告表示 */
@media (max-width: 900px) and (orientation: portrait) {
  #rotate-overlay:not(.dismissed) {
    display: flex !important;
  }
}

/* ===== モバイルタッチUI ===== */
#touch-ui {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 25;
}

/* ジョイスティックゾーン（左側30%） */
#joystick-zone {
  position: absolute;
  left: 0;
  top: 0;
  width: 35%;
  height: 100%;
  pointer-events: auto;
}

#joystick-container {
  position: absolute;
  left: 60px;
  bottom: 140px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.3);
  opacity: 0.5;
  display: flex;
  align-items: center;
  justify-content: center;
}

#joystick-thumb {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.7);
  transition: none;
}

/* 全アクションボタン（右下にまとめ） */
#touch-buttons {
  position: absolute;
  right: 10px;
  bottom: 70px;
  pointer-events: auto;
}

.touch-btn {
  position: absolute;
  border: none;
  border-radius: 50%;
  color: #fff;
  font-weight: bold;
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  opacity: 0.75;
}

.touch-btn.active {
  opacity: 1;
  filter: brightness(1.3);
}

/* FIRE — 一番大きく右下メイン */
.shoot-btn {
  width: 90px;
  height: 90px;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle, rgba(255, 60, 60, 0.85), rgba(200, 30, 30, 0.65));
  border: 3px solid rgba(255, 100, 100, 0.6);
  font-size: 18px;
}

/* JUMP — FIREの左 */
.jump-btn {
  width: 70px;
  height: 70px;
  right: 100px;
  bottom: 10px;
  background: radial-gradient(circle, rgba(60, 180, 255, 0.75), rgba(30, 100, 200, 0.55));
  border: 3px solid rgba(100, 180, 255, 0.5);
  font-size: 14px;
}

/* DASH — JUMPの上 */
.sprint-btn {
  width: 60px;
  height: 60px;
  right: 105px;
  bottom: 90px;
  background: radial-gradient(circle, rgba(60, 255, 60, 0.75), rgba(30, 180, 30, 0.55));
  border: 3px solid rgba(100, 255, 100, 0.5);
  font-size: 13px;
}

/* R (リロード) — AIMの上 */
.reload-btn {
  width: 52px;
  height: 52px;
  right: 14px;
  bottom: 170px;
  background: radial-gradient(circle, rgba(255, 180, 60, 0.75), rgba(200, 120, 30, 0.55));
  border: 2px solid rgba(255, 200, 100, 0.5);
  font-size: 14px;
}

/* AIM — FIREの左上 */
.aim-btn {
  width: 60px;
  height: 60px;
  right: 10px;
  bottom: 100px;
  background: radial-gradient(circle, rgba(200, 200, 255, 0.7), rgba(100, 100, 200, 0.5));
  border: 3px solid rgba(180, 180, 255, 0.5);
  font-size: 13px;
}

/* 武器切替 < > — DASHとRの上に横並び */
.weapon-btn {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.2) !important;
  border: 2px solid rgba(255, 255, 255, 0.35) !important;
  font-size: 20px !important;
}

#touch-wprev {
  right: 110px;
  bottom: 170px;
}

#touch-wnext {
  right: 75px;
  bottom: 170px;
}

/* バリアボタン — DASHの左 */
.barrier-btn {
  width: 55px;
  height: 55px;
  right: 175px;
  bottom: 92px;
  background: radial-gradient(circle, rgba(68, 170, 255, 0.7), rgba(30, 100, 200, 0.5));
  border: 3px solid rgba(100, 180, 255, 0.5);
  font-size: 18px;
}

/* 一時停止ボタン — タッチUI内（モバイル用） */
#touch-pause-area {
  position: fixed;
  top: 15px;
  left: 205px;
  pointer-events: auto;
  z-index: 20;
}

/* 一時停止ボタン — HUD内（PC/モバイル共通） */
#pause-btn-area {
  position: fixed;
  top: 15px;
  left: 205px;
  z-index: 20;
}

.pause-btn {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.4) !important;
  font-size: 16px !important;
  letter-spacing: 2px;
}

/* 一時停止オーバーレイ */
#pause-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  z-index: 200;
  justify-content: center;
  align-items: center;
}

#pause-content {
  text-align: center;
  color: #fff;
}

#pause-content h2 {
  font-size: 36px;
  margin-bottom: 30px;
}

#pause-resume-btn {
  padding: 14px 50px;
  font-size: 20px;
  font-weight: bold;
  background: #4488ff;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

/* ===== モバイルレスポンシブ ===== */
@media (max-width: 768px) {
  #start-overlay h1 {
    font-size: 28px;
  }
  #start-overlay p {
    font-size: 14px;
    padding: 0 20px;
    text-align: center;
  }
  #game-over-screen h1 {
    font-size: 40px;
  }
  #game-over-screen p {
    font-size: 18px;
  }
  #stage-level-display {
    font-size: 13px;
    top: 5px;
  }
  #core-hp-container {
    top: 22px;
  }
  #core-hp-bar {
    width: 180px;
    height: 10px;
  }
  #core-hp-container span {
    font-size: 10px;
  }
  #enemies-remaining {
    font-size: 13px;
    top: 10px;
    right: 10px;
  }
  #player-hp-bar {
    width: 130px;
    height: 12px;
  }
  #player-hp-container {
    bottom: 10px;
    left: 10px;
  }
  #player-hp-container span {
    font-size: 12px;
  }
  #money-display {
    bottom: 75px;
    left: 10px;
    font-size: 16px;
  }
  #minimap {
    width: 100px !important;
    height: 100px !important;
    top: 5px;
    left: 5px;
  }
  #weapon-bar .weapon-slot {
    width: 52px;
    height: 52px;
  }
  #weapon-bar .weapon-slot .slot-icon svg {
    width: 22px;
    height: 22px;
  }
  #weapon-bar .weapon-slot .slot-ammo {
    font-size: 8px;
  }
  #weapon-bar .weapon-slot .slot-key {
    font-size: 10px;
  }
  #weapon-bar {
    bottom: 6px;
  }
  #crosshair {
    font-size: 20px;
  }
  #message-display {
    font-size: 22px;
  }
  /* 準備フェーズUI調整 */
  #defense-panel {
    gap: 6px !important;
    padding: 10px 8px !important;
  }
  #weapon-shop {
    min-width: 150px !important;
    padding: 8px !important;
    font-size: 12px !important;
    max-height: 40vh;
    overflow-y: auto;
  }
  #weapon-shop h3 {
    font-size: 13px !important;
  }
}
