:root {
  --bg: #101417;
  --panel: #1b2226;
  --panel-2: #242d31;
  --line: #3b484e;
  --text: #edf3ee;
  --muted: #9fafaa;
  --green: #73c66c;
  --amber: #f0b44c;
  --red: #df695f;
  --cyan: #72c5df;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

button {
  font: inherit;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

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

.topbar,
.hud,
.shop-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.topbar {
  min-height: 76px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 180px;
}

.mark {
  width: 34px;
  height: 34px;
  border: 2px solid var(--green);
  border-radius: 50%;
  position: relative;
  flex: 0 0 auto;
}

.mark::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 4px;
  left: 18px;
  top: 6px;
  background: var(--amber);
  border-radius: 4px;
  transform: rotate(-22deg);
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.readout {
  display: grid;
  grid-template-columns: repeat(3, minmax(92px, 1fr));
  gap: 8px;
  width: min(460px, 100%);
}

.readout div {
  min-height: 48px;
  padding: 7px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.readout span,
.control-group span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.1;
}

.readout strong {
  display: block;
  margin-top: 5px;
  font-size: 19px;
  line-height: 1;
}

.matchbar {
  min-width: 190px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.matchbar span {
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

#onlineCount {
  color: var(--text);
  font-weight: 800;
}

.matchbar button {
  min-height: 34px;
  border: 1px solid #47727c;
  border-radius: 6px;
  color: var(--text);
  background: #24424a;
  cursor: pointer;
  font-weight: 800;
}

.battle-wrap {
  position: relative;
  min-height: 300px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #91c7d4;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 300px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.message {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  min-width: min(460px, calc(100% - 28px));
  min-height: 38px;
  padding: 9px 14px;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  color: #fff;
  background: rgba(15, 20, 22, 0.74);
  font-weight: 700;
}

.message.show {
  display: flex;
}

.hud {
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(280px, 1fr) minmax(150px, 220px);
  align-items: center;
  gap: 12px;
}

.player-card {
  min-height: 96px;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.player-head strong {
  font-size: 18px;
}

.player-head span {
  color: var(--muted);
  font-weight: 800;
}

.hp {
  height: 12px;
  border-radius: 999px;
  background: #111719;
  overflow: hidden;
}

.hp i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--green);
  border-radius: inherit;
  transition: width 180ms ease, background 180ms ease;
}

.p2 .hp i {
  background: var(--cyan);
}

.player-meta {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.player-meta b {
  color: var(--text);
}

.controls {
  min-height: 96px;
  display: grid;
  grid-template-columns: repeat(2, minmax(126px, 1fr)) minmax(160px, 1.2fr) minmax(88px, 0.58fr) minmax(100px, 0.68fr) minmax(86px, 0.54fr);
  gap: 10px;
  align-items: stretch;
}

.control-group,
.weapon-group {
  min-height: 64px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 6px;
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.control-group {
  grid-template-columns: 42px minmax(44px, 1fr) 42px;
}

.weapon-group {
  grid-template-columns: minmax(0, 1fr);
}

.control-group span {
  grid-column: 1 / -1;
}

.control-group strong {
  align-self: center;
  justify-self: center;
  font-size: 20px;
}

.control-group button,
.weapon-group select,
.fire,
.reset,
.sound,
.next-round,
.shop-option {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #151b1e;
  cursor: pointer;
  touch-action: manipulation;
}

.weapon-group select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 0 8px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}

.weapon-group select:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.control-group button {
  min-height: 36px;
  font-size: 22px;
  font-weight: 800;
}

.sound,
.fire,
.reset {
  min-height: 64px;
  font-weight: 900;
}

.sound {
  color: var(--text);
  background: #24424a;
  border-color: #47727c;
}

.sound.ready {
  color: #102016;
  background: var(--green);
  border-color: #a8e3a2;
}

.fire {
  color: #1b1205;
  background: var(--amber);
  border-color: #ffd08a;
}

.reset {
  color: var(--text);
  background: #2d3539;
}

.shop-panel {
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(260px, 1fr) minmax(120px, 160px);
  gap: 12px;
  align-items: stretch;
}

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

.shop-panel h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.shop-panel p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

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

.shop-option {
  min-height: 142px;
  padding: 10px;
  text-align: left;
  background: var(--panel-2);
}

.missile-card {
  display: grid;
  grid-template-columns: minmax(96px, 0.72fr) minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}

.missile-thumb {
  min-height: 112px;
  position: relative;
  display: block;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background:
    radial-gradient(circle at 74% 28%, rgba(255, 255, 255, 0.12), transparent 24%),
    linear-gradient(145deg, #10181b, #243034);
}

.missile-trail,
.missile-body,
.missile-effect {
  position: absolute;
  display: block;
}

.missile-trail {
  left: 10%;
  top: 50%;
  width: 44%;
  height: 8px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--missile-trail));
  opacity: 0.85;
}

.missile-body {
  left: 42%;
  top: 50%;
  width: 42%;
  height: 18px;
  transform: translateY(-50%);
  border: 2px solid #101617;
  background: var(--missile-body);
}

.missile-body::before,
.missile-body::after {
  content: "";
  position: absolute;
  display: block;
}

.missile-effect {
  right: 9px;
  bottom: 9px;
  width: 22px;
  height: 22px;
  border: 2px solid var(--missile-burst);
  border-radius: 50%;
  opacity: 0.72;
}

.missile-card[data-kind="shell"] .missile-body {
  width: 30px;
  height: 30px;
  border-radius: 50%;
}

.missile-card[data-kind="shell"] .missile-body::before {
  right: -2px;
  top: 8px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--missile-nose);
}

.missile-card[data-kind="bomb"] .missile-body {
  width: 46px;
  height: 28px;
  border-radius: 50%;
}

.missile-card[data-kind="bomb"] .missile-body::before {
  right: -13px;
  top: 5px;
  border-left: 15px solid var(--missile-nose);
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}

.missile-card[data-kind="bomb"] .missile-body::after {
  left: 17px;
  top: 0;
  width: 7px;
  height: 100%;
  background: var(--missile-band);
}

.missile-card[data-kind="dart"] .missile-body {
  width: 54px;
  height: 12px;
  border-radius: 2px;
}

.missile-card[data-kind="dart"] .missile-body::before {
  right: -18px;
  top: -5px;
  border-left: 20px solid var(--missile-nose);
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
}

.missile-card[data-kind="cluster"] .missile-body {
  width: 44px;
  height: 24px;
  border-radius: 999px;
}

.missile-card[data-kind="cluster"] .missile-body::before {
  left: 7px;
  top: -9px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--missile-band);
  box-shadow: 13px 0 0 var(--missile-band), 26px 0 0 var(--missile-band), 0 33px 0 var(--missile-band), 13px 33px 0 var(--missile-band), 26px 33px 0 var(--missile-band);
}

