:root {
  color-scheme: dark;
  --ink: #f5f4ed;
  --muted: #8d96a8;
  --panel: #171c28;
  --panel-2: #202635;
  --line: #30394d;
  --gold: #efb943;
  --blue: #72adff;
  --danger: #f16f67;
  --mint: #78c6aa;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0d1018;
}

body {
  color: var(--ink);
  font-family: Inter, ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

button, a { font: inherit; }
button { color: inherit; }

.game-shell {
  display: grid;
  grid-template-rows: 68px minmax(240px, 1fr) 144px;
  width: 100%;
  height: 100dvh;
  min-height: 480px;
  background: radial-gradient(circle at 50% 35%, #242b3c 0, #111520 62%);
}

.hud {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(152px, 1fr) auto minmax(44px, 1fr);
  align-items: center;
  gap: 18px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 16, 24, .92);
  box-shadow: 0 10px 28px rgba(0,0,0,.18);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  color: var(--ink);
  text-decoration: none;
  font-size: 15px;
  letter-spacing: .08em;
}

.brand b { color: var(--blue); }
.brand-wheel {
  width: 31px;
  height: 31px;
  border: 5px solid #5f769a;
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px #202838;
  position: relative;
}
.brand-wheel::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 12px;
  left: 7px;
  top: -10px;
  border-radius: 3px;
  background: var(--blue);
}

