:root {
  --bg: #051910;
  --bg-2: #082717;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-strong: rgba(255, 255, 255, 0.13);
  --cream: #f6f0de;
  --ink: #f9f5e8;
  --muted: rgba(249, 245, 232, 0.68);
  --green: #0f5737;
  --green-2: #184f37;
  --gold: #e2c66d;
  --line: rgba(246, 240, 222, 0.16);
  --danger: #ff6b4a;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(226, 198, 109, 0.09), transparent 24rem),
    radial-gradient(circle at 82% 4%, rgba(50, 136, 90, 0.18), transparent 22rem),
    linear-gradient(180deg, #061d12 0%, var(--bg) 45%, #07180f 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

body::before,
body::after {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
}

body::before {
  opacity: 0.06;
  background-image:
    linear-gradient(rgba(246, 240, 222, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(246, 240, 222, 0.06) 1px, transparent 1px);
  background-size: 34px 34px;
}

body::after {
  background:
    radial-gradient(circle at 60% 28%, transparent 0, transparent 34%, rgba(0, 0, 0, 0.38) 100%),
    linear-gradient(90deg, rgba(2, 14, 8, 0.54), transparent 30%, transparent 70%, rgba(2, 14, 8, 0.5));
}

button,
a {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
}

.game-shell {
  position: relative;
  z-index: 1;
  display: grid;
  gap: clamp(12px, 2.5vw, 20px);
  width: min(100%, 1480px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 60px;
  padding: 10px clamp(12px, 2vw, 20px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(5, 25, 16, 0.84), rgba(5, 25, 16, 0.56));
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(18px);
}

.game-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--cream);
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.game-brand img {
  width: 44px;
  height: 32px;
  object-fit: contain;
}

.game-score {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
  text-transform: uppercase;
}

.game-score span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.game-score strong {
  color: var(--gold);
}

.game-exit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(226, 198, 109, 0.34);
  border-radius: 999px;
  color: var(--gold);
  font-size: 0.84rem;
  font-weight: 950;
  text-transform: uppercase;
  background: rgba(226, 198, 109, 0.08);
}

.game-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 390px);
  gap: clamp(12px, 2vw, 18px);
  min-height: min(760px, calc(100svh - 112px));
}

.canvas-wrap,
.game-panel,
.start-card,
.leaderboard-card,
.result-panel {
  border: 1px solid rgba(246, 240, 222, 0.16);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(246, 240, 222, 0.08), rgba(246, 240, 222, 0.02)),
    rgba(4, 22, 13, 0.64);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.canvas-wrap {
  position: relative;
  min-height: 540px;
}

#penalty-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
}

.swipe-trail {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(246, 240, 222, 0.92), rgba(226, 198, 109, 0.92));
  box-shadow: 0 0 18px rgba(226, 198, 109, 0.34);
  opacity: 0;
  transform-origin: left center;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.swipe-trail.is-visible {
  opacity: 1;
}