.missile-card[data-kind="drill"] .missile-body {
  width: 44px;
  height: 18px;
  border-radius: 4px;
}

.missile-card[data-kind="drill"] .missile-body::before {
  right: -18px;
  top: -6px;
  border-left: 20px solid var(--missile-nose);
  border-top: 15px solid transparent;
  border-bottom: 15px solid transparent;
}

.missile-card[data-kind="drill"] .missile-body::after {
  left: 8px;
  top: -3px;
  width: 5px;
  height: 24px;
  transform: rotate(-28deg);
  background: var(--missile-band);
  box-shadow: 13px 6px 0 var(--missile-band);
}

.missile-card[data-kind="gust"] .missile-body {
  width: 50px;
  height: 14px;
  border-radius: 999px;
}

.missile-card[data-kind="gust"] .missile-body::before {
  right: -14px;
  top: -4px;
  border-left: 16px solid var(--missile-nose);
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
}

.missile-card[data-kind="gust"] .missile-body::after {
  left: -8px;
  top: -10px;
  border-right: 16px solid var(--missile-band);
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  filter: drop-shadow(0 20px 0 var(--missile-band));
}

.missile-card[data-kind="gust"] .missile-effect {
  border-style: dashed;
}

.missile-card[data-kind="timer"] .missile-body {
  width: 40px;
  height: 28px;
  border-radius: 7px;
}

.missile-card[data-kind="timer"] .missile-body::before {
  left: 13px;
  top: 6px;
  width: 12px;
  height: 12px;
  border: 3px solid var(--missile-nose);
  border-radius: 50%;
}

