:root {
  --ink: #07061A;
  --far: #171436;
  --lit: #2E2760;
  --violet: #6C4DFF;
  --mint: #2BE8C8;
  --amber: #FFD166;
  --pink: #FF3D7F;
  --pale: #EAF2FF;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: "Silkscreen", monospace;
  color: var(--pale);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: calc(100dvh * 0.64);
  max-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--ink);
  container-type: size;
  touch-action: none;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: 50% 50%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: var(--ink);
}

.hidden {
  display: none !important;
}

img {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  -webkit-user-drag: none;
}

/* ---------- HUD ---------- */

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 7%;
  min-height: 42px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2cqw;
  padding: max(0.8cqh, env(safe-area-inset-top)) 3cqw 0;
  background: var(--ink);
  border-bottom: 0.55cqw solid var(--amber);
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 2.2cqw;
  min-width: 0;
}

.hearts {
  display: flex;
  align-items: center;
  gap: 0.5cqw;
}

.hearts img {
  width: 6.2cqw;
  height: auto;
  display: block;
}

.wave {
  display: flex;
  align-items: center;
  gap: 1cqw;
}

.wave img {
  height: 5.4cqw;
  width: auto;
  display: block;
}

#waveNum {
  font-size: 3.6cqw;
  color: var(--amber);
  letter-spacing: 0.08em;
}

.weaponName {
  font-size: 2.7cqw;
  letter-spacing: 0.1em;
  color: var(--mint);
  white-space: nowrap;
}

#hud.crowded .weaponName {
  font-size: 2.1cqw;
  letter-spacing: 0.04em;
}

#score {
  font-size: 4.4cqw;
  line-height: 1;
  letter-spacing: 0.1em;
  color: var(--pale);
}

.iconbtn {
  flex: 0 0 auto;
  width: 8cqw;
  height: 8cqw;
  padding: 0;
  border: 0;
  background: transparent;
  display: block;
  cursor: pointer;
}

.iconbtn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.iconbtn:active {
  background: var(--lit);
}

/* ---------- Screens ---------- */

.screen {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#title {
  padding-top: max(7cqh, env(safe-area-inset-top));
  gap: 1.6cqh;
}

#logo {
  width: 84cqw;
  height: auto;
  display: block;
}

.tagline {
  margin: 0;
  max-width: 86cqw;
  text-align: center;
  background: var(--ink);
  border: 0.35cqw solid var(--lit);
  padding: 1.2cqw 2.4cqw;
  font-size: 2.75cqw;
  line-height: 1.6;
  letter-spacing: 0.12em;
  color: var(--pale);
  text-shadow: none;
}

.tagline b {
  color: var(--mint);
  font-weight: 400;
}

.bestLine {
  margin: 0;
  font-size: 2.5cqw;
  letter-spacing: 0.16em;
  color: var(--amber);
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 1.3cqh;
  width: 82cqw;
  margin-top: 0.6cqh;
}

.plate {
  display: flex;
  align-items: center;
  gap: 3cqw;
  width: 100%;
  padding: 1.5cqw 2.4cqw;
  background: var(--ink);
  border: 0.35cqw solid var(--pale);
  color: var(--pale);
  font-family: "Silkscreen", monospace;
  text-align: left;
  cursor: pointer;
}

.plate img {
  width: 10.5cqw;
  height: 10.5cqw;
  object-fit: contain;
  display: block;
}

.plateText {
  display: flex;
  flex-direction: column;
  gap: 0.7cqw;
  min-width: 0;
}

.plateText b {
  font-size: 3.9cqw;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.1;
  white-space: nowrap;
}

.plateText small {
  font-size: 2.15cqw;
  letter-spacing: 0.14em;
  color: var(--amber);
  white-space: nowrap;
}

.plate:active,
.plate.pressed {
  border-color: var(--amber);
  background: var(--far);
}

.plate:active .plateText b,
.plate.pressed .plateText b {
  color: var(--amber);
}

.plate.slim {
  padding: 1.1cqw 2cqw;
}

.plate.slim img {
  width: 8cqw;
  height: 8cqw;
}

.plate.slim .plateText b {
  font-size: 3.1cqw;
}

.howto {
  margin: 0.6cqh 0 0;
  width: 86cqw;
  background: var(--ink);
  border: 0.35cqw solid var(--lit);
  padding: 1.2cqw 1.8cqw;
  text-align: center;
  font-size: 2.15cqw;
  line-height: 1.9;
  letter-spacing: 0.1em;
  color: var(--mint);
}

.howto.small {
  width: 100%;
  font-size: 2.2cqw;
  color: var(--pale);
  margin: 0 0 1cqh;
  background: transparent;
  border: 0;
  padding: 0;
  line-height: 1.9;
}

/* ---------- Panels ---------- */

.panel {
  margin: auto;
  width: 84cqw;
  max-height: 88cqh;
  overflow-y: auto;
  background: var(--ink);
  border: 0.45cqw solid var(--pale);
  padding: 4.5cqw 4.2cqw;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1.7cqh;
}

.panel h2 {
  margin: 0;
  font-size: 4.6cqw;
  line-height: 1.25;
  letter-spacing: 0.1em;
  color: var(--amber);
  text-align: center;
  font-weight: 700;
}

.pauseBox {
  width: 78cqw;
  gap: 1.4cqh;
}

.pauseBox .plate {
  width: 100%;
}

.lobbyBox {
  width: 86cqw;
}

.avatars {
  display: flex;
  justify-content: center;
  gap: 4cqw;
  padding: 0.4cqh 0;
}

.avatarWrap {
  width: 20cqw;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1cqw;
  padding: 0.9cqw;
  background: var(--ink);
  border: 0.4cqw solid var(--amber);
}

