:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #51616f;
  --paper: #f7f9fb;
  --panel: #ffffff;
  --line: #cbd5dd;
  --red: #b4372d;
  --gold: #d7aa3b;
  --green: #2d7a5f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
a {
  min-height: 44px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

button:hover,
a:hover {
  background: #edf4f7;
}

button:active,
a:active {
  transform: translateY(1px);
}

.game-shell {
  width: min(1120px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(340px, 1fr) auto;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(1.7rem, 2.35rem, 2.35rem);
}

h2 {
  font-size: clamp(1.45rem, 2rem, 2rem);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.stats span {
  min-width: 92px;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
}

.stage {
  position: relative;
  min-height: 340px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background-image: url("images/saloon.png");
  background-position: center;
  background-size: cover;
  cursor: none;
}

.shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.28)),
    radial-gradient(circle at center, rgba(255, 235, 182, 0.08), rgba(0, 0, 0, 0.2));
  pointer-events: none;
}

.enemy-layer {
  position: absolute;
  inset: 0;
}

.enemy {
  position: absolute;
  width: clamp(82px, 13vw, 150px);
  height: clamp(110px, 19vw, 210px);
  border: 0;
  background: transparent;
  cursor: none;
  padding: 0;
  transform: translate(-50%, -50%) scale(0.15);
  transform-origin: center bottom;
  animation: pop-in 180ms ease-out forwards;
}

.enemy img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 7px 4px rgba(0, 0, 0, 0.52));
  pointer-events: none;
}

.enemy.warning img {
  animation: warning-pulse 340ms ease-in-out infinite;
}

.enemy.hit {
  animation: hit-out 180ms ease-in forwards;
}

.enemy.missed {
  animation: miss-out 260ms ease-in forwards;
}

.points {
  position: absolute;
  color: #ffffff;
  font-size: 1.45rem;
  font-weight: 800;
  text-shadow: 2px 2px 0 #000000;
  pointer-events: none;
  animation: float-points 620ms ease-out forwards;
}

.shot-flash {
  position: absolute;
  width: 34px;
  height: 34px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.4);
  pointer-events: none;
}

.shot-flash.active {
  animation: flash-shot 160ms ease-out;
}

.gun-cursor {
  position: absolute;
  z-index: 5;
  width: clamp(76px, 11vw, 126px);
  transform: translate(-22px, -18px) rotate(-18deg);
  transform-origin: 22px 18px;
  filter: drop-shadow(2px 3px 2px rgba(0, 0, 0, 0.55));
  pointer-events: none;
}

.gun-cursor.shooting {
  animation: recoil 120ms ease-out;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(246, 244, 239, 0.78);
  z-index: 8;
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(430px, 100%);
  padding: 22px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 6px 6px 0 var(--ink);
}

.panel p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.45;
}

.panel button {
  width: 100%;
  margin-top: 10px;
  background: var(--gold);
}

.panel .secondary-button {
  background: #ffffff;
}

.panel .danger-button {
  background: #f3d7d4;
}

.records-panel {
  margin-top: 12px;
}

.records-panel dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.records-panel div {
  padding: 8px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #f7f9fb;
}

.records-panel dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.records-panel dd {
  margin: 3px 0 0;
  font-size: 1.25rem;
  font-weight: 800;
}

.controls {
  display: grid;
  justify-content: center;
}

.controls a {
  display: grid;
  place-items: center;
  padding: 0 16px;
}

@keyframes pop-in {
  to {
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes hit-out {
  to {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(10deg) scale(0.2);
  }
}

@keyframes miss-out {
  to {
    opacity: 0;
    transform: translate(-50%, -50%) translateY(18px) scale(0.65);
  }
}

@keyframes warning-pulse {
  50% {
    filter: drop-shadow(0 7px 4px rgba(0, 0, 0, 0.52)) drop-shadow(0 0 12px rgba(255, 255, 255, 0.9));
  }
}

@keyframes float-points {
  to {
    opacity: 0;
    transform: translateY(-42px);
  }
}

@keyframes flash-shot {
  60% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.7);
  }
}

@keyframes recoil {
  50% {
    transform: translate(-16px, -10px) rotate(-26deg);
  }
}

@media (max-width: 720px) {
  .game-shell {
    padding: 12px;
    gap: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .stats {
    justify-content: stretch;
  }

  .stats span {
    flex: 1 1 90px;
  }

  .panel {
    box-shadow: 4px 4px 0 var(--ink);
  }
}
