:root {
  /* game-lobby-new.js 会按设备可视区域覆盖 W/H；首屏默认 720/1280 */
  --game-logical-ratio: 0.5625;
  --game-frame-ratio: var(--game-logical-ratio);
  --game-frame-width: 100vw;
  --game-frame-height: calc(var(--game-frame-width) / var(--game-logical-ratio));
  --safe-area-left: env(safe-area-inset-left, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  height: var(--game-viewport-height, 100dvh);
  background: #151817;
  color: #f7efe1;
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Noto Sans CJK SC",
    system-ui,
    sans-serif;
}

/* 游戏框按实际可视比例居中等比 contain，支持 9:16 到 9:21 长屏 */
.game-frame {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--game-frame-width);
  height: var(--game-frame-height);
  max-width: 100vw;
  max-height: var(--game-viewport-height, 100dvh);
  margin: auto;
  padding: 0;
  overflow: hidden;
  background: #e5e3da;
  border-radius: 0;
  transform: none;
}

.home-backdrop,
.game-loading {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
}

.home-backdrop {
  z-index: 0;
  display: block;
  object-fit: cover;
  object-position: center center;
  opacity: 0;
  pointer-events: none;
}

.home-backdrop.is-active {
  opacity: 1;
}

.game-loading {
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #c5d0c6 url("./assets/lobby-deck-overlook.jpg?v=20261001-deck-overlook") center / cover no-repeat;
  color: #302923;
  transition: opacity 280ms ease, visibility 280ms ease;
  pointer-events: auto;
}

.game-loading::after {
  position: absolute;
  inset: 0;
  content: "";
  background: rgba(236, 234, 222, 0.52);
}

.game-loading.is-complete {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.loading-brand,
.loading-seal,
.loading-track,
.loading-status {
  position: relative;
  z-index: 1;
}

.loading-brand {
  margin-bottom: 28px;
  color: #201c19;
  font-family: "STKaiti", "KaiTi", "Microsoft YaHei", serif;
  font-size: clamp(34px, 8vw, 52px);
  font-weight: 800;
  letter-spacing: 0;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.55);
}

.loading-seal {
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: 30px;
  place-items: center;
  border: 3px solid #82372e;
  color: #82372e;
  font: 800 29px "STKaiti", "KaiTi", serif;
  transform: rotate(45deg);
  animation: loading-seal-pulse 1.4s ease-in-out infinite;
}

.loading-seal span {
  transform: rotate(-45deg);
}

.loading-track {
  width: min(64%, 300px);
  height: 5px;
  overflow: hidden;
  background: rgba(48, 41, 35, 0.18);
}

.loading-track span {
  display: block;
  width: 0;
  height: 100%;
  background: #82372e;
  transition: width 240ms ease;
}

.loading-status {
  margin-top: 14px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
}

@keyframes loading-seal-pulse {
  0%, 100% { opacity: 0.62; transform: rotate(45deg) scale(0.94); }
  50% { opacity: 1; transform: rotate(45deg) scale(1); }
}

.profile-name-input {
  position: fixed;
  z-index: 5;
  display: none;
  height: 42px;
  padding: 0 8px;
  border: 0;
  border-radius: 2px;
  outline: none;
  background: transparent;
  color: #344c40;
  font: 700 16px "Microsoft YaHei", "PingFang SC", sans-serif;
  text-align: center;
  box-shadow: none;
}

.profile-name-input:focus {
  background: rgba(255, 252, 245, 0.88);
  box-shadow: inset 0 -2px #9f7950;
}

canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: #e5e3da;
  touch-action: none;
  image-rendering: auto;
}

canvas.home-backdrop-active {
  background-color: transparent;
}

@supports (height: 100svh) {
  body {
    min-height: 100svh;
  }
}
