/* CSS Reset & Variables */
:root {
  --color-bg: #03030c;
  --color-primary: #00f0ff; /* シアン */
  --color-secondary: #ff007c; /* ピンク/マゼンタ */
  --color-accent: #39ff14; /* ネオングリーン */
  --color-text: #e0e6ed;
  --color-panel: rgba(10, 10, 25, 0.85);
  --font-title: 'Orbitron', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;
  --glow-primary: 0 0 10px rgba(0, 240, 255, 0.6), 0 0 20px rgba(0, 240, 255, 0.3);
  --glow-secondary: 0 0 10px rgba(255, 0, 124, 0.6), 0 0 20px rgba(255, 0, 124, 0.3);
  --glow-accent: 0 0 10px rgba(57, 255, 20, 0.6);
}

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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--color-bg);
  font-family: var(--font-title);
  color: var(--color-text);
  display: flex;
  justify-content: center;
  align-items: center;
}

/* アスペクト比を固定したコンテナ (縦画面向け) */
#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-width: 56.25vh; /* 9:16 ratio (1080x1920) */
  background-color: #000;
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.15);
  overflow: hidden;
}

@media (min-aspect-ratio: 9/16) {
  #game-container {
    /* 横長画面の場合、高さを基準に幅を狭める */
    width: calc(100vh * (9/16));
    height: 100vh;
  }
}

@media (max-aspect-ratio: 9/16) {
  #game-container {
    /* 縦長画面の場合、幅を基準に高さを狭める */
    width: 100vw;
    height: calc(100vw * (16/9));
  }
}

/* Canvas Styling */
#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: block;
}

/* Common UI Screen Styling */
.ui-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  background-color: rgba(3, 3, 12, 0.4);
  transition: opacity 0.4s ease, visibility 0.4s ease;
  backdrop-filter: blur(4px);
}

.ui-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.ui-screen.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Buttons */
.glow-button {
  width: 240px;
  padding: 12px 24px;
  margin: 10px 0;
  background: rgba(0, 240, 255, 0.08);
  border: 2px solid var(--color-primary);
  border-radius: 4px;
  color: var(--color-primary);
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  outline: none;
  transition: all 0.3s ease;
  text-shadow: var(--glow-primary);
  box-shadow: inset 0 0 10px rgba(0, 240, 255, 0.1);
}

.glow-button:hover {
  background: var(--color-primary);
  color: var(--color-bg);
  box-shadow: var(--glow-primary);
  text-shadow: none;
  transform: translateY(-2px);
}

.glow-button:active {
  transform: translateY(0);
}

.glow-button.secondary {
  border-color: var(--color-secondary);
  color: var(--color-secondary);
  background: rgba(255, 0, 124, 0.08);
  text-shadow: var(--glow-secondary);
  box-shadow: inset 0 0 10px rgba(255, 0, 124, 0.1);
}

.glow-button.secondary:hover {
  background: var(--color-secondary);
  color: var(--color-bg);
  box-shadow: var(--glow-secondary);
  text-shadow: none;
}

/* Title Screen */
.menu-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.title-logo {
  text-align: center;
  margin-bottom: 3rem;
}

.title-logo h1 {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 0 10px var(--color-primary), 0 0 30px var(--color-primary);
  margin-bottom: 0.5rem;
}

.title-logo .subtitle {
  font-size: 1rem;
  letter-spacing: 8px;
  color: var(--color-secondary);
  text-shadow: var(--glow-secondary);
  font-weight: 700;
}

.footer-info {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 1px;
}

/* Guide Screen */
#guide-screen h2 {
  font-size: 2rem;
  color: var(--color-primary);
  margin-bottom: 2rem;
  text-shadow: var(--glow-primary);
}

.guide-content {
  width: 100%;
  max-width: 400px;
  background: var(--color-panel);
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  font-family: var(--font-mono);
}

.guide-section {
  margin-bottom: 1.5rem;
}

.guide-section:last-child {
  margin-bottom: 0;
}

.guide-section h3 {
  font-family: var(--font-title);
  color: var(--color-secondary);
  font-size: 0.9rem;
  letter-spacing: 1px;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 0, 124, 0.3);
  padding-bottom: 4px;
}

.guide-section p {
  font-size: 0.8rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 0.3rem;
}

.item-badge {
  display: inline-block;
  width: 18px;
  height: 18px;
  line-height: 16px;
  text-align: center;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: bold;
  font-family: var(--font-title);
  margin-right: 5px;
}

.item-badge.power {
  background-color: var(--color-secondary);
  color: #fff;
  box-shadow: var(--glow-secondary);
}

.item-badge.shield {
  background-color: var(--color-primary);
  color: #000;
  box-shadow: var(--glow-primary);
}

