:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b0d10;
  color: #eef2f4;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

button {
  border: 1px solid rgba(238, 242, 244, 0.24);
  background: rgba(20, 26, 32, 0.84);
  color: #f5f7f8;
  border-radius: 6px;
  min-width: 128px;
  height: 44px;
  padding: 0 18px;
  font: 800 13px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  border-color: rgba(247, 189, 67, 0.72);
  background: rgba(40, 48, 55, 0.92);
  outline: none;
}

button.primary {
  border-color: rgba(247, 189, 67, 0.78);
  background: #f7bd43;
  color: #16120a;
}

.shell {
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100vh;
  padding: clamp(8px, 2vw, 24px);
  background:
    radial-gradient(circle at 20% 15%, rgba(75, 126, 138, 0.22), transparent 32%),
    linear-gradient(145deg, #0c1115, #15100f 54%, #0b0d10);
}

.stage {
  position: relative;
  width: min(100%, calc((100vh - 16px) * 1.36));
  max-width: 1180px;
  aspect-ratio: 15 / 11;
  border: 1px solid rgba(238, 242, 244, 0.2);
  border-radius: 8px;
  overflow: hidden;
  background: #11151a;
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.52);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
}

.hud {
  position: absolute;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 4;
}

.hud-top {
  top: 12px;
  gap: 14px;
}

.hud-bottom {
  bottom: 12px;
  gap: 14px;
}

.brand,
.readouts,
.status-pills,
.loadout {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand,
.readouts span,
.status-pills span,
.loadout span {
  min-height: 30px;
  padding: 8px 10px;
  border: 1px solid rgba(238, 242, 244, 0.18);
  border-bottom-color: rgba(0, 0, 0, 0.52);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.02) 38%, rgba(0, 0, 0, 0.24)),
    rgba(8, 11, 14, 0.72);
  backdrop-filter: blur(10px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -8px 14px rgba(0, 0, 0, 0.28),
    0 5px 14px rgba(0, 0, 0, 0.2);
  font-size: clamp(10px, 1.5vw, 12px);
  font-weight: 900;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.brand {
  color: #f7bd43;
  letter-spacing: 0;
}

.mark {
  width: 12px;
  height: 12px;
  padding: 0;
  border-radius: 2px;
  background: linear-gradient(135deg, #f7bd43 0 45%, #e05245 45% 100%);
}

.bar-stack {
  display: grid;
  gap: 6px;
  width: min(42vw, 320px);
}

.meter {
  position: relative;
  height: 18px;
  border: 1px solid rgba(238, 242, 244, 0.24);
  border-bottom-color: rgba(0, 0, 0, 0.58);
  border-radius: 5px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 42%),
    rgba(8, 11, 14, 0.78);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -8px 12px rgba(0, 0, 0, 0.42),
    0 6px 16px rgba(0, 0, 0, 0.24);
  overflow: hidden;
}

.meter span {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 900;
  color: #f5f7f8;
  text-shadow: 0 1px 2px #000;
}

.meter i {
  display: block;
  width: 100%;
  height: 100%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.36), transparent 42%),
    linear-gradient(90deg, #e05245, #f7bd43);
  box-shadow:
    inset 0 -5px 8px rgba(0, 0, 0, 0.22),
    0 0 14px rgba(247, 189, 67, 0.25);
  transition: width 140ms ease;
}

.meter.energy i {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.36), transparent 42%),
    linear-gradient(90deg, #4b9f8f, #66d0d5);
  box-shadow:
    inset 0 -5px 8px rgba(0, 0, 0, 0.2),
    0 0 14px rgba(102, 208, 213, 0.25);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: none;
  place-items: center;
  padding: 28px;
  background: rgba(6, 8, 10, 0.66);
  backdrop-filter: blur(7px);
  text-align: center;
}

.overlay.show {
  display: grid;
}

.result-banner {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 9;
  display: grid;
  justify-items: center;
  gap: 5px;
  width: min(560px, calc(100% - 36px));
  padding: 22px 24px;
  border: 1px solid rgba(247, 189, 67, 0.46);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 38%),
    rgba(10, 13, 15, 0.82);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -12px 24px rgba(0, 0, 0, 0.34),
    0 22px 68px rgba(0, 0, 0, 0.5);
  text-align: center;
  transform: translate(-50%, -50%) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.result-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.result-banner.success {
  border-color: rgba(102, 208, 213, 0.58);
}