.missile-card[data-kind="timer"] .missile-body::after {
  right: -12px;
  top: 6px;
  border-left: 14px solid var(--missile-band);
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}

.missile-card[data-kind="nuke"] .missile-body {
  width: 48px;
  height: 30px;
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(215, 255, 79, 0.32);
}

.missile-card[data-kind="nuke"] .missile-body::before {
  right: -14px;
  top: 6px;
  border-left: 16px solid var(--missile-nose);
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
}

.missile-card[data-kind="nuke"] .missile-body::after {
  left: 17px;
  top: -1px;
  width: 9px;
  height: 32px;
  background: var(--missile-band);
}

.missile-card[data-kind="nuke"] .missile-effect {
  width: 30px;
  height: 30px;
  box-shadow: 0 0 18px var(--missile-burst);
}

.missile-card[data-kind="vortex"] .missile-body {
  width: 42px;
  height: 32px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 8px var(--missile-band), 0 0 18px rgba(185, 133, 244, 0.34);
}

.missile-card[data-kind="vortex"] .missile-body::before {
  left: 9px;
  top: 7px;
  width: 20px;
  height: 15px;
  border: 3px solid var(--missile-nose);
  border-left-color: transparent;
  border-radius: 50%;
  transform: rotate(-25deg);
}

.missile-card[data-kind="vortex"] .missile-effect {
  border-style: double;
  box-shadow: 0 0 16px var(--missile-burst);
}

.missile-card[data-kind="meteor"] .missile-body {
  width: 43px;
  height: 30px;
  clip-path: polygon(100% 50%, 70% 4%, 20% 14%, 0 55%, 32% 100%, 72% 86%);
}

.missile-card[data-kind="meteor"] .missile-body::before {
  left: -24px;
  top: 7px;
  width: 28px;
  height: 14px;
  border-radius: 999px 0 0 999px;
  background: var(--missile-band);
  filter: blur(1px);
}

.missile-card[data-kind="meteor"] .missile-body::after {
  right: 5px;
  top: 9px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--missile-nose);
}

.missile-card[data-kind="frost"] .missile-body {
  width: 46px;
  height: 30px;
  clip-path: polygon(100% 50%, 70% 0, 24% 0, 0 50%, 24% 100%, 70% 100%);
}

.missile-card[data-kind="frost"] .missile-body::before {
  left: 8px;
  top: -6px;
  width: 4px;
  height: 42px;
  background: var(--missile-band);
  box-shadow: 11px 0 0 var(--missile-band), 22px 0 0 var(--missile-band);
}

.missile-card[data-kind="frost"] .missile-effect {
  border-radius: 4px;
  transform: rotate(45deg);
}

.missile-card[data-kind="beam"] .missile-body {
  width: 54px;
  height: 14px;
  border-radius: 3px;
}

.missile-card[data-kind="beam"] .missile-body::before {
  right: -16px;
  top: -5px;
  border-left: 18px solid var(--missile-nose);
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
}

.missile-card[data-kind="beam"] .missile-body::after {
  left: 10px;
  top: -6px;
  width: 5px;
  height: 26px;
  transform: skewX(-22deg);
  background: var(--missile-band);
  box-shadow: 15px 0 0 var(--missile-band);
}

.missile-card[data-kind="beam"] .missile-effect {
  width: 12px;
  height: 34px;
  border-radius: 999px;
  box-shadow: 0 0 16px var(--missile-burst);
}

.missile-card[data-kind="tesla"] .missile-body {
  width: 48px;
  height: 16px;
  border-radius: 6px;
  box-shadow: 0 0 14px rgba(57, 214, 255, 0.28);
}

.missile-card[data-kind="tesla"] .missile-body::before {
  right: -15px;
  top: -5px;
  border-left: 17px solid var(--missile-nose);
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
}

.missile-card[data-kind="tesla"] .missile-body::after {
  left: 8px;
  top: -5px;
  width: 4px;
  height: 26px;
  transform: skewX(-24deg);
  background: var(--missile-band);
  box-shadow: 12px 0 0 var(--missile-band), 24px 0 0 var(--missile-band);
}

.missile-card[data-kind="tesla"] .missile-effect {
  border-style: dashed;
  box-shadow: 0 0 16px var(--missile-burst);
}

