:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #050606;
  color: #f2f4ef;
  --amber: #efb158;
  --amber-deep: #a95d28;
  --panel: rgba(8, 11, 10, 0.9);
}

* {
  box-sizing: border-box;
}

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

canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  cursor: crosshair;
  background: #101313;
}

.hud {
  position: fixed;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(242, 244, 239, 0.94);
  pointer-events: none;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.55);
  transition: opacity 220ms ease;
}

body:not(.in-run) .hud {
  opacity: 0.24;
}

.hud-top {
  top: 16px;
  left: 16px;
  right: 16px;
}

.hud-bottom {
  left: 16px;
  right: 16px;
  bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid rgba(220, 230, 215, 0.2);
  background: rgba(12, 16, 15, 0.68);
  backdrop-filter: blur(12px);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.brand i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f5bd66;
  box-shadow: 0 0 12px rgba(245, 189, 102, 0.8);
  animation: signal 1.8s ease-in-out infinite;
}

.pill,
.ammo,
.ability,
.bar-wrap {
  min-height: 40px;
  border: 1px solid rgba(220, 230, 215, 0.18);
  background: rgba(12, 16, 15, 0.62);
  backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 10px 30px rgba(0, 0, 0, 0.25);
}

.pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
}

.pill span,
.bar-wrap span,
.ammo span {
  font-size: 11px;
  color: rgba(242, 244, 239, 0.62);
  text-transform: uppercase;
}

.pill strong {
  font-size: 16px;
}

.bar-wrap {
  width: min(280px, 28vw);
  padding: 7px 10px;
}

.bar-wrap span {
  display: block;
  margin-bottom: 5px;
}

.bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.bar i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #b92323, #f2643a, #ffd071);
  box-shadow: 0 0 18px rgba(242, 100, 58, 0.45);
}

.bar.armor i {
  background: linear-gradient(90deg, #4f90bb, #9fd5e8);
  box-shadow: 0 0 18px rgba(99, 178, 220, 0.45);
}

.ammo,
.ability {
  display: flex;
  align-items: center;
  padding: 8px 12px;
}

.ammo strong {
  font-size: 24px;
  line-height: 1;
}

.ability {
  min-width: 140px;
  justify-content: center;
  font-size: 13px;
  color: rgba(242, 244, 239, 0.84);
}

.center-panel,
.shop {
  position: fixed;
  z-index: 8;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(920px, calc(100vw - 32px));
  border: 1px solid rgba(234, 238, 226, 0.22);
  background: var(--panel);
  backdrop-filter: blur(22px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.center-panel {
  max-width: 650px;
  padding: 34px;
}

.pause-panel,
.result-panel {
  max-width: 560px;
}

.eyebrow {
  margin-bottom: 12px;
  color: #efbd72;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(44px, 9vw, 82px);
  line-height: 0.95;
  letter-spacing: 0;
}

.lede {
  max-width: 570px;
  font-size: 15px;
}

h2 {
  font-size: 26px;
  letter-spacing: 0;
}

p {
  margin-top: 12px;
  color: rgba(242, 244, 239, 0.68);
  line-height: 1.5;
}

button {
  appearance: none;
  border: 1px solid rgba(255, 220, 150, 0.42);
  background: linear-gradient(180deg, #f0b85d, #b86d2e);
  color: #17110b;
  font: inherit;
  font-weight: 800;
  min-height: 42px;
  padding: 0 18px;
  margin-top: 24px;
  cursor: pointer;
  box-shadow: 0 14px 32px rgba(184, 109, 46, 0.25);
}

button:hover {
  filter: brightness(1.07);
}

button:focus-visible {
  outline: 2px solid #ffe0a2;
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.button-secondary {
  border-color: rgba(228, 234, 224, 0.24);
  background: rgba(255, 255, 255, 0.06);
  color: #e9eee6;
  box-shadow: none;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 22px;
}

.controls div {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(234, 238, 226, 0.12);
  background: rgba(255, 255, 255, 0.035);
}

.controls kbd {
  flex: none;
  min-width: 34px;
  padding: 4px 6px;
  border: 1px solid rgba(255, 224, 162, 0.25);
  background: rgba(239, 177, 88, 0.1);
  color: #ffd895;
  font: 700 10px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-align: center;
}

.controls span {
  overflow: hidden;
  color: rgba(242, 244, 239, 0.72);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  min-height: 22px;
  margin-top: 14px;
  color: rgba(255, 208, 113, 0.86);
  font-size: 13px;
}

.shop {
  padding: 18px;
}

.shop-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 8px 16px;
}

.shop-head button {
  margin-top: 0;
  white-space: nowrap;
}

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

.shop-card {
  min-height: 190px;
  border: 1px solid rgba(234, 238, 226, 0.15);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  padding: 16px;
}

.shop-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.shop-card p {
  min-height: 72px;
  margin: 0;
  font-size: 13px;
}

.shop-card .cost {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.shop-card button {
  min-height: 36px;
  margin: 0;
}

.shop-card.disabled {
  opacity: 0.5;
}

.shop-card.installed {
  border-color: rgba(112, 196, 228, 0.35);
  background: linear-gradient(180deg, rgba(112, 196, 228, 0.1), rgba(255, 255, 255, 0.02));
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 24px;
}

.result-stats div {
  padding: 13px;
  border: 1px solid rgba(234, 238, 226, 0.12);
  background: rgba(255, 255, 255, 0.035);
}

.result-stats span,
.result-stats strong {
  display: block;
}

.result-stats span {
  color: rgba(242, 244, 239, 0.55);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.result-stats strong {
  margin-top: 5px;
  font-size: 21px;
}

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

.control-hint {
  position: fixed;
  z-index: 4;
  top: 66px;
  left: 17px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(242, 244, 239, 0.45);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

body.in-run .control-hint {
  opacity: 1;
}

.control-hint i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(239, 177, 88, 0.65);
}

.toast {
  position: fixed;
  z-index: 7;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  min-width: 260px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 14px 18px;
  border: 1px solid rgba(234, 238, 226, 0.2);
  background: rgba(10, 13, 12, 0.78);
  color: rgba(242, 244, 239, 0.92);
  text-align: center;
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}

@keyframes signal {
  0%, 100% { opacity: 0.55; transform: scale(0.86); }
  50% { opacity: 1; transform: scale(1); }
}

@media (max-width: 760px) {
  .hud-top,
  .hud-bottom {
    flex-wrap: wrap;
  }

  .brand {
    width: 100%;
  }

  .bar-wrap {
    width: calc(50vw - 22px);
  }

  .shop-grid {
    grid-template-columns: 1fr;
    max-height: 62vh;
    overflow: auto;
  }

  .center-panel {
    padding: 24px;
  }

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

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

  .control-hint {
    display: none;
  }
}

@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;
  }
}
