:root {
  --ws-primary: #f59e0b; /* 主题色：原版同款橙 */
  --bg1: #3d4166;
  --bg2: #22254a;
  --bottle-w: 58px;  /* 由 game.js fitBottles() 按屏宽与瓶数动态计算 */
  --bottle-h: 214px;
  --gap-y: 30px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  min-height: 100vh;
  min-height: 100dvh; /* 手机地址栏收起/展开时按动态视口计算 */
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--bg1) 0%, var(--bg2) 100%);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overflow-x: hidden;
}

/* ── 顶栏 ─────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px 6px;
}

.icon-btn {
  width: 40px; height: 40px;
  border: 2px solid rgba(255,255,255,.55);
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 19px;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:active { transform: scale(.92); }

.level-badge {
  background: linear-gradient(180deg, #ffc45e 0%, var(--ws-primary) 100%);
  border: 3px solid rgba(255,255,255,.5);
  color: #713f00;
  font-weight: 800;
  font-size: 19px;
  padding: 7px 24px;
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(0,0,0,.25);
}

.level-info {
  margin-left: auto;
  color: rgba(255,255,255,.72);
  font-size: 13px;
  text-align: right;
  line-height: 1.5;
}

/* ── 瓶子区 ───────────────────────── */
main { flex: 1; display: flex; }

.grid {
  flex: 1;
  max-width: 780px;
  margin: 0 auto;
  padding: 18px 10px 150px;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: var(--gap-y) 10px;
}

.bottle {
  position: relative;
  width: var(--bottle-w);
  height: var(--bottle-h);
  cursor: pointer;
  transition: transform .18s ease;
}
.bottle.narrow { width: calc(var(--bottle-w) * 0.76); }
.bottle.narrow .neck { width: calc(var(--bottle-w) * 0.38); }
.bottle.selected {
  transform: translateY(-18px);
  filter: drop-shadow(0 12px 12px rgba(0, 0, 0, .35));
}

.bottle .neck {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: calc(var(--bottle-w) * 0.52);
  height: 18px;
  border: 3px solid rgba(255,255,255,.85);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}

.bottle .glass {
  position: absolute;
  top: 12px; left: 0; right: 0; bottom: 0;
  border: 3px solid rgba(255,255,255,.85);
  border-radius: 8px 8px 26px 26px;
  background: rgba(255,255,255,.07);
  overflow: hidden;
}

.layer {
  position: absolute;
  left: 0; right: 0;
  height: calc(25% + 1px);
}
.layer.mystery {
  background: repeating-linear-gradient(45deg, #6b7099 0 7px, #565b85 7px 14px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.92);
  font-weight: 800;
  font-size: max(11px, calc(var(--bottle-w) * 0.26));
}
.layer.reveal-anim { animation: revealPop .3s ease; }
@keyframes revealPop {
  0% { filter: brightness(1.9); }
  100% { filter: brightness(1); }
}
.layer.fill-anim { animation: fillIn .24s ease-out; transform-origin: bottom; }
@keyframes fillIn { from { transform: scaleY(0); } }

.bottle.tilt-left  { animation: tiltL .28s ease; }
.bottle.tilt-right { animation: tiltR .28s ease; }
@keyframes tiltR { 45% { transform: translate(16px, -14px) rotate(30deg); } }
@keyframes tiltL { 45% { transform: translate(-16px, -14px) rotate(-30deg); } }

/* ── 封存的瓶子：盖子封口 + 锁定交互 ────────── */
.bottle.sealed { cursor: default; }
.bottle.sealed .glass { border-color: rgba(255,255,255,.55); }
.bottle.sealed .neck { opacity: .55; }

.bottle .cap {
  display: none;
  position: absolute;
  top: 3px; left: 50%;
  transform: translateX(-50%);
  width: calc(var(--bottle-w) * 0.66); height: max(11px, calc(var(--bottle-w) * 0.26));
  background: linear-gradient(180deg, #f3f5ff 0%, #a8b2d6 100%);
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 7px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .25);
  z-index: 3;
}
.bottle.narrow .cap { width: calc(var(--bottle-w) * 0.45); }
.bottle.sealed .cap { display: block; }

/* 封瓶动画：瓶子弹跳 + 盖子落下 + 礼花飞散 */
.bottle.seal-anim { animation: sealPop .55s cubic-bezier(.34,1.56,.64,1); }
@keyframes sealPop {
  0% { transform: scale(1); }
  35% { transform: scale(1.09, .9); }
  65% { transform: scale(.95, 1.05); }
  100% { transform: scale(1); }
}
.bottle.seal-anim .cap { animation: capDrop .5s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes capDrop {
  0% { transform: translateX(-50%) translateY(-30px) scale(.55); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
}
.bottle .spark {
  position: absolute;
  top: 8px; left: 50%;
  width: 6px; height: 6px;
  margin-left: -3px;
  border-radius: 50%;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
}
.bottle.seal-anim .spark { animation: sparkFly .65s ease-out both; }
@keyframes sparkFly {
  0% { transform: translate(0, 0) scale(.4); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 0; }
}

/* 点已封存的瓶子：摇晃反馈 */
.bottle.shake { animation: shakeX .32s ease; }
@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-3px); }
}

