* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d1117;
  color: #e6edf3;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen.active { display: flex; }

/* MENU */
#menu-screen {
  background: radial-gradient(ellipse at center, #1f2937 0%, #0d1117 70%);
}
.title { text-align: center; margin-bottom: 40px; }
.title h1 {
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px rgba(239, 68, 68, 0.3);
}
.title p { color: #94a3b8; margin-top: 8px; font-size: 14px; letter-spacing: 4px; }

.big-btn {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: white;
  border: none;
  border-radius: 16px;
  padding: 18px 60px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
  transition: transform 0.1s;
}
.big-btn:active { transform: scale(0.95); }
.big-btn:disabled {
  background: #374151;
  box-shadow: none;
  color: #6b7280;
}
.small-btn {
  background: transparent;
  color: #94a3b8;
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 10px 22px;
  font-size: 14px;
  cursor: pointer;
  margin-top: 16px;
}
.hint { margin-top: 20px; color: #6b7280; font-size: 12px; }

/* SELECT */
#select-screen { background: #0d1117; }
#select-screen h2 {
  font-size: 22px;
  margin-bottom: 24px;
  letter-spacing: 3px;
  color: #f59e0b;
}
.section-label {
  font-size: 14px;
  color: #94a3b8;
  letter-spacing: 4px;
  margin: 8px 0 12px;
}
#difficulty-list {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}
.diff-btn {
  background: #1f2937;
  color: #94a3b8;
  border: 2px solid #374151;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.15s;
}
.diff-btn:active { transform: scale(0.95); }
.diff-btn[data-diff="easy"].selected { background: #064e3b; color: #34d399; border-color: #10b981; }
.diff-btn[data-diff="normal"].selected { background: #78350f; color: #fbbf24; border-color: #f59e0b; }
.diff-btn[data-diff="hard"].selected { background: #7f1d1d; color: #fca5a5; border-color: #ef4444; }
#character-list {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 95vw;
}
.char-card {
  background: #1f2937;
  border: 3px solid transparent;
  border-radius: 14px;
  padding: 14px;
  width: 110px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}
.char-card.selected {
  border-color: #f59e0b;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.4);
  transform: translateY(-4px);
}
.char-avatar {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 900;
  color: white;
}
.char-name { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.char-role { font-size: 10px; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; }
.char-stats { display: flex; justify-content: space-around; margin-top: 8px; font-size: 9px; color: #6b7280; }

/* GAME */
#game-screen { background: #0b1220; padding: 0; }
#game-canvas-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#game-canvas-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.loading-screen {
  position: absolute;
  inset: 0;
  background: rgba(13, 17, 23, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  color: #94a3b8;
  font-size: 14px;
  letter-spacing: 2px;
}
.loading-screen.hidden { display: none; }
.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: #f59e0b;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

#hud {
  position: absolute;
  top: env(safe-area-inset-top);
  left: 0;
  right: 0;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}
#score {
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
}
#score .label { color: #94a3b8; margin-right: 6px; }
#score #enemies-left { color: #f59e0b; font-weight: 800; }

#hp-wrap {
  flex: 1;
  max-width: 220px;
  margin: 0 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}
#hp-bar {
  height: 14px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
#hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #10b981, #34d399);
  transition: width 0.2s;
}
#hp-fill.low { background: linear-gradient(90deg, #ef4444, #f87171); }
#hp-fill.mid { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

#ammo-bar {
  display: flex;
  gap: 3px;
  justify-content: flex-end;
  height: 8px;
}
.ammo-dot {
  flex: 1;
  height: 100%;
  max-width: 18px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  transition: background 0.15s;
}
.ammo-dot.full {
  background: linear-gradient(180deg, #fde047, #f59e0b);
  border-color: #fbbf24;
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.5);
}

#reload-bar {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 6px;
  height: 14px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 6px;
  overflow: hidden;
  display: none;
  font-size: 9px;
  letter-spacing: 2px;
  color: white;
  text-align: center;
  line-height: 14px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
#reload-bar.active { display: block; }
#reload-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}
#reload-bar span { position: relative; z-index: 1; }

#pause-btn {
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
  pointer-events: auto;
  cursor: pointer;
}

.stick {
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.12);
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 5;
  touch-action: none;
}
#left-stick { left: 20px; }
#right-stick { right: 20px; }

.stick-knob {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.5);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: background 0.1s;
}
#right-stick .stick-knob { background: rgba(239, 68, 68, 0.3); border-color: rgba(239, 68, 68, 0.7); }
.stick.active .stick-knob { background: rgba(245, 158, 11, 0.6); }
#right-stick.active .stick-knob { background: rgba(239, 68, 68, 0.7); }

/* END */
#end-screen { background: rgba(13, 17, 23, 0.95); }
#end-title {
  font-size: 48px;
  font-weight: 900;
  letter-spacing: 4px;
  margin-bottom: 20px;
}
#end-title.win {
  background: linear-gradient(135deg, #10b981, #34d399);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#end-title.lose {
  background: linear-gradient(135deg, #ef4444, #f87171);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#end-stats { color: #94a3b8; margin-bottom: 30px; text-align: center; }

@media (max-width: 380px) {
  .stick { width: 120px; height: 120px; }
  .stick-knob { width: 50px; height: 50px; }
  .title h1 { font-size: 36px; }
}
