:root {
  color-scheme: dark;
  --green: #54fd54;
  --red: #fd5454;
  --panel: rgba(0, 0, 0, 0.86);
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #fdfdfd;
  font-family: "Courier New", monospace;
}

button,
input {
  font: inherit;
}

#shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #000;
}

#game {
  width: min(100vw, calc(100vh * 4 / 3));
  height: min(100vh, calc(100vw * 3 / 4));
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  touch-action: none;
}

.panel {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(320px, calc(100vw - 32px));
  transform: translate(-50%, -50%);
  padding: 18px;
  border: 2px solid #a9a9a9;
  background: var(--panel);
  text-align: center;
}

.panel[hidden] {
  display: none;
}

.panel h1 {
  margin: 0 0 14px;
  color: var(--red);
  font-size: 28px;
  letter-spacing: 0;
}

#joinForm {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

#nickname {
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid #a9a9a9;
  border-radius: 0;
  background: #000;
  color: #fdfdfd;
  text-transform: uppercase;
}

#join button {
  padding: 10px 12px;
  border: 1px solid #a9a9a9;
  border-radius: 0;
  background: #000;
  color: var(--green);
}

#status {
  min-height: 18px;
  margin: 12px 0 0;
  color: #fdfd54;
  font-size: 14px;
}

#hud {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  display: flex;
  gap: 12px;
  padding: 5px 7px;
  background: rgba(0, 0, 0, 0.72);
  color: #fdfd54;
  font-size: 14px;
  line-height: 1;
  pointer-events: none;
}

#score::before {
  content: "S ";
}

#players::before {
  content: "P ";
}

#latency::before {
  content: "L ";
}

#debugStats {
  position: fixed;
  top: calc(max(8px, env(safe-area-inset-top)) + 26px);
  left: max(8px, env(safe-area-inset-left));
  max-width: min(460px, calc(100vw - 16px));
  padding: 5px 7px;
  background: rgba(0, 0, 0, 0.72);
  color: #54fd54;
  font-size: 11px;
  line-height: 1.25;
  pointer-events: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-shadow: 1px 1px 0 #000;
}

#touchControls {
  position: fixed;
  inset: auto 0 max(14px, env(safe-area-inset-bottom)) 0;
  display: flex;
  justify-content: space-between;
  padding: 0 max(14px, env(safe-area-inset-left));
  pointer-events: none;
}

.pad {
  position: relative;
  width: 148px;
  height: 112px;
  pointer-events: auto;
}

.pad button {
  position: absolute;
  width: 48px;
  height: 48px;
  border: 2px solid rgba(253, 253, 253, 0.75);
  border-radius: 0;
  background: rgba(0, 0, 0, 0.52);
  color: #fdfdfd;
  font-size: 20px;
  line-height: 1;
}

.pad button:active,
.pad button.active {
  background: rgba(253, 84, 84, 0.8);
}

.pad .left {
  left: 0;
  top: 56px;
}

.pad .right {
  right: 0;
  top: 56px;
}

.pad .up {
  left: 50px;
  top: 0;
}

.pad .down {
  left: 50px;
  top: 56px;
}

.turret {
  width: 164px;
}

.turret .fire {
  left: 58px;
  top: 56px;
  color: var(--red);
}

#feed {
  position: fixed;
  right: max(8px, env(safe-area-inset-right));
  top: max(8px, env(safe-area-inset-top));
  width: min(280px, 50vw);
  color: #fdfdfd;
  font-size: 12px;
  text-align: right;
  pointer-events: none;
  text-shadow: 1px 1px 0 #000;
}

@media (hover: hover) and (pointer: fine) {
  #touchControls {
    display: none;
  }
}