/* ── 底部道具栏 ────────────────────── */
.toolbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(20,22,44,0) 0%, rgba(20,22,44,.92) 45%);
  z-index: 10;
}

.tool-btn {
  background: #565b85;
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 13px 22px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .3);
}
.tool-btn:active { transform: translateY(2px); }
.tool-btn:disabled { opacity: .45; cursor: default; transform: none; }

.count-badge {
  display: inline-block;
  min-width: 20px;
  background: rgba(0,0,0,.3);
  border-radius: 999px;
  font-size: 12px;
  padding: 1px 6px;
  margin-left: 2px;
}

/* ── Toast ────────────────────────── */
.toast {
  position: fixed;
  bottom: 104px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(0, 0, 0, .78);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  transition: .25s;
  pointer-events: none;
  z-index: 50;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── 过关弹框（antdv-modal-template 规范的 vanilla 适配：
      主题色变量驱动 + 渐变 header + 14px 圆角 + 中性黑阴影，禁彩色发光） ── */
.ws-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 38, .55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.ws-mask.hidden { display: none; }

.ws-modal {
  width: min(86vw, 360px);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--ws-primary) 25%, #fff);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .18), 0 8px 20px rgba(0, 0, 0, .08);
  background: linear-gradient(180deg, #fff 0%, color-mix(in srgb, var(--ws-primary) 4%, #fff) 100%);
  animation: popIn .22s ease-out;
}
@keyframes popIn { from { transform: scale(.9); opacity: 0; } }

.ws-modal-header {
  padding: 16px 24px;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--ws-primary) 22%, #fff) 0%,
    color-mix(in srgb, var(--ws-primary) 10%, #fff) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, .5);
}
.ws-modal-title {
  color: color-mix(in srgb, var(--ws-primary) 80%, black);
  font-weight: 700;
  font-size: 17px;
}

.ws-modal-body { padding: 20px 24px; text-align: center; }
.win-emoji { font-size: 46px; }

.win-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}
.win-stat { display: flex; flex-direction: column; gap: 3px; }
.win-label { color: #94a3b8; font-size: 12px; }
.win-value { color: #1e293b; font-size: 17px; font-weight: 600; }

.ws-modal-footer {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 4px 24px 20px;
}
.ws-btn {
  border: none;
  border-radius: 10px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.ws-btn:active { transform: translateY(1px); }
.ws-btn-primary {
  background: var(--ws-primary);
  color: #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .18);
}
.ws-btn-primary:hover { filter: brightness(1.06); }
.ws-btn-secondary {
  background: color-mix(in srgb, var(--ws-primary) 8%, #fff);
  color: color-mix(in srgb, var(--ws-primary) 80%, black);
  border: 1px solid color-mix(in srgb, var(--ws-primary) 22%, #fff);
}

/* ── 移动端竖屏适配 ────────────────── */
@media (max-width: 560px) {
  .topbar { padding: 10px 12px 4px; gap: 10px; }
  .level-badge { font-size: 16px; padding: 6px 18px; border-width: 2px; }
  .level-info { font-size: 11px; max-width: 42vw; }
  .icon-btn { width: 36px; height: 36px; font-size: 17px; }
  .grid { padding: 12px 8px 132px; }
  .toolbar { gap: 10px; padding: 12px 10px calc(12px + env(safe-area-inset-bottom)); }
  .tool-btn { padding: 13px 16px; font-size: 14px; border-radius: 12px; }
  .toast { bottom: 92px; font-size: 13px; max-width: 88vw; white-space: normal; text-align: center; }
  .ws-modal { width: min(90vw, 340px); }
  .win-stats { gap: 4px; }
}