.stats { display: flex; align-items: center; gap: clamp(17px, 4vw, 56px); }
.stats div { display: grid; min-width: 56px; text-align: center; }
.stats small, .shop-heading small, .modal-card small, .intro-card > small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .16em;
}
.stats strong { font-size: 19px; font-variant-numeric: tabular-nums; }
.stats div:first-child strong { color: #9dc7ff; }
.stats div:nth-child(2) strong { color: var(--gold); }

.icon-button {
  justify-self: end;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  font-weight: 900;
  cursor: pointer;
}
.icon-button:hover { border-color: #61708e; transform: translateY(-1px); }

.arena-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  isolation: isolate;
}

#game { display: block; width: 100%; height: 100%; outline: none; cursor: crosshair; }
.arena-wrap.placing #game { cursor: copy; }
.arena-vignette {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  box-shadow: inset 0 0 80px rgba(0,0,0,.38);
}

.controls {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 16px;
  padding: 13px 20px 16px;
  border-top: 1px solid var(--line);
  background: rgba(13, 16, 24, .96);
}

.fire-all {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  overflow: hidden;
  border: 1px solid #996b28;
  border-radius: 15px;
  background: linear-gradient(145deg, #5b3f1c, #29271f);
  cursor: pointer;
}
.fire-all:hover:not(:disabled) { border-color: var(--gold); }
.fire-all:active:not(:disabled) { transform: scale(.985); }
.fire-all:disabled { opacity: .62; cursor: default; }
.fire-all.active {
  border-color: var(--mint);
  background: linear-gradient(145deg, #205946, #1d322d);
  box-shadow: inset 0 0 22px rgba(120, 198, 170, .12);
}
.fire-all.active .fire-icon, .fire-all.active small { color: #9ee8cb; }
.fire-all .fire-icon { color: var(--gold); font-size: 25px; }
.fire-all span:nth-child(2) { display: grid; text-align: left; }
.fire-all b { letter-spacing: .08em; }
.fire-all small { color: #d8bd8b; font-size: 9px; margin-top: 3px; }
.fire-all i {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 4px;
  background: var(--gold);
  transform-origin: left;
}
.fire-all.active i { background: var(--mint); }

.shop-wrap { min-width: 0; }
.shop-heading { display: flex; align-items: end; justify-content: space-between; margin: 0 3px 7px; }
.shop-heading span:first-child { display: flex; gap: 9px; align-items: baseline; }
.shop-tools { display: flex; align-items: center; gap: 9px; }
.shop-tools > span { color: var(--muted); font-size: 11px; font-weight: 800; }
.shop-tools button {
  padding: 4px 7px;
  border: 1px solid #644347;
  border-radius: 6px;
  background: #2b2229;
  color: #d99591;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .08em;
  cursor: pointer;
}
.shop-tools button:hover:not(:disabled), .shop-tools button.active { border-color: var(--danger); color: #ffaaa4; background: #42292e; }
.shop-tools button:disabled { cursor: default; opacity: .45; }
.shop { display: grid; grid-template-columns: repeat(5, minmax(112px, 1fr)); gap: 8px; }
.shop-card {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 76px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  cursor: pointer;
  text-align: left;
}
.shop-card:hover:not(:disabled) { background: #222a3a; border-color: #65738d; }
.shop-card.selected { outline: 2px solid var(--blue); background: #202c40; }
.shop-card:disabled { cursor: default; filter: saturate(.4); opacity: .5; }
.shop-card img { width: 38px; height: 38px; }
.shop-card span { display: grid; overflow: hidden; }
.shop-card b { font-size: 11px; letter-spacing: .07em; white-space: nowrap; }
.shop-card small { color: var(--gold); font-size: 10px; font-weight: 800; margin-top: 5px; }
.shop-card.unlocked small { color: var(--mint); }

.placement-banner {
  position: absolute;
  z-index: 4;
  top: 12px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 7px 8px 7px 13px;
  border: 1px solid #5e7397;
  border-radius: 12px;
  background: rgba(17, 23, 34, .93);
  transform: translateX(-50%);
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
  font-size: 11px;
  letter-spacing: .09em;
}
.placement-banner button { border: 0; border-radius: 7px; padding: 7px 9px; background: #3a4458; font-size: 9px; cursor: pointer; }
.placement-banner i { color: var(--muted); font-style: normal; }
.arena-wrap.destroying #game { cursor: not-allowed; }

.toast {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 16px;
  pointer-events: none;
  opacity: 0;
  padding: 8px 12px;
  border-radius: 9px;
  background: rgba(10,12,18,.86);
  color: #d9e6fa;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  transform: translate(-50%, 8px);
  transition: .18s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.overlay {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 10, 16, .72);
  backdrop-filter: blur(5px);
}
.hidden { display: none !important; }

.intro-card, .modal-card {
  width: min(450px, 100%);
  padding: 25px 29px;
  border: 1px solid #3b455c;
  border-radius: 22px;
  background: linear-gradient(155deg, rgba(35,43,59,.98), rgba(18,22,32,.98));
  box-shadow: 0 28px 90px rgba(0,0,0,.48);
  text-align: center;
}
.intro-card h1 { margin: 7px 0 12px; font-size: clamp(39px, 7vh, 62px); line-height: .84; letter-spacing: -.055em; }
.intro-card h1 span { color: var(--blue); }
.intro-card p { max-width: 370px; margin: 0 auto; color: #b7becd; font-size: 13px; line-height: 1.5; }
.intro-steps { display: flex; justify-content: center; gap: 15px; margin: 19px 0; color: #adb5c4; font-size: 10px; font-weight: 700; }
.intro-steps span { display: flex; gap: 5px; align-items: center; }
.intro-steps b { display: grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; background: #344258; color: var(--blue); }

.primary-button {
  min-width: 190px;
  padding: 12px 20px;
  border: 0;
  border-radius: 11px;
  background: var(--blue);
  color: #111827;
  font-weight: 900;
  letter-spacing: .06em;
  cursor: pointer;
  box-shadow: 0 7px 20px rgba(75,137,226,.25);
}
.primary-button:hover { background: #9ac7ff; transform: translateY(-1px); }
.primary-button b { margin-left: 8px; }
.modal-card h2 { margin: 7px 0 20px; font-size: 38px; }
.results { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; overflow: hidden; margin: 0 0 19px; border: 1px solid var(--line); border-radius: 12px; background: var(--line); }
.results div { display: grid; padding: 11px; background: var(--panel); }
.results strong { margin-top: 3px; font-size: 21px; }

@media (max-width: 760px) {
  .game-shell { grid-template-rows: 58px minmax(230px, 1fr) 174px; }
  .hud { grid-template-columns: auto 1fr 38px; gap: 8px; padding: 7px 9px; }
  .brand { font-size: 0; gap: 0; }
  .brand-wheel { width: 29px; height: 29px; }
  .stats { justify-content: space-evenly; gap: 4px; }
  .stats div { min-width: 45px; }
  .stats small { font-size: 7px; }
  .stats strong { font-size: 15px; }
  .icon-button { width: 36px; height: 36px; border-radius: 10px; }
  .controls { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 9px; padding: 9px 9px 12px; }
  .fire-all { flex-direction: column; gap: 1px; }
  .fire-all .fire-icon { font-size: 20px; }
  .fire-all span:nth-child(2) { text-align: center; }
  .fire-all b { font-size: 12px; }
  .fire-all small { font-size: 7px; }
  .shop { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; scrollbar-width: none; }
  .shop::-webkit-scrollbar { display: none; }
  .shop-card { flex: 0 0 104px; grid-template-columns: 34px 1fr; height: 70px; padding: 7px; scroll-snap-align: start; }
  .shop-card img { width: 34px; height: 34px; }
  .shop-card b { font-size: 9px; }
  .shop-heading { margin-bottom: 6px; }
  .shop-heading b { font-size: 11px; }
  .shop-heading small { display: none; }
  .intro-card, .modal-card { padding: 21px 20px; }
  .intro-card h1 { font-size: 42px; }
  .intro-steps { gap: 7px; }
  .intro-steps span { display: grid; justify-items: center; }
}

@media (max-height: 610px) {
  .game-shell { grid-template-rows: 54px minmax(220px, 1fr) 116px; }
  .controls { padding-top: 7px; padding-bottom: 8px; }
  .shop-card { height: 60px; }
  .shop-card img { width: 31px; height: 31px; }
  .intro-card { padding: 17px 22px; }
  .intro-card h1 { font-size: 36px; }
  .intro-steps { margin: 11px 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
