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

:root {
  --bg: #14101f;
  --panel: rgba(28, 22, 43, 0.82);
  --accent: #ff2f55;
  --accent2: #ffd76a;
  --text: #f4f0ff;
  --muted: #a79fc4;
}

html, body {
  height: 100%;
  background: radial-gradient(circle at 50% 20%, #241a3c 0%, #100d18 60%, #08060d 100%);
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

#stage {
  position: relative;
  width: 100%;
  max-width: 1100px;
  aspect-ratio: 1100 / 700;
  max-height: 100%;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.07), 0 30px 80px rgba(255, 47, 85, 0.18),
    0 10px 40px rgba(0, 0, 0, 0.6);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #0d0b14;
  touch-action: none;
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  inset: 0;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  font-size: clamp(11px, 1.5vw, 15px);
}

.hud-left, .hud-right { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hud-right { flex-direction: column; align-items: flex-end; }

.chip {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 6px 14px;
  backdrop-filter: blur(8px);
  letter-spacing: 0.4px;
  color: var(--muted);
}

.chip b { color: var(--text); font-size: 1.12em; }

.lives { display: flex; gap: 4px; font-size: 1.5em; filter: drop-shadow(0 2px 6px rgba(255, 80, 120, 0.6)); }
.lives .lost { opacity: 0.18; filter: grayscale(1); }

.heat {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 4px 10px;
  backdrop-filter: blur(8px);
}

.heat-bar {
  width: clamp(70px, 12vw, 130px);
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  overflow: hidden;
}

.heat-bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffd76a, #ff2f55);
  transition: width 0.12s linear;
}

/* ---------- Overlay ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 6, 14, 0.72);
  backdrop-filter: blur(6px);
  transition: opacity 0.25s ease;
  padding: 16px;
}

.overlay.hidden { opacity: 0; pointer-events: none; }

.card {
  text-align: center;
  max-width: 520px;
  background: linear-gradient(160deg, rgba(48, 34, 74, 0.95), rgba(24, 18, 38, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  padding: clamp(18px, 4vw, 34px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.09);
  animation: pop 0.3s ease;
}

@keyframes pop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.cat-face { font-size: clamp(40px, 8vw, 64px); line-height: 1; margin-bottom: 6px; }
.card h1 {
  font-size: clamp(22px, 4vw, 36px);
  margin-bottom: 10px;
  background: linear-gradient(90deg, #ffd76a, #ff2f55 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.card p { color: var(--muted); font-size: clamp(12px, 2vw, 15px); line-height: 1.5; }
.card p + p { margin-top: 8px; }

.btn {
  margin-top: 18px;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: clamp(15px, 2.2vw, 19px);
  font-weight: 700;
  color: #2a0812;
  padding: 13px 38px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe08a, #ff8a4c);
  box-shadow: 0 10px 24px rgba(255, 138, 76, 0.4), inset 0 -3px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(255, 138, 76, 0.55); }
.btn:active { transform: translateY(1px) scale(0.98); }

.controls { margin-top: 14px; font-size: clamp(10px, 1.6vw, 13px) !important; opacity: 0.85; }
.controls b { color: var(--accent2); }

/* ---------- Мобильное управление ---------- */
.mobile-controls {
  position: fixed;
  inset: auto 0 0 0;
  padding: 12px 16px 20px;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(2, 52px);
  gap: 6px;
  pointer-events: auto;
}

.dpad button:nth-child(1) { grid-column: 2; grid-row: 1; }
.dpad button:nth-child(2) { grid-column: 1; grid-row: 2; }
.dpad button:nth-child(3) { grid-column: 2; grid-row: 2; }
.dpad button:nth-child(4) { grid-column: 3; grid-row: 2; }

.dpad button, .fire {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(40, 30, 62, 0.78);
  color: var(--text);
  font-size: 20px;
  border-radius: 16px;
  backdrop-filter: blur(6px);
  touch-action: none;
}

.fire {
  pointer-events: auto;
  width: 84px;
  height: 84px;
  font-size: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8a9e, #c81234);
  box-shadow: 0 0 26px rgba(255, 47, 85, 0.55);
}

.dpad button:active, .fire:active { transform: scale(0.94); background: rgba(90, 62, 130, 0.9); }

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