.result-banner.failure {
  border-color: rgba(224, 82, 69, 0.64);
}

.result-banner p,
.result-banner h2,
.result-banner span {
  margin: 0;
}

.result-banner p {
  color: #f7bd43;
  font-size: 12px;
  font-weight: 950;
}

.result-banner h2 {
  color: #f5f7f8;
  font-size: clamp(34px, 7vw, 72px);
  line-height: 0.9;
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.38);
}

.result-banner span {
  color: #dce4e6;
  font-size: 13px;
  font-weight: 800;
}

.title-block {
  width: min(680px, 100%);
}

.kicker {
  margin: 0 0 10px;
  color: #f7bd43;
  font-size: clamp(11px, 2vw, 13px);
  font-weight: 950;
}

h1,
h2,
.tagline {
  margin: 0;
}

h1 {
  font-size: clamp(48px, 10vw, 112px);
  line-height: 0.9;
  letter-spacing: 0;
  color: #f5f7f8;
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.42);
}

h2 {
  font-size: clamp(24px, 5vw, 46px);
  line-height: 1;
}

.tagline {
  margin-top: 16px;
  color: #ced6d9;
  font-size: clamp(14px, 2.4vw, 18px);
  font-weight: 700;
}

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

.chassis-strip {
  display: flex;
  gap: 10px;
  width: min(920px, calc(100vw - 44px));
  margin-top: 18px;
  padding: 8px 4px 12px;
  overflow-x: auto;
  pointer-events: auto;
}

.chassis-button {
  display: grid;
  grid-template-rows: 54px auto auto;
  justify-items: center;
  gap: 4px;
  flex: 0 0 118px;
  height: auto;
  min-width: 118px;
  padding: 8px;
  border-color: rgba(238, 242, 244, 0.18);
  background: rgba(8, 11, 14, 0.72);
}

.chassis-button.selected {
  border-color: rgba(247, 189, 67, 0.86);
  background: rgba(50, 43, 27, 0.86);
}

.chassis-button.locked {
  opacity: 0.55;
}

.chassis-icon {
  display: grid;
  place-items: center;
  width: 100%;
  height: 54px;
}

.chassis-icon svg {
  width: 108px;
  height: 54px;
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.34));
}

.chassis-name {
  max-width: 100%;
  color: #f5f7f8;
  font-size: 11px;
  font-weight: 950;
  text-align: center;
  white-space: normal;
}

.chassis-button small {
  color: #9eb0b6;
  font-size: 9px;
  font-weight: 900;
  text-align: center;
}

.upgrade,
.garage {
  align-content: center;
  gap: 22px;
}

.upgrade-grid,
.garage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 220px));
  gap: 12px;
  width: min(100%, 708px);
}

.garage-grid {
  grid-template-columns: repeat(3, minmax(0, 240px));
  width: min(100%, 780px);
  max-height: min(58vh, 470px);
  overflow: auto;
  padding-right: 4px;
}

.upgrade-card,
.garage-card {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 150px;
  padding: 16px;
  border: 1px solid rgba(238, 242, 244, 0.2);
  border-radius: 8px;
  background: rgba(20, 26, 32, 0.88);
  text-align: left;
}

.garage-card {
  min-height: 240px;
}

.garage-card.skill-card {
  min-height: 150px;
}

.garage-card.selected {
  border-color: rgba(247, 189, 67, 0.78);
  background: rgba(36, 42, 46, 0.92);
}

.upgrade-card strong,
.garage-card strong {
  color: #f7bd43;
  font-size: 15px;
}

.upgrade-card span,
.garage-card span {
  color: #dce4e6;
  font-size: 13px;
  line-height: 1.35;
}

.garage-card small {
  color: #9eb0b6;
  font-size: 11px;
  font-weight: 800;
}

.garage-card.locked {
  opacity: 0.68;
}

.garage-preview {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 86px;
  border: 1px solid rgba(238, 242, 244, 0.12);
  border-radius: 6px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    rgba(8, 11, 14, 0.48);
  background-size: 16px 16px;
  overflow: hidden;
}

.garage-preview svg {
  width: min(100%, 210px);
  height: 86px;
  filter: drop-shadow(0 12px 12px rgba(0, 0, 0, 0.38));
}

