/* ===== リセット & ベース ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

::selection {
  background: rgba(168, 85, 247, 0.3);
  color: #fff;
}

html {
  scroll-behavior: smooth;
}

html, body {
  background: #12121f;
  background-image:
    radial-gradient(ellipse 800px 600px at 50% 400px, rgba(168, 85, 247, 0.03), transparent),
    radial-gradient(ellipse 400px 400px at 50% 400px, rgba(10, 10, 46, 0.5), transparent);
  color: #c8d0e0;
  font-family: 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  min-height: 100vh;
}

/* ===== ヘッダー ===== */
#header {
  background: linear-gradient(180deg, #18182d 0%, #0e0e1e 100%);
  border-bottom: 1px solid rgba(168, 85, 247, 0.2);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(168, 85, 247, 0.08);
}

.header-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.header-logo {
  font-size: 1.5rem;
  font-weight: bold;
  color: #a855f7;
  text-decoration: none;
  letter-spacing: 0.15em;
  text-shadow: 0 0 12px rgba(168, 85, 247, 0.4);
  transition: text-shadow 0.2s;
  padding: 2px 10px;
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: 4px;
  background: rgba(168, 85, 247, 0.06);
}

.header-logo:hover {
  text-shadow: 0 0 20px rgba(168, 85, 247, 0.7);
}

.header-nav {
  display: flex;
  gap: 20px;
}

.header-nav a {
  color: #8890a8;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
  position: relative;
}

.header-nav a:hover {
  color: #c8b0f0;
}

.header-nav a::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 0;
  height: 1px;
  background: #a855f7;
  transition: width 0.2s;
}

.header-nav a:hover::after {
  width: 100%;
}

.header-nav a.current-page {
  color: #c8b0f0;
}

.header-nav a.current-page::after {
  width: 100%;
  background: rgba(168, 85, 247, 0.5);
}

/* ===== コンテンツレイアウト ===== */
#contents {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  display: flex;
  gap: 24px;
}

#main {
  flex: 1;
  min-width: 0;
}

#page-title {
  font-size: 1.4rem;
  color: #e0e4f0;
  margin-bottom: 14px;
  font-weight: bold;
  padding: 4px 0 4px 14px;
  border-left: 3px solid #a855f7;
  letter-spacing: 0.05em;
}

/* ===== サイドバー ===== */
#sub {
  width: 280px;
  flex-shrink: 0;
}

.sub-box {
  background: linear-gradient(180deg, #161628 0%, #111120 100%);
  border: 1px solid rgba(168, 85, 247, 0.15);
  border-top: 2px solid rgba(168, 85, 247, 0.35);
  border-radius: 2px 2px 8px 8px;
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(168, 85, 247, 0.05);
}

.sub-box h3 {
  font-size: 0.85rem;
  color: #a0a8c0;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(168, 85, 247, 0.15);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sub-links {
  list-style: none;
}

.sub-links li {
  font-size: 0.85rem;
  margin-bottom: 8px;
  color: #8890a8;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s;
}

.sub-links li:hover {
  background: rgba(168, 85, 247, 0.06);
}

.sub-links a {
  color: #7888cc;
  text-decoration: none;
  transition: color 0.15s;
}

.sub-links a:hover {
  color: #a888f0;
}

.sub-links li:has(strong) {
  border-left: 2px solid #44ee88;
  padding-left: 10px;
  background: rgba(68, 238, 136, 0.03);
  border-radius: 0 4px 4px 0;
}

.sub-links a:hover::before {
  content: '\203A ';
  color: #a855f7;
}

.sub-current {
  display: inline-block;
  font-size: 0.6rem;
  color: #44ee88;
  background: rgba(68, 238, 136, 0.08);
  border: 1px solid rgba(68, 238, 136, 0.25);
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: 0.05em;
}

/* ===== フッター ===== */
#footer {
  background: linear-gradient(180deg, #0e0e1e 0%, #0a0a16 100%);
  border-top: 1px solid rgba(168, 85, 247, 0.2);
  margin-top: 40px;
}

#footer::before {
  content: '';
  display: block;
  max-width: 1000px;
  margin: 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(168, 85, 247, 0.3), transparent);
}

.footer-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 20px;
  text-align: center;
  font-size: 0.8rem;
  color: #5a6080;
}

