/* ==========================================================================
   Cyberpunk Space Shooting Typing Game - Stylesheet
   ========================================================================== */

:root {
  --bg-color: #080b14;
  --panel-bg: rgba(13, 20, 36, 0.85);
  --panel-border: rgba(0, 242, 254, 0.3);
  --primary-cyan: #00f2fe;
  --secondary-blue: #4facfe;
  --accent-magenta: #ff007f;
  --accent-gold: #ffd700;
  --accent-green: #00ff88;
  --danger-red: #ff3366;
  --text-main: #f0f6fc;
  --text-muted: #8b949e;
  --font-display: 'Rajdhani', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-japanese: 'Zen Kaku Gothic New', 'Noto Sans JP', 'Meiryo', sans-serif;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-display);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* --- 背景グリッド & グロー --- */
.bg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 50% 100%, rgba(0, 242, 254, 0.12) 0%, transparent 60%),
    radial-gradient(circle at 80% 20%, rgba(255, 0, 127, 0.08) 0%, transparent 40%),
    linear-gradient(rgba(8, 11, 20, 0.7) 1px, transparent 1px),
    linear-gradient(90deg, rgba(8, 11, 20, 0.7) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
  pointer-events: none;
  z-index: 1;
}

/* --- アプリケーション全体コンテナ --- */
#app-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-width: 1280px;
  max-height: 860px;
  background: rgba(10, 14, 26, 0.95);
  border: 1px solid var(--panel-border);
  box-shadow: 0 0 50px rgba(0, 242, 254, 0.2), inset 0 0 20px rgba(0, 242, 254, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 12px;
  z-index: 2;
}

/* --- トップHUDバー --- */
.hud-header {
  height: 64px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  backdrop-filter: blur(10px);
  z-index: 10;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 20px;
}

.hud-item {
  display: flex;
  flex-direction: column;
}

.hud-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--primary-cyan);
  text-transform: uppercase;
}

.hud-value {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 0 10px rgba(0, 242, 254, 0.5);
  font-variant-numeric: tabular-nums;
}

/* シールドゲージ */
.shield-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shield-bar-bg {
  width: 120px;
  height: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(0, 242, 254, 0.4);
}

.shield-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #00ff88, #00f2fe);
  box-shadow: 0 0 10px #00ff88;
  transition: width 0.3s ease, background 0.3s ease;
}