.garage-card .mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 4px;
}

.garage-card .mini-actions button {
  min-width: 86px;
  height: 32px;
  padding: 0 10px;
  font-size: 11px;
}

.toast {
  position: absolute;
  left: 50%;
  top: 72px;
  z-index: 7;
  transform: translateX(-50%) translateY(-12px);
  min-height: 34px;
  max-width: min(520px, calc(100% - 32px));
  padding: 9px 14px;
  border: 1px solid rgba(247, 189, 67, 0.34);
  border-radius: 6px;
  background: rgba(8, 11, 14, 0.78);
  color: #f5f7f8;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

.mobile-controls {
  position: absolute;
  inset: auto 14px 16px 14px;
  z-index: 6;
  display: none;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
}

.move-pad {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(3, 48px);
  gap: 6px;
  pointer-events: auto;
}

.move-pad button,
.fire-pad button {
  min-width: 0;
  height: 48px;
  padding: 0;
  border-color: rgba(238, 242, 244, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.03) 42%, rgba(0, 0, 0, 0.24)),
    rgba(8, 11, 14, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -9px 14px rgba(0, 0, 0, 0.32),
    0 8px 18px rgba(0, 0, 0, 0.28);
  touch-action: none;
  user-select: none;
}

.move-pad button:active,
.fire-pad button:active {
  border-color: rgba(247, 189, 67, 0.88);
  background: rgba(50, 43, 27, 0.9);
}

.move-pad button[data-move="up"] {
  grid-column: 2;
  grid-row: 1;
}

.move-pad button[data-move="left"] {
  grid-column: 1;
  grid-row: 2;
}

.move-pad button[data-move="down"] {
  grid-column: 2;
  grid-row: 3;
}

.move-pad button[data-move="right"] {
  grid-column: 3;
  grid-row: 2;
}

.fire-pad {
  display: grid;
  gap: 10px;
  justify-items: end;
  pointer-events: auto;
}

.fire-pad button {
  width: 76px;
  height: 52px;
  font-size: 11px;
}

.fire-pad .fire-button {
  width: 92px;
  height: 64px;
  border-color: rgba(224, 82, 69, 0.76);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 40%),
    rgba(99, 33, 30, 0.88);
}

.mute-btn {
  min-width: 0 !important;
  width: 34px;
  height: 30px;
  padding: 0 !important;
  font-size: 14px;
  line-height: 1;
  display: grid;
  place-items: center;
  pointer-events: auto;
  cursor: pointer;
  border: 1px solid rgba(238, 242, 244, 0.18);
  border-bottom-color: rgba(0, 0, 0, 0.52);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.02) 38%, rgba(0, 0, 0, 0.24)),
    rgba(8, 11, 14, 0.72);
  backdrop-filter: blur(10px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -8px 14px rgba(0, 0, 0, 0.28),
    0 5px 14px rgba(0, 0, 0, 0.2);
}

.mute-btn:hover {
  border-color: rgba(247, 189, 67, 0.72);
  background: rgba(40, 48, 55, 0.92);
}

.mission-briefing {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  place-items: center;
  background: rgba(6, 8, 10, 0.82);
  backdrop-filter: blur(10px);
  text-align: center;
  pointer-events: none;
}

.mission-briefing.show {
  display: grid;
}

.mission-briefing .briefing-content {
  max-width: 520px;
}

.mission-briefing .briefing-mission {
  color: #f7bd43;
  font-size: clamp(11px, 2vw, 13px);
  font-weight: 950;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
}

.mission-briefing h2 {
  color: #f5f7f8;
  font-size: clamp(28px, 6vw, 56px);
  line-height: 0.95;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.4);
  margin: 0 0 12px;
}

.mission-briefing .briefing-theme {
  color: #ced6d9;
  font-size: clamp(13px, 2.2vw, 17px);
  font-weight: 700;
  margin: 0 0 6px;
}

.mission-briefing .briefing-hint {
  color: #9eb0b6;
  font-size: clamp(11px, 1.6vw, 13px);
  font-weight: 700;
  margin: 0;
}

.boss-alert {
  position: absolute;
  inset: 0;
  z-index: 11;
  display: none;
  place-items: center;
  pointer-events: none;
}

.boss-alert.show {
  display: grid;
}