.footer-links {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.footer-links a {
  color: #6a7098;
  text-decoration: none;
  margin: 0 14px;
  font-size: 0.8rem;
  transition: color 0.15s;
}

.footer-links a:hover {
  color: #9080c0;
}

#footer p {
  letter-spacing: 0.05em;
  opacity: 0.7;
}

/* ===== ゲーム説明セクション ===== */
.info-section {
  background: linear-gradient(180deg, #13132a 0%, #0f0f1e 100%);
  border: 1px solid rgba(168, 85, 247, 0.12);
  border-radius: 8px;
  padding: 28px 32px;
  margin-top: 20px;
  color: #a0a8c0;
  font-size: 0.9rem;
  line-height: 1.8;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  position: relative;
}

.info-section::before {
  content: 'ABOUT';
  position: absolute;
  top: -10px;
  left: 20px;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: #a855f7;
  background: #12121f;
  padding: 2px 10px;
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: 3px;
}

.info-section h2 {
  font-size: 1.1rem;
  color: #d0d4e8;
  margin-bottom: 10px;
  margin-top: 24px;
  padding-bottom: 8px;
  padding-left: 12px;
  border-bottom: 1px solid rgba(168, 85, 247, 0.12);
  border-left: 2px solid rgba(168, 85, 247, 0.4);
}

.info-section h2:first-child {
  margin-top: 0;
}

.info-section h3 {
  font-size: 1rem;
  color: #b8c0d8;
  margin-bottom: 8px;
  margin-top: 16px;
}

.info-section p {
  margin-bottom: 10px;
}

.info-section ul {
  padding-left: 0;
  margin-bottom: 10px;
  list-style: none;
}

.info-section li {
  margin-bottom: 8px;
  padding-left: 16px;
  position: relative;
}

.info-section li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 5px;
  height: 5px;
  background: rgba(168, 85, 247, 0.5);
  border-radius: 50%;
}

.info-section kbd {
  display: inline-block;
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: 4px;
  padding: 2px 7px;
  font-family: inherit;
  font-size: 0.8rem;
  color: #c8b0f0;
}

/* ===== アクセシビリティ ===== */
.btn:focus-visible,
.header-nav a:focus-visible,
.sub-links a:focus-visible,
.footer-links a:focus-visible {
  outline: 2px solid #a855f7;
  outline-offset: 2px;
}

/* ============================================================
   ゲームラッパー: 650x600固定
   タイトル・プレイ・ゲームオーバーの3状態をこの中で切り替える
   ============================================================ */
#game-wrapper {
  position: relative;
  width: 650px;
  height: 600px;
  overflow: hidden;
  margin: 0 auto 0 0;
  background: #050510;
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 4px;
  box-shadow:
    0 0 0 1px rgba(168, 85, 247, 0.15),
    0 0 40px rgba(168, 85, 247, 0.18),
    0 0 80px rgba(100, 140, 255, 0.08),
    0 4px 24px rgba(0, 0, 0, 0.6),
    inset 0 0 60px rgba(0, 0, 0, 0.3);
}

/* #game-wrapper::before のコーナーアクセントは視認性低下のため削除 */

/* 各ゲーム状態の共通スタイル */
.game-state {
  position: absolute;
  top: 0;
  left: 0;
  width: 650px;
  height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
}

/* ===== タイトル状態 ===== */
#title-state {
  background: radial-gradient(ellipse at center, #0a0a2e 0%, #050510 100%);
}

/* --- 星が流れる背景 --- */
.starfield {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.star-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 200%;
  animation: starScroll linear infinite;
}

