/* =========================================================================
   雪夜童话村 · 滚雪球  —  HUD / 加载页样式
   ========================================================================= */

:root {
  --ink: #e8f2ff;
  --dim: rgba(214, 231, 255, .58);
  --ice: #9fd8ff;
  --amber: #ffcf8a;
  --panel: rgba(9, 17, 36, .5);
  --line: rgba(159, 216, 255, .16);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #070b1a;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#app { position: fixed; inset: 0; }

#stage {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}

/* ---------------------------- HUD 容器 ---------------------------- */

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .7s ease;
}

#hud.on { opacity: 1; }

.panel {
  position: absolute;
  padding: 10px 13px 11px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
  box-shadow: 0 10px 30px rgba(2, 6, 18, .35), inset 0 1px 0 rgba(180, 220, 255, .08);
}

.panel-tl { left: 16px; top: 16px; min-width: 178px; }
.panel-tr { right: 16px; top: 16px; min-width: 172px; }

/* ---------------------------- 体积 ---------------------------- */

.vol-line {
  display: flex;
  align-items: baseline;
  gap: 5px;
  line-height: 1;
}

.vol-key {
  font-size: 11px;
  letter-spacing: .16em;
  color: var(--dim);
}

.vol-num {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: #ffffff;
  text-shadow: 0 0 18px rgba(140, 200, 255, .55);
  font-variant-numeric: tabular-nums;
  transition: color .3s;
}

.vol-unit {
  font-size: 12px;
  color: var(--dim);
}

.vol-bar {
  position: relative;
  margin-top: 9px;
  height: 5px;
  border-radius: 99px;
  background: rgba(150, 190, 255, .14);
  overflow: hidden;
}

.vol-bar > i {
  display: block;
  width: 3%;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #6aa9ff, #b6e4ff 70%, #ffffff);
  box-shadow: 0 0 12px rgba(150, 210, 255, .8);
  transition: width .18s linear;
}

.vol-goal {
  margin-top: 8px;
  font-size: 10.5px;
  letter-spacing: .04em;
  color: var(--dim);
}

/* ---------------------------- 联机 / 名字 ---------------------------- */

.net-line {
  display: flex;
  align-items: center;
  gap: 7px;
  pointer-events: auto;
}

.net-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: #6b7688;
  box-shadow: 0 0 0 3px rgba(120, 140, 170, .12);
  transition: background .3s, box-shadow .3s;
}

.net-dot.on {
  background: #57e39b;
  box-shadow: 0 0 0 3px rgba(87, 227, 155, .16), 0 0 10px rgba(87, 227, 155, .8);
}

.name-btn {
  flex: 1;
  padding: 2px 0;
  margin: 0;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: .03em;
  color: #cfe6ff;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-bottom: 1px dashed rgba(159, 216, 255, .28);
}