.avatarWrap img {
  width: 100%;
  height: auto;
  display: block;
}

.avatarWrap span {
  font-size: 2.1cqw;
  letter-spacing: 0.08em;
  color: var(--pale);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatarWrap.waiting {
  border-color: var(--lit);
}

.avatarWrap.waiting img {
  opacity: 0.45;
}

.avatarWrap.waiting span {
  color: var(--violet);
}

.lobbyStatus {
  margin: 0;
  text-align: center;
  font-size: 2.5cqw;
  line-height: 1.7;
  letter-spacing: 0.08em;
  color: var(--pale);
}

.lobbyNote {
  margin: 0;
  text-align: center;
  font-size: 2.1cqw;
  line-height: 1.8;
  letter-spacing: 0.06em;
  color: var(--mint);
}

.linkLabel {
  font-size: 2.2cqw;
  letter-spacing: 0.14em;
  color: var(--amber);
}

.linkRow {
  display: flex;
  gap: 1.6cqw;
}

.linkRow input {
  flex: 1;
  min-width: 0;
  background: var(--far);
  border: 0.35cqw solid var(--violet);
  color: var(--pale);
  font-family: "Silkscreen", monospace;
  font-size: 2.1cqw;
  padding: 1.6cqw;
}

.linkRow button {
  background: var(--amber);
  color: var(--ink);
  border: 0;
  font-family: "Silkscreen", monospace;
  font-weight: 700;
  font-size: 2.5cqw;
  letter-spacing: 0.08em;
  padding: 0 3cqw;
  cursor: pointer;
}

.linkRow button:active {
  background: var(--pale);
}

.textbtn {
  background: transparent;
  border: 0;
  color: var(--pale);
  font-family: "Silkscreen", monospace;
  font-size: 2.5cqw;
  letter-spacing: 0.12em;
  padding: 1.4cqw;
  text-decoration: underline;
  text-underline-offset: 0.6cqw;
  cursor: pointer;
  align-self: center;
}

.textbtn:active {
  color: var(--amber);
}

.endBox {
  width: 86cqw;
  gap: 1.3cqh;
}

.endSub {
  margin: 0;
  text-align: center;
  font-size: 2.4cqw;
  line-height: 1.8;
  letter-spacing: 0.08em;
  color: var(--mint);
}

.statRow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-top: 0.35cqw solid var(--lit);
  border-bottom: 0.35cqw solid var(--lit);
  padding: 1.4cqw 1cqw;
}

.statRow span {
  font-size: 2.6cqw;
  letter-spacing: 0.14em;
  color: var(--pale);
}

.statRow b {
  font-size: 5.2cqw;
  letter-spacing: 0.1em;
  color: var(--amber);
}

.board {
  display: flex;
  flex-direction: column;
  gap: 0.8cqh;
}

.boardHead {
  font-size: 2.2cqw;
  letter-spacing: 0.16em;
  color: var(--violet);
}

.board ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.7cqh;
}

.board li {
  display: flex;
  justify-content: space-between;
  gap: 2cqw;
  font-size: 2.4cqw;
  letter-spacing: 0.06em;
  color: var(--pale);
}

.board li a {
  color: var(--mint);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board li b {
  color: var(--amber);
  font-weight: 400;
}

/* ---------- Touch controls ---------- */

#controls {
  position: absolute;
  inset: 0;
  z-index: 25;
  pointer-events: none;
}

.stick {
  position: absolute;
  left: 4cqw;
  bottom: 3.5cqh;
  width: 30cqw;
  height: 28cqw;
  opacity: 0.5;
}

.stick img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.stick.active {
  opacity: 1;
}

.knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5.4cqw;
  height: 5.4cqw;
  margin-left: -2.7cqw;
  margin-top: -2.7cqw;
  background: var(--mint);
  display: none;
}

.stick.active .knob {
  display: block;
}

.thumbbtn {
  position: absolute;
  bottom: 3.4cqh;
  width: 15cqw;
  height: 18cqw;
  padding: 0;
  border: 0;
  background: transparent;
  opacity: 0.55;
  pointer-events: auto;
  cursor: pointer;
}

.thumbbtn img {
  width: 100%;
  height: 15cqw;
  object-fit: contain;
  display: block;
}

.thumbbtn span {
  display: block;
  margin-top: 0.2cqw;
  font-size: 1.9cqw;
  letter-spacing: 0.08em;
  color: var(--pale);
  text-align: center;
  background: var(--ink);
  line-height: 1.2;
}

.thumbbtn.dash {
  right: 18cqw;
}

.thumbbtn.swap {
  right: 3.5cqw;
}

.thumbbtn:active,
.thumbbtn.active {
  opacity: 1;
}

/* ---------- Toast ---------- */

.toast {
  position: absolute;
  left: 50%;
  bottom: 17cqh;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--ink);
  border: 0.4cqw solid var(--amber);
  color: var(--pale);
  font-size: 2.4cqw;
  letter-spacing: 0.08em;
  padding: 2cqw 3cqw;
  text-align: center;
  max-width: 82cqw;
  line-height: 1.5;
}

@media (max-height: 560px) and (orientation: landscape) {
  #stage {
    max-width: calc(100dvh * 0.72);
  }
}

@container (max-width: 360px) {
  .hud-left,
  .hud-right {
    gap: 1.4cqw;
  }
  .weaponName {
    font-size: 2.35cqw;
  }
  #score {
    font-size: 3.9cqw;
    letter-spacing: 0.06em;
  }
  .iconbtn {
    width: 7cqw;
    height: 7cqw;
  }
}

@container (max-width: 300px) {
  .weaponName {
    display: none;
  }
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 0.5cqw solid var(--amber);
  outline-offset: 0.4cqw;
}

#shareLink {
  -webkit-user-select: text;
  user-select: text;
}