.missile-card[data-kind="acid"] .missile-body {
  width: 46px;
  height: 26px;
  border-radius: 50%;
}

.missile-card[data-kind="acid"] .missile-body::before {
  right: -13px;
  top: 5px;
  border-left: 15px solid var(--missile-nose);
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}

.missile-card[data-kind="acid"] .missile-body::after {
  left: 9px;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--missile-band);
  box-shadow: 14px 6px 0 var(--missile-band);
}

.missile-card[data-kind="acid"] .missile-effect {
  border-radius: 45% 55% 50% 50%;
  transform: rotate(35deg);
}

.missile-card[data-kind="sonic"] .missile-body {
  width: 42px;
  height: 28px;
  border-radius: 999px;
}

.missile-card[data-kind="sonic"] .missile-body::before {
  right: -13px;
  top: 5px;
  border-left: 15px solid var(--missile-nose);
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
}

.missile-card[data-kind="sonic"] .missile-body::after {
  left: 10px;
  top: 6px;
  width: 14px;
  height: 14px;
  border: 3px solid var(--missile-band);
  border-left-color: transparent;
  border-radius: 50%;
}

.missile-card[data-kind="sonic"] .missile-effect {
  width: 32px;
  height: 18px;
  border-radius: 50%;
}

.missile-card[data-kind="prism"] .missile-body {
  width: 46px;
  height: 30px;
  clip-path: polygon(100% 50%, 70% 0, 12% 18%, 0 50%, 12% 82%, 70% 100%);
  box-shadow: 0 0 14px rgba(255, 140, 255, 0.28);
}

.missile-card[data-kind="prism"] .missile-body::before {
  left: 10px;
  top: -4px;
  width: 5px;
  height: 38px;
  transform: rotate(-38deg);
  background: var(--missile-band);
  box-shadow: 14px 8px 0 var(--missile-nose);
}

.missile-card[data-kind="prism"] .missile-effect {
  width: 34px;
  height: 12px;
  border-radius: 999px;
  transform: rotate(-25deg);
  box-shadow: 0 0 18px var(--missile-burst);
}

.missile-copy {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  gap: 5px;
}

.missile-copy strong,
.missile-copy em,
.missile-copy span,
.missile-copy small,
.missile-copy b {
  display: block;
  min-width: 0;
}

.missile-copy strong {
  font-size: 15px;
  line-height: 1.12;
}

.missile-copy em {
  color: var(--amber);
  font-size: 12px;
  font-style: normal;
  line-height: 1.15;
}

.missile-copy span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.missile-copy small {
  color: rgba(237, 244, 233, 0.72);
  font-size: 11px;
  line-height: 1.15;
}

.missile-copy b {
  align-self: end;
  color: var(--text);
  font-size: 12px;
}

.shop-option.selected {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green);
}

.next-round {
  min-height: 74px;
  color: #101706;
  background: var(--green);
  border-color: #a8e3a2;
  font-weight: 900;
}

.dev-panel {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100vw - 28px);
  padding: 8px;
  border: 1px solid rgba(255, 208, 138, 0.54);
  border-radius: 8px;
  background: rgba(17, 23, 25, 0.92);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
}

.dev-panel[hidden] {
  display: none;
}

.dev-panel strong {
  color: var(--amber);
  font-size: 12px;
  white-space: nowrap;
}

.dev-panel button {
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #222b2f;
  font-size: 12px;
  font-weight: 800;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(114, 197, 223, 0.8);
  outline-offset: 2px;
}

@media (max-width: 820px) {
  .shell {
    padding: 8px;
    gap: 8px;
  }

  .topbar,
  .hud,
  .shop-panel {
    border-radius: 0;
  }

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

  .readout {
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .matchbar {
    min-width: 0;
  }

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

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

  .shop-panel {
    grid-template-columns: 1fr;
  }

  .shop-options {
    grid-template-columns: 1fr;
  }

  .missile-card {
    grid-template-columns: minmax(92px, 0.42fr) minmax(0, 1fr);
  }

  .fire,
  .reset,
  .next-round {
    min-height: 54px;
  }

  .dev-panel {
    left: 8px;
    right: 8px;
    bottom: 8px;
    flex-wrap: wrap;
  }
}
