:root {
  color-scheme: dark;
  --panel: rgba(26, 3, 7, 0.72);
  --panel-edge: rgba(255, 141, 141, 0.2);
  --text: #fff7f7;
  --muted: #ffb9b9;
  --blue: #58d8ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(111, 8, 18, 0.35), transparent 44%),
    linear-gradient(180deg, #120005, #33040a 48%, #070003);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.game-shell {
  position: relative;
  width: min(100vw, 560px);
  height: min(100vh, 840px);
  aspect-ratio: 2 / 3;
  max-height: 100vh;
  background: #180006;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 26px 80px rgba(0, 0, 0, 0.58);
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.hud {
  position: absolute;
  inset: 12px 12px auto;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 7px;
  pointer-events: none;
}

.hud div {
  min-width: 0;
  padding: 7px 6px 8px;
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(36, 6, 12, 0.72), rgba(12, 1, 4, 0.46));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09);
  text-align: center;
}

.hud span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: clamp(0.48rem, 2.1vw, 0.62rem);
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hud strong {
  display: block;
  min-height: 1.1em;
  color: var(--text);
  font-size: clamp(0.72rem, 3.3vw, 1rem);
  font-variant-numeric: tabular-nums;
}

.life-pips {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(18, 0, 5, 0.68);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.life-pips.is-hidden {
  display: none;
}

.life-pips span {
  margin-right: 3px;
  color: #ffd1d1;
  font-size: 0.68rem;
  font-weight: 950;
  text-transform: uppercase;
}

.life-pip {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 30%, #ffb2a9 0 16%, #e92b2b 42%, #7b0309 100%);
  box-shadow: 0 0 10px rgba(255, 70, 70, 0.42), inset 0 -3px 5px rgba(60, 0, 0, 0.5);
}

.life-pip.is-empty {
  background: rgba(55, 4, 10, 0.74);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 28px;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(16, 0, 4, 0.12), rgba(13, 0, 4, 0.66)),
    image-set(url("Generated image 2.png") type("image/png"));
  background-size: cover;
  background-position: center;
  text-align: center;
}

.overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(17, 0, 5, 0.48);
}

.overlay.is-visible {
  display: grid;
}

.overlay > * {
  position: relative;
  max-width: 390px;
}

.overlay-panel {
  display: grid;
  gap: 11px;
  justify-items: center;
  width: min(100%, 420px);
}

.titlemark {
  font-size: clamp(2.7rem, 12vw, 5rem);
  font-weight: 950;
  line-height: 0.9;
  color: #ffffff;
  text-shadow: 0 0 12px rgba(69, 213, 255, 0.75), 0 5px 0 rgba(112, 4, 20, 0.84);
}

.overlay p {
  margin: 12px 0 4px;
  color: #ffe4e4;
  font-size: clamp(0.98rem, 3.6vw, 1.15rem);
  font-weight: 700;
  line-height: 1.35;
  text-shadow: 0 2px 10px #090003;
}

.loadout-section {
  display: grid;
  gap: 6px;
  width: 100%;
}

.loadout-section h2 {
  margin: 0;
  color: #ffb9b9;
  font-size: 0.68rem;
  font-weight: 950;
  letter-spacing: 0;
  text-align: left;
  text-transform: uppercase;
}

