:root {
  --ink: #172033;
  --paper: #fffaf0;
  --panel: rgba(255, 255, 255, 0.92);
  --blue: #1d7cff;
  --green: #1fc96b;
  --pink: #ff3fa4;
  --yellow: #ffd447;
  --orange: #ff7a2f;
  --line: rgba(23, 32, 51, 0.16);
  --shadow: 0 18px 50px rgba(23, 32, 51, 0.22);
  font-family: Inter, ui-rounded, "Trebuchet MS", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: #5bc9ff;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

button {
  font: inherit;
  touch-action: manipulation;
}

a,
[role="button"],
.app {
  touch-action: manipulation;
}

.app {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 560px;
  overflow: hidden;
  background:
    radial-gradient(circle at 14% 14%, rgba(255, 212, 71, 0.55), transparent 18%),
    radial-gradient(circle at 86% 20%, rgba(255, 63, 164, 0.42), transparent 15%),
    linear-gradient(135deg, #7de2ff 0%, #7eff9e 50%, #ffe868 100%);
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden {
  display: none !important;
}

.hud {
  position: absolute;
  z-index: 6;
  top: 14px;
  left: 50%;
  display: grid;
  width: min(1120px, calc(100vw - 24px));
  grid-template-columns: 1.2fr 1fr 1fr 1.5fr auto auto;
  gap: 10px;
  transform: translateX(-50%);
  pointer-events: none;
}

.hud-panel,
.icon-button {
  min-height: 54px;
  border: 2px solid rgba(23, 32, 51, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 22px rgba(23, 32, 51, 0.12);
}

.hud-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 14px;
}

.hud-label {
  color: rgba(23, 32, 51, 0.65);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hud strong {
  font-size: clamp(1rem, 2.2vw, 1.55rem);
  line-height: 1.05;
}

.timer-panel.final {
  animation: pulseDanger 0.45s infinite alternate;
  background: #fff2f2;
}

.icon-button {
  min-width: 58px;
  padding: 0 12px;
  color: var(--ink);
  font-weight: 950;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.icon-button:hover,
.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-2px);
}

.icon-button:active,
.primary-button:active,
.secondary-button:active {
  transform: translateY(1px) scale(0.98);
}

.screen {
  position: absolute;
  z-index: 10;
  inset: 0;
}

.lobby-screen {
  overflow: auto;
  padding: clamp(18px, 4vw, 38px);
  background:
    linear-gradient(rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.1)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.22) 0 14px, transparent 14px 38px);
}

.lobby-top,
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto 16px;
}

.top-actions,
.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 4px;
  color: #004e9c;
  font-size: 0.8rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.2rem, 6vw, 5.4rem);
  line-height: 0.93;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(1.35rem, 3vw, 2rem);
}

h3 {
  margin-bottom: 6px;
}

.lobby-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.4fr) minmax(260px, 0.8fr);
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto 16px;
}

