* { box-sizing: border-box; }
body {
  margin: 0;
  background-color: #05050a;
  color: #fff;
  font-family: 'Courier New', monospace;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-width: 800px;
  max-height: 600px;
  background: #000;
  border: 2px solid #33ff33;
  box-shadow: 0 0 30px rgba(48, 255, 48, 0.3);
}

.hidden { display: none !important; }

/* --- 📋 メニュー画面のデザイン --- */
#menu-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 20px;
}
.title {
  font-size: 2.5rem;
  color: #33ff33;
  text-shadow: 0 0 10px rgba(51,255,51,0.5);
  margin-bottom: 10px;
  text-align: center;
}
#trophy-room {
  color: #ffcc00;
  margin-bottom: 30px;
  font-size: 1.2rem;
  font-weight: bold;
}
.stage-buttons {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 80%;
}
.menu-btn {
  background: #111;
  border: 2px solid #33ff33;
  color: #33ff33;
  padding: 15px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s;
}
.menu-btn:hover:not(.locked) {
  background: #33ff33;
  color: #000;
  box-shadow: 0 0 15px #33ff33;
}
.menu-btn.locked {
  border-color: #444;
  color: #444;
  cursor: not-allowed;
}
.hint {
  margin-top: 20px;
  color: #888;
  font-size: 0.9rem;
  text-align: center;
}

/* --- 🕹️ ゲームプレイ画面のデザイン --- */
#play-screen {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}
#hud {
  display: flex;
  justify-content: space-between;
  padding: 10px 20px;
  background: #111;
  border-bottom: 1px solid #33ff33;
  color: #33ff33;
  font-weight: bold;
}

/* 縦長シューティング用のサイズ（全体の80%を占める広い戦場） */
canvas {
  flex-grow: 1;
  background: #000;
  width: 100%;
  height: 80%;
}

/* --- ⌨️ 数式入力とスマホボタン --- */
#ui-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: #111;
  border-top: 1px solid #33ff33;
}
#formula-input {
  background: #222;
  border: 1px solid #33ff33;
  color: #33ff33;
  padding: 8px;
  width: 60%;
  margin: 0 10px;
  font-size: 1rem;
}
#apply-btn {
  background: #33ff33;
  border: none;
  padding: 8px 15px;
  cursor: pointer;
  font-weight: bold;
  font-size: 1rem;
}
#touch-controls {
  display: flex;
  width: 100%;
  height: 70px;
}
.ctrl-btn {
  flex: 1;
  background: #151520;
  border: 1px solid #33ff33;
  color: #33ff33;
  font-size: 1.2rem;
  user-select: none;
  cursor: pointer;
}
.ctrl-btn:active {
  background: #33ff33;
  color: #000;
}

/* --- ✨ 華やかなクリア演出 --- */
#clear-overlay {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  animation: fadeIn 0.5s ease-out;
}
.clear-content {
  text-align: center;
  animation: scaleUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.clear-title {
  font-size: 3rem;
  color: #ff00ff;
  text-shadow: 0 0 20px #ff00ff, 0 0 40px #ff00ff;
  margin-bottom: 10px;
}
.clear-subtitle {
  color: #00ffff;
  font-size: 1.2rem;
  margin-bottom: 20px;
}
#next-stage-btn {
  background: #00ffff;
  border: none;
  padding: 12px 30px;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 0 15px #00ffff;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleUp { from { transform: scale(0.5); } to { transform: scale(1); } }