/* ============================================================
   MONSTER CITY — Style Sheet
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Rajdhani:wght@500;700&display=swap');

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

:root {
  --orange:  #ff6a00;
  --red:     #cc1a1a;
  --gold:    #ffd54f;
  --dark:    #0d0d0f;
  --panel:   rgba(10,10,14,0.88);
  --green:   #39ff14;
  --blue:    #00c8ff;
  --purple:  #9b59f7;
  --hp-green:#2ecc71;
  --hp-red:  #e74c3c;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Rajdhani', 'Arial Narrow', Arial, sans-serif;
  color: #fff;
}

/* ── CONTAINER ─────────────────────────────────────────────── */
#game-container {
  position: relative;
  width: 100vw; height: 100vh;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  image-rendering: pixelated;
}

/* ── SCREENS ───────────────────────────────────────────────── */
.screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
}
.screen.active, .screen.visible {
  opacity: 1; pointer-events: all;
}
.screen.hidden { display: none !important; }

/* ── START SCREEN ──────────────────────────────────────────── */
#start-screen { background: radial-gradient(ellipse at 50% 60%, #1a0a00 0%, #000 100%); }

.bg-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
}

.start-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column;
  align-items: center; gap: 28px;
  padding: 20px;
}

.title-block { text-align: center; }

.title-crack-wrap {
  position: relative; display: inline-block;
}

.game-title {
  font-family: 'Bebas Neue', 'Impact', sans-serif;
  font-size: clamp(56px, 10vw, 120px);
  line-height: .9;
  letter-spacing: 6px;
  background: linear-gradient(180deg, #fff 0%, #ff9a00 40%, #cc2200 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 0 24px rgba(255,100,0,.8));
  animation: titlePulse 3s ease-in-out infinite;
}
@keyframes titlePulse {
  0%,100% { filter: drop-shadow(0 0 24px rgba(255,100,0,.8)); }
  50%      { filter: drop-shadow(0 0 48px rgba(255,60,0,1)); }
}

.city-text {
  font-size: 1.15em;
  background: linear-gradient(180deg, #ffdd00 0%, #ff6600 60%, #aa1100 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: clamp(14px, 2vw, 22px);
  letter-spacing: 10px;
  color: #ff9a00;
  margin-top: 4px;
  opacity: .85;
}

/* ── FACTION SELECT ────────────────────────────────────────── */
.faction-select {
  display: flex; align-items: center; gap: 24px;
  flex-wrap: wrap; justify-content: center;
}

.faction-card {
  background: var(--panel);
  border: 2px solid #333;
  border-radius: 12px;
  padding: 14px 20px;
  width: 200px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, transform .2s, box-shadow .2s;
  position: relative; overflow: hidden;
}
.faction-card::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(255,120,0,.12), transparent 70%);
  pointer-events: none;
}
.faction-card:hover, .faction-card.selected {
  border-color: var(--orange);
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 0 24px rgba(255,100,0,.5);
}
.faction-card.selected { border-color: var(--gold); }

.faction-card canvas { display: block; margin: 0 auto 8px; border-radius: 6px; }

.faction-label {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 20px; letter-spacing: 3px;
  color: var(--orange);
}
.faction-desc { font-size: 11px; color: #aaa; margin: 4px 0; line-height: 1.3; }
.faction-key {
  display: inline-block; margin-top: 6px;
  background: var(--orange); color: #000;
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 12px; letter-spacing: 2px;
  padding: 2px 10px; border-radius: 3px;
}
.faction-vs {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 40px; color: #ff3300;
  text-shadow: 0 0 20px #ff3300;
  animation: vsPulse 1.5s ease-in-out infinite;
}
@keyframes vsPulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.15); }
}

