/* =====================================================================
   1. 设计变量（主题）
   界面只用下面这些变量取色；加主题 = 在 [data-theme] 里覆盖一组变量。
   html[data-theme] 由 index.html 头部脚本按系统设置 / 用户选择写入。
   ===================================================================== */
:root {
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  --font-mono: ui-monospace, Menlo, monospace;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --space: 12px;
  --horizon: 34vh;
  --logo-top: 4vh;
  --card-gap: 24px;
  --card-scale: 1;

  --surface: #fff5d9;
  --surface-2: #f9e7bc;
  --border: #eed49e;
  --text: #5a3a1a;
  --text-muted: #a88a62;
  --heading: #a35a00;
  --success: #3c9a1e;
  --danger: #d4462a;

  --accent: #f6b51e;
  --accent-top: #ffe066;
  --accent-edge: #c98a0a;
  --accent-text: #5a2e00;

  --btn-bg: #fffbec;
  --btn-text: #6b4320;
  --btn-edge: #dfc086;
  --input-bg: #fffdf5;
  --input-border: #e8cf9a;
  --focus: #f0a500;

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --shadow: 0 14px 40px rgba(70, 35, 5, .28);
  --backdrop: rgba(40, 20, 5, .38);
  --stage-bg: #120a04;

  --sky: linear-gradient(#7cc8f2, #bfe6fa 70%, #e8f6fc);
  --sun-core: #fff7c2;
  --sun-glow: #ffe27a;
  --cloud: #fff;
  --cloud-opacity: .9;
  --stars-opacity: 0;
  --dirt-filter: none;
}

[data-theme="dark"] {
  --surface: #2b2219;
  --surface-2: #372b20;
  --border: #4d3c2a;
  --text: #f1e4cc;
  --text-muted: #b09a7a;
  --heading: #ffcf5a;
  --success: #8fe36b;
  --danger: #ff8a6b;

  --accent-text: #3d1f00;

  --btn-bg: #3a2e22;
  --btn-text: #f1e4cc;
  --btn-edge: #5c4732;
  --input-bg: #1f1812;
  --input-border: #4d3c2a;

  --shadow: 0 14px 40px rgba(0, 0, 0, .55);
  --backdrop: rgba(0, 0, 0, .5);
  --stage-bg: #0b0603;

  --sky: linear-gradient(#0d1b3a, #233a6a 70%, #3d4f7a);
  --sun-core: #fdf6dc;
  --sun-glow: #c9d6ff;
  --cloud: #8fa0c8;
  --cloud-opacity: .25;
  --stars-opacity: 1;
  --dirt-filter: brightness(.55) saturate(.85);
}

/* =====================================================================
   2. 基础
   ===================================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--stage-bg); color: var(--text); font-family: var(--font); }
button { font: inherit; }
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }

/* =====================================================================
   3. 通用组件
   ===================================================================== */
.card { position: relative; display: flex; flex-direction: column; gap: var(--space); text-align: center;
  padding: 22px 24px 16px; border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text); border: 2px solid var(--border); box-shadow: var(--shadow); }
.card h2 { margin: 0; color: var(--heading); }
.card-menu { width: min(420px, 92vw); }
.card-dialog { min-width: 320px; padding: 26px 40px; gap: 10px; animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }

.btn { cursor: pointer; padding: 10px 16px; border-radius: var(--radius); font-weight: 700;
  color: var(--btn-text); background: var(--btn-bg); border: 2px solid var(--btn-edge); box-shadow: 0 2px 0 var(--btn-edge);
  transition: transform .06s, filter .1s; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.btn-primary { color: var(--accent-text); background: linear-gradient(var(--accent-top), var(--accent)); border-color: var(--accent-edge); box-shadow: 0 3px 0 var(--accent-edge); }
.btn-lg { font-size: 20px; padding: 13px; }
.btn-sm { padding: 6px 14px; }
.btn.selected { outline: 3px solid var(--accent); outline-offset: 1px; }
.btn-row { display: flex; gap: 10px; justify-content: center; }
.btn-row > .btn { flex: 1; white-space: nowrap; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon svg { width: 20px; height: 20px; fill: currentColor; }

.field { display: flex; flex-direction: column; gap: 4px; text-align: left; font-size: 13px; color: var(--text-muted); }
.field-label { line-height: 18px; min-height: 18px; white-space: nowrap; }
.input { font: inherit; padding: 10px 12px; border-radius: 10px; min-width: 0; outline: none;
  border: 2px solid var(--input-border); background: var(--input-bg); color: var(--text); }
.input:focus { border-color: var(--focus); }
.input::placeholder { color: var(--text-muted); opacity: .8; }

.text-muted { margin: 0; font-size: 12px; color: var(--text-muted); }
/* 只在主菜单、且开了黑夜模式时出现。房间里的比赛画面另有白天/黑夜开关 */
.night-hint { display: none; margin: 0; font-size: 13px; font-weight: 700; line-height: 1.5; color: var(--heading); }
[data-theme="dark"] .night-hint { display: block; }
.text-error { margin: 0; min-height: 1.2em; font-size: 14px; color: var(--danger); }
.text-success { color: var(--success); font-weight: 700; }
.list .text-muted, .list .text-success { font-size: 12px; line-height: 16px; font-weight: 700; }
.chip { font-family: var(--font-mono); letter-spacing: 4px; padding: 2px 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.room-note { margin: 0; font-size: 13px; font-weight: 700; line-height: 1.45; color: var(--heading); }
.room-note:empty { display: none; }
.list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 8px; vertical-align: 1px; background: transparent; }
.dot.host { background: var(--accent); }

/* 弹窗里的文字层级：小标题 / 大标题 / 大数字 / 说明 */
.dialog-kicker { font-size: 22px; font-weight: 700; }
.dialog-label { font-size: 16px; color: var(--text-muted); }
.dialog-title, .dialog-display { font-weight: 900; color: #ffd23a; -webkit-text-stroke: 2px #8a4b00; paint-order: stroke fill; text-shadow: 0 4px 0 #a35a00; }
.dialog-title { font-size: 42px; }
.dialog-display { font-size: 54px; }
.dialog-title.bad { color: #ff8a5c; -webkit-text-stroke-color: #7a2a10; text-shadow: 0 4px 0 #8a3418; }
.dialog-text { font-size: 16px; line-height: 1.6; white-space: pre-line; }
.dialog-text.small { font-size: 13px; color: var(--text-muted); min-height: 1.2em; }

/* =====================================================================
   4. 菜单 / 房间：天空 + 地面 + 地下的金子
   ===================================================================== */
#scene { position: fixed; inset: 0; overflow: hidden; }
#scene .sky { position: absolute; left: 0; right: 0; top: 0; height: var(--horizon); background: var(--sky); }
#scene .sky::before { content: ""; position: absolute; inset: 0; opacity: var(--stars-opacity); transition: opacity .4s;
  background:
    radial-gradient(1.5px 1.5px at 12% 22%, #fff, transparent), radial-gradient(1px 1px at 26% 60%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 38% 14%, #fff, transparent), radial-gradient(1px 1px at 55% 40%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 66% 70%, #fff, transparent), radial-gradient(1px 1px at 74% 30%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 92% 58%, #fff, transparent), radial-gradient(1px 1px at 6% 75%, #fff, transparent); }
#scene .sun { position: absolute; right: 12%; top: 16%; width: 96px; height: 96px; border-radius: 50%;
  background: radial-gradient(circle, var(--sun-core) 0 45%, var(--sun-glow) 60%, transparent 72%); }
#scene .cloud { position: absolute; height: 26px; border-radius: 26px; background: var(--cloud); opacity: var(--cloud-opacity); animation: drift linear infinite; }
#scene .cloud::before, #scene .cloud::after { content: ""; position: absolute; background: var(--cloud); border-radius: 50%; }
#scene .cloud::before { width: 44px; height: 44px; left: 18%; top: -22px; }
#scene .cloud::after { width: 30px; height: 30px; left: 52%; top: -14px; }
#scene .c1 { width: 120px; top: 30%; animation-duration: 80s; animation-delay: -20s; }
#scene .c2 { width: 90px; top: 55%; animation-duration: 110s; animation-delay: -70s; transform: scale(.8); }
#scene .c3 { width: 150px; top: 18%; animation-duration: 140s; animation-delay: -10s; }
@keyframes drift { from { left: -200px; } to { left: 110vw; } }
#scene .dirt { position: absolute; left: 0; right: 0; top: var(--horizon); bottom: 0; filter: var(--dirt-filter);
  background: #d9c27a url(art/bg_182.svg) center top / cover; border-top: 10px solid #ca8e64; box-shadow: inset 0 3px 0 #a8673e; }
#scene .deco { position: absolute; transform: translate(-50%, -50%); cursor: pointer; pointer-events: auto;
  filter: drop-shadow(0 2px 0 rgba(80, 40, 10, .25)); transition: opacity .2s; }
#scene .deco:hover { filter: drop-shadow(0 3px 0 rgba(80, 40, 10, .35)) brightness(1.08); }
#scene .deco.popped { opacity: 0; pointer-events: none; }
#scene .deco.back { animation: deco-pop .3s; }
@keyframes deco-pop { from { transform: translate(-50%, -50%) scale(.4); } }
#scene .deco.kicked { animation: kick .35s; }
@keyframes kick { 40% { transform: translate(calc(-50% + var(--kx)), calc(-50% + var(--ky))) rotate(8deg); } }
#scene.boom { animation: lobby-shake .4s; }
@keyframes lobby-shake {
  20% { transform: translate(5px, -3px); } 45% { transform: translate(-4px, 3px); }
  70% { transform: translate(3px, 1px); }
}
.lobby-fx { position: fixed; z-index: 6; pointer-events: none; }
.lobby-bit { position: fixed; z-index: 6; width: 26px; margin: -13px 0 0 -13px; pointer-events: none; animation: bit .7s ease-out forwards; }
@keyframes bit { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(.3); opacity: 0; } }
.lobby-pay { position: fixed; z-index: 6; pointer-events: none; font-weight: 900; font-size: 26px; color: #009900;
  text-shadow: 0 2px 0 #043; animation: pay 1s ease-out forwards; }
@keyframes pay { to { transform: translate(-50%, -52px); opacity: 0; } }

/* 菜单不滚动：--horizon 和 --card-scale 由 main.js 的 fitMenu 按屏幕算，保证一屏放下 */
.menu-head { position: absolute; left: 0; right: 0; top: 0; height: var(--horizon); display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; pointer-events: none; }
.screen-menu { align-items: flex-start; overflow: hidden; overflow: clip; pointer-events: none;
  padding-top: calc(var(--horizon) + var(--card-gap));
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
/* 卡片按 --card-scale 从顶部缩小。负的 margin-bottom 把布局高度收成缩小后的高度，
   否则原高度会伸出屏幕，overflow 把底部的准备/离开裁掉。 */
.screen-menu .card-menu { flex-shrink: 0; pointer-events: auto;
  transform: scale(var(--card-scale)); transform-origin: top center;
  margin-bottom: calc((var(--card-scale) - 1) * var(--card-h, 0px)); }
.logo { margin: 0 0 auto; padding-top: var(--logo-top); line-height: 0; }
.logo img { width: min(380px, 78vw); filter: drop-shadow(0 3px 0 rgba(90, 40, 0, .35)); }
/* 电脑屏幕：标题放大，按宽高取小的，矮屏也放得下卡片 */
@media (min-width: 900px) and (min-height: 600px) {
  .logo img { width: min(600px, 46vw, 72vh); filter: drop-shadow(0 4px 0 rgba(90, 40, 0, .35)); }
}
/* 横屏矮屏：标题和矿工在左边，卡片在右边 */
.menu-side .menu-head { right: 60%; left: 72px; }
html.menu-side:not(.in-game) .corner-tools { left: calc(var(--sal) + 12px); right: auto; top: calc(var(--sat) + 12px); flex-direction: column; }
.menu-side .logo img { width: min(210px, 26vw); }
.menu-side .menu-miner { transform: scale(.8); transform-origin: 50% 100%; margin-top: -25px; }
/* 卡片贴在右边、从右上角缩小，上边距由 fitMenu 垂直居中。底部留出系统横条。 */
.menu-side .screen-menu { align-items: flex-start; justify-content: flex-end;
  padding: var(--card-gap) max(12px, var(--sar)) var(--sab) max(40%, calc(var(--sal) + 12px)); }
.menu-side .screen-menu .card-menu { transform-origin: top right; }
/* 矿工站在地平线上，钩子从绞盘处摆动（绞盘位置来自原版矿工精灵） */
.menu-miner { position: relative; width: 150px; height: 123px; margin-bottom: -4px; }
.menu-miner > img { width: 100%; display: block; }
.swing { position: absolute; left: 49px; top: 95px; width: 0; height: 0; transform-origin: 0 0; animation: swing 1.7s ease-in-out infinite alternate; }
.swing .rope { position: absolute; left: -1px; top: 0; width: 2px; height: 30px; background: #333; }
.swing .claw { position: absolute; left: -32px; top: 26px; width: 64px; }
@keyframes swing { from { transform: rotate(52deg); } to { transform: rotate(-52deg); } }
.corner-tools { position: fixed; top: calc(env(safe-area-inset-top) + 16px); right: calc(env(safe-area-inset-right) + 16px); z-index: 5;
  display: flex; gap: 10px; }
.icon-muted, html.muted .icon-sound { display: none; }
html.muted .icon-muted { display: block; }
#btn-pause svg { width: 15px; height: 15px; }
#btn-forfeit .icon-leave { fill: none; stroke: currentColor; }
/* 电脑局内：暂停 / 离开 / 静音排在矿场上方，不压画面。 */
html:not(.touch).in-game #stage { --pad-top: 52px; }
html:not(.touch).in-game #stage .corner-tools {
  position: absolute; z-index: 5; inset: auto;
  top: calc(env(safe-area-inset-top) + 6px); right: calc(env(safe-area-inset-right) + 12px);
  display: flex; gap: 8px; }
html:not(.touch).in-game #stage .corner-tools .btn-icon { width: 40px; height: 40px; opacity: 1; }
html:not(.touch).in-game #stage .corner-tools .btn-icon svg { width: 20px; height: 20px; }
/* 手机局内：矿场嵌在掌机壳上。暂停和静音在顶部，放钩和炸药在拇指区。 */
html.touch.in-game #stage { background: #ffc34a; }
html.touch.in-game #canvas-wrap {
  border-radius: 2px; background: #111; outline: none;
  box-shadow: 0 0 0 8px #111; }
html.touch.in-game #game { border-radius: 2px; }
html.touch.in-game #stage .corner-tools { position: absolute; inset: 0; z-index: 4; display: block; pointer-events: none; }
html.touch.in-game #stage .corner-tools .btn-icon,
html.touch.in-game #stage .corner-tools .btn-forfeit { position: absolute; pointer-events: auto; opacity: 1;
  width: 54px; height: 54px; padding: 0; border-radius: 50%; }
html.touch.in-game #stage .corner-tools .btn-icon svg,
html.touch.in-game #stage .corner-tools #btn-forfeit svg { width: 22px; height: 22px; }
html.touch.in-game #stage .btn-forfeit { display: flex; align-items: center; justify-content: center; font-size: 13px; line-height: 1.05; }
html.touch.in-game #stage.pad-side #btn-pause,
html.touch.in-game #stage.pad-side #btn-forfeit { left: calc(env(safe-area-inset-left) + (var(--pad-w) - 54px) / 2); top: calc(env(safe-area-inset-top) + 22px); }
html.touch.in-game #stage.pad-side #btn-pause:not(.hidden) ~ #btn-forfeit { top: calc(env(safe-area-inset-top) + 88px); }
html.touch.in-game #stage.pad-side #mute-toggle { right: calc(env(safe-area-inset-right) + (var(--pad-w) - 54px) / 2); top: calc(env(safe-area-inset-top) + 22px); margin: 0; }
html.touch.in-game #stage.pad-bottom #btn-pause,
html.touch.in-game #stage.pad-bottom #btn-forfeit { left: calc(env(safe-area-inset-left) + 16px); top: calc((env(safe-area-inset-top) + var(--pad-top) - 54px) / 2); }
html.touch.in-game #stage.pad-bottom #btn-pause:not(.hidden) ~ #btn-forfeit { left: calc(env(safe-area-inset-left) + 80px); }
html.touch.in-game #stage.pad-bottom #mute-toggle { right: calc(env(safe-area-inset-right) + 16px); left: auto; margin: 0; top: calc((env(safe-area-inset-top) + var(--pad-top) - 54px) / 2); }
#stage[data-phase="shopout"] .btn-next { visibility: hidden; }
/* 矮屏：卡片排紧一点，少缩放 */
@media (max-height: 720px) {
  .card-menu { gap: 8px; padding: 14px 18px 12px; }
  .btn-lg { font-size: 17px; padding: 9px; }
}

#code-input { flex: 1; text-transform: uppercase; letter-spacing: 3px; text-align: center; }
.mode-switch { display: flex; gap: 8px; justify-content: center; }
.mode-desc { margin: 0; font-size: 13px; line-height: 1.6; min-height: 2.4em; }
.match-look { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.match-look .look-label { font-size: 13px; color: var(--text-muted); text-align: center; }
.match-look .mode-switch { justify-content: center; }
.room-code-row { display: flex; align-items: center; justify-content: center; gap: 8px; }
.room-code-row h2 { margin: 0; }

/* =====================================================================
   5. 游戏
   ===================================================================== */
#stage { background: var(--stage-bg); }
#canvas-wrap { position: relative; overflow: hidden; border-radius: 6px; box-shadow: 0 10px 40px rgba(0, 0, 0, .6); }
#game { display: block; width: 100%; height: 100%; }
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
/* 弹窗盖住整个屏幕，手机上画面很小时也有地方放 */
.overlay-dim { position: fixed; z-index: 3; padding: 12px; background: var(--backdrop); }
#ov-pause.from-shop .pause-mine-hint { display: none; }
/* =====================================================================
   5b. 手机
   html.touch 由页面头部按 (pointer: coarse) 加上，碰到触摸事件时 main.js 也会补上。
   #stage 的 pad-bottom / pad-side 由 main.js 按哪种摆法画面更大来选。
   ===================================================================== */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
html.touch { -webkit-tap-highlight-color: transparent; }
html:not(.touch) .only-touch, html.touch .only-keys { display: none; }
#stage { --pad-h: 0px; --pad-w: 0px; --pad-top: 0px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  padding: calc(env(safe-area-inset-top) + var(--pad-top)) calc(env(safe-area-inset-right) + var(--pad-w)) calc(env(safe-area-inset-bottom) + var(--pad-h)) calc(env(safe-area-inset-left) + var(--pad-w)); }
#stage.pad-bottom { --pad-h: 120px; --pad-top: 80px; }
#stage.pad-side { --pad-w: 152px; }
#stage.pad-bottom.compact { --pad-h: 96px; --pad-top: 64px; }
#stage.pad-side.compact { --pad-w: 104px; }
#game { touch-action: none; }
.touch-pad { display: none; position: absolute; inset: 0; z-index: 1; pointer-events: none; }
html.touch .touch-pad { display: block; }
.touch-btn { --size: 72px; position: absolute; width: var(--size); height: var(--size); padding: 0; border-radius: 50%; pointer-events: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; touch-action: none;
  font-size: 12px; font-weight: 700; color: var(--btn-text); background: var(--btn-bg); border: 2px solid var(--btn-edge);
  box-shadow: 0 3px 0 var(--btn-edge), 0 6px 16px rgba(0, 0, 0, .35); transition: transform .05s, box-shadow .05s; }
.touch-btn:active, .touch-btn.down { transform: translateY(4px); box-shadow: 0 0 0 var(--btn-edge), inset 0 3px 5px rgba(60, 30, 0, .35); }
.touch-btn svg { width: 26px; height: 26px; fill: currentColor; }
.touch-btn img { height: 28px; }
.touch-btn b { color: var(--heading); }
.touch-btn .touch-count { color: #6b4320; }
.touch-drop { --size: 88px; color: var(--accent-text); background: linear-gradient(var(--accent-top), var(--accent)); border-color: var(--accent-edge);
  box-shadow: 0 3px 0 var(--accent-edge), 0 6px 16px rgba(0, 0, 0, .35); font-size: 14px; }
.touch-drop img { height: 38px; }
.touch-dyn { --size: 76px; }
.touch-dyn img { height: 30px; }
/* 炸药数量：圆角小牌子压在按钮顶上 */
.touch-count { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); min-width: 26px; padding: 1px 7px; border-radius: 999px;
  font-size: 13px; line-height: 18px; font-weight: 800; color: #6b4320; background: #fff; border: 2px solid #a67c3a;
  box-shadow: 0 2px 4px rgba(80, 40, 0, .28); text-shadow: none; }
.touch-dyn.empty .touch-count { color: #8a7a66; background: #f4ead8; border-color: #cbb892; }
.touch-dyn.empty { opacity: .6; }
#stage:not(.playing) .touch-btn { opacity: .3; pointer-events: none; }
#stage:not([data-phase="play"]):not([data-phase="intro"]) .touch-pad { visibility: hidden; }
html.touch .btn-next { min-height: 32px; }
.offer.picked { transform: translateY(-4%); }
.offer.picked img { filter: drop-shadow(0 0 6px #fff) drop-shadow(0 3px 2px rgba(0, 0, 0, .5)); }

/* 竖屏底栏四键；横屏左右下颊，炸药/放钩在最下面给拇指。白底浅边。 */
html.touch.in-game .touch-btn,
html.touch.in-game #stage .corner-tools .btn-icon,
html.touch.in-game #stage .corner-tools .btn-forfeit {
  color: #6b4320;
  background: #fff;
  border-color: #f0d7a8;
  box-shadow: 0 0 0 3px #f6e4c4, 0 4px 0 #e8c98a;
}
html.touch.in-game .touch-btn:active, html.touch.in-game .touch-btn.down,
html.touch.in-game #stage .corner-tools .btn-icon:active, html.touch.in-game #stage .corner-tools .btn-icon.down,
html.touch.in-game #stage .corner-tools .btn-forfeit:active, html.touch.in-game #stage .corner-tools .btn-forfeit.down {
  transform: translateY(4px);
  box-shadow: 0 0 0 3px #f0dcc0, inset 0 3px 6px rgba(120, 70, 20, .16);
}
html.touch.in-game .touch-drop { color: #6a4318; background: #fff; border-color: #f0d7a8; }
html.touch.in-game .touch-dyn { color: #8a3030; background: #fff; border-color: #f0d7a8; }
html.touch.in-game .touch-drop img { height: 24px; }
html.touch.in-game .touch-count { color: #6b4320; background: #fff; border-color: #a67c3a; }
html.touch.in-game[data-theme="dark"] #stage { background: #d45a12; }
html.touch.in-game[data-theme="dark"] .touch-btn,
html.touch.in-game[data-theme="dark"] #stage .corner-tools .btn-icon,
html.touch.in-game[data-theme="dark"] #stage .corner-tools .btn-forfeit {
  color: #f2f2f2;
  background: #1a1a1a;
  border-color: #111;
  box-shadow: 0 4px 0 #0a0a0a, inset 0 1px 0 rgba(255, 255, 255, .12);
}
html.touch.in-game[data-theme="dark"] .touch-btn:active,
html.touch.in-game[data-theme="dark"] .touch-btn.down,
html.touch.in-game[data-theme="dark"] #stage .corner-tools .btn-icon:active,
html.touch.in-game[data-theme="dark"] #stage .corner-tools .btn-icon.down,
html.touch.in-game[data-theme="dark"] #stage .corner-tools .btn-forfeit:active,
html.touch.in-game[data-theme="dark"] #stage .corner-tools .btn-forfeit.down {
  box-shadow: 0 0 0 #0a0a0a, inset 0 3px 6px rgba(0, 0, 0, .55);
}
html.touch.in-game[data-theme="dark"] .touch-drop,
html.touch.in-game[data-theme="dark"] .touch-dyn {
  color: #f2f2f2;
  background: #1a1a1a;
  border-color: #111;
}
html.touch.in-game[data-theme="dark"] .touch-btn img { filter: brightness(1.35); }
html.touch.in-game[data-theme="dark"] .touch-count { color: #f2e4cc; background: #1a1a1a; border-color: #4a4036; }
html.touch.in-game[data-theme="dark"] .touch-dyn.empty .touch-count { color: #9a8c7c; background: #141414; border-color: #333; }
#stage.pad-bottom .touch-btn { bottom: calc(env(safe-area-inset-bottom) + (var(--pad-h) - var(--size)) / 2); }
html.touch.in-game #stage.pad-bottom .touch-drop,
html.touch.in-game #stage.pad-bottom .touch-dyn { --size: 78px; }
html.touch.in-game #stage.pad-bottom .touch-dyn { left: calc(50% - var(--size) - 14px); }
html.touch.in-game #stage.pad-bottom .touch-drop { left: calc(50% + 14px); }
html.touch.in-game #stage.pad-side .touch-drop,
html.touch.in-game #stage.pad-side .touch-dyn { --size: 78px; bottom: calc(env(safe-area-inset-bottom) + 22px); }
html.touch.in-game #stage.pad-side .touch-drop { right: calc(env(safe-area-inset-right) + 56px); left: auto; }
html.touch.in-game #stage.pad-side .touch-dyn { left: calc(env(safe-area-inset-left) + 56px); right: auto; }
html.touch.in-game #stage.pad-side.compact .touch-drop,
html.touch.in-game #stage.pad-side.compact .touch-dyn { --size: 72px; }
html.touch.in-game #stage.pad-side.compact .touch-drop { right: calc(env(safe-area-inset-right) + 14px); }
html.touch.in-game #stage.pad-side.compact .touch-dyn { left: calc(env(safe-area-inset-left) + 14px); }
#stage.pad-bottom .touch-dyn { left: calc(50% - 20px - 88px); }
#stage.pad-bottom .touch-drop { left: calc(50% + 20px); }
#stage.pad-side .touch-drop { right: calc(env(safe-area-inset-right) + (var(--pad-w) - 88px) / 2); bottom: calc(env(safe-area-inset-bottom) + 24px); }
#stage.pad-side .touch-dyn { left: calc(env(safe-area-inset-left) + (var(--pad-w) - 76px) / 2); bottom: calc(env(safe-area-inset-bottom) + 24px); }

.toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 14px); z-index: 6; transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 700; white-space: nowrap;
  color: var(--text); background: var(--surface); border: 2px solid var(--border); box-shadow: var(--shadow); transition: opacity .3s, transform .3s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 过关 / 获胜：金块、钻石和星星从上面撒下来 */
.celebrate { position: fixed; inset: 0; z-index: 4; overflow: hidden; pointer-events: none; }
.celebrate img { position: absolute; top: -60px; animation: fall linear forwards; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35)); }
@keyframes fall {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translate(var(--dx), 110vh) rotate(var(--rot)); opacity: 0; }
}
.card-dialog.win { animation: pop .35s cubic-bezier(.2, 1.6, .4, 1), glow 1.2s ease-in-out .35s 3 alternate; }
@keyframes glow { to { box-shadow: var(--shadow), 0 0 0 4px #ffd23a, 0 0 40px 8px rgba(255, 210, 58, .7); } }

.card-dialog { min-width: min(320px, 100%); max-width: 100%; max-height: 100%; overflow-y: auto;
  padding: clamp(16px, 4vmin, 26px) clamp(20px, 6vmin, 40px); }
.dialog-title { font-size: clamp(28px, 8vmin, 42px); }
.dialog-display { font-size: clamp(36px, 11vmin, 54px); }
.dialog-kicker { font-size: clamp(18px, 5vmin, 22px); }

/* =====================================================================
   5c. 每关目标 / 过关画面：照原版主时间轴 next（52–60 帧）和 yes（94–108 帧），不跟主题变。
   位置按原版舞台坐标换算，字号 em 以矿场 800 宽 = 50em 计
   ===================================================================== */
.card-screen { inset: auto; overflow: visible; background: #e8c040;
  -webkit-text-size-adjust: none; text-size-adjust: none; }
/* 手机会把比屏幕更宽的文字块自动放大。卡片按 800 宽排，窄屏就会把字撑大，牌子却照常缩小 */
.card-screen *, .shop * { max-height: 1000000px; }
.card-group, .card-echo, .card-info, .card-btns, .card-status { position: absolute; z-index: 2; }
.card-panel { position: absolute; inset: 0; width: 100%; height: 100%; }
/* 目标、过关、失败、结束同一套。单人和合作是 4:3，四周多铺一点，细边留在矿场外。
   对抗横屏 8:3、竖屏 2:3 由 .wide-bg 把这张图等比放大盖住整条矿场，见 main.js。 */
.card-screen > .stage-art { left: -2% !important; top: -2% !important; width: 104% !important; height: 104% !important;
  object-fit: cover; object-position: center; z-index: 1; }
.card-screen.wide-bg > .stage-art { left: var(--bleed-x) !important; top: var(--bleed-y) !important;
  width: var(--bleed-w) !important; height: var(--bleed-h) !important; }
.drop-screen { overflow: visible; }
.drop-screen.win > .over-lose { display: none !important; }
.drop-screen:not(.win) > .over-win { display: none !important; }
.card-result small { display: block; margin-top: .25em; font-size: .5em; line-height: 1.3; color: #ffe9a8; }
.card-line { position: absolute; left: -20%; right: -20%; transform: translateY(-50%); text-align: center; white-space: nowrap;
  font-family: var(--font); font-weight: 700; color: #ffff00; }
.card-goal-label { top: 29%; font-size: 2.3em; }
.card-goal { top: 64%; font-size: 3.6em; font-family: Arial, var(--font); color: #00cc00; }
.card-result { top: 49%; font-size: 2.3em; line-height: 1.35; }
.card-screen.bad .card-result { color: #ffcc66; }
/* 目标：两行字从牌子的棕色渐显（原版颜色变换 add 158,80,0 → 0，8 帧） */
.card-screen.play .card-goal-label, .card-screen.play .card-goal { animation: card-text-in .44s linear .06s both; }
@keyframes card-text-in { from { color: #9e5000; } }
/* 过关：牌子从 0.18 倍放大（以牌子上部 1/4 处为定点），再压扁弹两下；
   放到原大那一帧后面冒出一个黄色的牌子影子，放大到 1.6 倍淡掉 */
.card-group { transform-origin: 50% 25%; }
.card-screen.play:not(.bad) .card-group { animation: card-zoom .83s linear both; }
@keyframes card-zoom {
  0% { transform: scale(.178); } 7.14% { transform: scale(.281); } 14.29% { transform: scale(.383); }
  21.43% { transform: scale(.486); } 28.57% { transform: scale(.589); } 35.71% { transform: scale(.692); }
  42.86% { transform: scale(.794); } 50% { transform: scale(.897); } 57.14% { transform: scale(1); }
  64.29% { transform: scale(1.03, .972); } 71.43% { transform: scale(1.059, .944); } 78.57% { transform: scale(1.0125, 1); }
  85.71% { transform: scale(.966, 1.056); } 92.86% { transform: scale(.983, 1.028); } 100% { transform: none; }
}
.card-echo { opacity: 0; background: #fef600;
  -webkit-mask: url(art/card_panel.svg) 0 0 / 100% 100% no-repeat; mask: url(art/card_panel.svg) 0 0 / 100% 100% no-repeat; }
.card-screen.play:not(.bad) .card-echo { animation: card-echo .33s linear .44s both; }
@keyframes card-echo {
  0% { opacity: 1; transform: scale(1); background: #9b4e00; }
  80% { opacity: .07; transform: scale(1.6); background: #fef600; }
  100% { opacity: 0; transform: scale(1.6); }
}
.card-screen.play.bad .card-group { animation: card-fade .3s ease-out both; }
@keyframes card-fade { from { opacity: 0; transform: translateY(-6%); } }

/* 没达标 / 游戏结束（原版 no）：牌子从舞台上方 −75 匀速滑到 149，20 帧；下面再出成绩和按钮。
   对抗赢家换成过关的墙纸和放大弹跳 */
.drop-screen .card-result { line-height: 1.35; }
.drop-screen:not(.win) .card-echo { display: none; }
.drop-screen.play:not(.win) .card-group { animation: card-drop 1.11s linear both; }
@keyframes card-drop { from { transform: translateY(-153.4%); } }
.drop-screen.play.win .card-group { animation: card-zoom .83s linear both; }
.drop-screen.play.win .card-echo { animation: card-echo .33s linear .44s both; }
.card-info, .card-btns, .card-status { left: 50%; transform: translateX(-50%); text-align: center; }
.card-info { top: 62%; min-width: 46%; max-width: 92%; padding: .45em 1.3em; border-radius: .5em; white-space: pre-line;
  font-size: 1.15em; font-weight: 800; line-height: 1.35; color: #ffe9a8; background: rgba(90, 45, 0, .82);
  box-shadow: 0 .15em 0 rgba(0, 0, 0, .25); }
.drop-screen .card-info { top: 57.5%; }
.card-info:empty { display: none; }
.card-info small { display: block; margin-top: .28em; font-size: .82em; font-weight: 700; line-height: 1.35; color: #f1cf8a; }
.card-screen.play:not(.drop-screen) .card-info { animation: card-rise .35s ease-out .55s both; }
.card-btns { top: 83%; display: flex; flex-wrap: wrap; justify-content: center; gap: .55em .7em; width: 94%; }
.drop-screen .card-btn { min-width: 6.6em; padding: .45em .7em; }
.card-btn { min-width: 8.5em; padding: .45em 1em; cursor: pointer; font: 800 1.15em var(--font); color: #fff;
  background: #339933; border: 2px solid #1d5f1d; border-radius: 3px; box-shadow: 0 .18em 0 #1d5f1d; }
.card-btn:hover { background: #3fb83f; }
.card-btn:active { transform: translateY(.12em); box-shadow: 0 .06em 0 #1d5f1d; }
.card-btn.alt { background: #996633; border-color: #5f3d1d; box-shadow: 0 .18em 0 #5f3d1d; }
.card-btn.alt:hover { background: #ad7743; }
.card-btn.on { background: #b38a2e; border-color: #6b5016; box-shadow: 0 .18em 0 #6b5016; }
.card-btn:disabled { opacity: .55; cursor: default; }
.card-status, .shop-wait { font-weight: 800; color: #5a2d00; text-shadow: 0 0 .25em #fff6b0, 0 0 .12em #fff6b0; }
.card-status { top: 9%; width: 90%; font-size: 1.05em; z-index: 3; }
/* 结果没出来前（result 阶段）不给按钮；牌子落定后成绩和按钮再依次浮上来。
   「还没决定」若一开始就摆在顶上，会和滑下来的牌子叠在一起，所以等牌子落定再淡入。 */
.drop-screen .card-status { opacity: 0; }
.drop-screen.waiting .card-btns, .drop-screen.waiting .card-status { visibility: hidden; }
.drop-screen.play .card-info { animation: card-rise .35s ease-out 1.05s both; }
.drop-screen.play .card-btns { animation: card-rise .35s ease-out 1.3s both; }
.drop-screen.play .card-status { animation: status-fade .4s ease-out 1.15s both; }
.drop-screen.play.win .card-info { animation-delay: .8s; }
.drop-screen.play.win .card-btns { animation-delay: 1.05s; }
.drop-screen.play.win .card-status { animation-delay: .9s; }
@keyframes status-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes card-rise { from { opacity: 0; transform: translate(-50%, 40%); } }

/* 对抗成绩：两人一栏，赢家盖金色「胜」章并发光，输家灰掉抖一下 */
.vs-board { display: flex; gap: 1em; justify-content: center; margin: .25em 0 .1em; }
.vs-col { position: relative; min-width: 7.5em; padding: .2em .8em; border-radius: .4em; background: rgba(0, 0, 0, .22); line-height: 1.25; }
.vs-col .vs-name { font-size: .85em; color: #f1cf8a; max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs-col .vs-money { font: 800 1.35em Arial, var(--font); color: #00dd00; }
.vs-col .vs-state { font-size: .75em; color: #f1cf8a; }
.vs-col .vs-stamp { position: absolute; right: -.6em; top: -.7em; width: 1.9em; height: 1.9em; border-radius: 50%; display: none;
  align-items: center; justify-content: center; font-size: 1em; color: #7a3d00; background: radial-gradient(#fff3a0, #ffc21a 70%);
  border: .12em solid #a35a00; transform: rotate(-12deg); }
.vs-col.champ .vs-stamp { display: flex; }
.vs-col.champ { box-shadow: 0 0 0 .14em #ffd23a; }
.drop-screen.play .vs-col.champ { animation: vs-glow .9s ease-in-out 1.6s 3 alternate; }
.drop-screen.play .vs-col.champ .vs-stamp { animation: vs-stamp .4s cubic-bezier(.2, 1.6, .4, 1) 1.5s both; }
.vs-col.loser { filter: grayscale(.85) brightness(.85); }
.drop-screen.play .vs-col.loser { animation: vs-shake .45s ease-in-out 1.5s both; }
@keyframes vs-glow { to { box-shadow: 0 0 0 .14em #ffd23a, 0 0 1.2em .3em rgba(255, 210, 58, .8); } }
@keyframes vs-stamp { from { opacity: 0; transform: rotate(-12deg) scale(2.6); } }
@keyframes vs-shake { 0% { filter: none; } 20% { transform: translateX(-.35em); } 40% { transform: translateX(.3em); }
  60% { transform: translateX(-.2em); } 80% { transform: translateX(.1em); } 100% { transform: none; } }

/* =====================================================================
   6. 商店：照原版画面，不跟主题变。原版舞台坐标（550×400）按 800/550 换算成百分比，由 main.js 定位
   ===================================================================== */
.shop { inset: auto; background: #3b2412; overflow: hidden; font-family: Tahoma, var(--font);
  box-shadow: 0 0 0 100vmax var(--stage-bg); -webkit-text-size-adjust: none; text-size-adjust: none; }
.stage-art { position: absolute; pointer-events: none; }
.shop-counter { position: absolute; inset: 0; }
.offer { position: absolute; cursor: pointer; transition: transform .12s; }
.offer:hover, .offer.pending { transform: translateY(-4%); }
.offer img { position: absolute; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .5)); }
.offer.pending img { filter: drop-shadow(0 0 8px #ffff00) drop-shadow(0 3px 2px rgba(0, 0, 0, .5)); }
.offer .price { position: absolute; left: -40px; right: -40px; text-align: center; color: #009900; font-weight: 700; font-size: 1.1em;
  text-shadow: 0 1px 0 #000; white-space: nowrap; }
.offer.poor .price { color: #cc3300; }
.offer.sold { display: none; }
.offer .vote { position: absolute; left: 50%; bottom: calc(100% + .15em); transform: translateX(-50%); width: max-content; z-index: 2; pointer-events: none; }
.shop-wait { font-size: 1.05em; white-space: nowrap; }
.shop-desc .shop-wait b { color: inherit; }
.shop-desc { position: absolute; left: 8.9%; top: 78.5%; width: 82.7%; height: 17.9%; color: #ffff00; font-size: 1.05em; line-height: 1.35;
  text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; text-shadow: 0 1px 0 #000; }
.shop-desc b { color: #fff; }
.shop-vote { display: flex; gap: .7em; justify-content: center; margin-top: .4em; }
.shop-vote .card-btn { min-width: 5.4em; padding: .28em .85em; font-size: .92em; }
.shop-money { position: absolute; left: 2.5%; top: 15%; font-size: 1.15em; font-weight: 800; color: #f1d7a8; text-shadow: 0 2px 0 #000; }
.shop-money b { color: #00cc00; }
.btn-next { position: absolute; left: 77.5%; top: 15%; width: 16.4%; height: 4.9%; padding: 0; cursor: pointer; font-weight: 800; font-size: 0.95em;
  color: #fff; background: #339933; border: 2px solid #1d5f1d; border-radius: 3px; box-shadow: 0 .18em 0 #1d5f1d; }
.btn-next:hover { background: #3fb83f; }
.btn-next:active { transform: translateY(.12em); box-shadow: 0 .06em 0 #1d5f1d; }
.btn-next.on { background: #996633; border-color: #5f3d1d; box-shadow: 0 .18em 0 #5f3d1d; }
.btn-next.on:active { box-shadow: 0 .06em 0 #5f3d1d; }
.shop-status { position: absolute; right: 6%; top: 21%; font-size: 0.85em; color: #f1d7a8; text-shadow: 0 1px 0 #000; text-align: right; }
[data-theme="dark"] #theme-toggle .icon-moon, :root:not([data-theme="dark"]) #theme-toggle .icon-sun { display: none; }
