:root {
  --bg: #120f2a;
  --panel: rgba(34, 27, 72, 0.78);
  --card: rgba(36, 28, 78, 0.94);
  --text: #fff6e8;
  --muted: #c4b9e8;
  --accent: #ffb347;
  --accent-dark: #c96a1c;
  --heart: #ff5f7e;
}

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

html,
body {
  height: 100%;
}

body {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% -10%, #3a2a78 0%, #1a1440 45%, var(--bg) 80%);
  color: var(--text);
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.app {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(96vw, calc((100dvh - 96px) * 2 / 3));
}

/* ---------- HUD ---------- */

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  backdrop-filter: blur(6px);
}

.stat {
  display: flex;
  flex-direction: column;
  min-width: 56px;
  line-height: 1.1;
}

.label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.value {
  font-size: 22px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

#score.bump {
  animation: bump 0.25s ease-out;
}

.lives {
  display: flex;
  gap: 3px;
}

.lives.hurt {
  animation: shake 0.4s;
}

.heart {
  width: 22px;
  height: 22px;
  fill: var(--heart);
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.3));
}

.heart.empty {
  fill: rgba(255, 255, 255, 0.14);
  filter: none;
}

.buttons {
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* ---------- Игровое поле ---------- */

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 3px rgba(255, 255, 255, 0.06);
  touch-action: none;
  cursor: none;
}

.stage canvas#game {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- Экраны ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(14, 10, 38, 0.5);
  backdrop-filter: blur(3px);
  cursor: default;
  transition: opacity 0.25s;
}

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

.card {
  width: 100%;
  max-width: 360px;
  max-height: 100%;
  overflow-y: auto;
  padding: 24px 22px;
  text-align: center;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.overlay:not(.hidden) .card {
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.kicker {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

h1 {
  font-size: clamp(28px, 7vw, 38px);
  font-weight: 900;
  line-height: 1.05;
  background: linear-gradient(180deg, #ffd88a, #ff9a3c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

h2 {
  font-size: 30px;
  font-weight: 900;
  color: var(--accent);
}

.text {
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

.legend {
  list-style: none;
  display: grid;
  gap: 4px;
  margin: 16px 0 18px;
  text-align: left;
  font-size: 14px;
  line-height: 1.25;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.legend canvas {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
}

.legend b {
  color: #fff;
}

.results {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.results > div {
  display: flex;
  flex-direction: column;
  padding: 10px 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.badge {
  margin: -2px 0 14px;
  font-weight: 900;
  color: #ffd54a;
  animation: glow 1.2s ease-in-out infinite alternate;
}

.badge.hidden {
  display: none;
}

.btn {
  font: inherit;
  font-size: 20px;
  font-weight: 900;
  padding: 12px 38px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffc76e, #ff9a3c);
  color: #4a2a17;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--accent-dark), 0 10px 22px rgba(0, 0, 0, 0.35);
  transition: transform 0.1s, box-shadow 0.1s, filter 0.15s;
}

.btn:hover {
  filter: brightness(1.06);
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--accent-dark), 0 6px 14px rgba(0, 0, 0, 0.35);
}

.hint {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
}

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

@keyframes bump {
  50% { transform: scale(1.25); color: var(--accent); }
}

@keyframes shake {
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

@keyframes glow {
  from { text-shadow: 0 0 4px rgba(255, 213, 74, 0.3); }
  to { text-shadow: 0 0 14px rgba(255, 213, 74, 0.9); }
}

@media (max-width: 380px) {
  .value { font-size: 19px; }
  .heart { width: 18px; height: 18px; }
  .icon-btn { width: 32px; height: 32px; }
}
