:root {
  --bg-dark: #1a1c2c;
  --bg-mid: #2b2f4a;
  --accent: #ff4d6d;
  --accent2: #ffd166;
  --green: #4ade80;
  --panel: rgba(20, 22, 40, 0.85);
  --text: #f5f5f7;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(160deg, #1a1c2c 0%, #2b2f4a 55%, #3d2b4a 100%);
  color: var(--text);
  font-family: 'M PLUS Rounded 1c', sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

/* ---------- Header ---------- */
#game-header {
  text-align: center;
  padding: 10px 10px 4px;
  flex-shrink: 0;
}

#game-title {
  font-family: 'Bangers', 'M PLUS Rounded 1c', sans-serif;
  font-size: clamp(24px, 5vw, 34px);
  letter-spacing: 2px;
  margin: 0;
  color: var(--accent2);
  text-shadow: 2px 2px 0 rgba(0,0,0,0.4);
}

#game-title i {
  color: var(--accent);
  margin-right: 6px;
}

#game-subtitle {
  margin: 4px 0 0;
  font-size: clamp(11px, 2.5vw, 14px);
  opacity: 0.75;
}

/* ---------- HUD ---------- */
#hud {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  flex-wrap: wrap;
  justify-content: center;
  flex-shrink: 0;
}

#hp-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  padding: 6px 12px;
  border-radius: 20px;
  border: 2px solid rgba(255,255,255,0.08);
}

#hp-label {
  font-weight: 900;
  font-size: 13px;
  color: var(--accent2);
}

#hp-bar-bg {
  width: 140px;
  height: 14px;
  background: #12131f;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.15);
}

#hp-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #4ade80, #a3e635);
  border-radius: 10px;
  transition: width 0.25s ease, background 0.25s ease;
}

#hp-value {
  font-size: 13px;
  font-weight: 700;
  min-width: 28px;
  text-align: right;
}

#stat-wrap {
  display: flex;
  gap: 8px;
}

.stat-box {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--panel);
  padding: 6px 10px;
  border-radius: 14px;
  font-size: 13px;
  border: 2px solid rgba(255,255,255,0.08);
}

.stat-box i { color: var(--accent); }
.stat-box small { opacity: 0.6; font-size: 10px; }

#respawn-btn {
  background: linear-gradient(135deg, var(--accent), #ff8fa3);
  border: none;
  color: white;
  font-family: inherit;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 16px;
  cursor: pointer;
  font-size: 13px;
  box-shadow: 0 3px 0 #c9304a;
  transition: transform 0.1s;
}
#respawn-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #c9304a;
}

/* ---------- Stage ---------- */
#stage-wrap {
  position: relative;
  flex: 1;
  margin: 6px 10px 10px;
  border-radius: 18px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 30%, #3a3f66 0%, #1e2038 70%);
  border: 3px solid rgba(255,255,255,0.08);
  box-shadow: inset 0 0 60px rgba(0,0,0,0.5);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

#overlay-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

/* floating hit text */
.hit-text {
  position: absolute;
  font-family: 'Bangers', sans-serif;
  font-weight: bold;
  color: var(--accent2);
  text-shadow: 2px 2px 0 rgba(0,0,0,0.6), -1px -1px 0 rgba(0,0,0,0.6);
  pointer-events: none;
  animation: floatUp 0.8s ease-out forwards;
  white-space: nowrap;
}

@keyframes floatUp {
  0% { transform: translate(-50%, -50%) scale(0.6); opacity: 1; }
  30% { transform: translate(-50%, -120%) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -220%) scale(1); opacity: 0; }
}

/* impact particle */
.impact-particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  animation: particleFly 0.5s ease-out forwards;
}

@keyframes particleFly {
  0% { opacity: 1; transform: translate(0,0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.2); }
}

/* screen shake */
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 4px); }
  40% { transform: translate(6px, -4px); }
  60% { transform: translate(-4px, -6px); }
  80% { transform: translate(4px, 6px); }
}
.shaking { animation: shake 0.3s ease; }

/* KO stamp */
#ko-stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-12deg) scale(0);
  font-family: 'Bangers', sans-serif;
  font-size: clamp(48px, 12vw, 96px);
  color: var(--accent);
  -webkit-text-stroke: 3px #fff;
  text-shadow: 4px 4px 0 rgba(0,0,0,0.5);
  pointer-events: none;
  opacity: 0;
  z-index: 10;
}

#ko-stamp.show {
  animation: koPop 1.4s cubic-bezier(.34,1.56,.64,1) forwards;
}

@keyframes koPop {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-12deg) scale(0); }
  15% { opacity: 1; transform: translate(-50%, -50%) rotate(-12deg) scale(1.15); }
  25% { transform: translate(-50%, -50%) rotate(-12deg) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(-12deg) scale(1); }
}

#hint-text {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.4);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  opacity: 0.85;
  pointer-events: none;
  animation: fadeHint 4s ease forwards;
}

@keyframes fadeHint {
  0%, 60% { opacity: 0.85; }
  100% { opacity: 0; }
}

/* ---------- Footer ---------- */
#game-footer {
  text-align: center;
  padding: 4px 10px 8px;
  flex-shrink: 0;
}
#game-footer p {
  margin: 0;
  font-size: 11px;
  opacity: 0.5;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  #hud { gap: 8px; padding: 6px 8px; }
  #hp-bar-bg { width: 90px; }
  .stat-box { padding: 5px 8px; font-size: 11px; }
  #respawn-btn { padding: 7px 12px; font-size: 12px; }
  #game-footer p { font-size: 10px; }
}