.panel,
.modal-card {
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.practice-panel,
.stats-panel,
.shop-panel {
  padding: 16px;
}

.practice-scene {
  position: relative;
  min-height: 220px;
  overflow: hidden;
  border: 2px solid rgba(23, 32, 51, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(transparent 70%, rgba(77, 172, 70, 0.32) 70%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.3) 0 18px, transparent 18px 36px),
    linear-gradient(160deg, #62d8ff, #ffe35f);
}

.practice-splat,
.practice-target,
.practice-gun {
  position: absolute;
  display: block;
}

.practice-splat {
  width: 92px;
  height: 92px;
  border-radius: 42% 58% 53% 47%;
  opacity: 0.78;
}

.splat-a {
  left: 9%;
  top: 18%;
  background: var(--pink);
  transform: rotate(19deg);
}

.splat-b {
  right: 18%;
  bottom: 18%;
  background: var(--green);
  transform: rotate(-12deg);
}

.practice-target {
  width: 78px;
  height: 78px;
  border: 8px solid #ff3f3f;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 10px #ffd447, inset 0 0 0 22px #1d7cff;
  animation: bob 1.8s ease-in-out infinite;
}

.target-a {
  left: 32%;
  top: 24%;
}

.target-b {
  right: 10%;
  top: 12%;
  width: 54px;
  height: 54px;
  animation-duration: 1.1s;
}

.practice-gun {
  left: 50%;
  bottom: 14px;
  width: 150px;
  height: 46px;
  border-radius: 24px 8px 8px 24px;
  background: linear-gradient(90deg, #26364f 0 42%, #ff3fa4 42% 72%, #ffd447 72%);
  transform: translateX(-50%);
}

.practice-gun::after {
  position: absolute;
  right: -58px;
  top: 14px;
  width: 72px;
  height: 16px;
  border-radius: 8px;
  background: #172033;
  content: "";
}

.lobby-stats,
.results-grid,
.stat-list {
  display: grid;
  gap: 10px;
}

.lobby-stats {
  grid-template-columns: repeat(4, 1fr);
  margin: 14px 0;
}

.lobby-stats div,
.results-grid div,
.stat-list div {
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.lobby-stats span,
.results-grid span,
.stat-list span {
  display: block;
  color: rgba(23, 32, 51, 0.62);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.lobby-stats strong,
.results-grid strong,
.stat-list strong {
  font-size: 1.35rem;
}

.stat-list {
  grid-template-columns: repeat(2, 1fr);
}

.primary-button,
.secondary-button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 950;
  color: var(--ink);
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease, box-shadow 140ms ease;
}

.primary-button {
  width: 100%;
  background: linear-gradient(135deg, #ffd447, #ff7a2f 48%, #ff3fa4);
  box-shadow: 0 10px 0 #b83a63, 0 18px 34px rgba(184, 58, 99, 0.28);
}

.secondary-button {
  border: 2px solid rgba(23, 32, 51, 0.14);
  background: #fff;
  box-shadow: 0 8px 18px rgba(23, 32, 51, 0.12);
}

.secondary-button.danger {
  color: #9c183b;
}

.shop-panel {
  max-width: 1180px;
  margin: 0 auto 28px;
}

.section-heading p {
  margin-bottom: 0;
}

.shop-browser {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 14px;
  border: 2px solid rgba(23, 32, 51, 0.1);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.68);
}

.shop-browser strong {
  display: block;
  line-height: 1.25;
}

.shop-filter {
  display: grid;
  min-width: min(260px, 100%);
  gap: 5px;
  color: rgba(23, 32, 51, 0.7);
  font-size: 0.76rem;
  font-weight: 950;
  text-transform: uppercase;
}

.shop-filter select {
  min-height: 44px;
  border: 2px solid rgba(23, 32, 51, 0.15);
  border-radius: 8px;
  padding: 0 36px 0 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 950;
}

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

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

.shop-card {
  display: grid;
  gap: 10px;
  min-height: 210px;
  padding: 14px;
  border: 2px solid rgba(23, 32, 51, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.shop-card.equipped {
  border-color: #1d7cff;
  box-shadow: inset 0 0 0 3px rgba(29, 124, 255, 0.2);
}

.shop-kicker {
  align-self: start;
  width: max-content;
  max-width: 100%;
  margin: 0;
  border-radius: 8px;
  padding: 5px 8px;
  background: rgba(255, 212, 71, 0.48);
  color: #7a3e00;
  font-size: 0.72rem;
  font-weight: 1000;
  text-transform: uppercase;
}

.gun-preview {
  position: relative;
  height: 58px;
}

.gun-body {
  position: absolute;
  left: 8px;
  top: 18px;
  width: 150px;
  height: 30px;
  border-radius: 20px 8px 8px 20px;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.12);
}

.gun-body::after {
  position: absolute;
  right: -45px;
  top: 9px;
  width: 56px;
  height: 12px;
  border-radius: 8px;
  background: #172033;
  content: "";
}

.gun-body::before {
  position: absolute;
  left: 38px;
  bottom: -30px;
  width: 28px;
  height: 34px;
  border-radius: 5px 5px 12px 12px;
  background: #172033;
  transform: rotate(-9deg);
  content: "";
}

.pet-preview {
  position: relative;
  height: 74px;
}

.pet-body,
.pet-ear,
.pet-blaster {
  position: absolute;
  display: block;
}

.pet-body {
  left: 24px;
  top: 20px;
  width: 58px;
  height: 50px;
  border-radius: 50%;
  background: var(--pet-color, #27ffbf);
  box-shadow: inset 0 -7px 0 rgba(0, 0, 0, 0.12);
}

.pet-body::before,
.pet-body::after {
  position: absolute;
  top: 17px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #172033;
  content: "";
}

.pet-body::before {
  left: 15px;
}

.pet-body::after {
  right: 15px;
}

.pet-ear {
  top: 4px;
  width: 0;
  height: 0;
  border-right: 15px solid transparent;
  border-bottom: 28px solid #172033;
  border-left: 15px solid transparent;
}

.pet-ear.left {
  left: 18px;
  transform: rotate(-24deg);
}

.pet-ear.right {
  left: 64px;
  transform: rotate(24deg);
}

.pet-blaster {
  left: 78px;
  top: 36px;
  width: 72px;
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, #172033, var(--pet-accent, #ff3fa4));
}

.pet-blaster::after {
  position: absolute;
  right: -12px;
  top: 3px;
  width: 18px;
  height: 8px;
  border-radius: 8px;
  background: var(--pet-accent, #ffd447);
  content: "";
}

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

.pet-actions .primary-button,
.pet-actions .secondary-button {
  width: 100%;
  padding-right: 10px;
  padding-left: 10px;
}

.automation-card {
  background: rgba(255, 255, 255, 0.86);
}

.automation-preview {
  display: grid;
  height: 58px;
  place-items: center;
}

.automation-preview span {
  display: grid;
  width: 70px;
  height: 48px;
  place-items: center;
  border: 3px solid rgba(23, 32, 51, 0.18);
  border-radius: 8px;
  background: linear-gradient(135deg, #1d7cff, #27ffbf);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 1000;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.14);
}

.shop-card h3 {
  margin: 4px 0 0;
}

.shop-card p {
  min-height: 40px;
  margin: 0;
  color: rgba(23, 32, 51, 0.74);
}

.gun-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.gun-stats span {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid rgba(23, 32, 51, 0.13);
  border-radius: 8px;
  padding: 4px 8px;
  background: rgba(29, 124, 255, 0.08);
  color: rgba(23, 32, 51, 0.78);
  font-size: 0.78rem;
  font-weight: 900;
}

.shop-card button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.25);
  opacity: 0.62;
  transform: none;
}

.empty-shop-card {
  align-content: center;
}

.modal-screen {
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 32, 51, 0.45);
  backdrop-filter: blur(6px);
}

.modal-card {
  width: min(680px, 100%);
  padding: clamp(18px, 4vw, 32px);
  animation: popIn 220ms ease both;
}

.modal-card.small {
  width: min(420px, 100%);
}

.modal-card .primary-button,
.modal-card .secondary-button {
  width: 100%;
  margin-top: 10px;
}

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

.result-actions .primary-button,
.result-actions .secondary-button {
  flex: 1;
}

.combo,
.reload,
.countdown {
  position: absolute;
  z-index: 7;
  left: 50%;
  pointer-events: none;
  transform: translateX(-50%);
  text-align: center;
  font-weight: 1000;
  text-shadow: 0 4px 0 rgba(23, 32, 51, 0.12);
}

.combo {
  top: 86px;
  color: #ff3fa4;
  font-size: clamp(1.4rem, 4vw, 2.8rem);
  animation: popIn 200ms ease both;
}

.reload {
  bottom: 90px;
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: #9c183b;
}

.countdown {
  top: 46%;
  color: #fff;
  font-size: clamp(5rem, 18vw, 13rem);
  -webkit-text-stroke: 4px #ff3f3f;
  animation: slam 0.7s ease both;
}

.has-happyfun-topbar .screen {
  inset: 58px 0 0;
}

.has-happyfun-topbar .hud {
  top: 70px;
}

.has-happyfun-topbar .combo {
  top: 142px;
}

@keyframes bob {
  50% {
    transform: translateY(-16px);
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes slam {
  from {
    opacity: 0;
    transform: translateX(-50%) scale(1.5);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
}

@keyframes pulseDanger {
  to {
    transform: scale(1.035);
    border-color: #ff3f3f;
  }
}

@media (max-width: 860px) {
  .app {
    min-height: 620px;
  }

  .hud {
    top: 8px;
    grid-template-columns: repeat(3, 1fr) auto auto;
  }

  .has-happyfun-topbar .screen {
    inset: 58px 0 0;
  }

  .has-happyfun-topbar .hud {
    top: 68px;
  }

  .has-happyfun-topbar .combo {
    top: 138px;
  }

  .gun-panel {
    display: none;
  }

  .lobby-grid,
  .shop-grid,
  .shop-grid.recommended-shop,
  .control-grid,
  .results-grid {
    grid-template-columns: 1fr;
  }

  .lobby-top,
  .section-heading,
  .shop-browser {
    align-items: stretch;
    flex-direction: column;
  }

  .lobby-stats,
  .stat-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .app {
    min-height: 640px;
  }

  .hud {
    grid-template-columns: repeat(3, 1fr);
  }

  .icon-button {
    min-height: 42px;
  }

  .hud-panel {
    min-height: 48px;
    padding: 6px 8px;
  }

  .hud-label {
    font-size: 0.62rem;
  }

  .lobby-stats,
  .stat-list {
    grid-template-columns: 1fr;
  }

  .shop-panel {
    padding: 12px;
  }

  .shop-browser {
    position: sticky;
    z-index: 3;
    top: 0;
    margin: -2px -2px 12px;
  }

  .shop-card {
    min-height: 0;
  }
}
