:root {
  color-scheme: dark;
  --app-height: 100vh;
  --mobile-controls: 0px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #050608;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-touch-callout: none;
  user-select: none;
}

body {
  background: #050608;
  color: #eef8ff;
}

canvas {
  display: block;
  width: 100vw;
  height: calc(var(--app-height) - var(--mobile-controls));
  cursor: crosshair;
  touch-action: none;
}

.hud {
  position: fixed;
  top: 16px;
  left: 18px;
  right: 18px;
  display: grid;
  grid-template-columns: 180px minmax(260px, 520px) 120px;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
}

.identity,
.readout,
.controls {
  border: 1px solid rgba(183, 226, 255, 0.16);
  border-radius: 8px;
  background: rgba(6, 10, 14, 0.62);
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

.mobile-pad {
  display: none;
}

.identity {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  padding: 12px 14px;
  font-weight: 900;
}

.logo {
  width: 20px;
  height: 20px;
  display: inline-block;
  border-radius: 50%;
  background:
    radial-gradient(circle, #fff 0 18%, transparent 19%),
    conic-gradient(#ff4f7b, #ffd45e, #60f5ff, #ff4f7b);
  box-shadow: 0 0 22px rgba(96, 245, 255, 0.46);
}

.bars {
  display: grid;
  gap: 8px;
}

.bars label {
  display: grid;
  grid-template-columns: 58px 44px 1fr;
  align-items: center;
  gap: 9px;
  min-height: 22px;
  color: rgba(238, 248, 255, 0.72);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.bars b {
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.bars i {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.bars em {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #60f5ff, #85ff90);
  box-shadow: 0 0 20px rgba(96, 245, 255, 0.36);
}

#energyBar {
  background: linear-gradient(90deg, #ffd45e, #60f5ff);
}

#ammoBar {
  background: linear-gradient(90deg, #ff4f7b, #ffd45e);
}

.readout {
  justify-self: end;
  min-width: 110px;
  padding: 10px 13px;
  text-align: right;
}

.readout span,
.readout small {
  display: block;
  color: rgba(238, 248, 255, 0.64);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.readout b {
  display: block;
  color: #fff;
  font-size: 30px;
  line-height: 1;
}

.controls {
  position: fixed;
  left: 18px;
  right: 18px;
  bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  width: fit-content;
  max-width: calc(100vw - 36px);
  padding: 10px;
  color: rgba(238, 248, 255, 0.74);
  font-size: 12px;
  pointer-events: none;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 24px;
  margin-right: 5px;
  padding: 0 7px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-bottom-color: rgba(255, 255, 255, 0.36);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  font: 900 11px/1 Inter, system-ui, sans-serif;
}

.screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 48%, rgba(96, 245, 255, 0.16), transparent 31%),
    linear-gradient(180deg, rgba(4, 6, 10, 0.22), rgba(4, 6, 10, 0.86));
  text-align: center;
}

.hidden {
  display: none;
}

.screen p {
  margin: 0;
  color: #ffd45e;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.screen h1,
.screen h2 {
  margin: 0;
  color: #fff;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 0 0 38px rgba(96, 245, 255, 0.26), 0 20px 90px rgba(0, 0, 0, 0.6);
}

.screen h1 {
  font-size: clamp(54px, 11vw, 128px);
  line-height: 0.9;
}

.screen h2 {
  font-size: clamp(42px, 8vw, 86px);
  line-height: 0.92;
}

.screen > span {
  display: block;
  max-width: 660px;
  color: rgba(238, 248, 255, 0.78);
  font-size: clamp(15px, 2.1vw, 20px);
}

button {
  min-width: 210px;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid rgba(238, 248, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #eef8ff;
  font: 900 13px/1 Inter, system-ui, sans-serif;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 16px 54px rgba(0, 0, 0, 0.34);
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(238, 248, 255, 0.48);
  background: rgba(255, 255, 255, 0.13);
}

button.primary {
  border-color: rgba(96, 245, 255, 0.7);
  background: linear-gradient(135deg, #60f5ff, #85ff90 45%, #ffd45e);
  color: #041015;
}

.choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 240px));
  gap: 12px;
  margin-top: 6px;
}

.choice {
  min-height: 132px;
  padding: 16px;
  text-align: left;
  text-transform: none;
}

.choice strong {
  display: block;
  margin-bottom: 9px;
  color: #fff;
  font-size: 16px;
  text-transform: uppercase;
}

.choice span {
  display: block;
  color: rgba(238, 248, 255, 0.72);
  font-size: 13px;
  line-height: 1.35;
}

@media (max-width: 760px), (max-height: 560px) and (orientation: landscape) {
  :root {
    --mobile-controls: 154px;
  }

  .hud {
    left: 10px;
    right: 10px;
    top: 10px;
    grid-template-columns: 1fr auto;
  }

  .identity {
    display: none;
  }

  .bars {
    grid-column: 1;
  }

  .bars label {
    grid-template-columns: 52px 38px 1fr;
    font-size: 11px;
  }

  .readout {
    min-width: 82px;
  }

  .readout b {
    font-size: 22px;
  }

  .controls {
    display: none;
  }

  .screen {
    inset: 0 0 var(--mobile-controls);
    padding: 18px;
  }

  .screen h1 {
    font-size: clamp(42px, 13vw, 72px);
  }

  .screen h2 {
    font-size: clamp(36px, 12vw, 60px);
  }

  .screen > span {
    max-width: 330px;
    font-size: 15px;
  }

  button {
    min-width: 176px;
  }

  .mobile-pad {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(126px, 42vw) minmax(162px, 1fr);
    gap: 12px;
    height: var(--mobile-controls);
    padding: 10px max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
    border-top: 1px solid rgba(238, 248, 255, 0.14);
    background: linear-gradient(180deg, rgba(9, 13, 19, 0.96), rgba(3, 5, 8, 0.99));
    touch-action: none;
    -webkit-touch-callout: none;
    user-select: none;
  }

  .move-pad,
  .action-pad {
    align-self: center;
  }

  .move-pad {
    display: grid;
    grid-template-columns: repeat(3, minmax(38px, 1fr));
    grid-template-rows: repeat(2, 52px);
    gap: 8px;
    max-width: 178px;
  }

  .move-pad button:nth-child(1) {
    grid-column: 2;
  }

  .move-pad button:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
  }

  .move-pad button:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
  }

  .move-pad button:nth-child(4) {
    grid-column: 3;
    grid-row: 2;
  }

  .action-pad {
    justify-self: end;
    display: grid;
    grid-template-columns: repeat(2, minmax(70px, 1fr));
    gap: 8px;
    width: min(100%, 220px);
  }

  .mobile-pad button {
    min-width: 0;
    min-height: 52px;
    padding: 0 8px;
    border-color: rgba(238, 248, 255, 0.2);
    background: rgba(238, 248, 255, 0.1);
    color: #eef8ff;
    font-size: 12px;
    box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.26), 0 8px 24px rgba(0, 0, 0, 0.32);
    touch-action: none;
  }

  .mobile-pad button.is-pressed {
    transform: translateY(3px);
    border-color: rgba(96, 245, 255, 0.64);
    background: rgba(96, 245, 255, 0.2);
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25), 0 0 24px rgba(96, 245, 255, 0.18);
  }

  .mobile-pad .shoot {
    border-color: rgba(255, 212, 94, 0.56);
    color: #041015;
    background: linear-gradient(135deg, #ffd45e, #60f5ff);
  }

  .aim-cluster {
    grid-template-columns: 126px 74px;
    grid-template-rows: repeat(3, 48px);
    align-items: center;
    justify-content: end;
    gap: 6px;
    width: min(100%, 214px);
  }

  .aim-stick {
    grid-column: 1;
    grid-row: 1 / 4;
    justify-self: center;
    width: 126px;
    height: 126px;
  }

  .aim-stick .stick-base {
    width: 116px;
    height: 116px;
    border-color: rgba(255, 212, 94, 0.44);
    background:
      radial-gradient(circle at 50% 50%, rgba(255, 212, 94, 0.18), transparent 34%),
      linear-gradient(145deg, rgba(238, 248, 255, 0.13), rgba(13, 8, 6, 0.96));
  }

  .aim-stick .stick-knob {
    width: 56px;
    height: 56px;
    background: linear-gradient(145deg, #fff5c9, #ffd45e);
  }

  .aim-cluster .dash {
    grid-column: 2;
    grid-row: 1;
  }

  .aim-cluster .shock {
    grid-column: 2;
    grid-row: 2;
  }

  .aim-cluster .reload {
    grid-column: 2;
    grid-row: 3;
  }

  .choices {
    grid-template-columns: 1fr;
    width: min(360px, calc(100vw - 32px));
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  :root {
    --mobile-controls: 96px;
  }

  .hud {
    top: 6px;
  }

  .bars label {
    min-height: 19px;
  }

  .mobile-pad {
    grid-template-columns: minmax(198px, 42vw) minmax(236px, 1fr);
    padding-top: 7px;
    padding-bottom: max(7px, env(safe-area-inset-bottom));
  }

  .move-pad {
    grid-template-columns: repeat(4, 46px);
    grid-template-rows: 44px;
    max-width: none;
  }

  .move-pad button:nth-child(n) {
    grid-column: auto;
    grid-row: auto;
  }

  .action-pad {
    grid-template-columns: repeat(4, minmax(62px, 1fr));
    width: min(100%, 382px);
  }

  .mobile-pad button {
    min-height: 44px;
    font-size: 11px;
  }
}

@media (max-width: 760px), (max-height: 560px) and (orientation: landscape) {
  :root {
    --mobile-controls: 174px;
  }

  .move-pad {
    display: grid;
    place-items: center;
    justify-self: start;
    width: 158px;
    max-width: 158px;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  .move-pad button {
    display: none;
  }

  .analogue-stick {
    position: relative;
    display: grid;
    place-items: center;
    width: 134px;
    height: 134px;
    border-radius: 50%;
    touch-action: none;
    -webkit-touch-callout: none;
    user-select: none;
  }

  .stick-base {
    position: relative;
    display: block;
    width: 124px;
    height: 124px;
    border: 1px solid rgba(238, 248, 255, 0.2);
    border-radius: 50%;
    background:
      radial-gradient(circle at 50% 50%, rgba(96, 245, 255, 0.18), transparent 34%),
      linear-gradient(145deg, rgba(238, 248, 255, 0.12), rgba(6, 10, 14, 0.96));
    box-shadow: inset 0 0 0 11px rgba(255, 255, 255, 0.035), 0 12px 34px rgba(0, 0, 0, 0.38);
  }

  .stick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    display: block;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(145deg, #fff, #60f5ff);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.38), inset 0 -5px 0 rgba(0, 0, 0, 0.2);
    transform: translate(-50%, -50%);
    pointer-events: none;
  }

  .action-pad {
    grid-template-columns: 126px 74px;
    grid-template-rows: repeat(3, 48px);
    gap: 6px;
    width: min(100%, 214px);
  }

  .mobile-pad button {
    min-height: 48px;
    font-size: 12px;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  :root {
    --mobile-controls: 118px;
  }

  .mobile-pad {
    grid-template-columns: minmax(116px, 22vw) minmax(580px, 1fr);
  }

  .action-pad {
    grid-template-columns: 104px 92px 104px 104px;
    grid-template-rows: 64px;
    align-items: center;
    justify-content: end;
    width: min(100%, 448px);
  }

  .mobile-pad button {
    min-height: 64px;
    font-size: 12px;
  }

  .analogue-stick {
    width: 92px;
    height: 92px;
  }

  .stick-base {
    width: 88px;
    height: 88px;
  }

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

  .aim-stick {
    grid-column: 2;
    grid-row: 1;
    width: 92px;
    height: 92px;
  }

  .aim-stick .stick-base {
    width: 88px;
    height: 88px;
  }

  .aim-stick .stick-knob {
    width: 44px;
    height: 44px;
  }

  .aim-cluster .dash,
  .aim-cluster .shock,
  .aim-cluster .reload {
    grid-row: 1;
  }

  .aim-cluster .dash {
    grid-column: 1;
  }

  .aim-cluster .shock {
    grid-column: 3;
  }

  .aim-cluster .reload {
    grid-column: 4;
  }
}