.item-badge.bomb {
  background-color: var(--color-accent);
  color: #000;
  box-shadow: var(--glow-accent);
}

/* HUD Overlay */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  background-color: transparent;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem;
  backdrop-filter: none;
}

.hud-top, .hud-bottom {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
}

.hud-item {
  display: flex;
  flex-direction: column;
  background: rgba(10, 10, 25, 0.6);
  padding: 6px 12px;
  border-left: 3px solid var(--color-primary);
  border-radius: 0 4px 4px 0;
}

.hud-label {
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.hud-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-primary);
  text-shadow: var(--glow-primary);
}

.hud-status-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 60%;
}

.hud-bar-container {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.hud-bar-label {
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 1px;
}

.hud-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.hud-bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 4px;
  transition: width 0.2s ease-out;
}

.hud-bar-fill.shield-fill {
  background: linear-gradient(90deg, #0099ff, var(--color-primary));
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
}

.hud-bar-fill.energy-fill {
  background: linear-gradient(90deg, #32cd32, var(--color-accent));
  box-shadow: 0 0 8px rgba(57, 255, 20, 0.5);
}

.hud-bombs {
  background: rgba(10, 10, 25, 0.6);
  padding: 6px 12px;
  border-right: 3px solid var(--color-secondary);
  border-radius: 4px 0 0 4px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* Pause & GameOver & Clear Screens */
#pause-screen h2, #gameover-screen h2, #clear-screen h2 {
  font-size: 2rem;
  letter-spacing: 2px;
  margin-bottom: 1rem;
}

#pause-screen h2 {
  color: var(--color-primary);
  text-shadow: var(--glow-primary);
}

.alert-text {
  color: var(--color-secondary);
  text-shadow: var(--glow-secondary);
}

.clear-text {
  color: var(--color-accent);
  text-shadow: var(--glow-accent);
}

.summary-text {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 2rem;
  text-align: center;
}

.stats-panel {
  width: 100%;
  max-width: 300px;
  background: var(--color-panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 1.2rem;
  margin-bottom: 2rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.stat-row:last-child {
  margin-bottom: 0;
}

/* Mobile Bomb Button */
#mobile-bomb-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 0, 124, 0.15);
  border: 2px solid var(--color-secondary);
  color: var(--color-secondary);
  font-family: var(--font-title);
  font-weight: bold;
  font-size: 0.8rem;
  z-index: 8;
  cursor: pointer;
  outline: none;
  box-shadow: var(--glow-secondary);
  text-shadow: var(--glow-secondary);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.1s ease;
}

#mobile-bomb-btn:active {
  transform: scale(0.9);
  background: var(--color-secondary);
  color: var(--color-bg);
}

/* Glitch Animation Effect */
.glitch-text {
  position: relative;
}

.glitch-text::before,
.glitch-text::after {
  content: 'AEGIS COSMOS';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-bg);
}

.glitch-text::before {
  left: 2px;
  text-shadow: -2px 0 var(--color-secondary);
  clip: rect(44px, 450px, 56px, 0);
  animation: glitch-anim 5s infinite linear alternate-reverse;
}

.glitch-text::after {
  left: -2px;
  text-shadow: -2px 0 var(--color-primary), 0 2px var(--color-primary);
  clip: rect(85px, 450px, 140px, 0);
  animation: glitch-anim2 5s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
  0% { clip: rect(31px, 9999px, 94px, 0); }
  10% { clip: rect(112px, 9999px, 76px, 0); }
  20% { clip: rect(85px, 9999px, 5px, 0); }
  30% { clip: rect(27px, 9999px, 115px, 0); }
  40% { clip: rect(73px, 9999px, 29px, 0); }
  50% { clip: rect(118px, 9999px, 137px, 0); }
  60% { clip: rect(9px, 9999px, 53px, 0); }
  70% { clip: rect(104px, 9999px, 82px, 0); }
  80% { clip: rect(50px, 9999px, 120px, 0); }
  90% { clip: rect(13px, 9999px, 41px, 0); }
  100% { clip: rect(88px, 9999px, 66px, 0); }
}

@keyframes glitch-anim2 {
  0% { clip: rect(76px, 9999px, 116px, 0); }
  11% { clip: rect(43px, 9999px, 6px, 0); }
  22% { clip: rect(122px, 9999px, 88px, 0); }
  33% { clip: rect(5px, 9999px, 110px, 0); }
  44% { clip: rect(89px, 9999px, 32px, 0); }
  55% { clip: rect(131px, 9999px, 145px, 0); }
  66% { clip: rect(56px, 9999px, 70px, 0); }
  77% { clip: rect(102px, 9999px, 13px, 0); }
  88% { clip: rect(18px, 9999px, 99px, 0); }
  100% { clip: rect(94px, 9999px, 125px, 0); }
}
