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

body {
  background: #0a0a1a;
  color: #e0e0e0;
  font-family: 'Zen Maru Gothic', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

#game-wrapper {
  width: 100%;
  max-width: 500px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-title {
  font-family: 'DotGothic16', monospace;
  font-size: 28px;
  color: #b388ff;
  text-shadow: 0 0 20px rgba(179, 136, 255, 0.5);
  margin-top: 10px;
}

.game-subtitle {
  font-size: 14px;
  color: #7c6f9f;
  margin-bottom: 16px;
}

.hidden {
  display: none !important;
}

/* タイトル画面 */
#title-screen {
  text-align: center;
  margin-top: 30px;
}

#title-tower {
  font-size: 120px;
  animation: tower-float 3s ease-in-out infinite;
  filter: drop-shadow(0 0 30px rgba(179, 136, 255, 0.4));
}

@keyframes tower-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

#title-catchphrase {
  font-family: 'DotGothic16', monospace;
  font-size: 16px;
  color: #9c7cff;
  margin: 20px 0;
  text-shadow: 0 0 10px rgba(156, 124, 255, 0.3);
}

#highscore-display {
  font-family: 'DotGothic16', monospace;
  font-size: 14px;
  color: #ffd700;
  margin-bottom: 20px;
  min-height: 20px;
}

#start-btn, #retry-btn, #continue-btn {
  font-family: 'DotGothic16', monospace;
  font-size: 22px;
  padding: 14px 50px;
  background: linear-gradient(135deg, #7c4dff, #b388ff);
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(124, 77, 255, 0.4);
  display: block;
  margin: 0 auto;
}

#continue-btn {
  font-size: 18px;
  padding: 10px 40px;
  margin-top: 12px;
  background: linear-gradient(135deg, #2e7d32, #66bb6a);
  box-shadow: 0 4px 20px rgba(46, 125, 50, 0.4);
}

#start-btn:hover, #retry-btn:hover, #continue-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 30px rgba(124, 77, 255, 0.6);
}

#title-hint {
  font-size: 12px;
  color: #6a5f8a;
  margin-top: 20px;
  line-height: 1.8;
}

/* ゲーム画面 */
#game-screen {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#game-hud {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  font-family: 'DotGothic16', monospace;
  font-size: 14px;
  margin-bottom: 8px;
  width: 100%;
}

#game-hud > div {
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 10px;
  border-radius: 6px;
  transition: background 0.3s;
}

#game-hud > div.hud-flash {
  background: rgba(255, 215, 0, 0.35);
}

#hud-floor { color: #b388ff; }
#hud-hp { color: #ff6b6b; }
#hud-atk { color: #ffa726; }
#hud-def { color: #42a5f5; }
#hud-exp { color: #ffd700; }
#hud-coin { color: #ffab40; }

/* ステータスポップアップ */
#hud-popup {
  font-family: 'DotGothic16', monospace;
  font-size: 16px;
  color: #ffd700;
  text-align: center;
  min-height: 24px;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

#game-canvas {
  border: 2px solid rgba(179, 136, 255, 0.3);
  border-radius: 8px;
  background: #111122;
  image-rendering: pixelated;
  max-width: 100%;
  touch-action: none;
}

#game-log {
  font-family: 'DotGothic16', monospace;
  font-size: 12px;
  color: #a89cc8;
  width: 100%;
  min-height: 50px;
  max-height: 70px;
  overflow-y: auto;
  padding: 6px 10px;
  margin-top: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  line-height: 1.6;
}

.log-damage { color: #ff6b6b; }
.log-heal { color: #66bb6a; }
.log-item { color: #ffd700; }
.log-floor { color: #b388ff; }
.log-special { color: #ff80ab; }
.log-coin { color: #ffab40; }

/* モバイルコントロール */
#mobile-controls {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
}

.ctrl-row {
  display: flex;
  gap: 4px;
}

.ctrl-btn {
  width: 56px;
  height: 56px;
  font-size: 22px;
  background: rgba(179, 136, 255, 0.15);
  border: 1px solid rgba(179, 136, 255, 0.3);
  border-radius: 10px;
  color: #b388ff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.ctrl-btn:active {
  background: rgba(179, 136, 255, 0.35);
  transform: scale(0.92);
}

@media (pointer: coarse) {
  #mobile-controls {
    display: flex;
  }
}

@media (max-width: 420px) {
  #mobile-controls {
    display: flex;
  }
  .game-title { font-size: 22px; }
  #game-hud { font-size: 12px; gap: 6px; }
}

/* レベルアップ画面 */
#levelup-screen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#levelup-title {
  font-family: 'DotGothic16', monospace;
  font-size: 32px;
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
  margin-bottom: 24px;
  animation: levelup-pulse 0.6s ease-in-out infinite alternate;
}

@keyframes levelup-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

#levelup-choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 90%;
  max-width: 350px;
}

.levelup-btn {
  font-family: 'DotGothic16', monospace;
  font-size: 16px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 215, 0, 0.3);
  border-radius: 10px;
  color: #e0e0e0;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.levelup-btn:hover {
  background: rgba(255, 215, 0, 0.15);
  border-color: rgba(255, 215, 0, 0.6);
  transform: translateX(5px);
}

