:root {
  color-scheme: dark;
  --bg: #0f172a;
  --surface: #121b33;
  --surface-soft: rgba(18, 27, 51, 0.9);
  --stroke: rgba(148, 163, 184, 0.25);
  --text: #f8fafc;
  --muted: #cbd5f5;
  --accent: #fb7185;
  --accent-strong: #f43f5e;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.35);
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Inter", system-ui, sans-serif;
  background:
    radial-gradient(1000px 700px at 15% 10%, rgba(251, 113, 133, 0.15), transparent 70%),
    radial-gradient(900px 600px at 90% 0%, rgba(56, 189, 248, 0.12), transparent 65%),
    var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 32px 16px 40px;
}

.page {
  width: 100%;
  max-width: 1040px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.subtitle {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
  max-width: 820px;
}

.game-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.game-stage {
  position: relative;
  width: 900px;
  height: 760px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(16, 23, 42, 0.92), rgba(9, 13, 27, 0.96));
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hud {
  position: absolute;
  top: 16px;
  left: 18px;
  z-index: 3;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 999px;
  padding: 6px 14px;
  letter-spacing: 0.2px;
  backdrop-filter: blur(6px);
}

.message {
  position: absolute;
  top: 120px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  font-size: 38px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  text-shadow: 0 0 18px rgba(244, 63, 94, 0.35);
  white-space: nowrap;
}

.message.is-winning {
  animation: heartbeat 1.1s ease-in-out infinite;
}

.win-image {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 220px;
  height: 220px;
  transform: translate(-50%, -50%) scale(0.2);
  opacity: 0;
  z-index: 2;
  pointer-events: none;
  filter: drop-shadow(0 16px 36px rgba(15, 23, 42, 0.55));
}

.win-image.is-active {
  animation: winScale 2.6s ease-out forwards;
}

@keyframes winScale {
  0% {
    transform: translate(-50%, -50%) scale(0.2);
    opacity: 0;
  }
  40% {
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.35);
    opacity: 1;
  }
}

@keyframes heartbeat {
  0% {
    transform: translateX(-50%) scale(1);
    text-shadow: 0 0 18px rgba(244, 63, 94, 0.3);
  }
  45% {
    transform: translateX(-50%) scale(1.08);
    text-shadow: 0 0 24px rgba(244, 63, 94, 0.55);
  }
  100% {
    transform: translateX(-50%) scale(1);
    text-shadow: 0 0 18px rgba(244, 63, 94, 0.3);
  }
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  position: relative;
  z-index: 2;
  background: transparent;
}

.controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.btn {
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn:hover {
  background: var(--surface-soft);
  border-color: rgba(251, 113, 133, 0.5);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

@media (max-width: 980px) {
  .game-stage {
    transform: scale(0.9);
  }
}

@media (max-width: 860px) {
  .game-stage {
    transform: scale(0.8);
  }
}

@media (max-width: 740px) {
  .game-stage {
    transform: scale(0.72);
  }
}