.shield-bar-fill.danger {
  background: linear-gradient(90deg, #ff0055, #ff3366);
  box-shadow: 0 0 12px #ff0055;
  animation: pulse-danger 0.8s infinite;
}

@keyframes pulse-danger {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* --- 英文組み立てターゲットエリア --- */
.sentence-board {
  background: rgba(13, 20, 36, 0.9);
  border-bottom: 1px solid rgba(0, 242, 254, 0.2);
  padding: 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
}

.sentence-translation {
  font-family: var(--font-japanese);
  font-size: 15px;
  color: var(--accent-gold);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sentence-category-tag {
  font-size: 11px;
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid var(--accent-gold);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--accent-gold);
  font-family: var(--font-display);
  font-weight: 700;
}

.sentence-slots {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.word-slot {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 未完成スロット */
.word-slot.empty {
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.3);
}

/* 現在撃つべきターゲットスロット */
.word-slot.current-target {
  background: rgba(0, 242, 254, 0.15);
  border: 1px solid var(--primary-cyan);
  color: var(--primary-cyan);
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.4);
  animation: slot-pulse 1.2s infinite;
  transform: scale(1.05);
}

@keyframes slot-pulse {
  0%, 100% { border-color: var(--primary-cyan); box-shadow: 0 0 10px rgba(0, 242, 254, 0.3); }
  50% { border-color: #fff; box-shadow: 0 0 20px rgba(0, 242, 254, 0.8); }
}

/* 完成済みスロット */
.word-slot.completed {
  background: linear-gradient(135deg, rgba(0, 255, 136, 0.2), rgba(0, 242, 254, 0.2));
  border: 1px solid var(--accent-green);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.4);
}

/* --- シューティングキャンバスエリア --- */
.game-viewport {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* --- コンボ表示ポップアップ --- */
.combo-display {
  position: absolute;
  top: 20px;
  right: 30px;
  pointer-events: none;
  text-align: right;
  z-index: 5;
  transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.combo-count {
  font-size: 38px;
  font-weight: 900;
  color: var(--accent-gold);
  text-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
  line-height: 1;
}

.combo-text {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #fff;
  text-transform: uppercase;
}

/* --- 画面オーバーレイ & モーダル --- */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(6, 10, 18, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.modal-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: 0 0 40px rgba(0, 242, 254, 0.25);
  border-radius: 12px;
  padding: 36px 40px;
  width: 90%;
  max-width: 600px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: modal-enter 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modal-enter {
  from { transform: scale(0.9) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-title {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #fff;
  text-shadow: 0 0 15px rgba(0, 242, 254, 0.6);
  text-transform: uppercase;
}

.modal-subtitle {
  font-family: var(--font-japanese);
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ボタン共通 */
.btn {
  background: linear-gradient(135deg, var(--primary-cyan), var(--secondary-blue));
  color: #060a12;
  border: none;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 12px 28px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.4);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(0, 242, 254, 0.7);
  background: linear-gradient(135deg, #fff, var(--primary-cyan));
}

.btn:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

/* カテゴリ選択ボタングリッド */
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin: 10px 0;
}

.category-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(0, 242, 254, 0.2);
  border-radius: 8px;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.category-btn:hover, .category-btn.active {
  background: rgba(0, 242, 254, 0.12);
  border-color: var(--primary-cyan);
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.3);
  transform: translateY(-2px);
}

.category-btn-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.category-btn-desc {
  font-family: var(--font-japanese);
  font-size: 12px;
  color: var(--text-muted);
}

/* リザルト統計 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 10px 0;
}

.stat-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 12px;
}

.stat-box-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-box-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-gold);
  margin-top: 4px;
}

/* リザルト英文復習カード */
.review-card {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(0, 242, 254, 0.2);
  border-radius: 8px;
  padding: 14px;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.review-english {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary-cyan);
}

.review-japanese {
  font-family: var(--font-japanese);
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* カスタムテキストエリア */
.custom-textarea {
  width: 100%;
  height: 140px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 242, 254, 0.3);
  border-radius: 8px;
  padding: 12px;
  color: #fff;
  font-family: var(--font-japanese);
  font-size: 14px;
  resize: none;
  outline: none;
}

.custom-textarea:focus {
  border-color: var(--primary-cyan);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.4);
}

/* 難易度設定スイッチ */
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--font-japanese);
  font-size: 14px;
}

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

select {
  background: #0d1424;
  color: #fff;
  border: 1px solid var(--panel-border);
  padding: 6px 12px;
  border-radius: 4px;
  outline: none;
  font-family: var(--font-display);
  font-size: 14px;
}

/* レスポンシブ調整 */
@media (max-width: 768px) {
  .hud-header {
    padding: 0 12px;
  }
  .hud-value {
    font-size: 16px;
  }
  .shield-bar-bg {
    width: 80px;
  }
  .category-grid {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================================================
   無料サーバー（XREA等）広告対応レイアウト自動調整
   ========================================================================== */

/* 広告要素（#vdbanner）自体のコンテナスタイル */
#vdbanner {
  position: relative;
  z-index: 999;
  width: 100%;
  text-align: center;
  background: rgba(8, 11, 20, 0.95);
  margin: 0 auto;
}

/* 広告要素が存在する場合のbody調整 */
body:has(#vdbanner) {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  height: 100vh;
  overflow-y: auto;
}

/* 広告要素が存在する場合のみ、固定ヘッダーの初期位置を広告の高さ分ずらす */
body:has(#vdbanner) header {
    top: 80px; /* 広告のバナー高さ＋余白を考慮した適切な値を設定 */
}

/* 画面スクロール時は、広告を無視して画面最上部に追従固定させる */
body:has(#vdbanner) header.scrolled {
    top: 0;
}

/* 広告の表示によりファーストビュー（Heroエリア）が画面外に押し出されないよう高さを補正 */
body:has(#vdbanner) #hero {
    height: calc(100vh - 80px);
}

/* アプリケーション全体コンテナの高さ補正 */
body:has(#vdbanner) #app-container {
    height: calc(100vh - 80px);
    max-height: calc(100vh - 80px);
}

@media (max-width: 768px) {
    /* スマホ用ナビゲーションメニュー（ドロワー）等がある場合も、広告を考慮した位置調整を行う */
    body:has(#vdbanner) .nav-menu {
        top: 150px; /* ヘッダー高 70px + 広告高 80px */
        height: calc(100vh - 150px);
    }
    body:has(#vdbanner) header.scrolled .nav-menu {
        top: 60px; /* スクロール時は通常位置に補正 */
        height: calc(100vh - 60px);
    }

    body:has(#vdbanner) #app-container {
        height: calc(100vh - 80px);
    }
}