.levelup-btn .choice-name {
  color: #ffd700;
  font-size: 18px;
}

.levelup-btn .choice-desc {
  color: #a0a0a0;
  font-size: 13px;
  margin-top: 4px;
}

/* ガチャ画面 */
#gacha-screen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#gacha-title {
  font-family: 'DotGothic16', monospace;
  font-size: 28px;
  color: #ff80ab;
  text-shadow: 0 0 20px rgba(255, 128, 171, 0.4);
  margin-bottom: 12px;
}

#gacha-coins {
  font-family: 'DotGothic16', monospace;
  font-size: 18px;
  color: #ffab40;
  margin-bottom: 16px;
}

#gacha-machine {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, #2a1a4e, #1a0a2e);
  border: 3px solid rgba(255, 128, 171, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  position: relative;
}

#gacha-capsule {
  font-size: 60px;
  transition: transform 0.3s;
}

#gacha-machine.spinning #gacha-capsule {
  animation: gacha-spin 0.6s ease-out;
}

@keyframes gacha-spin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(360deg) scale(0.5); }
  100% { transform: rotate(720deg) scale(1); }
}

#gacha-result {
  text-align: center;
  margin-bottom: 16px;
  animation: gacha-reveal 0.4s ease-out;
}

@keyframes gacha-reveal {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

#gacha-result-rarity {
  font-family: 'DotGothic16', monospace;
  font-size: 14px;
  margin-bottom: 4px;
}

#gacha-result-emoji {
  font-size: 48px;
  margin-bottom: 4px;
}

#gacha-result-name {
  font-family: 'DotGothic16', monospace;
  font-size: 18px;
  color: #e0e0e0;
}

#gacha-result-desc {
  font-size: 13px;
  color: #a0a0a0;
  margin-top: 4px;
}

.rarity-common { color: #b0bec5; }
.rarity-rare { color: #42a5f5; }
.rarity-sr { color: #ffd700; }
.rarity-ssr { color: #ff80ab; text-shadow: 0 0 10px rgba(255, 128, 171, 0.5); }

#gacha-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.gacha-btn {
  font-family: 'DotGothic16', monospace;
  font-size: 18px;
  padding: 12px 36px;
  background: linear-gradient(135deg, #c2185b, #ff80ab);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(194, 24, 91, 0.4);
}

.gacha-btn:hover {
  transform: scale(1.05);
}

.gacha-btn:disabled {
  background: #333;
  color: #666;
  box-shadow: none;
  cursor: default;
  transform: none;
}

.gacha-btn--sub {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
  font-size: 15px;
  padding: 8px 30px;
}

.gacha-btn--sub:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ゲームオーバー画面 */
#gameover-screen {
  text-align: center;
  margin-top: 30px;
}

#gameover-title {
  font-family: 'DotGothic16', monospace;
  font-size: 32px;
  color: #ff6b6b;
  text-shadow: 0 0 20px rgba(255, 107, 107, 0.4);
  margin-bottom: 20px;
}

#gameover-stats {
  font-family: 'DotGothic16', monospace;
  font-size: 15px;
  color: #c0b8d8;
  line-height: 2;
  margin-bottom: 16px;
}

#gameover-epitaph {
  font-size: 14px;
  color: #9c7cff;
  font-style: italic;
  margin-bottom: 20px;
  padding: 0 20px;
}

/* 復活セクション */
#revive-section {
  margin-bottom: 24px;
}

#revive-label {
  font-family: 'DotGothic16', monospace;
  font-size: 18px;
  color: #ffd700;
  margin-bottom: 12px;
  animation: levelup-pulse 0.8s ease-in-out infinite alternate;
}

#revive-btn {
  font-family: 'DotGothic16', monospace;
  font-size: 18px;
  padding: 14px 32px;
  background: linear-gradient(135deg, #1a1a2e, #2a2a4e);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

#revive-btn:hover {
  transform: scale(1.05);
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.5);
}

.revive-x-icon {
  font-family: serif;
  font-weight: bold;
  font-size: 20px;
}

#revive-hint {
  font-size: 11px;
  color: #6a5f8a;
  margin-top: 8px;
}

#revive-section.used {
  display: none;
}

#retry-btn {
  font-size: 20px;
}

/* 戻るリンク */
.back-to-top-link {
  display: inline-block;
  margin-top: 20px;
  margin-bottom: 20px;
  padding: 8px 16px;
  font-size: 14px;
  color: #7c6f9f;
  text-decoration: none;
  border: 1px solid rgba(124, 111, 159, 0.3);
  border-radius: 8px;
  transition: all 0.2s;
}

.back-to-top-link:hover {
  color: #b388ff;
  border-color: rgba(179, 136, 255, 0.5);
}