button {
  min-width: 144px;
  min-height: 46px;
  padding: 0 22px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #83ecff, #218fe7);
  color: #011724;
  font: inherit;
  font-size: 1rem;
  font-weight: 950;
  box-shadow: 0 11px 26px rgba(13, 178, 255, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

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

.secondary {
  background: linear-gradient(180deg, #fff3d2, #ffa43d);
  color: #281000;
  box-shadow: 0 11px 26px rgba(255, 142, 43, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.character-grid,
.gun-grid,
.module-grid,
.upgrade-grid,
.progress-panel,
.mission-list,
.achievement-list,
.result-grid,
.best-strip {
  display: grid;
  width: 100%;
  gap: 8px;
}

.character-grid,
.module-grid,
.upgrade-grid,
.progress-panel,
.mission-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.achievement-list {
  grid-template-columns: 1fr;
}

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

.character-button,
.gun-button,
.module-button,
.upgrade-button,
.mission-card,
.achievement-card {
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(24, 0, 7, 0.76);
  color: #ffe8e8;
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.character-button {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 72px;
}

.gun-button {
  display: grid;
  place-items: center;
  min-height: 50px;
  padding: 5px;
}

.character-button strong,
.character-button span,
.module-button strong,
.module-button span,
.upgrade-button strong,
.upgrade-button span,
.mission-card strong,
.mission-card span,
.achievement-card strong,
.achievement-card span {
  display: block;
}

.character-button strong,
.module-button strong,
.upgrade-button strong,
.mission-card strong,
.achievement-card strong {
  color: #ffffff;
  font-size: 0.9rem;
}

.character-button span,
.module-button span,
.upgrade-button span,
.mission-card span,
.achievement-card span {
  margin-top: 3px;
  color: #ffcaca;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
}

.mission-card,
.achievement-card {
  min-height: 64px;
}

.mission-card.is-complete,
.achievement-card.is-complete {
  border-color: rgba(215, 255, 101, 0.62);
  background: rgba(40, 57, 8, 0.74);
}

.mission-meter {
  height: 6px;
  margin-top: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.mission-meter i {
  display: block;
  height: 100%;
  width: var(--meter, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, #58d8ff, #d7ff65);
}

.character-button.is-selected,
.gun-button.is-selected,
.module-button.is-selected,
.upgrade-button:not(:disabled):hover {
  border-color: rgba(116, 231, 255, 0.75);
  background: rgba(17, 73, 91, 0.82);
}

.character-button.is-locked {
  opacity: 0.58;
}

.craft-sprite {
  position: relative;
  display: block;
  width: 48px;
  height: 58px;
  margin: auto;
}

.craft-sprite::before,
.craft-sprite::after,
.sprite-body,
.sprite-cockpit {
  position: absolute;
  content: "";
}

.sprite-body {
  left: 18px;
  top: 4px;
  width: 12px;
  height: 40px;
  border: 2px solid var(--sprite-stroke, #7ccbea);
  border-radius: 70% 70% 45% 45%;
  background: linear-gradient(180deg, #ffffff, var(--sprite-body, #dff6ff));
  box-shadow: 0 0 12px var(--sprite-glow, rgba(52, 203, 255, 0.5));
}

.sprite-cockpit {
  left: 21px;
  top: 12px;
  width: 6px;
  height: 16px;
  border-radius: 999px;
  background: var(--sprite-accent, #2fb4f4);
}

.craft-sprite::before,
.craft-sprite::after {
  top: 26px;
  width: 20px;
  height: 15px;
  border: 2px solid var(--sprite-stroke, #7ccbea);
  background: linear-gradient(180deg, #ffffff, var(--sprite-wing, #e7f0f7));
}

.craft-sprite::before {
  left: 0;
  transform: skewY(-28deg);
  border-radius: 80% 20% 20% 70%;
}

.craft-sprite::after {
  right: 0;
  transform: skewY(28deg);
  border-radius: 20% 80% 70% 20%;
}

.craft-vial {
  --sprite-body: #e6ffd9;
  --sprite-wing: #dfffd1;
  --sprite-stroke: #9be65e;
  --sprite-accent: #82d83e;
  --sprite-glow: rgba(130, 216, 62, 0.58);
  transform: scaleX(0.82) scaleY(1.08);
}

.craft-tcell {
  --sprite-body: #ffd8e9;
  --sprite-wing: #ffd0e5;
  --sprite-stroke: #ff77b7;
  --sprite-accent: #ff4b9e;
  --sprite-glow: rgba(255, 75, 158, 0.58);
  transform: scaleX(1.08) scaleY(0.95);
}

.gun-icon {
  position: relative;
  display: block;
  width: 32px;
  height: 32px;
}

.gun-icon i {
  position: absolute;
  display: block;
  left: 50%;
  bottom: 3px;
  width: 4px;
  height: 24px;
  border-radius: 999px;
  background: var(--gun-color, #75f3ff);
  box-shadow: 0 0 10px var(--gun-color, #75f3ff);
  transform-origin: 50% 100%;
}

.gun-needle i:nth-child(1) {
  transform: translateX(-50%);
}

.gun-twin i:nth-child(1) {
  transform: translateX(-8px);
}

.gun-twin i:nth-child(2) {
  transform: translateX(4px);
}

.gun-spread i:nth-child(1) {
  transform: translateX(-50%) rotate(-22deg);
}

.gun-spread i:nth-child(2) {
  transform: translateX(-50%);
}

.gun-spread i:nth-child(3) {
  transform: translateX(-50%) rotate(22deg);
}

.gun-beam i {
  width: 8px;
  height: 28px;
  background: #ffffff;
}

.gun-burst i:nth-child(1) {
  transform: translateX(-50%) rotate(-34deg);
}

.gun-burst i:nth-child(2) {
  transform: translateX(-50%) rotate(-16deg);
}

.gun-burst i:nth-child(3) {
  transform: translateX(-50%);
}

.gun-burst i:nth-child(4) {
  transform: translateX(-50%) rotate(16deg);
}

.gun-burst i:nth-child(5) {
  transform: translateX(-50%) rotate(34deg);
}

.gun-wave i:nth-child(1),
.gun-wave i:nth-child(2) {
  width: 5px;
  background: #d7ff65;
}

.gun-wave i:nth-child(1) {
  transform: translateX(-8px) rotate(-12deg);
}

.gun-wave i:nth-child(2) {
  transform: translateX(4px) rotate(12deg);
}

.module-button.is-locked,
.upgrade-button:disabled {
  opacity: 0.55;
}

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

.stats-drawer,
.progress-drawer {
  width: 100%;
}

.stats-drawer summary,
.progress-drawer summary {
  width: fit-content;
  margin: 0 auto;
  padding: 7px 13px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(20, 0, 6, 0.62);
  color: #ffd1d1;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 950;
  text-transform: uppercase;
  list-style: none;
}

.stats-drawer summary::-webkit-details-marker,
.progress-drawer summary::-webkit-details-marker {
  display: none;
}

.stats-drawer[open] summary,
.progress-drawer[open] summary {
  margin-bottom: 8px;
}

.result-grid div,
.best-strip div,
.progress-panel div {
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(22, 0, 7, 0.74);
}

.result-grid span,
.best-strip span,
.progress-panel span {
  display: block;
  color: #ffb9b9;
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.result-grid strong,
.best-strip strong,
.progress-panel strong {
  display: block;
  color: #ffffff;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}

.controls span {
  padding: 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(24, 0, 7, 0.7);
  color: #ffd0d0;
  font-size: 0.78rem;
  font-weight: 800;
}

@media (max-width: 520px) {
  .game-shell {
    width: 100vw;
    height: 100vh;
    aspect-ratio: auto;
  }

  .hud {
    inset: 8px 8px auto;
    gap: 5px;
  }

  .overlay {
    place-items: start center;
    padding: 18px 28px 24px;
  }

  .overlay-panel {
    gap: 8px;
  }

  .titlemark {
    font-size: 2.45rem;
  }

  .overlay p {
    margin: 4px 0 2px;
    font-size: 0.92rem;
  }

  .loadout-section {
    gap: 4px;
  }

  .hud div {
    padding: 6px 3px;
  }

  .life-pips {
    left: 8px;
    bottom: 8px;
    padding: 6px 7px;
  }

  .character-grid,
  .module-grid,
  .upgrade-grid,
  .progress-panel,
  .mission-list {
    grid-template-columns: 1fr;
  }

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

  .character-button {
    min-height: 64px;
  }

  .module-button,
  .upgrade-button {
    min-height: 48px;
  }

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