:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: #050916;
  color: #f7fbff;
}

button {
  font: inherit;
}

.game-shell {
  width: min(100vw, 1320px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px 20px 18px;
}

#restart,
.music-toggle,
.menu-button,
.pause-button,
.menu-actions button,
.icon-button,
.play-again-button {
  min-width: 96px;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: #ffffff;
  color: #08101f;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
}

.music-toggle,
.menu-button,
.pause-button {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(130, 247, 255, 0.5);
  background: rgba(14, 33, 52, 0.92);
  color: #d9fbff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.music-toggle[aria-pressed="false"] {
  border-color: rgba(255, 255, 255, 0.18);
  color: #aebbd2;
}

.pause-button[aria-pressed="true"] {
  border-color: rgba(255, 211, 91, 0.7);
  color: #ffe8a2;
}

.game-stage {
  position: relative;
  margin-top: 0;
  overflow: hidden;
  border-radius: 8px;
}

.game-stage.is-front-screen {
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(148, 200, 255, 0.48);
  background:
    linear-gradient(rgba(2, 7, 18, 0.42), rgba(2, 7, 18, 0.52)),
    url('Assets/barn.png') center / cover no-repeat;
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.36);
}

.game-stage.is-front-screen canvas {
  opacity: 0;
}

.game-stage:not(.is-playing) .in-game-controls,
.game-stage:not(.is-playing) .fire-button {
  display: none;
}

.loading-screen,
.main-menu {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 32%, rgba(130, 247, 255, 0.12), transparent 32%),
    rgba(2, 7, 18, 0.56);
  backdrop-filter: blur(2px);
}

.loading-screen[hidden],
.main-menu[hidden],
.main-how-to[hidden] {
  display: none;
}

.loading-panel,
.main-menu-panel {
  width: min(92vw, 420px);
  border: 1px solid rgba(130, 247, 255, 0.34);
  border-radius: 8px;
  background: rgba(6, 15, 30, 0.9);
  padding: 20px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
}

.loading-panel h1,
.main-menu-panel h1 {
  margin: 0;
  color: #ffffff;
  font-size: clamp(2rem, 6vw, 3.35rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.loading-panel p {
  margin: 14px 0 10px;
  color: #d9fbff;
  font-weight: 900;
}

.loading-track {
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(130, 247, 255, 0.46);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.loading-track b {
  display: block;
  width: var(--progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #82f7ff, #ffe082);
  transition: width 0.18s ease;
}

.main-menu-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.primary-menu-button,
.secondary-menu-button {
  min-height: 48px;
  border-radius: 8px;
  font-weight: 900;
  cursor: pointer;
}

.primary-menu-button {
  border: 0;
  background: #ffffff;
  color: #08101f;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32);
}

.secondary-menu-button {
  border: 1px solid rgba(130, 247, 255, 0.46);
  background: rgba(14, 33, 52, 0.92);
  color: #d9fbff;
}

.main-how-to {
  margin-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 12px;
  text-align: left;
}

.main-how-to ul {
  margin: 0;
  padding-left: 20px;
  color: #c6d2e6;
  line-height: 1.45;
  font-size: 0.92rem;
}

.in-game-controls {
  position: absolute;
  left: 24px;
  bottom: 24px;
  z-index: 5;
}

.settings-button {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid rgba(130, 247, 255, 0.52);
  border-radius: 50%;
  background: rgba(8, 17, 35, 0.76);
  color: #f7fbff;
  font-size: 1.65rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
}

.settings-button span {
  display: block;
  transform: translateY(-1px);
}

.quick-menu {
  position: absolute;
  bottom: 62px;
  left: 0;
  width: 170px;
  display: grid;
  gap: 8px;
  border: 1px solid rgba(130, 247, 255, 0.32);
  border-radius: 8px;
  background: rgba(8, 17, 35, 0.94);
  padding: 10px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.4);
}

.quick-menu[hidden] {
  display: none;
}

.menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 7, 18, 0.72);
  backdrop-filter: blur(6px);
}

.menu-overlay[hidden] {
  display: none;
}

.menu-panel {
  width: min(92vw, 520px);
  border: 1px solid rgba(130, 247, 255, 0.28);
  border-radius: 8px;
  background: rgba(8, 17, 35, 0.96);
  padding: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
}

.menu-head,
.menu-section label,
.menu-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.menu-head h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0;
}