.high-score-display {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 18px; letter-spacing: 4px;
  color: var(--gold); text-shadow: 0 0 10px var(--gold);
  min-height: 24px;
}

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn-start {
  background: linear-gradient(135deg, #ff6a00, #ee0979);
  border: none; border-radius: 8px;
  color: #fff; font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 22px; letter-spacing: 4px;
  padding: 12px 40px; cursor: pointer;
  box-shadow: 0 0 20px rgba(255,80,0,.5);
  transition: transform .15s, box-shadow .15s;
}
.btn-start:hover { transform: scale(1.05); box-shadow: 0 0 32px rgba(255,80,0,.9); }

.btn-back {
  background: rgba(255,255,255,.08);
  border: 1px solid #444; border-radius: 8px;
  color: #aaa; font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 18px; letter-spacing: 3px;
  padding: 10px 28px; cursor: pointer;
  transition: border-color .2s, color .2s;
}
.btn-back:hover { border-color: #888; color: #fff; }

.btn-menu {
  display: block; width: 220px; margin: 8px auto;
  background: rgba(255,255,255,.07);
  border: 1px solid #555; border-radius: 8px;
  color: #ddd; font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 20px; letter-spacing: 3px;
  padding: 12px; cursor: pointer;
  transition: background .2s, border-color .2s;
}
.btn-menu:hover { background: rgba(255,100,0,.18); border-color: var(--orange); }

.btn-pause {
  background: rgba(0,0,0,.4);
  border: 1px solid #444; border-radius: 6px;
  color: #fff; font-size: 16px;
  padding: 6px 10px; cursor: pointer;
  transition: background .2s;
}
.btn-pause:hover { background: rgba(255,100,0,.3); }

.btn-sound-toggle {
  background: rgba(255,255,255,.07);
  border: 1px solid #444; border-radius: 6px;
  color: #bbb; font-family: 'Rajdhani', Arial, sans-serif;
  font-size: 13px; padding: 6px 14px;
  cursor: pointer; transition: .2s;
}
.btn-sound-toggle:hover { border-color: #888; color: #fff; }

/* ── SELECT SCREEN ─────────────────────────────────────────── */
#select-screen {
  background: radial-gradient(ellipse at 50% 40%, #0d0518 0%, #000 100%);
}
.select-content {
  display: flex; flex-direction: column;
  align-items: center; gap: 24px;
  padding: 20px; width: 100%;
}
.select-title {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: clamp(28px, 5vw, 48px); letter-spacing: 6px;
  color: var(--orange);
}
.unit-cards {
  display: flex; gap: 20px; flex-wrap: wrap;
  justify-content: center;
}
.unit-card {
  background: var(--panel);
  border: 2px solid #333; border-radius: 12px;
  padding: 16px; width: 180px; text-align: center;
  cursor: pointer; transition: .2s;
}
.unit-card:hover, .unit-card.selected {
  border-color: var(--orange);
  box-shadow: 0 0 20px rgba(255,100,0,.4);
  transform: translateY(-4px);
}
.unit-card canvas { display: block; margin: 0 auto 10px; border-radius: 6px; }
.unit-card-name {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 20px; letter-spacing: 3px; color: var(--gold);
}
.unit-card-role { font-size: 11px; color: #aaa; margin: 3px 0; }
.unit-card-ability { font-size: 10px; color: #777; line-height: 1.4; }

.select-actions { display: flex; gap: 16px; }

/* ── HUD ────────────────────────────────────────────────────── */
.hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 12px 16px; z-index: 50;
  background: linear-gradient(to bottom, rgba(0,0,0,.7) 0%, transparent 100%);
  pointer-events: none;
}
.hud.hidden { display: none; }

.hud-left, .hud-center, .hud-right {
  display: flex; flex-direction: column; gap: 6px;
}
.hud-center { align-items: center; }
.hud-right  { align-items: flex-end; pointer-events: all; }

.hud-label {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 12px; letter-spacing: 2px; color: #aaa;
}

.hud-hp {
  display: flex; align-items: center; gap: 8px;
}
.hp-bar-bg {
  width: 140px; height: 14px;
  background: rgba(255,255,255,.1);
  border-radius: 7px; overflow: hidden;
  border: 1px solid #333;
}
.hp-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--hp-green), #27ae60);
  transition: width .3s, background .3s;
  border-radius: 7px;
}
.hud-val {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 16px; color: #fff; min-width: 28px;
}

.hud-coins {
  display: flex; align-items: center; gap: 4px;
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 18px; color: var(--gold);
  text-shadow: 0 0 8px var(--gold);
}
.hud-coins.hidden { display: none; }

.wave-indicator {
  display: flex; align-items: baseline; gap: 6px;
  font-family: 'Bebas Neue', Impact, sans-serif;
}
.wave-num {
  font-size: 36px; color: #fff;
  text-shadow: 0 0 16px rgba(255,150,0,.8);
}

.score-display {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 18px; letter-spacing: 3px;
  color: var(--gold); text-shadow: 0 0 8px rgba(255,200,0,.5);
}

.ability-bar {
  display: flex; gap: 6px;
}
.ability-slot {
  position: relative;
  width: 42px; height: 42px;
  background: rgba(0,0,0,.6);
  border: 2px solid #444; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.ab-key {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 18px; color: #fff; z-index: 1;
  position: relative;
}
.ab-cd {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 0; background: rgba(0,150,255,.4);
  transition: height .1s;
}

/* ── COMBO POPUP ───────────────────────────────────────────── */
.combo-popup {
  position: absolute;
  top: 30%; left: 50%; transform: translateX(-50%);
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: clamp(24px, 4vw, 42px);
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 0 20px var(--orange), 2px 2px 0 rgba(0,0,0,.8);
  pointer-events: none; z-index: 200;
  animation: comboPop .6s ease-out forwards;
}
.combo-popup.hidden { display: none; }
@keyframes comboPop {
  0%   { transform: translateX(-50%) scale(.6); opacity: 1; }
  60%  { transform: translateX(-50%) scale(1.1); opacity: 1; }
  100% { transform: translateX(-50%) scale(1) translateY(-30px); opacity: 0; }
}

/* ── WAVE TRANSITION ───────────────────────────────────────── */
.wave-transition {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 150;
}
.wave-transition.hidden { display: none; }
.wave-trans-inner { text-align: center; }
.wave-trans-title {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: clamp(36px, 7vw, 72px);
  letter-spacing: 6px;
  background: linear-gradient(135deg, #ff6a00, #ee0979);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: slideDown .4s ease-out;
}
@keyframes slideDown {
  from { transform: translateY(-40px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}
.wave-trans-sub {
  font-family: 'Rajdhani', Arial, sans-serif;
  font-size: 18px; color: #ccc; margin: 8px 0 20px;
  letter-spacing: 2px;
}
.wave-enemy-preview {
  display: flex; justify-content: center; gap: 12px; margin-bottom: 20px;
  font-size: 40px;
}
.wave-trans-bar {
  width: 300px; height: 6px;
  background: #222; border-radius: 3px; overflow: hidden;
  margin: 0 auto;
}
.wave-trans-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--orange), var(--red));
  border-radius: 3px;
  animation: waveProgress 3s linear forwards;
}
@keyframes waveProgress {
  from { width: 0; } to { width: 100%; }
}

/* ── BOSS ALERT ────────────────────────────────────────────── */
.boss-alert {
  position: absolute; top: 20%; left: 50%;
  transform: translateX(-50%);
  z-index: 200; pointer-events: none;
  animation: bossAlert 2s ease-out forwards;
}
.boss-alert.hidden { display: none; }
.boss-alert-text {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: clamp(32px, 6vw, 64px);
  letter-spacing: 6px;
  color: #ff0000;
  text-shadow: 0 0 30px #ff0000, 0 0 60px rgba(255,0,0,.5);
}
@keyframes bossAlert {
  0%   { opacity: 0; transform: translateX(-50%) scale(.7); }
  15%  { opacity: 1; transform: translateX(-50%) scale(1.05); }
  80%  { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) scale(1); }
}

/* ── PAUSE / GAME OVER ─────────────────────────────────────── */
#pauseScreen, #gameOverScreen {
  background: rgba(0,0,0,.85);
  backdrop-filter: blur(4px);
}
.pause-content, .gameover-content {
  text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: 16px;
}
.pause-content h2, .gameover-content h2 {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: clamp(36px, 6vw, 64px);
  letter-spacing: 6px;
}
.go-title {
  background: linear-gradient(180deg, #fff, #ff4400);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.go-score-block {
  background: rgba(255,255,255,.06);
  border: 1px solid #333; border-radius: 10px;
  padding: 16px 32px; min-width: 260px;
}
.go-row {
  display: flex; justify-content: space-between;
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 20px; letter-spacing: 2px;
  padding: 4px 0; border-bottom: 1px solid #222;
  color: #ccc;
}
.go-row:last-child { border-bottom: none; }
.go-best { color: var(--gold); }

/* ── MOBILE CONTROLS ───────────────────────────────────────── */
.mobile-controls {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 180px; z-index: 80;
  display: flex; justify-content: space-between;
  align-items: flex-end; padding: 0 16px 16px;
  pointer-events: none;
}
.mobile-controls.hidden { display: none; }

.joystick-zone {
  width: 130px; height: 130px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: all;
}
.joystick-base {
  width: 110px; height: 110px;
  background: rgba(255,255,255,.08);
  border: 2px solid rgba(255,255,255,.2);
  border-radius: 50%;
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.joystick-knob {
  width: 48px; height: 48px;
  background: radial-gradient(circle, rgba(255,150,0,.8), rgba(255,80,0,.6));
  border: 2px solid rgba(255,200,0,.5);
  border-radius: 50%;
  position: absolute;
  transition: none;
}

.mobile-right {
  display: flex; flex-direction: column;
  align-items: flex-end; gap: 10px;
  pointer-events: all;
}
.mob-abilities { display: flex; gap: 8px; }

.mob-btn {
  background: rgba(0,0,0,.6);
  border: 2px solid #555; border-radius: 50%;
  color: #fff; font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 13px; letter-spacing: 1px;
  cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: center;
  touch-action: none; -webkit-tap-highlight-color: transparent;
  transition: background .1s;
}
.mob-btn:active { background: rgba(255,100,0,.5); }
.mob-fire {
  width: 80px; height: 80px;
  background: rgba(220,40,0,.7);
  border-color: #ff6a00;
  font-size: 15px;
}
.mob-q, .mob-e, .mob-b, .mob-t {
  width: 48px; height: 48px;
  font-size: 15px;
}

/* ── SHAKE ANIMATION ───────────────────────────────────────── */
@keyframes screenShake {
  0%,100% { transform: translate(0,0); }
  20%      { transform: translate(-6px, 3px); }
  40%      { transform: translate(6px, -3px); }
  60%      { transform: translate(-4px, -4px); }
  80%      { transform: translate(4px, 2px); }
}
.shake { animation: screenShake .25s ease-out; }

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 600px) {
  .faction-card { width: 155px; padding: 10px 12px; }
  .faction-card canvas { width: 140px; height: 110px; }
  .hud { padding: 8px; }
  .hp-bar-bg { width: 100px; }
  .unit-card { width: 145px; }
}
