:root {
  color-scheme: dark;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --surface: #111418;
  --surface-2: #1a1f25;
  --line: #303842;
  --text-muted: #aab3bd;
  --accent: #3ef241;
  --accent-dark: #073c0b;
  --blue: #2b8cff;
  --danger: #ff4545;
}

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

html,
body {
  width: 100%;
  min-width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overscroll-behavior: none;
  background: #000;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  touch-action: manipulation;
}

button,
input,
select,
textarea {
  font: inherit;
}

#ftsetup,
#lobby,
#mainScreen,
#countdown,
#death,
#heal,
#hit,
#phit,
#dragoverlay {
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
}

#ftsetup > * {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding:
    calc(var(--safe-top) + 20px)
    calc(var(--safe-right) + 20px)
    calc(var(--safe-bottom) + 20px)
    calc(var(--safe-left) + 20px);
}

#ftsetup h1 {
  margin: 0;
  align-self: end;
  font-size: clamp(2rem, 9vw, 3.25rem);
  line-height: .96;
  letter-spacing: -.04em;
}

#setupusername,
#setupphone,
#setupgun {
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 20px;
}

#setupusername form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  min-height: 0;
}

#username,
#pin {
  width: min(100%, 520px);
  min-height: 56px;
  height: 56px;
  margin: 0 auto;
  padding: 0 18px;
  border-width: 2px;
  border-radius: 16px;
  text-indent: 0;
  font-size: 20px;
  color: #fff;
  background: var(--surface);
}

#username:focus,
#pin:focus {
  border-color: #fff !important;
}

.btncontainer {
  padding-bottom: 2px;
}

.nextbtn,
#readyBtn,
#teamBtn,
.classBtn {
  min-height: 52px;
  border-radius: 16px;
  cursor: pointer;
  touch-action: manipulation;
}

.nextbtn {
  width: min(100%, 520px);
  height: 56px;
  display: grid;
  place-items: center;
}

.nextbtn h3 {
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

#blegps {
  gap: 12px;
  min-height: 0;
}

.permbox {
  width: min(100%, 520px);
  min-height: 58px;
  height: auto;
  margin: 0;
  border-width: 2px;
  border-radius: 16px;
  padding: 12px 16px;
  place-items: center;
  background: var(--surface);
}

#power {
  width: 100%;
  place-items: center;
}

#power img {
  height: min(26vh, 150px);
}

#power h2 {
  max-width: 360px;
  margin-top: 20px;
  font-size: clamp(1rem, 4.5vw, 1.3rem);
  line-height: 1.35;
}

#compatNotice {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 14px 16px;
  border: 1px solid #705a16;
  border-radius: 16px;
  background: #211c0d;
  color: #ffe7a0;
  font-size: 14px;
  line-height: 1.45;
}

#compatNotice[hidden] {
  display: none;
}

#lobby {
  grid-template-rows: auto minmax(100px, 1fr) auto auto auto;
  gap: 12px;
  padding:
    calc(var(--safe-top) + 10px)
    calc(var(--safe-right) + 12px)
    calc(var(--safe-bottom) + 12px)
    calc(var(--safe-left) + 12px);
}

#lobby > * {
  margin: 0;
}

#lobbybar {
  position: relative;
  min-height: 54px;
  place-items: center;
}

#lobbybar h1 {
  font-size: clamp(1.45rem, 6vw, 2rem);
}

#lobby img {
  left: 0;
  top: 50%;
  width: 32px;
  height: 32px;
  margin: 0;
  transform: translateY(-50%);
}

#roster {
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.player {
  margin: 6px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

#teamBtn,
#readyBtn {
  width: 100%;
  max-width: 520px;
  height: 56px;
}

#teamBtn h1,
#readyBtn h1 {
  margin: auto;
  font-size: 20px;
}

#classContainer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.classBtn,
.classBtnPressed {
  display: grid;
  place-items: center;
  width: 100%;
  height: 48px;
  margin: 0;
  border-radius: 14px;
  background: var(--surface-2);
}