.icon-button {
  min-width: 40px;
  width: 40px;
  padding: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #f7fbff;
}

.menu-section {
  margin-top: 18px;
}

.menu-section label {
  color: #d9fbff;
  font-weight: 800;
}

.menu-section input {
  width: 100%;
  margin-top: 10px;
  accent-color: #82f7ff;
}

.menu-section .toggle-row {
  justify-content: flex-start;
  cursor: pointer;
}

.menu-section .toggle-input {
  position: absolute;
  width: 1px;
  inline-size: 1px;
  height: 1px;
  block-size: 1px;
  margin-top: 0;
  opacity: 0;
}

.toggle-switch {
  position: relative;
  width: 54px;
  height: 30px;
  margin-left: auto;
  border: 1px solid rgba(130, 247, 255, 0.38);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.16s ease, border-color 0.16s ease;
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #f7fbff;
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.36);
  transition: transform 0.16s ease;
}

.menu-section .toggle-input:checked + .toggle-switch {
  border-color: rgba(130, 247, 255, 0.9);
  background: rgba(130, 247, 255, 0.34);
}

.menu-section .toggle-input:checked + .toggle-switch::after {
  transform: translateX(24px);
}

.menu-section .toggle-input:focus-visible + .toggle-switch {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}

.how-to-play {
  margin-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 14px 0;
}

.how-to-play summary {
  cursor: pointer;
  color: #f7fbff;
  font-weight: 900;
}

.how-to-play ul {
  margin: 12px 0 0;
  padding-left: 20px;
  color: #c6d2e6;
  line-height: 1.5;
}

.menu-actions {
  margin-top: 18px;
  flex-wrap: wrap;
}

.menu-actions button {
  flex: 1 1 116px;
  min-width: 0;
  background: #ffffff;
  color: #08101f;
}

.quit-confirm {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.quit-confirm[hidden] {
  display: none;
}

.quit-confirm p {
  grid-column: 1 / -1;
  margin: 0;
  color: #ffe8a2;
  font-weight: 900;
  text-align: center;
}

.quit-confirm button {
  min-height: 40px;
  border: 1px solid rgba(130, 247, 255, 0.46);
  border-radius: 8px;
  background: rgba(14, 33, 52, 0.92);
  color: #d9fbff;
  font-weight: 900;
  cursor: pointer;
}

.shop-overlay {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(2, 7, 18, 0.86);
  backdrop-filter: blur(6px);
}

.shop-overlay[hidden] {
  display: none;
}

.shop-frame {
  position: relative;
  width: min(94vw, 980px);
  max-height: 92vh;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid rgba(130, 247, 255, 0.3);
  background: rgba(6, 15, 30, 0.97);
  padding: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}

.shop-head {
  display: grid;
  grid-template-columns: 96px 1fr 132px;
  align-items: center;
  gap: 14px;
}

.shop-nav {
  display: grid;
}

.shop-title {
  text-align: center;
}

.shop-title h2 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
  font-weight: 900;
  letter-spacing: 0;
}

.shop-message {
  min-height: 1.3em;
  margin: 4px 0 0;
  color: #9eefff;
  font-size: 0.9rem;
  font-weight: 800;
}

.shop-wallet {
  display: grid;
  gap: 8px;
  justify-items: stretch;
}

.shop-balance {
  min-height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(130, 247, 255, 0.36);
  border-radius: 8px;
  background: rgba(4, 10, 22, 0.82);
  color: #ffffff;
  font-weight: 900;
}

