:root {
  color-scheme: dark;
  --page-bg: #15171c;
  --label-bg: rgba(15, 18, 24, 0.78);
  --label-border: rgba(255, 255, 255, 0.16);
  --character-width: 120px;
  --character-scale: 1;
  --character-offset-y: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: #f7f2e8;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.room {
  position: relative;
  width: min(100%, 1280px, 155vh);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  background-image: url("assets/rooms/room.png");
  background-position: center;
  background-size: cover;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.48);
}

.room::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.room--empty::after {
  opacity: 1;
}

.characters {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.character {
  position: absolute;
  width: var(--character-width);
  margin: 0;
  opacity: 0;
  transform: translate(-50%, calc(-100% + var(--character-offset-y))) scale(var(--character-scale));
  transform-origin: 50% 100%;
  transition:
    opacity 400ms ease,
    transform 400ms ease;
  text-align: center;
}

.character--visible {
  --character-offset-y: 0px;
  opacity: 1;
}

.character--leaving {
  --character-offset-y: 20px;
  opacity: 0;
  pointer-events: none;
}

.character__shadow {
  position: absolute;
  bottom: 0;
  left: 50%;
  z-index: 0;
  width: 58%;
  height: 12%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.36);
  filter: blur(1px);
  transform: translateX(-50%);
}

.character__sprite,
.character__placeholder {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: 190px;
  filter: drop-shadow(0 12px 10px rgba(0, 0, 0, 0.42));
}

.character__sprite {
  display: block;
  height: auto;
  object-fit: contain;
}

.character__sprite--avatar {
  height: var(--character-width);
  border-radius: 50%;
  background: #343943;
  object-fit: cover;
}

.character__placeholder {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: #4a4f59;
  color: #f7f2e8;
  font-size: clamp(32px, 7vw, 64px);
  font-weight: 800;
  line-height: 1;
}

.character__sprite[hidden],
.character__placeholder[hidden] {
  display: none;
}

.character__name {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  z-index: 2;
  display: inline-block;
  max-width: 100%;
  padding: 5px 10px;
  overflow: hidden;
  border: 1px solid var(--label-border);
  border-radius: 999px;
  background: var(--label-bg);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.24);
  color: #fff8e8;
  font-size: clamp(12px, 1.6vw, 15px);
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  transform: translateX(-50%);
  white-space: nowrap;
}

.floor-debug {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.floor-debug__shape {
  fill: rgba(92, 214, 255, 0.08);
  stroke: rgba(92, 214, 255, 0.9);
  stroke-dasharray: 8 6;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.floor-debug__vertex {
  fill: #fff8e8;
  stroke: rgba(92, 214, 255, 0.95);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.empty-state {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  transform: translate(-50%, -50%);
  padding: 14px 22px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(15, 18, 24, 0.58);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
  color: #f7f2e8;
  font-size: clamp(18px, 3vw, 28px);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.connection-error {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2000;
  transform: translate(-50%, -50%);
  padding: 16px 24px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(16, 18, 24, 0.84);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.34);
  color: #fff;
  font-size: clamp(18px, 3vw, 28px);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .app {
    padding: 12px;
  }

  .room {
    border-radius: 14px;
  }
}
