body {
  background:
    radial-gradient(1200px 700px at 20% 10%, rgba(110, 231, 255, 0.08), transparent 55%),
    radial-gradient(900px 600px at 80% 90%, rgba(114, 46, 209, 0.12), transparent 50%),
    var(--bg);
}

#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#lasers,
#items,
#bullets,
#characters {
  position: absolute;
  inset: 0;
  z-index: 1;
}

#items {
  z-index: 2;
}

#characters {
  z-index: 3;
}

.laser {
  position: absolute;
  height: 0.55vmin;
  width: 160vmin;
  margin: 0;
  transform-origin: 0 50%;
  border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--skin) 90%, #fff), transparent);
  box-shadow: 0 0 0.8vmin color-mix(in srgb, var(--skin) 80%, transparent);
  pointer-events: none;
  opacity: 0.9;
}

.item {
  position: absolute;
  width: var(--item-size);
  height: var(--item-size);
  font-size: var(--item-size);
  margin: 0;
  transform: translate(-50%, -50%);
  border-radius: 0.22em;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0;
  color: #0b1220;
  border: 0.06em solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 0.08em 0.2em rgba(0, 0, 0, 0.35);
}

.item-medkit { background: #7dffa2; }
.item-shotgun { background: #faad14; }
.item-laser { background: #69c0ff; }
.item-invuln { background: #ffd666; }

.item::after {
  font-size: 0.42em;
  line-height: 1;
}

.item-medkit::after { content: "+"; }
.item-shotgun::after { content: "散"; }
.item-laser::after { content: "光"; }
.item-invuln::after { content: "盾"; }

/* --char-size 与 --bullet-size 由 display.js 从共享物理常量算出。
   内部装饰一律用 em，跟着角色尺寸整体缩放，改场地倍数时不用逐条调。 */
.bullet {
  position: absolute;
  width: var(--bullet-size);
  height: var(--bullet-size);
  font-size: var(--bullet-size);
  margin: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: color-mix(in srgb, var(--skin) 80%, #fff);
  box-shadow: 0 0 0.667em color-mix(in srgb, var(--skin) 70%, transparent);
}

.character {
  position: absolute;
  width: var(--char-size);
  height: var(--char-size);
  font-size: var(--char-size);
  margin: 0;
  transform: translate(-50%, -50%);
  transition: left 50ms linear, top 50ms linear;
}

.character .spin {
  width: 100%;
  height: 100%;
  transform: rotate(var(--facing, 0rad));
}

.character .hpbar {
  position: absolute;
  left: 50%;
  top: -0.225em;
  width: 1.125em;
  height: 0.0875em;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(7, 11, 20, 0.55);
  overflow: hidden;
}

.character .hpbar i {
  display: block;
  height: 100%;
  width: 100%;
  background: #7dffa2;
}

.character.is-hit .body {
  animation: hitflash 0.16s linear;
}

@keyframes hitflash {
  from { filter: brightness(2); }
  to { filter: none; }
}

.character .body {
  width: 100%;
  height: 100%;
  border-radius: 28%;
  background: linear-gradient(180deg, color-mix(in srgb, var(--skin) 88%, #fff), var(--skin));
  box-shadow:
    0 0 0 0.05em color-mix(in srgb, var(--skin) 40%, transparent),
    0 0.15em 0.3em rgba(0, 0, 0, 0.35);
}

.character .face {
  position: absolute;
  left: 50%;
  top: 38%;
  width: 54%;
  height: 28%;
  transform: translateX(-50%);
}

.character .eye {
  position: absolute;
  top: 0;
  width: 0.0875em;
  height: 0.0875em;
  border-radius: 50%;
  background: #141414;
}

.character .eye.l { left: 18%; }
.character .eye.r { right: 18%; }

.character .badge {
  position: absolute;
  left: 50%;
  /* 这个元素自己改了 font-size，除 font-size 外的 em 都以它的新字号为基准，
     所以下面几个值是按 badge 字号折算的，不是按角色尺寸。 */
  bottom: -1.235em;
  transform: translateX(-50%);
  min-width: 3.06em;
  padding: 0.088em 0.412em;
  border-radius: 999px;
  background: rgba(7, 11, 20, 0.82);
  border: 1px solid var(--line);
  font-size: 0.2125em;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
}

.character.is-offline {
  opacity: 0.55;
}

.character.is-dead .spin,
.character.is-dead .hpbar {
  visibility: hidden;
}

.character.is-dead .badge {
  color: var(--danger);
}

.character.is-invuln .body {
  box-shadow:
    0 0 0.08em 0.05em #ffe58f,
    0 0 0.28em 0.08em rgba(255, 214, 102, 0.85),
    0 0.15em 0.3em rgba(0, 0, 0, 0.35);
  animation: invuln-pulse 0.55s linear infinite;
}

@keyframes invuln-pulse {
  50% { filter: brightness(1.35); }
}

.board[hidden] {
  display: none;
}

.board {
  position: absolute;
  top: 8.2vmin;
  left: 2.4vmin;
  width: min(34vmin, 280px);
  margin: 0;
  padding: 1.1vmin 1.2vmin;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 1.4vmin;
  background: var(--panel);
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.board li {
  display: grid;
  grid-template-columns: 2.2vmin 1fr auto auto;
  gap: 0.8vmin;
  align-items: center;
  font-size: 1.55vmin;
  padding: 0.25vmin 0;
}

.board .rank {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.board .score {
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.board .lv {
  color: var(--muted);
}

#hud {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

#hud > * {
  pointer-events: auto;
}

.topbar {
  position: absolute;
  top: 2.2vmin;
  left: 2.4vmin;
  display: flex;
  gap: 1.2vmin;
  align-items: center;
}

.pill {
  padding: 0.8vmin 1.6vmin;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  font-size: 2vmin;
}

.pill strong {
  color: var(--accent);
}

.room {
  color: var(--muted);
  font-size: 1.5vmin;
  letter-spacing: 0.08em;
}

.actions {
  position: absolute;
  top: 2.2vmin;
  right: 2.4vmin;
  display: flex;
  gap: 1vmin;
}

.actions button {
  padding: 0.8vmin 1.5vmin;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  cursor: pointer;
}

.actions button:hover {
  border-color: rgba(110, 231, 255, 0.5);
}

.wait {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  color: var(--muted);
  font-size: 3.2vmin;
  letter-spacing: 0.12em;
  pointer-events: none;
}

.wait[hidden] {
  display: none;
}

.qr-box {
  position: absolute;
  right: 2.4vmin;
  bottom: 2.4vmin;
  width: max(160px, 16vmin);
  padding: 1.2vmin;
  border: 1px solid var(--line);
  border-radius: 1.6vmin;
  background: var(--panel);
  text-align: center;
}

.qr-box img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0.8vmin;
  background: #f4f7ff;
}

.qr-box p {
  margin: 0.8vmin 0 0;
  font-size: 1.4vmin;
  color: var(--muted);
}

.qr-box a {
  display: block;
  margin-top: 0.4vmin;
  color: var(--accent);
  font-size: 1.15vmin;
  word-break: break-all;
  text-decoration: none;
}

.modal {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(7, 11, 20, 0.55);
}

.modal[hidden] {
  display: none;
}

.dialog {
  width: min(72vmin, 420px);
  padding: 3.2vmin;
  border: 1px solid var(--line);
  border-radius: 2vmin;
  background: #10182b;
}

.dialog h2 {
  margin: 0 0 1.2vmin;
  font-size: 2.8vmin;
}

.dialog p {
  margin: 0 0 2.4vmin;
  font-size: 2.2vmin;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1.2vmin;
}

.dialog-actions button {
  padding: 0.8vmin 1.6vmin;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}

.dialog-actions .primary {
  background: var(--accent);
  color: #082028;
  border-color: transparent;
  font-weight: 700;
}

.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.6vmin;
  margin: 0 0 1.8vmin;
  font-size: 2vmin;
}

.field.check {
  justify-content: flex-start;
}

.field.check input {
  width: 2vmin;
  height: 2vmin;
}

.field.skills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8vmin 1.6vmin;
  width: 100%;
  min-inline-size: 0;
  margin: 0 0 2.4vmin;
  padding: 1.2vmin 0 0;
  border: none;
  border-top: 1px solid var(--line);
}

.field.skills legend {
  padding: 0;
  margin-bottom: 0.8vmin;
  color: var(--muted);
  font-size: 1.6vmin;
}

.field.skills label {
  display: flex;
  align-items: center;
  gap: 0.6vmin;
  font-size: 1.8vmin;
}

.field.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 0.6vmin;
}

.stepper button {
  width: 3.2vmin;
  height: 3.2vmin;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.stepper input {
  width: 6vmin;
  padding: 0.4vmin;
  border: 1px solid var(--line);
  border-radius: 0.6vmin;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: center;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}