.shop-back,
.shop-add-currency,
.shop-buy {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: #ffffff;
  color: #08101f;
  font-weight: 900;
  cursor: pointer;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.shop-card {
  display: grid;
  gap: 8px;
  justify-items: center;
  min-width: 0;
  border: 1px solid rgba(130, 247, 255, 0.2);
  border-radius: 8px;
  background: rgba(8, 22, 38, 0.9);
  padding: 12px;
}

.shop-card.is-owned {
  border-color: rgba(130, 247, 255, 0.55);
}

.shop-card.is-active {
  border-color: rgba(255, 211, 91, 0.78);
  box-shadow: inset 0 0 0 1px rgba(255, 211, 91, 0.28);
}

.shop-card.is-locked {
  opacity: 0.62;
}

.shop-projectile-preview {
  width: min(100%, 132px);
  height: auto;
  aspect-ratio: 1;
}

.shop-card h3,
.shop-card p {
  margin: 0;
  text-align: center;
}

.shop-card h3 {
  color: #ffffff;
  font-size: 1rem;
  font-weight: 900;
}

.shop-card p {
  color: #b8c7db;
  font-size: 0.82rem;
  font-weight: 700;
}

.shop-buy {
  width: 100%;
}

.shop-buy.is-active {
  background: #ffe082;
}

.shop-buy:disabled {
  cursor: default;
  opacity: 0.68;
}

@media (max-width: 720px) {
  .shop-head {
    grid-template-columns: 1fr;
  }

  .shop-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  transition: opacity 0.18s ease;
  border: 1px solid rgba(148, 200, 255, 0.48);
  border-radius: 8px;
  background: #001227;
  cursor: none;
  touch-action: none;
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.36);
}

.shop-projectile-preview {
  width: min(100%, 132px);
  aspect-ratio: 1;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: default;
  touch-action: auto;
}

.fire-button {
  position: absolute;
  right: 24px;
  bottom: 22px;
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  overflow: hidden;
  border: none;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 248, 232, 0.08), rgba(0, 0, 0, 0) 56%),
    url('Assets/special button.png') center / cover no-repeat;
  color: white;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 0 28px rgba(255, 90, 36, 0.24);
}

.fire-button:disabled {
  cursor: default;
}

.fire-button span,
.fire-button small {
  position: relative;
  z-index: 2;
}

.fire-button span {
  display: none;
}

.fire-button small {
  margin-top: 54px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(16, 8, 5, 0.72);
  color: #fff6dc;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.fire-meter {
  --charge: 0%;
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: conic-gradient(from -90deg, rgba(255, 226, 119, 0.96) var(--charge), rgba(255, 255, 255, 0.08) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 8px), #000 calc(100% - 7px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 8px), #000 calc(100% - 7px));
  opacity: 0.95;
  z-index: 1;
}

.fire-button[data-state="ready"] {
  animation: fire-ready-pulse 0.72s ease-in-out infinite alternate;
}

.fire-button[data-state="ready"]::after {
  position: absolute;
  inset: -12px;
  content: "";
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 90%, rgba(255, 222, 89, 0.8), transparent 24%),
    radial-gradient(circle at 35% 75%, rgba(255, 86, 30, 0.65), transparent 25%),
    radial-gradient(circle at 65% 72%, rgba(255, 135, 32, 0.62), transparent 27%);
  opacity: 0.78;
  filter: blur(4px);
  animation: fire-ready-flame 0.45s ease-in-out infinite alternate;
}

.sr-hud {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@keyframes fire-ready-pulse {
  from { box-shadow: 0 0 18px rgba(255, 107, 40, 0.35), 0 0 34px rgba(255, 224, 112, 0.2); }
  to { box-shadow: 0 0 34px rgba(255, 107, 40, 0.76), 0 0 62px rgba(255, 224, 112, 0.48); }
}

@keyframes fire-ready-flame {
  from { transform: translateY(6px) scale(0.94); }
  to { transform: translateY(-5px) scale(1.04); }
}

.fire-meter[data-state="active"],
.fire-button[data-state="active"] .fire-meter {
  background: conic-gradient(from -90deg, #ffe27f var(--charge), #ff6f1e 0, #ff2e21 0, rgba(255, 255, 255, 0.08) 0);
  opacity: 0.95;
}

.fire-meter[data-state="cooldown"],
.fire-button[data-state="cooldown"] .fire-meter {
  background: conic-gradient(from -90deg, #8da5c4 var(--charge), rgba(255, 255, 255, 0.08) 0);
  opacity: 0.72;
}

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

  .in-game-controls {
    left: 12px;
    bottom: 12px;
  }

  .fire-button {
    right: 12px;
    bottom: 12px;
    width: 76px;
    height: 76px;
  }

  .fire-button small {
    margin-top: 42px;
    font-size: 0.5rem;
  }

  .quick-menu {
    width: 150px;
  }
}