.star-layer-1 {
  background-image:
    radial-gradient(1px 1px at 5% 8%, #fff, transparent),
    radial-gradient(1px 1px at 12% 25%, rgba(255,255,255,0.7), transparent),
    radial-gradient(1px 1px at 22% 42%, #fff, transparent),
    radial-gradient(1px 1px at 35% 15%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 48% 55%, rgba(255,255,255,0.8), transparent),
    radial-gradient(1px 1px at 62% 30%, #fff, transparent),
    radial-gradient(1px 1px at 75% 68%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 88% 12%, rgba(255,255,255,0.9), transparent),
    radial-gradient(1px 1px at 93% 45%, #fff, transparent),
    radial-gradient(1px 1px at 18% 72%, rgba(255,255,255,0.7), transparent),
    radial-gradient(1px 1px at 42% 88%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 58% 5%, #fff, transparent),
    radial-gradient(1px 1px at 82% 82%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 30% 60%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 70% 48%, rgba(255,255,255,0.8), transparent);
  animation-duration: 40s;
}

.star-layer-2 {
  background-image:
    radial-gradient(1.5px 1.5px at 8% 18%, rgba(180,200,255,0.9), transparent),
    radial-gradient(1.5px 1.5px at 25% 52%, rgba(180,200,255,0.6), transparent),
    radial-gradient(1.5px 1.5px at 45% 8%, rgba(200,220,255,0.8), transparent),
    radial-gradient(1.5px 1.5px at 68% 38%, rgba(180,200,255,0.7), transparent),
    radial-gradient(1.5px 1.5px at 85% 72%, rgba(200,220,255,0.9), transparent),
    radial-gradient(1.5px 1.5px at 15% 85%, rgba(180,200,255,0.5), transparent),
    radial-gradient(1.5px 1.5px at 55% 65%, rgba(200,220,255,0.7), transparent),
    radial-gradient(1.5px 1.5px at 38% 28%, rgba(180,200,255,0.6), transparent),
    radial-gradient(1.5px 1.5px at 78% 15%, rgba(200,220,255,0.8), transparent),
    radial-gradient(1.5px 1.5px at 92% 55%, rgba(180,200,255,0.5), transparent);
  animation-duration: 25s;
}

.star-layer-3 {
  background-image:
    radial-gradient(2px 2px at 15% 35%, rgba(100,160,255,0.9), transparent),
    radial-gradient(2px 2px at 55% 20%, rgba(100,180,255,0.7), transparent),
    radial-gradient(2px 2px at 80% 60%, rgba(120,160,255,0.8), transparent),
    radial-gradient(2px 2px at 35% 78%, rgba(100,160,255,0.6), transparent),
    radial-gradient(2px 2px at 65% 92%, rgba(120,180,255,0.9), transparent);
  animation-duration: 15s;
}

@keyframes starScroll {
  0%   { transform: translateY(0); }
  100% { transform: translateY(-50%); }
}

/* --- タイトルコンテンツ --- */
.title-content {
  text-align: center;
  position: relative;
  z-index: 10;
}

/* --- ロゴ部分 --- */
.title-logo {
  margin-bottom: 1.5rem;
  position: relative;
}

.title-logo::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  height: 80%;
  background: radial-gradient(ellipse, rgba(68, 136, 255, 0.35) 0%, transparent 70%);
  pointer-events: none;
  z-index: -1;
}

.title-sub-top {
  font-size: 0.8rem;
  letter-spacing: 0.55em;
  color: rgba(140, 200, 255, 0.75);
  text-transform: uppercase;
  margin-bottom: 0.3rem;
  padding: 2px 12px;
  padding-left: calc(12px + 0.55em);
  display: inline-block;
  border-left: 1px solid rgba(100, 180, 255, 0.35);
  border-right: 1px solid rgba(100, 180, 255, 0.35);
}

.game-title {
  font-size: 3.5rem;
  letter-spacing: 0.12em;
  line-height: 1.1;
  margin: 0;
  padding: 0;
}

.title-char {
  display: inline-block;
  background: linear-gradient(180deg, #ffffff 0%, #88bbff 40%, #4488ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: charFloat 3s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.15s);
}

@keyframes charFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.title-sub-bottom {
  font-size: 1.9rem;
  letter-spacing: 0.55em;
  color: transparent;
  background: linear-gradient(90deg, #ff6644, #ffaa22, #ffdd44, #ffaa22, #ff6644);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  padding-left: 0.55em;
  margin-top: 0.1rem;
  font-weight: bold;
  animation: blastShimmer 4s ease-in-out infinite;
}

@keyframes blastShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* --- タグライン --- */
.title-tagline {
  font-size: 0.9rem;
  color: rgba(160, 190, 230, 0.85);
  margin-bottom: 1.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(100, 140, 200, 0.15);
  letter-spacing: 0.03em;
}

/* --- ハイスコア表示 --- */
.title-score-box {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: rgba(10, 20, 50, 0.6);
  border: 1px solid rgba(100, 160, 255, 0.2);
  border-radius: 4px;
  padding: 8px 24px;
  margin-bottom: 1.4rem;
  animation: scoreBoxPulse 3s ease-in-out infinite;
}

@keyframes scoreBoxPulse {
  0%, 100% {
    border-color: rgba(100, 160, 255, 0.2);
    box-shadow: none;
  }
  50% {
    border-color: rgba(100, 160, 255, 0.5);
    box-shadow: 0 0 12px rgba(100, 160, 255, 0.12), inset 0 0 8px rgba(100, 160, 255, 0.06);
  }
}

.score-label {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  color: rgba(150, 180, 220, 0.7);
  text-transform: uppercase;
}

.score-value {
  font-size: 1.5rem;
  color: #ffdd55;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

/* --- ボタン共通 --- */
.btn {
  display: inline-block;
  padding: 14px 48px;
  font-size: 1.3rem;
  color: #fff;
  background: linear-gradient(160deg, #2f55cc 0%, #1a35a0 60%, #3355cc 100%);
  border: 2px solid rgba(100, 160, 255, 0.7);
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
}

.btn:hover {
  background: linear-gradient(160deg, #4466dd 0%, #2244bb 60%, #4466dd 100%);
  box-shadow: 0 0 32px rgba(80, 130, 255, 0.7), 0 0 64px rgba(80, 130, 255, 0.2);
}

.btn:active {
  transform: scale(0.97);
}

.title-btn {
  animation: btnGlow 2s ease-in-out infinite;
}

@keyframes btnGlow {
  0%, 100% {
    box-shadow: 0 0 8px rgba(80, 130, 255, 0.3);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 28px rgba(80, 130, 255, 0.7), 0 0 56px rgba(80, 130, 255, 0.2);
    transform: scale(1.015);
  }
}

/* --- スタートヒント --- */
.start-hint {
  font-size: 0.8rem;
  color: rgba(170, 200, 240, 0.65);
  margin-top: 0.5rem;
  margin-bottom: 1.2rem;
  animation: hintBlink 2.5s ease-in-out infinite;
}

@keyframes hintBlink {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

/* --- 操作ガイド --- */
.title-controls {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}

.control-item {
  font-size: 0.75rem;
  color: rgba(150, 170, 200, 0.5);
}

.control-item kbd {
  display: inline-block;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 0.7rem;
  color: rgba(200, 220, 255, 0.7);
}

/* --- 砲台シルエット（タイトル画面用） --- */
.title-turret {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  opacity: 0.4;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: charFloat 4s ease-in-out infinite;
}

.title-turret-barrel {
  width: 3px;
  height: 18px;
  background: linear-gradient(to top, #4466aa, #88ccff);
  border-radius: 1px;
}

.title-turret-body {
  width: 56px;
  height: 20px;
  background: linear-gradient(to bottom, #4488cc, #223366);
  clip-path: polygon(0% 100%, 15% 0%, 85% 0%, 100% 100%);
  margin-top: -2px;
}

.title-turret-glow {
  width: 30px;
  height: 12px;
  background: radial-gradient(ellipse at 50% 0%, rgba(80, 180, 255, 0.8), transparent);
  border-radius: 0 0 50% 50%;
}

/* ===== プレイ状態 ===== */
#game-state {
  background: radial-gradient(ellipse at 50% 100%, #0a0a2e 0%, #050510 60%);
}

#game-area {
  position: absolute;
  top: 0;
  left: 0;
  width: 650px;
  height: 600px;
  overflow: hidden;
}

/* 星背景 */
#game-area::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 30% 50%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 50% 10%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 70% 60%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 90% 30%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 20% 80%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 60% 85%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 80% 15%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 40% 40%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 15% 65%, rgba(255,255,255,0.5), transparent);
  pointer-events: none;
}

/* ===== HUD ===== */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: rgba(5, 5, 16, 0.85);
  font-size: 0.9rem;
  z-index: 100;
  border-bottom: 1px solid rgba(80, 130, 255, 0.3);
}

#score-display { color: #aaccff; }
#wave-display { color: #ffcc44; font-weight: bold; }
#miss-display { font-size: 0.8rem; }
.miss-label { color: #ff6655; font-weight: bold; letter-spacing: 0.05em; }
#miss-count { color: #ffaa88; font-weight: bold; font-size: 0.9rem; }
.miss-sep { color: #445566; }
.miss-lost-label { color: #887766; font-size: 0.7rem; }
#miss-lost { color: #ff4444; font-weight: bold; font-size: 0.9rem; }
#lives-display { color: #ff4466; font-size: 1.2rem; letter-spacing: 4px; }

/* ===== タイピング表示 ===== */
#typing-display {
  position: absolute;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.4rem;
  letter-spacing: 0.05em;
  background: rgba(5, 5, 16, 0.9);
  padding: 6px 20px;
  border-radius: 8px;
  border: 1px solid rgba(80, 130, 255, 0.4);
  min-width: 180px;
  text-align: center;
  z-index: 100;
  min-height: 2rem;
}

#typed-text { color: #44aaff; }
#untyped-text { color: #667788; }

#typing-display.pending {
  border-color: rgba(255, 204, 68, 0.85);
  box-shadow: 0 0 14px rgba(255, 204, 68, 0.35);
}

#typing-display.pending #typed-text {
  color: #ffdd66;
}

#typing-display.pending #untyped-text {
  color: #ffb266;
}

/* ===== 自機（スペースシップ） ===== */
#turret {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 砲身 */
.turret-barrel {
  width: 3px;
  height: 14px;
  background: linear-gradient(to top, #4488dd, #88ddff);
  border-radius: 1px 1px 0 0;
  box-shadow: 0 -4px 8px rgba(100, 200, 255, 0.5);
}

/* コックピット */
.turret-cockpit {
  width: 10px;
  height: 8px;
  background: radial-gradient(ellipse at 50% 30%, #aaddff, #3366bb);
  border-radius: 50% 50% 30% 30%;
  margin-top: -1px;
}

/* メイン船体 */
.turret-body {
  width: 44px;
  height: 16px;
  background: linear-gradient(to bottom, #4488cc, #223366);
  clip-path: polygon(0% 100%, 15% 0%, 85% 0%, 100% 100%);
  margin-top: -2px;
  position: relative;
}

/* 翼 - 左右に ::before/::after で */
.turret-body::before,
.turret-body::after {
  content: '';
  position: absolute;
  bottom: 0;
  width: 14px;
  height: 10px;
  background: linear-gradient(to bottom, #3366aa, #1a2a55);
}

.turret-body::before {
  left: -10px;
  clip-path: polygon(100% 0%, 100% 100%, 0% 100%);
}

.turret-body::after {
  right: -10px;
  clip-path: polygon(0% 0%, 100% 100%, 0% 100%);
}

/* エンジン噴射 */
.turret-engine {
  width: 16px;
  height: 6px;
  background: radial-gradient(ellipse at 50% 0%, rgba(80, 180, 255, 0.8), rgba(80, 180, 255, 0.2), transparent);
  border-radius: 0 0 50% 50%;
  animation: enginePulse 0.8s ease-in-out infinite alternate;
}

@keyframes enginePulse {
  0% { opacity: 0.6; height: 4px; }
  100% { opacity: 1; height: 8px; }
}

/* ===== 敵 ===== */
.enemy {
  position: absolute;
  text-align: center;
  z-index: 10;
  transform: translateX(-50%);
}

.enemy-word {
  display: block;
  font-size: 1.3rem;
  font-weight: 600;
  color: #ddeeff;
  text-shadow: 0 0 8px rgba(100, 180, 255, 0.5), 0 1px 2px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  line-height: 1.2;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(6, 12, 24, 0.58);
  border: 1px solid rgba(86, 132, 190, 0.42);
}

.enemy-reading {
  display: block;
  font-size: 0.8rem;
  color: #99aabb;
  white-space: nowrap;
  margin-top: 1px;
  line-height: 1.2;
  padding: 0 5px;
  border-radius: 4px;
  background: rgba(4, 8, 16, 0.45);
}

.enemy-roman {
  display: block;
  font-size: 0.85rem;
  color: #778899;
  white-space: nowrap;
  margin-top: 2px;
  line-height: 1.2;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(3, 7, 14, 0.55);
}

.enemy-roman .roman-typed { color: #44aaff; }
.enemy-roman .roman-untyped { color: #778899; }

.enemy.targeted { z-index: 20; }

.enemy.targeted .enemy-word {
  color: #ffdd44;
  text-shadow: 0 0 12px rgba(255, 200, 50, 0.7);
  border-color: rgba(255, 212, 98, 0.6);
  background: rgba(42, 29, 5, 0.65);
}

.enemy.pending-candidate:not(.targeted) {
  z-index: 18;
}

.enemy.pending-candidate:not(.targeted) .enemy-word {
  color: #ffd86a;
  text-shadow: 0 0 10px rgba(255, 200, 90, 0.6);
  border-color: rgba(255, 204, 110, 0.56);
  background: rgba(45, 29, 5, 0.6);
}

.enemy.pending-candidate:not(.targeted) .roman-typed {
  color: #ffde75;
}

.enemy.pending-primary:not(.targeted) .enemy-word {
  text-shadow: 0 0 14px rgba(255, 200, 90, 0.9);
}

/* 通常敵: 逆三角形のエイリアンシップ */
.enemy-body {
  width: 28px;
  height: 18px;
  margin: 0 auto 4px;
  background: linear-gradient(to bottom, #5577cc, #223355);
  clip-path: polygon(50% 100%, 0% 20%, 15% 0%, 85% 0%, 100% 20%);
  position: relative;
}

/* 敵のコア（光る目） */
.enemy-body::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 4px;
  background: radial-gradient(ellipse, #88ddff, #4488cc);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(100, 200, 255, 0.7);
}

.enemy.targeted .enemy-body {
  background: linear-gradient(to bottom, #ddaa33, #885500);
}

.enemy.targeted .enemy-body::after {
  background: radial-gradient(ellipse, #ffee88, #ffcc44);
  box-shadow: 0 0 8px rgba(255, 200, 50, 0.8);
}

.enemy.pending-candidate:not(.targeted) .enemy-body {
  background: linear-gradient(to bottom, #c18f33, #6d4614);
}

.enemy.pending-candidate:not(.targeted) .enemy-body::after {
  background: radial-gradient(ellipse, #ffe28e, #d79d39);
  box-shadow: 0 0 7px rgba(255, 200, 90, 0.7);
}

/* ボス敵: 大型の六角形エイリアン戦艦 */
.enemy.boss .enemy-body {
  width: 48px;
  height: 32px;
  background: linear-gradient(to bottom, #bb44aa, #441133);
  clip-path: polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%);
}

.enemy.boss .enemy-body::after {
  top: 8px;
  width: 10px;
  height: 7px;
  background: radial-gradient(ellipse, #ff88dd, #cc44aa);
  box-shadow: 0 0 10px rgba(255, 100, 200, 0.8);
  animation: bossCorePulse 1.5s ease-in-out infinite alternate;
}

/* filterではなくbox-shadow + opacityで脈動（コア部分のみ、軽量） */
@keyframes bossCorePulse {
  0% { box-shadow: 0 0 6px rgba(255, 100, 200, 0.5); }
  100% { box-shadow: 0 0 14px rgba(255, 100, 200, 0.9); opacity: 0.8; }
}

.enemy.boss .enemy-word {
  font-size: 1.5rem;
  color: #ffaadd;
}

.boss-hp {
  display: flex;
  justify-content: center;
  gap: 3px;
  margin-top: 2px;
}

.boss-hp-pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff4466;
  box-shadow: 0 0 4px rgba(255, 68, 102, 0.6);
}

.boss-hp-pip.empty {
  background: #333;
  box-shadow: none;
}

/* ===== 弾エフェクト ===== */
.bullet {
  position: absolute;
  width: 2px;
  height: 20px;
  background: #ffffff;
  z-index: 30;
  pointer-events: none;
  animation: bulletFly 0.15s linear forwards;
}

@keyframes bulletFly {
  from { opacity: 1; }
  to { opacity: 0.3; transform: translate(var(--bullet-dx), var(--bullet-dy)); }
}

/* ===== 爆発エフェクト ===== */
.explosion {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff, #ffdd44, transparent);
  z-index: 25;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: explode 0.4s ease-out forwards;
}

@keyframes explode {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.8; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(6); }
}

.explosion.boss-explosion {
  animation: bossExplode 0.7s ease-out forwards;
}

@keyframes bossExplode {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(4); }
  60% { opacity: 0.7; transform: translate(-50%, -50%) scale(8); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(12); }
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  z-index: 24;
  pointer-events: none;
  animation: particleFly 0.5s ease-out forwards;
}

@keyframes particleFly {
  0% { opacity: 1; transform: translate(0, 0); }
  100% { opacity: 0; transform: translate(var(--px), var(--py)); }
}

/* 画面シェイク */
.screen-shake { animation: shake 0.3s ease-out; }

@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-4px, 2px); }
  40% { transform: translate(4px, -2px); }
  60% { transform: translate(-2px, 4px); }
  80% { transform: translate(2px, -4px); }
}

/* ===== WAVE表示 ===== */
#wave-announce {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 200;
  text-align: center;
  pointer-events: none;
}

#wave-announce-text {
  font-size: 3rem;
  font-weight: bold;
  color: #ffcc44;
  text-shadow: 0 0 30px rgba(255, 200, 50, 0.8);
  animation: waveAnnounce 1.5s ease-out forwards;
}

@keyframes waveAnnounce {
  0% { opacity: 0; transform: scale(0.5); }
  20% { opacity: 1; transform: scale(1.1); }
  40% { transform: scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.2); }
}

/* ===== ゲームオーバー状態 ===== */
#gameover-state {
  background: radial-gradient(ellipse at center, #0a0a2e 0%, #050510 100%);
}

.gameover-content {
  text-align: center;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 0;
  max-height: 100%;
  overflow-y: auto;
}

.gameover-title {
  font-size: 2.6rem;
  color: #ff4466;
  text-shadow: 0 0 30px rgba(255, 68, 102, 0.6);
  margin-bottom: 1.2rem;
  letter-spacing: 0.2em;
}

.result-box {
  background: rgba(255, 255, 255, 0.05);
  padding: 20px 40px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 0.8rem;
}

.result-box p { font-size: 1.2rem; margin: 10px 0; color: #ccddee; }
.result-box span { color: #ffcc44; font-weight: bold; }

/* ===== ランキング送信 ===== */
.ranking-submit {
  margin-bottom: 0.6rem;
}

.ranking-submit-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

#player-name-input {
  width: 160px;
  padding: 8px 12px;
  font-size: 1rem;
  color: #e0e4f0;
  background: rgba(10, 10, 30, 0.8);
  border: 1px solid rgba(100, 160, 255, 0.4);
  border-radius: 6px;
  outline: none;
  font-family: inherit;
}

#player-name-input:focus {
  border-color: rgba(100, 160, 255, 0.8);
  box-shadow: 0 0 8px rgba(100, 160, 255, 0.3);
}

#player-name-input::placeholder {
  color: rgba(150, 170, 200, 0.5);
}

.btn-small {
  padding: 8px 20px;
  font-size: 0.9rem;
}

#submit-status {
  font-size: 0.8rem;
  margin-top: 4px;
  min-height: 1.2em;
}

.submit-status-sending { color: #aaccff; }
.submit-status-info { color: #99aabb; }
.submit-status-success { color: #44ee88; }
.submit-status-error { color: #ff6655; }

/* ===== ランキング表示 ===== */
.ranking-board {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 10px 16px;
  margin-bottom: 0.8rem;
  text-align: left;
}

.ranking-title {
  font-size: 0.85rem;
  color: #ffcc44;
  letter-spacing: 0.15em;
  margin-bottom: 8px;
  text-align: center;
}

.ranking-row {
  display: flex;
  align-items: center;
  padding: 3px 0;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.ranking-row:last-child {
  border-bottom: none;
}

.ranking-rank {
  width: 28px;
  color: #8890a8;
  flex-shrink: 0;
}

.ranking-name {
  flex: 1;
  color: #ccddee;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-score {
  width: 70px;
  text-align: right;
  color: #ffcc44;
  font-weight: bold;
  flex-shrink: 0;
}

.ranking-wave {
  width: 36px;
  text-align: right;
  color: #8890a8;
  font-size: 0.75rem;
  flex-shrink: 0;
  margin-left: 8px;
}

/* ===== ダメージフラッシュ ===== */
.damage-flash { animation: damageFlash 0.3s ease-out; }

@keyframes damageFlash {
  0% { background-color: rgba(255, 0, 0, 0.3); }
  100% { background-color: transparent; }
}

/* ===== 被弾時ショックウェーブ（自機中心、赤〜オレンジ系） ===== */
.player-shockwave {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 80, 60, 0.8), rgba(255, 120, 40, 0.4), transparent);
  z-index: 25;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: playerShockwave 0.5s ease-out forwards;
}

@keyframes playerShockwave {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.7; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(10); }
}

/* ===== 無敵時間中の自機点滅 ===== */
#turret.invincible {
  animation: invincibleBlink 0.15s ease-in-out infinite alternate;
}

@keyframes invincibleBlink {
  0% { opacity: 1; }
  100% { opacity: 0.3; }
}