.boss-alert-text {
  color: #e05245;
  font-size: clamp(36px, 8vw, 80px);
  font-weight: 950;
  letter-spacing: 0.06em;
  text-shadow:
    0 0 40px rgba(224, 82, 69, 0.6),
    0 0 80px rgba(224, 82, 69, 0.3),
    0 6px 0 rgba(0, 0, 0, 0.5);
  animation: bossPulse 0.4s ease-in-out infinite alternate;
}

@keyframes bossPulse {
  from { transform: scale(1); opacity: 0.85; }
  to { transform: scale(1.06); opacity: 1; }
}

.boss-flash {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(224, 82, 69, 0.25);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.boss-flash.show {
  opacity: 1;
}

.tutorial-tip {
  position: absolute;
  left: 50%;
  bottom: 140px;
  z-index: 7;
  transform: translateX(-50%) translateY(-8px);
  max-width: min(440px, calc(100% - 40px));
  padding: 12px 18px;
  border: 1px solid rgba(102, 208, 213, 0.48);
  border-radius: 8px;
  background: rgba(8, 11, 14, 0.85);
  backdrop-filter: blur(8px);
  color: #f5f7f8;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.tutorial-tip.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.tutorial-tip .tip-key {
  display: inline-block;
  padding: 2px 7px;
  margin: 0 2px;
  border: 1px solid rgba(247, 189, 67, 0.5);
  border-radius: 3px;
  background: rgba(247, 189, 67, 0.15);
  color: #f7bd43;
  font-size: 11px;
  font-weight: 950;
}

@media (max-width: 720px) {
  .shell {
    padding: 0;
  }

  .stage {
    width: 100vw;
    max-width: none;
    max-height: calc(100dvh - 140px);
    border: 0;
    border-radius: 0;
    aspect-ratio: 15 / 11;
    height: auto;
  }

  .hud {
    left: 6px;
    right: 6px;
  }

  .hud-top {
    top: 6px;
    gap: 6px;
  }

  .hud-bottom {
    bottom: 6px;
    gap: 6px;
  }

  .brand {
    display: none;
  }

  .readouts,
  .status-pills,
  .loadout {
    gap: 4px;
    flex-wrap: wrap;
  }

  .readouts span,
  .status-pills span,
  .loadout span {
    padding: 5px 6px;
    min-height: 24px;
    font-size: 11px;
  }

  .loadout {
    flex-wrap: wrap;
    justify-content: end;
    max-width: 55vw;
  }

  .bar-stack {
    width: min(42vw, 180px);
  }

  .mobile-controls {
    display: flex;
  }

  .upgrade-grid,
  .garage-grid {
    grid-template-columns: 1fr;
    max-width: 340px;
    max-height: 55dvh;
  }

  .upgrade-card,
  .garage-card {
    min-height: 160px;
  }

  .chassis-strip {
    width: calc(100vw - 16px);
  }

  .mission-briefing .briefing-content {
    padding: 16px;
  }

  .mission-briefing h2 {
    font-size: clamp(22px, 7vw, 40px);
  }

  .tutorial-tip {
    bottom: 150px;
    font-size: 12px;
    padding: 8px 14px;
  }

  .result-banner {
    width: calc(100% - 20px);
    padding: 14px 12px;
  }

  .result-banner h2 {
    font-size: clamp(28px, 10vw, 48px);
  }

  .result-banner .actions {
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .result-banner .actions button {
    padding: 10px 14px;
    font-size: 13px;
  }

  .title-block {
    width: 100%;
    padding: 0 8px;
  }

  h1 {
    font-size: clamp(28px, 9vw, 48px);
  }

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

  .actions button {
    padding: 12px 18px;
    font-size: 14px;
  }

  .overlay {
    padding: 12px;
  }

  .tagline {
    font-size: clamp(12px, 3vw, 16px);
  }
}

@media (pointer: coarse) and (min-width: 721px) {
  .mobile-controls {
    display: flex;
  }

  .hud-bottom {
    bottom: 116px;
  }
}

.watermark {
  position: fixed;
  right: 10px;
  bottom: 6px;
  z-index: 100;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.15);
  letter-spacing: 0.05em;
  pointer-events: none;
  user-select: none;
  font-family: "Segoe UI", system-ui, sans-serif;
}