.shot-banner {
  position: absolute;
  left: 50%;
  top: 18px;
  min-width: min(340px, calc(100% - 32px));
  padding: 12px 16px;
  border: 1px solid rgba(246, 240, 222, 0.2);
  border-radius: 999px;
  color: var(--cream);
  font-weight: 950;
  text-align: center;
  text-transform: uppercase;
  background: rgba(5, 25, 16, 0.78);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translate(-50%, -12px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.shot-banner.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.game-panel {
  display: flex;
  flex-direction: column;
  justify-content: end;
  gap: 18px;
  padding: clamp(18px, 3vw, 28px);
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 950;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
  overflow-wrap: anywhere;
}

h1 {
  max-width: 430px;
  color: var(--cream);
  font-size: clamp(2rem, 5.2vw, 4.25rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  color: var(--cream);
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
}

.game-copy,
.result-panel p {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.attempts {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.attempts span {
  min-height: 9px;
  border-radius: 999px;
  background: rgba(246, 240, 222, 0.14);
}

.attempts span.is-goal {
  background: var(--gold);
  box-shadow: 0 0 18px rgba(226, 198, 109, 0.4);
}

.attempts span.is-save {
  background: var(--danger);
}

.game-hint,
.name-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}

.game-hint strong {
  color: var(--cream);
}

.name-field {
  align-items: stretch;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.name-field span {
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.name-field input {
  min-height: 56px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 16px;
  color: var(--cream);
  font: inherit;
  font-size: 1rem;
  font-weight: 850;
  background: rgba(255, 255, 255, 0.07);
  outline: 0;
}

.name-field input:focus {
  border-color: rgba(226, 198, 109, 0.7);
  box-shadow: 0 0 0 3px rgba(226, 198, 109, 0.14);
}

.swipe-copy {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.shoot-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  border: 0;
  border-radius: 999px;
  color: #061d12;
  font-weight: 950;
  cursor: pointer;
  background: linear-gradient(100deg, #e2c66d, #f6f0de, #0f5737, #e2c66d);
  background-size: 280% 100%;
  box-shadow: 0 16px 34px rgba(226, 198, 109, 0.18);
  animation: move-gold 5s ease-in-out infinite;
}

.shoot-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.start-panel,
.leaderboard-panel,
.result-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 50% 40%, rgba(226, 198, 109, 0.18), transparent 18rem),
    rgba(2, 12, 7, 0.78);
  backdrop-filter: blur(12px);
}

.start-panel {
  z-index: 30;
}

.result-panel[hidden],
.start-panel[hidden],
.leaderboard-panel[hidden],
.start-panel.is-hidden {
  display: none;
}

.start-card,
.leaderboard-card,
.result-card {
  position: relative;
  display: grid;
  gap: 16px;
  width: min(100%, 520px);
  padding: clamp(22px, 5vw, 38px);
  border: 1px solid rgba(226, 198, 109, 0.28);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(246, 240, 222, 0.1), rgba(246, 240, 222, 0.03)),
    rgba(5, 25, 16, 0.94);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.46);
  text-align: center;
}

.start-card {
  text-align: left;
}

.leaderboard-card {
  width: min(100%, 620px);
  text-align: left;
}

.leaderboard-box {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
}

.leaderboard-box h3 {
  margin: 0;
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.leaderboard-box ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard-box li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 7px;
  color: var(--cream);
  font-weight: 850;
  background: rgba(255, 255, 255, 0.06);
}

.leaderboard-box li span:first-child,
.leaderboard-box li span:last-child {
  color: var(--gold);
}

.result-exit {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(246, 240, 222, 0.18);
  border-radius: 999px;
  color: rgba(249, 245, 232, 0.76);
  font-size: 0.82rem;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.07);
}

.result-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 6px;
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.qr-card {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(226, 198, 109, 0.28);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(246, 240, 222, 0.1), rgba(246, 240, 222, 0.03)),
    rgba(255, 255, 255, 0.06);
}

.qr-card img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  object-fit: contain;
  background: #fff;
}

.qr-card figcaption {
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.popup-reset,
.feedback-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  color: #061d12;
  font-weight: 950;
  cursor: pointer;
  background: linear-gradient(100deg, #e2c66d, #f6f0de, #0f5737, #e2c66d);
  background-size: 280% 100%;
  box-shadow: 0 16px 34px rgba(226, 198, 109, 0.18);
  animation: move-gold 5s ease-in-out infinite;
}

.feedback-button {
  border: 1px solid rgba(246, 240, 222, 0.18);
  color: var(--cream);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
  animation: none;
}

@keyframes move-gold {
  0%,
  100% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }
}

@media (max-width: 900px) {
  .game-shell {
    gap: 8px;
    padding: max(6px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  }

  .game-stage {
    grid-template-columns: 1fr;
    gap: 8px;
    min-height: 0;
  }

  .canvas-wrap {
    order: 1;
    min-height: clamp(560px, 72svh, 760px);
  }

  .game-panel {
    order: 2;
    gap: 10px;
    padding: 14px;
  }

  .game-copy {
    font-size: 0.95rem;
  }

  .start-panel,
  .leaderboard-panel,
  .result-panel {
    padding: 14px;
  }

  .result-actions {
    grid-template-columns: 1fr;
  }

  .qr-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 520px) {
  .game-header {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 52px;
    padding: 7px 10px;
  }

  .game-brand span {
    max-width: 132px;
    overflow: hidden;
    font-size: 0.9rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .game-brand img {
    width: 38px;
    height: 28px;
  }

  .game-exit {
    min-height: 32px;
    padding: 0 11px;
    font-size: 0.76rem;
  }

  .game-score span {
    min-height: 32px;
    padding: 0 10px;
  }

  .game-score span:last-child {
    display: none;
  }

  .game-panel {
    border-radius: 8px;
  }

  .game-panel .eyebrow {
    display: none;
  }

  .game-copy,
  .swipe-copy {
    font-size: 0.9rem;
  }

  h1 {
    max-width: 100%;
    font-size: clamp(1.45rem, 7vw, 2rem);
    line-height: 1.02;
  }

  .canvas-wrap {
    min-height: clamp(560px, 70svh, 660px);
  }

  .attempts span {
    min-height: 7px;
  }

  .game-hint {
    padding: 11px 12px;
  }

  .shoot-button {
    min-height: 52px;
  }

  .qr-grid {
    gap: 8px;
  }

  .qr-card {
    padding: 8px;
  }

  .qr-card figcaption {
    font-size: 0.68rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