.classBtn h3,
.classBtnPressed h3 {
  width: 100%;
  height: auto;
  margin: 0;
  padding: 12px 8px;
  font-size: 15px;
  line-height: 1;
}

.classBtnPressed {
  background: #135d1b;
}

#mainScreen {
  grid-auto-rows: unset;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 8px;
  height: 100vh;
  height: 100dvh;
  padding:
    calc(var(--safe-top) + 8px)
    var(--safe-right)
    var(--safe-bottom)
    var(--safe-left);
}

#mainTopBar {
  min-height: 58px;
  grid-template-columns: 48px 1fr 48px;
  padding: 0 10px;
}

#mainTopBar img {
  width: 30px;
  height: 30px;
}

#mainCountdown h2 {
  font-size: clamp(1.4rem, 7vw, 2rem);
}

#mainCountdown h4 {
  font-size: 10px;
  letter-spacing: .12em;
  color: var(--text-muted);
}

#mainStatsBar {
  width: min(72%, 320px);
  min-height: 36px;
  margin: 0 auto;
  border-radius: 12px;
  background: var(--surface-2);
}

#mainStatsBar * {
  margin: 0;
  padding: 6px 4px;
  font-size: 16px;
}

#middlePanel {
  min-height: 0;
  overflow: hidden;
}

#mapContainer {
  width: auto;
  height: 100%;
  min-height: 0;
  margin: 0 10px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border-width: 3px;
  border-radius: 18px;
  background: #05080d;
}

#mapContainer table {
  width: 100%;
  border-collapse: collapse;
}

#viewTableUsers {
  display: table-row-group;
  width: 100%;
}

#viewTableUsers tr {
  border-bottom: 1px solid var(--line);
}

#viewTableUsers td {
  padding: 10px 12px;
  vertical-align: middle;
}

#viewTableUsers td:last-child {
  text-align: right;
  color: #d8e0e8;
}

#mainBottomBar {
  grid-template-columns: minmax(76px, 1fr) minmax(130px, 2fr) minmax(76px, 1fr);
  min-height: 88px;
  padding-bottom: 4px;
}

#mainBottomBarLeft,
#mainBottomBarMiddle,
#mainBottomBarRight {
  min-width: 0;
  border-width: 2px 2px 0 0;
}

#mainBottomBarRight {
  border-width: 2px 0 0 2px;
}

#mainBottomBarMiddle {
  margin-top: 12px;
  border-width: 2px 0 0;
}

#mainBottomBarRight img {
  height: 34px;
}

#ammoBox,
#shoppingMall {
  min-width: 64px;
  min-height: 64px;
  place-items: center;
}

#ammoBox h3,
#shoppingMall h3 {
  margin: 2px 0;
  font-size: 15px;
}

progress[value] {
  width: calc(100% - 16px);
  height: 28px;
}

#death {
  padding:
    calc(var(--safe-top) + 24px)
    calc(var(--safe-right) + 18px)
    calc(var(--safe-bottom) + 24px)
    calc(var(--safe-left) + 18px);
}

#death h1 {
  margin: 0;
  font-size: clamp(3rem, 16vw, 5rem);
}

#death h2 {
  font-size: clamp(2rem, 10vw, 3rem);
}

#death h3,
#death h4 {
  font-size: clamp(1.25rem, 6vw, 2rem);
}

#death h5 {
  font-size: clamp(3rem, 16vw, 5rem);
}

#countdown h1 {
  font-size: min(50vw, 13rem);
}

@media (max-height: 520px) and (orientation: landscape) {
  #ftsetup > * {
    padding-top: calc(var(--safe-top) + 10px);
    padding-bottom: calc(var(--safe-bottom) + 10px);
  }

  #ftsetup h1 {
    font-size: 2rem;
  }

  #setupusername,
  #setupphone,
  #setupgun {
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 8px;
  }

  #power img {
    height: 70px;
  }

  #power h2 {
    margin-top: 8px;
    font-size: 14px;
  }

  #lobby {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
  }

  #lobbybar {
    grid-column: 1 / -1;
  }

  #roster {
    grid-row: 2 / 5;
  }
}
