/* 石了个石：Q 版可爱网游风。糖果色、圆润描边、果冻弹跳；只用 CSS 与 Canvas 粒子，不依赖外部库。 */
:root {
  --ink: #5b3a6e;
  --ink-soft: #8d74a3;
  --pink: #ff7eb6;
  --pink-d: #e2558f;
  --lemon: #ffd84d;
  --lemon-d: #f0a51e;
  --mint: #4fd6a5;
  --mint-d: #22a577;
  --sky: #4fb3ff;
  --sky-d: #2b84d4;
  --grape: #a78bfa;
  --grape-d: #7b5fd6;
  --peach: #ff9f68;
  --cream: #fffdf6;
  --cream-2: #ffeccb;
  --edge: #f6bb82;
  --edge-2: #db9253;
  --radius: 22px;
  --ts: 44px;       /* 牌边长（JS 按可用空间计算） */
  --th: 5px;        /* 牌厚度 */
  --tilt: 12deg;    /* 棋盘倾角 */
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
/* 手机防闪屏：棋盘整体绑了点击事件，安卓 Chrome/微信每点一下会整块闪一次点击高亮；
   manipulation 关掉双击缩放（连点两张牌不再让页面缩放跳动）；对局区禁止长按选中文字 */
html { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
#game { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body {
  position: relative;
  background:
    radial-gradient(900px 500px at 50% 115%, rgba(255, 216, 77, .35), transparent 65%),
    linear-gradient(180deg, #8fd6ff 0%, #b8b3ff 48%, #ffc6e4 100%);
  color: var(--ink);
  font: 13px/1.55 "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
/* 飘动的白云（纯背景渐变，合成层平移，几乎不占 CPU） */
body::before {
  content: ""; position: fixed; inset: -10% -30% auto -30%; height: 70%; pointer-events: none; z-index: 0;
  background:
    radial-gradient(46px 30px at 8% 18%, #fff 96%, transparent 100%),
    radial-gradient(34px 26px at 11% 13%, #fff 96%, transparent 100%),
    radial-gradient(40px 24px at 14% 19%, #fff 96%, transparent 100%),
    radial-gradient(56px 34px at 44% 30%, rgba(255, 255, 255, .9) 96%, transparent 100%),
    radial-gradient(40px 30px at 47% 24%, rgba(255, 255, 255, .9) 96%, transparent 100%),
    radial-gradient(44px 26px at 51% 31%, rgba(255, 255, 255, .9) 96%, transparent 100%),
    radial-gradient(50px 30px at 80% 12%, #fff 96%, transparent 100%),
    radial-gradient(36px 28px at 83% 7%, #fff 96%, transparent 100%),
    radial-gradient(42px 24px at 86% 13%, #fff 96%, transparent 100%);
  opacity: .75; animation: clouds 60s linear infinite alternate;
}
@keyframes clouds { to { transform: translateX(14%); } }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--ink-soft); }

.fx-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 45; }
.fly-layer { position: fixed; inset: 0; pointer-events: none; z-index: 30; perspective: 900px; }
.screen { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; }

/* 描边大字：多重白色阴影做描边 + 彩色投影 */
.logo span, .banner b, .chest-title, .modal-card h2 {
  text-shadow: 3px 0 #fff, -3px 0 #fff, 0 3px #fff, 0 -3px #fff, 2px 2px #fff, -2px 2px #fff, 2px -2px #fff, -2px -2px #fff,
    0 7px 0 var(--sd, var(--pink-d)), 0 11px 16px rgba(110, 60, 160, .35);
}

/* ---------------- 按钮 ---------------- */
.btn {
  border: 3px solid #fff; border-radius: 999px; padding: 7px 20px; font-weight: 800; letter-spacing: .06em;
  transition: transform .15s cubic-bezier(.3, 1.8, .5, 1), filter .15s;
}
/* 悬停效果只给有鼠标的设备：手机点过的元素会“粘住”悬停态，来回跳成闪烁 */
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { transform: translateY(-2px) scale(1.03); }
}
.btn:active:not(:disabled) { transform: translateY(3px) scale(.97); }
.btn:disabled { filter: grayscale(.7) opacity(.7); cursor: not-allowed; }
.btn-primary {
  color: #fff; text-shadow: 0 2px 0 rgba(180, 90, 0, .45);
  background: linear-gradient(180deg, #ffe680 0%, var(--lemon) 45%, #ffb238 100%);
  box-shadow: 0 5px 0 var(--lemon-d), 0 10px 18px rgba(240, 165, 30, .45), inset 0 3px 0 rgba(255, 255, 255, .7);
}
.btn-big { font-size: 20px; padding: 10px 44px; }
.btn-ghost {
  color: var(--grape-d); background: linear-gradient(180deg, #fff, #f3eeff);
  box-shadow: 0 4px 0 #cbbcf5, 0 8px 14px rgba(123, 95, 214, .2);
}
.btn-danger { color: #fff; background: linear-gradient(180deg, #ff9dc6, var(--pink)); box-shadow: 0 4px 0 var(--pink-d); }

/* ---------------- 大厅 ---------------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; flex: none; }
.back-link {
  color: var(--grape-d); font-weight: 800; text-decoration: none; padding: 5px 14px; border-radius: 999px;
  background: #fff; box-shadow: 0 4px 0 #cbbcf5, 0 6px 12px rgba(123, 95, 214, .2);
}
@media (hover: hover) and (pointer: fine) { .back-link:hover { transform: translateY(-1px); } }
.who { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.who label { color: #fff; text-shadow: 0 1px 2px rgba(90, 50, 140, .5); }
.who select {
  background: #fff; border: 3px solid #fff; border-radius: 999px; padding: 3px 10px; color: var(--ink); font-weight: 700;
  box-shadow: 0 4px 0 #cbbcf5;
}
.lobby-body { flex: 1; overflow-y: auto; padding: 0 16px 24px; }
.hero { position: relative; text-align: center; padding: 14px 0 8px; }
.hero-tiles { position: absolute; inset: 0; pointer-events: none; perspective: 600px; }
.hero-tile {
  position: absolute; width: 56px; height: 56px; border-radius: 26%;
  background: linear-gradient(180deg, var(--cream), var(--cream-2));
  box-shadow: 0 0 0 3px #fff, 0 6px 0 var(--edge), 0 8px 0 var(--edge-2), 0 14px 18px rgba(110, 60, 160, .3);
  display: grid; place-items: center;
  animation: hover-tile 5s ease-in-out infinite;
}
.hero-tile img { width: 82%; height: 82%; object-fit: contain; }
@keyframes hover-tile {
  0%, 100% { transform: translateY(0) rotate(-8deg) scale(1); }
  50% { transform: translateY(-14px) rotate(8deg) scale(1.06); }
}
.logo {
  position: relative; margin: 4px 0 4px; font-family: "ZCOOL KuaiLe", "Microsoft YaHei", sans-serif; font-weight: 400;
  font-size: clamp(42px, 9vw, 68px); line-height: 1.15; letter-spacing: .02em;
}
.logo span { display: inline-block; color: var(--pink); --sd: var(--pink-d); animation: logo-bob 2.4s ease-in-out infinite; }
.logo span:nth-child(2) { color: var(--lemon); --sd: var(--lemon-d); animation-delay: .15s; }
.logo span:nth-child(3) { color: var(--mint); --sd: var(--mint-d); animation-delay: .3s; }
.logo span:nth-child(4) { color: var(--sky); --sd: var(--sky-d); animation-delay: .45s; }
@keyframes logo-bob {
  0%, 100% { transform: translateY(0) rotate(-4deg) scale(1); }
  50% { transform: translateY(-8px) rotate(4deg) scale(1.06, .96); }
}
.tagline {
  position: relative; z-index: 1; display: inline-block; margin: 8px 0 14px; padding: 3px 16px; border-radius: 999px;
  color: var(--grape-d); font-weight: 700; background: rgba(255, 255, 255, .78); box-shadow: 0 3px 0 rgba(203, 188, 245, .9);
}
.hero-actions { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; align-items: center; }
.lobby-note { position: relative; z-index: 1; min-height: 1.5em; margin: 12px 0 0; color: #fff; font-weight: 700; text-shadow: 0 1px 3px rgba(110, 60, 160, .6); }

.panel {
  position: relative; border-radius: var(--radius); padding: 14px 14px 16px; border: 3px solid #fff;
  background: linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(255, 247, 252, .96));
  box-shadow: 0 7px 0 rgba(167, 139, 250, .45), 0 16px 28px rgba(110, 60, 170, .2);
}
.panel h2 {
  display: inline-block; margin: -26px 0 10px; padding: 4px 16px; border-radius: 999px; font-size: 15px; color: #fff;
  border: 3px solid #fff; background: linear-gradient(180deg, #ff9dc6, var(--pink)); box-shadow: 0 3px 0 var(--pink-d);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .12);
}
.panel h2 small { font-weight: 400; color: #fff; opacity: .9; font-size: 12px; margin-left: 6px; }
.reward-panel h2 { background: linear-gradient(180deg, #ffe680, #ffb238); box-shadow: 0 3px 0 var(--lemon-d); }
.rank-panel h2 { background: linear-gradient(180deg, #8ecfff, var(--sky)); box-shadow: 0 3px 0 var(--sky-d); }
.login-panel h2 { background: linear-gradient(180deg, #c6b5ff, var(--grape)); box-shadow: 0 3px 0 var(--grape-d); }
.lobby-grid {
  display: grid; gap: 22px 14px; margin: 26px auto 0; max-width: 1100px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr);
}
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { border-radius: 16px; padding: 8px 10px; text-align: center; background: #ffe8f3; box-shadow: inset 0 -3px 0 rgba(226, 85, 143, .15); }
.stat:nth-child(2) { background: #dff8ee; box-shadow: inset 0 -3px 0 rgba(34, 165, 119, .15); }
.stat:nth-child(3) { background: #e2f1ff; box-shadow: inset 0 -3px 0 rgba(43, 132, 212, .15); }
.stat:nth-child(4) { background: #fff5d6; box-shadow: inset 0 -3px 0 rgba(240, 165, 30, .18); }
.stat b { display: block; font-size: 24px; line-height: 1.2; font-weight: 900; }
.stat:nth-child(1) b { color: var(--pink-d); }
.stat:nth-child(2) b { color: var(--mint-d); }
.stat:nth-child(3) b { color: var(--sky-d); }
.stat:nth-child(4) b { color: var(--lemon-d); }
.stat span { color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.reward-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.reward-chip {
  display: flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: 999px; font-weight: 700;
  background: #fff8dc; box-shadow: 0 0 0 2px #ffe08a, 0 3px 0 #ffd05a;
}
.reward-chip img, .reward-chip .noimg { width: 36px; height: 36px; object-fit: contain; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 2px #ffe8a8; }
.reward-chip b { color: var(--pink-d); }
.tier-title { margin-top: 26px !important; }
.tier-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.tier-list li { display: flex; align-items: center; gap: 8px; }
.medal {
  flex: none; min-width: 56px; text-align: center; padding: 2px 8px; border-radius: 999px; font-weight: 800; font-size: 12px;
  color: #fff; background: linear-gradient(180deg, #c6b5ff, var(--grape)); box-shadow: 0 3px 0 var(--grape-d);
}
.medal.m1 { background: linear-gradient(180deg, #ffe680, #ffb238); box-shadow: 0 3px 0 var(--lemon-d); }
.medal.m2 { background: linear-gradient(180deg, #d9ecff, #8ab8e0); box-shadow: 0 3px 0 #5d8fbc; }
.medal.m3 { background: linear-gradient(180deg, #ffc9a8, var(--peach)); box-shadow: 0 3px 0 #d8743c; }
.tier-list .reward-chip { padding: 2px 8px 2px 2px; }
.tier-list .reward-chip img { width: 28px; height: 28px; }
.rank-head { display: flex; align-items: center; justify-content: space-between; }
.rank-rule { margin: 0 0 8px; font-size: 12px; }
.seg { display: inline-flex; background: #eef5ff; border-radius: 999px; padding: 3px; box-shadow: inset 0 2px 4px rgba(43, 132, 212, .15); margin-top: -18px; }
.seg-btn { border: 0; background: none; padding: 3px 14px; border-radius: 999px; color: var(--ink-soft); font-weight: 700; }
.seg-btn.active { background: linear-gradient(180deg, #8ecfff, var(--sky)); color: #fff; box-shadow: 0 3px 0 var(--sky-d); }
.rank-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.rank-row {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) 52px 58px 58px; align-items: center; gap: 6px;
  padding: 5px 6px; border-radius: 12px; font-weight: 700;
}
.rank-row:nth-child(odd) { background: #f4f9ff; }
.rank-row.head { color: var(--ink-soft); font-size: 12px; background: none; }
.rank-row .no { text-align: center; font-weight: 900; color: var(--grape-d); }
.rank-row .no.m1, .rank-row .no.m2, .rank-row .no.m3 {
  width: 26px; height: 26px; line-height: 22px; border-radius: 50%; margin: 0 auto; font-size: 12px; color: #fff; border: 2px solid #fff;
}
.rank-row .no.m1 { background: linear-gradient(180deg, #ffe680, #ffb238); box-shadow: 0 2px 0 var(--lemon-d), 0 0 10px rgba(255, 196, 60, .8); }
.rank-row .no.m2 { background: linear-gradient(180deg, #d9ecff, #8ab8e0); box-shadow: 0 2px 0 #5d8fbc; }
.rank-row .no.m3 { background: linear-gradient(180deg, #ffc9a8, var(--peach)); box-shadow: 0 2px 0 #d8743c; }
.rank-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .num { text-align: right; font-variant-numeric: tabular-nums; }
.rank-row .clr { color: var(--mint-d); }
.rank-empty { color: var(--ink-soft); padding: 14px 6px; text-align: center; font-weight: 700; }
.rank-me { margin-top: 8px; padding: 6px; border-radius: 14px; background: #fff5d6; box-shadow: 0 0 0 2px #ffe08a; }
.login-panel { max-width: 360px; margin: 30px auto 0; display: grid; gap: 10px; }
.login-panel label { display: grid; gap: 4px; color: var(--ink-soft); font-weight: 700; }
.login-panel input { background: #f7f3ff; border: 2px solid #e2d8ff; border-radius: 14px; padding: 7px 12px; }
.login-panel input:focus { outline: none; border-color: var(--grape); background: #fff; }
.captcha-row { grid-template-columns: 1fr auto; align-items: end; }
.captcha-row input { grid-column: 1; }
.captcha-row img { grid-column: 2; grid-row: 1 / span 2; border-radius: 10px; cursor: pointer; background: #fff; box-shadow: 0 0 0 2px #e2d8ff; }
.form-msg { min-height: 1.4em; margin: 0; color: var(--pink-d); font-weight: 700; }

/* ---------------- 对局 ---------------- */
.hud { flex: none; display: flex; align-items: center; gap: 10px; padding: 7px 12px; }
.hud-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 3px solid #fff; font-size: 20px; line-height: 1; font-weight: 900;
  color: var(--grape-d); background: #fff; box-shadow: 0 3px 0 #cbbcf5;
}
.hud-level {
  white-space: nowrap; font-weight: 800; padding: 3px 14px; border-radius: 999px; letter-spacing: .06em; color: #fff; border: 3px solid #fff;
  background: linear-gradient(180deg, #7ee8c2, var(--mint)); box-shadow: 0 3px 0 var(--mint-d);
}
.hud-level.hard { background: linear-gradient(180deg, #ff9dc6, var(--pink)); box-shadow: 0 3px 0 var(--pink-d); }
.hud-item {
  white-space: nowrap; display: flex; align-items: baseline; gap: 4px; padding: 2px 12px; border-radius: 999px; font-weight: 700;
  color: var(--ink-soft); background: rgba(255, 255, 255, .85); box-shadow: 0 3px 0 rgba(203, 188, 245, .9);
}
.hud-item b { color: var(--ink); font-size: 16px; font-variant-numeric: tabular-nums; }
/* 同步提示只在网络慢（超过 0.7 秒）时出现，且不再闪烁，避免手机上每次同步都一闪一闪 */
.hud-sync { margin-left: auto; white-space: nowrap; color: #fff; font-weight: 700; font-size: 12px; opacity: .9; text-shadow: 0 1px 2px rgba(110, 60, 160, .6); }

/* 横排：游戏内矮而宽的面板把卡槽放到右侧，牌可以更大 */
#game.side { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr); }
#game.side .hud { grid-column: 1 / -1; }
#game.side .stage { grid-column: 1; grid-row: 2; }
#game.side .bottom { grid-column: 2; grid-row: 2; justify-content: center; gap: 12px; padding: 8px 14px 12px 4px; }
.stage { position: relative; flex: 1; min-height: 0; perspective: 1400px; perspective-origin: 50% 20%; }
.board-wrap {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%) rotateX(var(--tilt));
  transform-origin: 50% 60%;
}
.board { position: relative; }
.board::before {
  /* 薄荷色软垫底座：波点 + 白边 */
  content: ""; position: absolute; inset: -16px -16px -20px; border-radius: 30px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .38) 0 2.5px, transparent 3.5px) 0 0 / 22px 22px,
    linear-gradient(160deg, #a8f0d8, #6fd3b2);
  box-shadow: 0 0 0 5px #fff, 0 14px 0 #4bb893, 0 24px 32px rgba(90, 60, 150, .32);
}
.board::after {
  content: ""; position: absolute; inset: -8px -8px -12px; border-radius: 24px; pointer-events: none;
  border: 3px dashed rgba(255, 255, 255, .8);
}

.tile {
  position: absolute; width: var(--ts); height: var(--ts); border-radius: 26%;
  background: linear-gradient(180deg, #fffefa 0%, var(--cream) 55%, var(--cream-2) 100%);
  box-shadow:
    0 var(--th) 0 var(--edge),
    0 calc(var(--th) + 2px) 0 var(--edge-2),
    0 calc(var(--th) + 6px) 8px rgba(110, 60, 160, .28),
    inset 0 0 0 2px #fff,
    inset 0 -4px 0 rgba(246, 187, 130, .35);
  display: grid; place-items: center;
  /* 不再给每张牌常驻 will-change：上百张牌各占一个 GPU 图层叠在 3D 倾斜的棋盘里，手机上会闪烁/掉块 */
  transition: transform .16s cubic-bezier(.3, 1.8, .5, 1), box-shadow .14s ease;
}
.tile img { width: 82%; height: 82%; object-fit: contain; pointer-events: none; }
/* 被压住的牌：用半透明遮罩压暗（整张牌加 filter 会让每张牌离屏重绘，手机上闪），图片单独去色 */
.tile.dim::before {
  content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; pointer-events: none;
  background: rgba(70, 45, 110, .34);
}
.tile.dim img { filter: grayscale(.55); }
.tile.can { cursor: pointer; }
@media (hover: hover) and (pointer: fine) {
  .tile.can:hover {
    transform: translateY(-5px) scale(1.06);
    box-shadow:
      0 calc(var(--th) + 5px) 0 var(--edge),
      0 calc(var(--th) + 7px) 0 var(--edge-2),
      0 calc(var(--th) + 14px) 14px rgba(110, 60, 160, .3),
      0 0 0 3px var(--lemon), 0 0 16px rgba(255, 216, 77, .9),
      inset 0 0 0 2px #fff;
  }
}
.tile.blind {
  background:
    radial-gradient(circle at 30% 26%, rgba(255, 255, 255, .55) 0 12%, transparent 13%),
    repeating-linear-gradient(45deg, #c2afff 0 7px, #ab94f7 7px 14px);
  box-shadow:
    0 var(--th) 0 #8d72e0, 0 calc(var(--th) + 2px) 0 #6e53c4,
    0 calc(var(--th) + 6px) 8px rgba(110, 60, 160, .3), inset 0 0 0 2px #fff;
}
.tile.blind::after {
  content: "?"; color: #fff; font-weight: 900; font-size: calc(var(--ts) * .5); line-height: 1;
  text-shadow: 0 2px 0 #7b5fd6;
}
.tile.blind img { display: none; }
.tile.blind.await { animation: await-pulse .7s ease-in-out infinite; }
@keyframes await-pulse { 50% { transform: translateY(-3px) scale(1.05); } }
.tile.flip { animation: flip-in .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes flip-in { 0% { transform: rotateY(90deg) scale(.8); } 100% { transform: rotateY(0) scale(1); } }
.tile.drop { animation: drop-in .5s cubic-bezier(.3, 1.7, .5, 1) both; }
@keyframes drop-in { 0% { transform: translateY(-50px) scale(.6); opacity: 0; } 100% { transform: none; opacity: 1; } }
.tile.shuffle-spin { animation: shuffle-spin .65s ease; }
@keyframes shuffle-spin { 0% { transform: none; } 50% { transform: rotate(180deg) scale(.6) translateY(-10px); } 100% { transform: rotate(360deg); } }

.bottom { flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 10px 10px; }
.hold { display: flex; gap: 14px; min-height: calc(var(--ts) * .9); align-items: flex-end; }
.hold-col { position: relative; width: var(--ts); height: calc(var(--ts) + 10px); }
.hold-col .tile { transform: none; }
.tray {
  position: relative; padding: 9px 11px 11px; border-radius: 24px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .22) 0 2px, transparent 3px) 0 0 / 18px 18px,
    linear-gradient(180deg, #d6c8ff, #b29af5);
  box-shadow: 0 0 0 4px #fff, 0 9px 0 #8d72e0, 0 18px 26px rgba(90, 60, 150, .3);
}
.tray.warn { box-shadow: 0 0 0 4px #fff, 0 9px 0 #8d72e0, 0 0 0 8px rgba(255, 126, 182, .75), 0 0 26px rgba(255, 126, 182, .9); animation: warn-pulse 1s ease-in-out infinite; }
@keyframes warn-pulse { 50% { transform: scale(1.015); } }
.tray.shake { animation: shake .5s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-8px) rotate(-1deg); } 40%, 80% { transform: translateX(8px) rotate(1deg); } }
.tray-slots { display: flex; gap: 4px; }
.tray-slot {
  width: calc(var(--ts) + 2px); height: calc(var(--ts) + var(--th) + 2px); border-radius: 26%;
  background: rgba(255, 255, 255, .38); border: 2px dashed rgba(255, 255, 255, .9);
  box-shadow: inset 0 3px 6px rgba(90, 60, 150, .2);
}
.tray-tiles { position: absolute; left: 11px; top: 9px; }
.tray-tiles .tile { transition: left .24s cubic-bezier(.3, 1.6, .5, 1), transform .2s ease; }
.tray-tiles .tile.pop { animation: pop-out .36s ease forwards; }
@keyframes pop-out {
  0% { transform: scale(1); }
  40% { transform: scale(1.35) translateY(-12px) rotate(-8deg); filter: brightness(1.3) drop-shadow(0 0 10px #fff3a8); }
  100% { transform: scale(0) translateY(-24px) rotate(20deg); opacity: 0; }
}
.props { display: flex; gap: 10px; }
.prop {
  position: relative; display: flex; align-items: center; gap: 6px; border: 3px solid #fff; border-radius: 18px; padding: 4px 14px 4px 8px;
  background: linear-gradient(180deg, #8ecfff, var(--sky)); color: #fff; font-weight: 800;
  box-shadow: 0 4px 0 var(--sky-d), 0 8px 14px rgba(90, 60, 150, .25);
  transition: transform .15s cubic-bezier(.3, 1.8, .5, 1);
}
.prop:nth-child(2) { background: linear-gradient(180deg, #c6b5ff, var(--grape)); box-shadow: 0 4px 0 var(--grape-d), 0 8px 14px rgba(90, 60, 150, .25); }
.prop:nth-child(3) { background: linear-gradient(180deg, #7ee8c2, var(--mint)); box-shadow: 0 4px 0 var(--mint-d), 0 8px 14px rgba(90, 60, 150, .25); }
@media (hover: hover) and (pointer: fine) { .prop:hover:not(:disabled) { transform: translateY(-2px) scale(1.05); } }
.prop:active:not(:disabled) { transform: translateY(3px) scale(.96); }
.prop:disabled { filter: grayscale(1) opacity(.55); cursor: not-allowed; }
.prop em {
  position: absolute; top: -9px; right: -9px; min-width: 20px; height: 20px; border-radius: 10px; font-style: normal;
  font-size: 11px; line-height: 16px; text-align: center; background: var(--pink); border: 2px solid #fff;
}
.ico { width: 18px; height: 18px; display: inline-block; position: relative; }
.ico-out::before, .ico-out::after { content: ""; position: absolute; left: 2px; right: 2px; height: 5px; border-radius: 3px; background: #fff; }
.ico-out::before { top: 2px; opacity: .6; }
.ico-out::after { bottom: 3px; }
.ico-undo::before { content: ""; position: absolute; inset: 3px 2px 3px 4px; border: 3px solid #fff; border-left-color: transparent; border-radius: 50%; }
.ico-undo::after { content: ""; position: absolute; left: 0; top: 3px; border: 5px solid transparent; border-top-color: #fff; transform: rotate(-35deg); }
.ico-shuffle::before, .ico-shuffle::after { content: ""; position: absolute; left: 1px; right: 1px; height: 3px; top: 7px; background: #fff; border-radius: 2px; }
.ico-shuffle::before { transform: rotate(35deg); }
.ico-shuffle::after { transform: rotate(-35deg); }

.banner {
  position: absolute; left: 0; right: 0; top: 34%; z-index: 20; text-align: center; pointer-events: none;
  animation: banner-in 1.9s ease forwards;
}
.banner b {
  display: block; font-family: "ZCOOL KuaiLe", "Microsoft YaHei", sans-serif; font-weight: 400;
  font-size: 40px; letter-spacing: .12em; color: var(--lemon); --sd: var(--lemon-d);
}
.banner.hard b { color: var(--pink); --sd: var(--pink-d); }
.banner span {
  display: inline-block; margin-top: 6px; padding: 3px 16px; border-radius: 999px; font-weight: 800;
  color: var(--grape-d); background: #fff; box-shadow: 0 3px 0 #cbbcf5;
}
@keyframes banner-in {
  0% { opacity: 0; transform: scale(.3); }
  14% { opacity: 1; transform: scale(1.18); }
  24% { transform: scale(.94); }
  32%, 80% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.1) translateY(-16px); }
}

/* ---------------- 弹窗 ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: rgba(90, 60, 140, .38); backdrop-filter: blur(3px); animation: fade-in .2s ease;
}
@keyframes fade-in { from { opacity: 0; } }
.modal-card {
  width: min(440px, 100%); max-height: 100%; overflow-y: auto; border-radius: 28px; padding: 22px 20px 18px; text-align: left;
  background: linear-gradient(180deg, #fff, #fff4fa); border: 4px solid #fff;
  box-shadow: 0 0 0 4px var(--pink), 0 10px 0 4px var(--pink-d), 0 24px 50px rgba(90, 50, 140, .4);
  animation: card-in .45s cubic-bezier(.3, 1.7, .5, 1);
}
@keyframes card-in { 0% { transform: scale(.4) rotate(-6deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.modal-card h2 {
  margin: 0 0 12px; text-align: center; font-family: "ZCOOL KuaiLe", "Microsoft YaHei", sans-serif; font-weight: 400;
  font-size: 26px; color: var(--pink); --sd: var(--pink-d); letter-spacing: .06em;
}
.modal-body { color: var(--ink); font-weight: 600; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }
.rules { margin: 0; padding-left: 18px; display: grid; gap: 7px; }
.rules b { color: var(--pink-d); }
.result-line { display: flex; justify-content: space-between; padding: 7px 10px; margin-bottom: 5px; border-radius: 12px; background: #f6f1ff; }
.result-line b { color: var(--grape-d); }

.toast {
  position: fixed; left: 50%; bottom: 22px; z-index: 70; transform: translateX(-50%);
  padding: 8px 20px; border-radius: 999px; font-weight: 800; color: var(--grape-d); background: #fff;
  box-shadow: 0 4px 0 #cbbcf5, 0 10px 24px rgba(90, 50, 140, .3); animation: toast-in .35s cubic-bezier(.3, 1.7, .5, 1);
}
@keyframes toast-in { from { transform: translateX(-50%) scale(.5); opacity: 0; } }

/* ---------------- Q 版宝箱 ---------------- */
.chest-overlay {
  position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: safe center;
  padding: 16px; overflow-x: hidden; overflow-y: auto; text-align: center;
  background: radial-gradient(circle at 50% 42%, #fff8d2 0%, #ffd2ea 42%, #b9a2ff 100%);
  animation: fade-in .3s ease;
}
.rays {
  position: absolute; left: 50%; top: 42%; width: 200vmax; height: 200vmax; margin: -100vmax 0 0 -100vmax;
  background: repeating-conic-gradient(from 0deg, rgba(255, 255, 255, .55) 0 7deg, transparent 7deg 18deg);
  -webkit-mask: radial-gradient(circle, #000 0, transparent 42%);
  mask: radial-gradient(circle, #000 0, transparent 42%);
  opacity: .5; animation: spin 16s linear infinite; transition: opacity .6s;
}
.chest-overlay.opened .rays { opacity: 1; animation-duration: 7s; }
@keyframes spin { to { transform: rotate(360deg); } }
.chest-title {
  position: relative; margin: 0; font-family: "ZCOOL KuaiLe", "Microsoft YaHei", sans-serif; font-weight: 400;
  font-size: clamp(32px, 7vw, 48px); color: var(--lemon); --sd: var(--lemon-d); letter-spacing: .08em;
  animation: title-pop .7s cubic-bezier(.3, 1.8, .5, 1);
}
@keyframes title-pop { 0% { transform: scale(.2) rotate(-10deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.chest-sub {
  position: relative; display: inline-block; margin: 8px 0 0; padding: 3px 16px; border-radius: 999px; font-weight: 800;
  color: var(--grape-d); background: #fff; box-shadow: 0 3px 0 #cbbcf5;
}
/* 顶部留出箱盖弹开的空间；奖励区预留高度，卡片出现时整体不跳动 */
.chest-scene { position: relative; flex: none; width: 240px; height: 210px; margin: 64px 0 0; display: grid; place-items: end center; }
.chest-overlay.dropping .chest-scene { animation: chest-drop 1s cubic-bezier(.4, 0, .6, 1) both; }
@keyframes chest-drop {
  0% { transform: translateY(-110vh) scale(.9, 1.1); }
  62% { transform: translateY(0) scale(.9, 1.1); }
  74% { transform: translateY(0) scale(1.22, .76); }
  86% { transform: translateY(-14px) scale(.94, 1.08); }
  100% { transform: none; }
}
.chest {
  position: relative; width: 196px; height: 176px; border: 0; padding: 0; background: none; transform-origin: 50% 100%;
}
.chest > span { position: absolute; display: block; }
.chest.idle { animation: chest-idle 1.4s ease-in-out infinite; }
@keyframes chest-idle {
  0%, 100% { transform: scale(1, 1); }
  25% { transform: scale(1.05, .95); }
  55% { transform: translateY(-10px) scale(.96, 1.05); }
  75% { transform: scale(1.02, .98); }
}
.chest.shake { animation: chest-shake .5s ease; }
@keyframes chest-shake {
  0%, 100% { transform: none; }
  15% { transform: rotate(-9deg) scale(1.06, .94); }
  35% { transform: rotate(8deg) scale(.95, 1.07); }
  55% { transform: rotate(-7deg) scale(1.08, .92); }
  75% { transform: rotate(5deg) scale(.97, 1.04); }
}
.chest.open { animation: chest-jump .6s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes chest-jump { 0% { transform: scale(1.25, .75); } 45% { transform: translateY(-18px) scale(.92, 1.1); } 100% { transform: none; } }
.chest:focus-visible { outline: 3px dashed #fff; outline-offset: 12px; border-radius: 30px; }
.ch-shadow {
  left: 26px; right: 26px; bottom: -6px; height: 20px; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(90, 50, 140, .35), transparent 70%);
}
/* 箱体：圆润木箱 + 粗描边 + 金色包边 */
.ch-body {
  left: 12px; right: 12px; bottom: 6px; height: 96px; border-radius: 20px 20px 30px 30px; z-index: 1;
  border: 5px solid #7a3b12;
  background:
    repeating-linear-gradient(180deg, transparent 0 26px, rgba(122, 59, 18, .22) 26px 29px),
    linear-gradient(180deg, #f0a45a 0%, #d97a33 70%, #c0652a 100%);
  box-shadow: inset 0 7px 0 rgba(255, 255, 255, .32), inset 0 -8px 0 rgba(120, 50, 10, .22);
}
.ch-band { position: absolute; top: -5px; bottom: -5px; width: 24px; border: 4px solid #7a3b12; border-radius: 8px;
  background: linear-gradient(90deg, #fff1a6, #ffd048 45%, #f0a51e); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .6); }
.ch-band-l { left: 24px; }
.ch-band-r { right: 24px; }
/* 锁扣压在箱盖与箱体接缝上，开箱时留在箱体上 */
.ch-lock {
  left: 50%; bottom: 76px; width: 46px; height: 46px; margin-left: -23px; border-radius: 50%; z-index: 4;
  border: 5px solid #7a3b12; background: radial-gradient(circle at 35% 30%, #fffbe0 0 14%, #ffd84d 40%, #f0a51e 100%);
  box-shadow: 0 3px 0 rgba(122, 59, 18, .5); display: grid; place-items: center;
}
.ch-lock::after { content: "\2665"; color: var(--pink-d); font-size: 18px; line-height: 1; text-shadow: 0 1px 0 #fff; }
/* 张开后露出的金光 */
.ch-mouth {
  left: 26px; right: 26px; bottom: 90px; height: 30px; border-radius: 50%; z-index: 2;
  background: radial-gradient(ellipse at 50% 60%, #fffbe0 0%, #ffe066 45%, #f0a51e 80%);
  box-shadow: 0 0 30px 12px rgba(255, 230, 110, .9); transform: scale(0); transition: transform .35s .12s cubic-bezier(.3, 1.8, .5, 1);
}
.chest.open .ch-mouth { transform: scale(1); }
.ch-beam {
  left: 40px; right: 40px; bottom: 100px; height: 240px; z-index: 0; transform-origin: 50% 100%; transform: scaleY(0);
  background: linear-gradient(0deg, rgba(255, 246, 190, .95), rgba(255, 246, 190, 0));
  filter: blur(4px); border-radius: 50% 50% 0 0; transition: transform .5s .1s cubic-bezier(.3, 1.4, .5, 1);
}
.chest.open .ch-beam { transform: scaleY(1); }
/* 箱盖：圆拱形，打开时弹起后仰 */
.ch-lid {
  left: 8px; right: 8px; bottom: 94px; height: 70px; z-index: 3; transform-origin: 12% 100%;
  border-radius: 90px 90px 18px 18px / 70px 70px 18px 18px; border: 5px solid #7a3b12;
  background:
    radial-gradient(ellipse 40% 26% at 32% 28%, rgba(255, 255, 255, .55), transparent 70%),
    linear-gradient(180deg, #f6b066 0%, #df8339 80%);
  box-shadow: inset 0 -7px 0 rgba(120, 50, 10, .2);
  transition: transform .6s cubic-bezier(.3, 1.8, .45, 1);
}
.ch-lid .ch-band { border-radius: 10px 10px 6px 6px; top: -4px; bottom: -5px; }
.chest.open .ch-lid { transform: translate(-16px, -66px) rotate(-24deg); }
.chest.open .ch-lock { animation: lock-pop .5s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes lock-pop { 40% { transform: scale(1.3) rotate(-15deg); } }
/* 闪闪星星 */
.ch-spark { width: 16px; height: 16px; z-index: 4; background: #fff;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: twinkle 1.4s ease-in-out infinite; filter: drop-shadow(0 0 4px #fff6b0); }
.ch-spark.s1 { left: -4px; top: 40px; }
.ch-spark.s2 { right: -2px; top: 20px; animation-delay: .35s; width: 22px; height: 22px; }
.ch-spark.s3 { left: 22px; top: -6px; animation-delay: .7s; width: 12px; height: 12px; }
.ch-spark.s4 { right: 20px; bottom: 16px; animation-delay: 1s; }
@keyframes twinkle { 0%, 100% { transform: scale(.2) rotate(0); opacity: .2; } 50% { transform: scale(1) rotate(45deg); opacity: 1; } }
.chest-hint {
  position: relative; margin: 14px 0 0; padding: 4px 18px; border-radius: 999px; font-weight: 800; color: #fff;
  background: linear-gradient(180deg, #ff9dc6, var(--pink)); border: 3px solid #fff; box-shadow: 0 3px 0 var(--pink-d);
  animation: hint-bob 1s ease-in-out infinite;
}
@keyframes hint-bob { 50% { transform: translateY(-4px) scale(1.05); } }
.loot { position: relative; display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; max-width: 640px; min-height: 144px; margin-top: 8px; perspective: 800px; }
.loot-card {
  position: relative; width: 104px; height: 132px; transform-style: preserve-3d;
  transform: translate(var(--fx, 0), var(--fy, -140px)) scale(.1) rotateY(180deg); opacity: 0;
  transition: transform .75s cubic-bezier(.3, 1.6, .5, 1), opacity .3s;
}
.loot-card.out { transform: translate(0, 0) scale(1) rotateY(180deg); opacity: 1; }
.loot-card.flipped { transform: translate(0, 0) scale(1) rotateY(0deg); opacity: 1; }
.loot-card .lc-face, .loot-card .lc-back {
  position: absolute; inset: 0; border-radius: 24px; backface-visibility: hidden; border: 4px solid #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px;
}
.loot-card .lc-face {
  background: linear-gradient(180deg, #fffdf2, #fff0c4); color: var(--ink);
  box-shadow: 0 0 0 4px var(--lemon), 0 7px 0 4px var(--lemon-d), 0 0 26px rgba(255, 216, 77, .9);
}
.loot-card .lc-back {
  transform: rotateY(180deg);
  background: radial-gradient(circle at 50% 50%, #fff 0 16%, transparent 17%), repeating-linear-gradient(45deg, #ffb3d4 0 8px, #ff8fc0 8px 16px);
  box-shadow: 0 0 0 4px var(--pink), 0 7px 0 4px var(--pink-d);
}
.lc-face .lc-art {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #fff 0 20%, #ffeec0 70%); box-shadow: inset 0 0 0 3px #fff, 0 3px 0 #f6d27a;
}
.lc-face img, .lc-face .noimg { width: 52px; height: 52px; object-fit: contain; }
.lc-face strong { font-size: 12px; line-height: 1.3; font-weight: 800; }
.lc-face em {
  font-style: normal; font-weight: 900; color: #fff; padding: 0 10px; border-radius: 999px;
  background: linear-gradient(180deg, #ff9dc6, var(--pink)); box-shadow: 0 2px 0 var(--pink-d);
}
.lc-face .trophy { font-size: 40px; line-height: 1; }
.chest-note {
  position: relative; max-width: 480px; margin: 16px 0 0; padding: 6px 16px; border-radius: 16px; min-height: 1.5em;
  font-weight: 700; color: var(--grape-d); background: rgba(255, 255, 255, .85); box-shadow: 0 3px 0 rgba(203, 188, 245, .9);
}
.chest-note:empty { visibility: hidden; }
.chest-actions { position: relative; display: flex; gap: 12px; margin-top: 14px; }

/* ---------------- 适配 ---------------- */
@media (max-width: 900px) {
  .lobby-grid { grid-template-columns: 1fr 1fr; }
  .rank-panel { grid-column: 1 / -1; }
}
@media (max-width: 700px), (max-height: 520px) {
  .hero-tile { width: 42px; height: 42px; opacity: .7; }
  .hero-tile:nth-child(n+5) { display: none; }
}
@media (max-width: 560px) {
  .hud { gap: 6px; padding: 7px 8px; }
  .hud-level { padding: 3px 10px; font-size: 12px; letter-spacing: 0; }
  .hud-item { padding: 2px 9px; }
  .hud-item b { font-size: 14px; }
  .lobby-grid { grid-template-columns: 1fr; }
  .rank-row { grid-template-columns: 30px minmax(0, 1fr) 44px 50px 52px; font-size: 12px; }
  .prop { padding: 3px 10px 3px 6px; }
  .props { gap: 8px; }
}
@media (max-height: 460px) {
  .hero { padding: 4px 0 2px; }
  .logo { font-size: 40px; }
  .tagline { margin: 4px 0 8px; }
  .hud { padding: 4px 10px; }
  .bottom { gap: 4px; padding-bottom: 6px; }
  .chest-scene { height: 180px; margin-top: 40px; transform: scale(.85); }
  .loot { min-height: 118px; }
  .loot-card { width: 86px; height: 110px; }
  .lc-face .lc-art { width: 48px; height: 48px; }
  .lc-face img { width: 40px; height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