.name-btn:active { color: #fff; }

.name-input {
  display: none;
  flex: 1;
  width: 100%;
  padding: 2px 4px;
  border: 1px solid rgba(159, 216, 255, .45);
  border-radius: 6px;
  background: rgba(8, 16, 34, .9);
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
  outline: none;
}

.name-input.on { display: block; }

/* ---------------------------- 排行榜 ---------------------------- */

.board-title {
  margin-top: 11px;
  font-size: 9.5px;
  letter-spacing: .18em;
  color: rgba(160, 190, 230, .5);
  text-transform: uppercase;
}

.board-list {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.board-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2.5px 0;
  font-size: 12px;
  line-height: 1.35;
  color: rgba(214, 231, 255, .72);
}

.board-list li .rk {
  width: 12px;
  flex: none;
  font-size: 10px;
  color: rgba(150, 180, 220, .55);
  font-variant-numeric: tabular-nums;
}

.board-list li .nm {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-list li .rr {
  flex: none;
  font-variant-numeric: tabular-nums;
  color: rgba(159, 216, 255, .85);
}

.board-list li.me {
  color: #ffffff;
  font-weight: 700;
}

.board-list li.me .rk { color: var(--amber); }
.board-list li.me .rr { color: var(--amber); }

/* ---------------------------- 提示 Toast ---------------------------- */

.toast-layer {
  position: absolute;
  left: 50%;
  top: 13%;
  width: min(92vw, 460px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.toast {
  padding: 7px 15px;
  border-radius: 99px;
  background: rgba(9, 17, 36, .62);
  border: 1px solid rgba(159, 216, 255, .22);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: 13px;
  letter-spacing: .02em;
  color: #eaf4ff;
  white-space: nowrap;
  animation: toastLife 2.3s ease forwards;
}

.toast.bad {
  border-color: rgba(255, 130, 150, .35);
  color: #ffd7de;
}

.toast.good {
  border-color: rgba(255, 207, 138, .42);
  color: #ffeccd;
}

@keyframes toastLife {
  0%   { opacity: 0; transform: translateY(8px) scale(.96); }
  10%  { opacity: 1; transform: translateY(0) scale(1); }
  72%  { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-10px) scale(.98); }
}

/* ---------------------------- 虚拟摇杆 ---------------------------- */

.joy {
  position: absolute;
  left: 22px;
  bottom: 26px;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  touch-action: none;
  background: radial-gradient(circle at 50% 50%, rgba(120, 170, 255, .10), rgba(10, 18, 38, .34) 70%);
  border: 1px solid rgba(159, 216, 255, .2);
  box-shadow: inset 0 0 26px rgba(70, 120, 200, .18);
}

body.touch .joy { display: flex; }

.joy-stick {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, rgba(255, 255, 255, .95), rgba(190, 218, 255, .55) 60%, rgba(120, 160, 220, .35));
  box-shadow: 0 0 18px rgba(150, 200, 255, .5), inset 0 -3px 8px rgba(40, 70, 120, .35);
  will-change: transform;
}

/* ---------------------------- 胜利浮层 ---------------------------- */

.win {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .45s ease, visibility .45s;
  background: radial-gradient(ellipse at 50% 55%, rgba(40, 110, 190, .26), rgba(4, 8, 20, .62) 72%);
}

.win.on { opacity: 1; visibility: visible; }

.win-card {
  max-width: 380px;
  padding: 26px 30px 24px;
  border-radius: 20px;
  text-align: center;
  background: linear-gradient(160deg, rgba(24, 52, 96, .86), rgba(8, 16, 36, .92));
  border: 1px solid rgba(159, 216, 255, .34);
  box-shadow: 0 24px 70px rgba(0, 10, 30, .6), inset 0 1px 0 rgba(200, 235, 255, .16),
              0 0 60px rgba(90, 175, 255, .22);
  transform: translateY(10px) scale(.97);
  transition: transform .5s cubic-bezier(.2, .9, .3, 1);
}

.win.on .win-card { transform: translateY(0) scale(1); }

.win-kicker {
  font-size: 9.5px;
  letter-spacing: .42em;
  color: rgba(159, 216, 255, .7);
}

.win-title {
  margin-top: 12px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.45;
  background: linear-gradient(100deg, #ffffff, #b6e4ff 55%, #7fc4ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.win-sub {
  margin-top: 10px;
  font-size: 11.5px;
  letter-spacing: .06em;
  color: var(--dim);
}

/* ---------------------------- 加载页 ---------------------------- */

.loader {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  background: #05070f;
  transition: opacity .6s ease;
}

.loader.hide {
  opacity: 0;
  pointer-events: none;
}

.ball-wrap {
  position: relative;
  width: 78px;
  height: 78px;
}

.loader-ball {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #ffffff 0%, #e4efff 42%, #9dbdec 78%, #7d9ed4 100%);
  box-shadow: 0 0 30px rgba(150, 200, 255, .45),
              inset -7px -9px 16px rgba(48, 78, 138, .55),
              inset 6px 7px 12px rgba(255, 255, 255, .5);
  animation: loaderRoll 1.35s cubic-bezier(.45, 0, .55, 1) infinite;
}

.loader-shadow {
  position: absolute;
  left: 50%;
  bottom: -18px;
  width: 52px;
  height: 10px;
  margin-left: -26px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(110, 165, 255, .4), rgba(110, 165, 255, 0) 70%);
  animation: loaderShadow 1.35s cubic-bezier(.45, 0, .55, 1) infinite;
}

.loader-text {
  font-size: 12px;
  letter-spacing: .28em;
  color: rgba(200, 222, 255, .62);
}

@keyframes loaderRoll {
  0%   { transform: translateY(0) rotate(0deg); }
  50%  { transform: translateY(-15px) rotate(180deg); }
  100% { transform: translateY(0) rotate(360deg); }
}

@keyframes loaderShadow {
  0%, 100% { transform: scaleX(1); opacity: .6; }
  50%      { transform: scaleX(.55); opacity: .22; }
}

/* ---------------------------- 小屏适配 ---------------------------- */

@media (max-width: 520px) {
  .panel { padding: 8px 10px 9px; border-radius: 12px; }
  .panel-tl { left: 10px; top: 10px; min-width: 148px; }
  .panel-tr { right: 10px; top: 10px; min-width: 140px; }
  .vol-num { font-size: 22px; }
  .vol-goal { font-size: 9.5px; }
  .board-list li { font-size: 11px; }
  .board-title { font-size: 8.5px; }
  .name-btn, .name-input { font-size: 11px; }
  .toast { font-size: 12px; padding: 6px 12px; }
  .joy { width: 104px; height: 104px; left: 16px; bottom: 20px; }
  .joy-stick { width: 48px; height: 48px; }
}

@media (max-height: 430px) {
  .vol-goal, .board-title { display: none; }
  .joy { width: 96px; height: 96px; }
  .joy-stick { width: 44px; height: 44px; }
}
