:root {
  color-scheme: dark;
  --ink: #f5fbff;
  --muted: rgba(232, 244, 255, 0.74);
  --panel: rgba(24, 32, 42, 0.72);
  --panel-strong: rgba(12, 19, 28, 0.9);
  --line: rgba(255, 255, 255, 0.2);
  --cyan: #8ee8f0;
  --orange: #ff8f5f;
  --red: #e43831;
  --green: #65d66f;
  --gold: #ffd756;
  --blue: #74b7ff;
  --shadow: rgba(0, 0, 0, 0.42);
  font-family: "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0b1018;
  color: var(--ink);
}

button {
  border: 0;
  color: inherit;
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-width: 320px;
  overflow: hidden;
  background: #72a5cc;
  isolation: isolate;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: none;
  touch-action: none;
  outline: none;
}

.hud {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.hud button,
.menu-overlay button {
  pointer-events: auto;
}

.top-left {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.small-tab,
.match-card,
.top-center,
.leaderboard,
.input-monitor,
.status-line,
.slot,
.menu-panel,
.mobile-stick,
.mobile-jump,
.mobile-fire {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 12px 30px var(--shadow);
  backdrop-filter: blur(8px);
}

.small-tab {
  height: 34px;
  padding: 0 11px;
  border-radius: 6px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.match-card {
  min-width: 178px;
  padding: 8px 10px;
  border-radius: 6px;
}

.match-card span,
.menu-panel p,
.menu-stats span,
.leader-row,
.status-line span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.match-card strong {
  display: block;
  margin-top: 2px;
  font-size: 0.95rem;
}

.top-center {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  min-width: 270px;
  transform: translateX(-50%);
  border-radius: 6px;
  padding: 8px 14px;
  text-align: center;
}

.top-center strong {
  display: block;
  font-size: 1.08rem;
  line-height: 1;
}

.top-center span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.leaderboard {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  width: min(220px, calc(100vw - 28px));
  border-radius: 6px;
  overflow: hidden;
}

.leader-row {
  display: grid;
  grid-template-columns: 1fr 32px;
  gap: 8px;
  align-items: center;
  padding: 5px 8px;
  min-height: 26px;
}

.leader-row.header {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
}

.leader-row strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.78rem;
}

.leader-row b {
  color: var(--gold);
  text-align: right;
  font-size: 0.78rem;
}

.leader-row .team-blue {
  color: #89ccff;
}

.leader-row .team-red {
  color: #ff9a83;
}

.input-monitor {
  position: absolute;
  top: 82px;
  left: 12px;
  width: 282px;
  border-radius: 6px;
  padding: 9px;
  background: rgba(12, 19, 28, 0.76);
}

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

.monitor-head strong {
  font-size: 0.78rem;
  text-transform: uppercase;
}

.monitor-head span,
.stick-cell span {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.monitor-buttons,
.monitor-pads {
  display: grid;
  gap: 5px;
}

.monitor-buttons {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.monitor-pads {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 6px;
}

.monitor-buttons span,
.monitor-pads span {
  display: grid;
  min-width: 0;
  min-height: 25px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(245, 251, 255, 0.7);
  font-size: 0.61rem;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.monitor-buttons span.active,
.monitor-pads span.active {
  border-color: rgba(255, 215, 86, 0.95);
  background: rgba(255, 215, 86, 0.26);
  color: #fff7d0;
  box-shadow: 0 0 18px rgba(255, 215, 86, 0.32);
}

.stick-readouts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.stick-cell {
  min-width: 0;
}

.stick-meter {
  position: relative;
  width: 54px;
  height: 54px;
  margin: 0 auto 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background:
    linear-gradient(rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.12)) 50% 0 / 1px 100% no-repeat,
    linear-gradient(90deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.12)) 0 50% / 100% 1px no-repeat,
    rgba(0, 0, 0, 0.22);
}

.stick-meter i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 14px rgba(142, 232, 240, 0.65);
  transform: translate(-50%, -50%);
}

.stick-meter.jitter {
  border-color: rgba(255, 143, 95, 0.9);
  box-shadow: 0 0 16px rgba(255, 143, 95, 0.24);
}

.stick-cell span {
  display: block;
  text-align: center;
  white-space: nowrap;
}

.axis-dump {
  margin-top: 7px;
  padding: 5px 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.18);
  color: rgba(232, 244, 255, 0.78);
  font: 800 0.56rem/1.35 Consolas, "Segoe UI", monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crosshair,
.hit-marker {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
}

.crosshair i,
.hit-marker i {
  position: absolute;
  background: rgba(244, 254, 255, 0.9);
  box-shadow: 0 0 7px rgba(0, 0, 0, 0.45);
}

.crosshair i:nth-child(1),
.crosshair i:nth-child(2) {
  left: 16px;
  width: 2px;
  height: 10px;
}

.crosshair i:nth-child(1) {
  top: 0;
}

.crosshair i:nth-child(2) {
  bottom: 0;
}

.crosshair i:nth-child(3),
.crosshair i:nth-child(4) {
  top: 16px;
  width: 10px;
  height: 2px;
}

.crosshair i:nth-child(3) {
  left: 0;
}

.crosshair i:nth-child(4) {
  right: 0;
}

.hit-marker {
  opacity: 0;
  transition: opacity 80ms ease;
}

.hit-marker.active {
  opacity: 1;
}

.hit-marker i {
  width: 14px;
  height: 3px;
  background: #fff3cc;
}

.hit-marker i:nth-child(1) {
  left: 4px;
  top: 7px;
  transform: rotate(45deg);
}

.hit-marker i:nth-child(2) {
  right: 4px;
  top: 7px;
  transform: rotate(-45deg);
}

.hit-marker i:nth-child(3) {
  left: 4px;
  bottom: 7px;
  transform: rotate(-45deg);
}

.hit-marker i:nth-child(4) {
  right: 4px;
  bottom: 7px;
  transform: rotate(45deg);
}

.bottom-hud {
  position: absolute;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  width: min(520px, calc(100vw - 24px));
  transform: translateX(-50%);
}

.hotbar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

.slot {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 54px;
  border-radius: 5px;
  place-items: center;
  color: rgba(255, 255, 255, 0.72);
}

.slot.selected {
  border-color: rgba(142, 232, 240, 0.9);
  background: rgba(24, 60, 70, 0.82);
  color: var(--ink);
}

.slot span {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 0.7rem;
  font-weight: 900;
}

.slot strong {
  max-width: 100%;
  padding: 13px 4px 4px;
  overflow: hidden;
  font-size: clamp(0.64rem, 1.8vw, 0.8rem);
  line-height: 1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-line {
  display: grid;
  grid-template-columns: 1fr 44px 92px;
  gap: 8px;
  align-items: center;
  min-height: 32px;
  margin: 6px auto 0;
  padding: 5px 7px;
  border-radius: 5px;
}

.health-wrap {
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 2px;
  background: rgba(8, 8, 8, 0.58);
}

.health-wrap i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #d71f22, #ff524a);
  transform-origin: left center;
}

.status-line strong {
  color: #fff4e5;
  font-size: 0.9rem;
  text-align: center;
}

.status-line span {
  color: var(--cyan);
  text-align: right;
}

.damage-vignette {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(circle, transparent 46%, rgba(201, 20, 20, 0.52) 100%);
  transition: opacity 120ms ease;
}

.damage-vignette.active {
  opacity: 1;
}

.menu-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 7, 11, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.menu-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.menu-panel {
  width: min(420px, 100%);
  border-radius: 8px;
  padding: 22px;
  background: rgba(15, 25, 35, 0.86);
  text-align: center;
}

.menu-panel p,
.menu-panel h1 {
  margin: 0;
}

.menu-panel h1 {
  margin-top: 6px;
  font-size: clamp(2rem, 7vw, 3.6rem);
  line-height: 0.95;
  text-transform: uppercase;
}

.menu-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 18px 0;
}

.menu-stats div {
  min-width: 0;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

.menu-stats strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deploy-btn {
  width: 100%;
  min-height: 48px;
  border-radius: 6px;
  background: linear-gradient(180deg, #5ee2e9, #2aa8bf);
  color: #06242b;
  font-weight: 950;
  text-transform: uppercase;
  box-shadow: 0 13px 24px rgba(18, 191, 214, 0.24);
  cursor: pointer;
}

.mobile-stick,
.mobile-fire,
.mobile-jump {
  display: none;
  pointer-events: auto;
}

@media (max-width: 800px) {
  .leaderboard {
    display: none;
  }

  .top-center {
    min-width: 188px;
    max-width: 52vw;
    padding: 7px 8px;
  }

  .top-left {
    gap: 5px;
  }

  .match-card {
    display: none;
  }

  .input-monitor {
    top: 70px;
    left: 12px;
    width: min(276px, calc(100vw - 24px));
    padding: 7px;
  }

  .monitor-buttons span,
  .monitor-pads span {
    min-height: 22px;
    font-size: 0.55rem;
  }

  .stick-meter {
    width: 44px;
    height: 44px;
  }

  .top-center strong {
    font-size: 0.82rem;
  }

  .top-center span {
    font-size: 0.58rem;
  }

  .hotbar {
    gap: 4px;
  }

  .slot {
    min-height: 48px;
  }

  .status-line {
    grid-template-columns: 1fr 38px 82px;
  }

  .mobile-stick {
    position: absolute;
    left: 18px;
    bottom: 102px;
    display: block;
    width: 104px;
    height: 104px;
    border-radius: 50%;
  }

  .mobile-stick i {
    position: absolute;
    left: 34px;
    top: 34px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.44);
  }

  .mobile-fire,
  .mobile-jump {
    position: absolute;
    display: block;
    border-radius: 50%;
  }

  .mobile-fire {
    right: 24px;
    bottom: 118px;
    width: 70px;
    height: 70px;
    background:
      radial-gradient(circle, rgba(255, 255, 255, 0.26) 0 21%, transparent 22%),
      rgba(255, 96, 70, 0.66);
  }

  .mobile-jump {
    right: 104px;
    bottom: 122px;
    width: 62px;
    height: 62px;
    background: rgba(112, 199, 238, 0.66);
  }

  .mobile-jump::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 45%;
    width: 22px;
    height: 22px;
    border-top: 7px solid rgba(255, 255, 255, 0.72);
    border-left: 7px solid rgba(255, 255, 255, 0.72);
    transform: translate(-50%, -35%) rotate(45deg);
  }
}

@media (max-height: 560px) {
  .bottom-hud {
    width: min(420px, calc(100vw - 20px));
  }

  .slot {
    min-height: 42px;
  }

  .menu-panel {
    padding: 16px;
  }

  .menu-stats {
    margin: 12px 0;
  }

  .input-monitor {
    top: 58px;
    width: 250px;
  }

  .monitor-pads {
    display: none;
  }

  .stick-readouts {
    margin-top: 5px;
  }

  .axis-dump {
    display: none;
  }
}
