/* 束水攻沙·两岸争功 —— theme tokens 与共享组件 */
:root {
  --c-sand: #D9A441; --c-river: #2F7F86; --c-cinnabar: #C7402D; --c-silk: #F3E6C8; --c-ink: #2B211A;
  --c-north: #2E8B7A; --c-south: #D4552F; --c-silt: #C9962F; --c-good: #3E9B6E; --c-danger: #C7402D;
  --radius: 6px; --shadow: 0 4px 0 rgba(43, 33, 26, .35);
  --t-press: 120ms; --t-pop: 260ms; --t-alert: 800ms;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #e9d9b0; color: var(--c-ink); }
body { font-family: var(--yoroll-font-body), sans-serif; font-weight: 500; }
canvas { display: block; }
#stage { position: fixed; inset: 0; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }

/* 面板：漆木框 + 绢帛底（九宫格，中心 fill） */
.ui-panel {
  --pb: 44px;
  border: var(--pb) solid transparent;
  border-image: url("assets/ui_panel.webp") 122 fill / var(--pb) stretch;
  padding: 4px 8px; color: var(--c-ink);
  filter: drop-shadow(0 8px 14px rgba(43, 33, 26, .35));
}
/* 按钮：高度固定为 --bh，纵向不拉伸，只横向延展中段 */
.ui-btn {
  --bh: 64px; height: var(--bh); min-width: calc(var(--bh) * 2.6);
  display: inline-flex; align-items: center; justify-content: center;
  border-style: solid; border-color: transparent; background: none;
  border-width: calc(var(--bh) * .138) calc(var(--bh) * .372);
  padding: 0; cursor: pointer; user-select: none; touch-action: manipulation;
  font-family: var(--yoroll-font-title), var(--yoroll-font-body), sans-serif; font-weight: 700;
  font-size: calc(var(--bh) * .3); line-height: 1; white-space: nowrap; letter-spacing: .04em;
  transition: transform var(--t-press), filter var(--t-press);
}
.ui-btn.primary { border-image: url("assets/ui_btn_primary.webp") 80 215 80 215 fill / calc(var(--bh) * .138) calc(var(--bh) * .372) stretch; color: #FFF1D0; text-shadow: 0 2px 0 rgba(60, 10, 0, .6); }
/* 次按钮：青石雕板（源图 1500×572，实测内框 左211 上104 右136 下74） */
.ui-btn.secondary { border-width: calc(var(--bh) * .18) calc(var(--bh) * .369) calc(var(--bh) * .13);
  border-image: url("assets/ui_btn_secondary.webp") 104 211 74 211 fill / calc(var(--bh) * .18) calc(var(--bh) * .369) calc(var(--bh) * .13) stretch; color: #F3E6C8; text-shadow: 0 2px 0 rgba(0, 20, 30, .6); }

/* 横幅：卷轴（源图 1532×588，实测内框 左141 上134 右128 下94），高度固定，只横向延展 */
.ui-banner { --bh: 72px; height: var(--bh); display: inline-flex; align-items: center; justify-content: center; min-width: calc(var(--bh) * 3);
  border-style: solid; border-color: transparent;
  border-width: calc(var(--bh) * .228) calc(var(--bh) * .218) calc(var(--bh) * .16) calc(var(--bh) * .24);
  border-image: url("assets/ui_banner.webp") 134 128 94 141 fill / calc(var(--bh) * .228) calc(var(--bh) * .218) calc(var(--bh) * .16) calc(var(--bh) * .24) stretch; }
.ui-banner > .in { display: flex; align-items: center; justify-content: center; gap: .5em; padding: 0 .4em; white-space: nowrap; line-height: 1;
  font-size: calc(var(--bh) * .3); color: var(--c-ink); }

/* 票券：旧纸票（源图 1490×731，实测内框 左119 上74 右128 下104） */
.ui-coupon { border-style: solid; border-color: transparent; border-width: 20px 34px 28px 32px;
  border-image: url("assets/ui_coupon.webp") 74 128 104 119 fill / 20px 34px 28px 32px stretch; }
.ui-coupon > .in { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 6px; text-align: center; }
.ui-coupon code { font-size: 20px; font-weight: 700; letter-spacing: .08em; color: var(--c-cinnabar); }
.ui-coupon.used { filter: grayscale(.7) opacity(.75); }

/* 化身头顶昵称牌（代码绘制，跟随 3D 位置） */
#plates { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.nameplate { position: absolute; left: 0; top: 0; padding: 2px 8px; max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: clamp(11px, 1.15vw, 20px); font-weight: 700; line-height: 1.35; color: #fff; border-radius: var(--radius);
  border: 2px solid rgba(43, 33, 26, .85); box-shadow: 0 2px 0 rgba(43, 33, 26, .4); will-change: transform; }
.nameplate.t0 { background: var(--c-north); } .nameplate.t1 { background: var(--c-south); }
.nameplate.me { outline: 3px solid #ffd45a; }
.nameplate.hit { animation: plate-hit var(--t-pop); }
@keyframes plate-hit { 40% { filter: brightness(1.5); margin-top: -6px; } }

.x-btn { position: absolute; right: -6px; top: -8px; width: 44px; height: 44px; border: 2px solid var(--c-ink); border-radius: 50%;
  background: var(--c-silk); color: var(--c-ink); font-size: 18px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow); z-index: 1; }
.modal .ui-panel { position: relative; }
.toast { position: fixed; left: 50%; top: calc(14px + var(--safe-t)); transform: translate(-50%, -160%); transition: transform var(--t-pop); z-index: 60; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); }
#ui > .river-view { position: absolute; inset: 0; pointer-events: none; }
.modal .actions { gap: 10px; flex-wrap: wrap; }
.river-view > * { pointer-events: auto; }
.gauge .bar.good { box-shadow: var(--shadow), 0 0 0 3px rgba(62, 155, 110, .55); }
.ui-btn:active { transform: translateY(3px) scale(.98); }
.ui-btn:focus-visible { outline: 3px solid var(--c-sand); outline-offset: 2px; }
.ui-btn[disabled] { filter: grayscale(.8) brightness(.8); pointer-events: none; }

/* 入口页 */
/* 横屏：面板靠左、示范河道与潘公在右侧露出；竖屏/窄屏：面板沉底、河道在上 */
#ui > .entry { position: absolute; inset: 0; pointer-events: none; display: flex; align-items: center; justify-content: flex-start;
  padding: calc(12px + var(--safe-t)) calc(14px + var(--safe-r)) calc(12px + var(--safe-b)) calc(14px + var(--safe-l)); }
.entry > * { pointer-events: auto; }
.entry .ui-panel { width: min(460px, 38vw); max-height: 100%; overflow: auto; text-align: center; flex: none; }
.entry h1 { margin: 0; font-size: clamp(28px, 4vw, 52px); letter-spacing: .08em; color: var(--c-cinnabar); text-shadow: 0 2px 0 #fff3; }
.entry .sub { margin: 6px 0 2px; font-size: clamp(13px, 1.5vw, 19px); color: var(--c-river); font-weight: 700; }
.entry .lead { margin: 6px auto 12px; max-width: 30em; font-size: clamp(13px, 1.2vw, 16px); line-height: 1.6; text-align: left; }
.entry .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 12px; justify-items: center; }
.entry .grid .ui-btn { --bh: clamp(48px, 5vw, 62px); width: 100%; max-width: 280px; min-width: 0; }
.entry .know { margin: 12px 0 2px; font-size: 13px; opacity: .8; }

/* 试手感操作条：示范进度一句话 + 移动键 + 夯土（代码绘制的木质圆键） */
.try { position: absolute; right: calc(14px + var(--safe-r)); bottom: calc(14px + var(--safe-b)); display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  max-width: min(560px, 58vw); pointer-events: none; }
.try > *, .try-ctl > * { pointer-events: auto; }
.try-cap { font-size: clamp(13px, 1.25vw, 18px); font-weight: 700; line-height: 1.4; text-align: right; }
.try-ctl { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; pointer-events: none; }
.try-tip { font-size: 13px; }
.try-ctl .ui-btn { --bh: 56px; min-width: 132px; }
.pad { width: 60px; height: 56px; flex: none; display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--c-silk); background: #6b4426; border: 3px solid var(--c-ink); border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 2px 0 rgba(255, 230, 180, .35); user-select: none; touch-action: none;
  transition: transform var(--t-press), background var(--t-press); }
.pad.held, .pad:active { transform: translateY(3px); background: var(--c-cinnabar); box-shadow: 0 1px 0 rgba(43, 33, 26, .35); }
.pad:focus-visible { outline: 3px solid var(--c-sand); outline-offset: 2px; }
.ui-btn.tap { animation: btn-tap var(--t-press); }
@keyframes btn-tap { 50% { transform: translateY(4px) scale(.96); filter: brightness(1.2); } }
.river-view .try { bottom: calc(84px + var(--safe-b)); }

@media (max-height: 520px) and (min-aspect-ratio: 11/10) {
  .ui-panel { --pb: 30px; }
  .entry .lead, .try-tip { display: none; }
  .entry .know { margin-top: 6px; font-size: 12px; }
  .entry .grid .ui-btn { --bh: 46px; }
  .try-ctl .ui-btn { --bh: 50px; } .pad { height: 50px; }
}
@media (max-aspect-ratio: 11/10), (max-width: 719px) {
  #ui > .entry { flex-direction: column-reverse; align-items: stretch; justify-content: flex-start; gap: 8px; }
  .entry .ui-panel { --pb: 32px; width: 100%; max-width: 560px; align-self: center; max-height: 46%; }
  .entry h1 { font-size: clamp(26px, 8vw, 40px); } .entry .sub { font-size: 14px; } .entry .lead { display: none; }
  .entry .grid { grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; } .entry .grid .ui-btn { --bh: 50px; font-size: 14px; }
  .entry .links { margin-top: 8px; } .entry .know { margin-top: 8px; font-size: 12px; }
  .entry .ui-panel { max-height: 54%; }
  .entry .try { position: static; max-width: none; align-self: stretch; align-items: stretch; }
  .entry .try-cap { text-align: center; } .try-ctl { justify-content: center; } .try-tip { display: none; }
  .river-view .try { left: calc(12px + var(--safe-l)); right: calc(12px + var(--safe-r)); max-width: none; align-items: stretch; }
  .river-view .try-cap { text-align: center; }
}

/* 舞台预览角标与返回 */
.stage-bar { position: absolute; left: calc(12px + var(--safe-l)); top: calc(12px + var(--safe-t)); display: flex; gap: 10px; align-items: center; }
.stage-bar .ui-btn { --bh: 48px; }
.chip { background: rgba(243, 230, 200, .92); border: 2px solid var(--c-ink); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 6px 12px; font-size: 14px; }
.gauge { position: absolute; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); width: min(560px, 90vw); }
.gauge .bar { position: relative; height: 22px; border: 3px solid var(--c-ink); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  background: linear-gradient(90deg, var(--c-silt) 0 45%, var(--c-good) 45% 67.5%, var(--c-danger) 67.5% 100%); }
.gauge .needle { position: absolute; top: -6px; width: 6px; height: 34px; margin-left: -3px; background: #fff; border: 2px solid var(--c-ink); border-radius: 3px; transition: left .25s linear; }
.gauge .lab { display: flex; justify-content: space-between; margin-top: 4px; font-size: 13px; font-weight: 700; text-shadow: 0 1px 0 #fff8; }

/* 弹窗 */
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(43, 33, 26, .55); z-index: 50;
  padding: calc(12px + var(--safe-t)) 12px calc(12px + var(--safe-b)); }
.modal .ui-panel { width: min(520px, 94vw); max-height: 92vh; display: flex; flex-direction: column; }
.modal h2 { margin: 0 0 8px; font-size: 22px; color: var(--c-cinnabar); text-align: center; }
.modal .body { overflow: auto; font-size: 15px; line-height: 1.7; flex: 1; }
.modal .body li { margin: 2px 0; }
.modal .actions { display: flex; justify-content: center; padding-top: 10px; }
.modal .actions .ui-btn { --bh: 52px; }
.loadfail { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); }

/* ───────── 通用小件 ───────── */
body.no-stage #stage, body.no-stage #plates { display: none; }
.net-frame { position: fixed; left: 0; top: 0; width: 0; height: 0; border: 0; visibility: hidden; }
.mini-btn { min-height: 44px; min-width: 44px; padding: 6px 12px; border: 2px solid var(--c-ink); border-radius: var(--radius); background: var(--c-silk); color: var(--c-ink);
  font: inherit; font-weight: 700; font-size: 14px; line-height: 1.2; box-shadow: var(--shadow); cursor: pointer; touch-action: manipulation; user-select: none;
  transition: transform var(--t-press); }
.mini-btn:active { transform: translateY(3px); box-shadow: none; }
.mini-btn:focus-visible { outline: 3px solid var(--c-sand); outline-offset: 2px; }
.mini-btn.on { background: var(--c-cinnabar); color: #fff; }
.field { width: 100%; min-height: 46px; padding: 8px 10px; border: 2px solid var(--c-ink); border-radius: var(--radius); background: #fffaf0;
  font: inherit; font-size: 16px; color: var(--c-ink); }
.field:focus { outline: 3px solid var(--c-sand); outline-offset: 1px; }
.hint { margin: 4px 0 0; font-size: 12px; line-height: 1.55; opacity: .82; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.row label { flex: none; min-width: 5.5em; font-weight: 700; font-size: 14px; }
.row .field { flex: 1 1 120px; width: auto; min-width: 0; }
.row .field.short { flex: 0 0 72px; }
.row .ui-btn { --bh: 50px; min-width: 0; flex: 1 1 130px; }
.entry .links { display: flex; justify-content: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
@keyframes pulse { to { filter: brightness(1.35); transform: scale(1.04); } }
@keyframes cap-in { 0% { transform: translateX(-50%) translateY(-40px) rotate(-3deg); opacity: 0; } 35% { transform: translateX(-50%) translateY(6px) rotate(1.5deg); opacity: 1; } 60% { transform: translateX(-50%) rotate(-.8deg); } 100% { transform: translateX(-50%); } }
@keyframes ring { from { transform: scale(1); opacity: .9; } to { transform: scale(1.35); opacity: 0; } }

/* ───────── 对局 HUD（大屏 / 单机试玩共用） ───────── */
#ui > .hud { position: absolute; inset: 0; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-top { position: absolute; left: calc(12px + var(--safe-l)); right: calc(12px + var(--safe-r)); top: calc(10px + var(--safe-t));
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; pointer-events: none !important; }
.hud-top > * { pointer-events: auto; }
.hud-top .hud-back { --bh: 46px; min-width: 0; }
.hud-nav { display: flex; align-items: center; gap: 8px; pointer-events: none !important; }
.hud-nav > * { pointer-events: auto; }
/* 游戏标题：放在左上角按钮右边的空当——上方是屏幕边，右边到倒计时牌之间没有别的东西，下方的比分栏从 68px 才开始，
   字幕、鼓点圈、潘公气泡、结算侧栏、二维码都不经过这里。窄屏放不下时收起，不挤占对局信息。 */
.hud-title { display: flex; align-items: baseline; gap: .35em; margin-left: clamp(4px, .8vw, 16px); pointer-events: none !important; white-space: nowrap; line-height: 1; height: 46px; align-items: center; }
.hud-title b { font-size: clamp(24px, 2.5vw, 50px); color: var(--c-cinnabar); letter-spacing: .08em;
  text-shadow: -2px -2px 0 #fffaf0, 2px -2px 0 #fffaf0, -2px 2px 0 #fffaf0, 2px 2px 0 #fffaf0, 0 4px 0 rgba(43, 33, 26, .35); }
.hud-title span { font-size: clamp(12px, 1.05vw, 20px); font-weight: 700; color: #fff; background: var(--c-cinnabar); border-radius: 4px; padding: .25em .5em; letter-spacing: .1em; }
@media (max-width: 1399px) { .hud-title span { display: none; } }
@media (max-width: 899px), (max-aspect-ratio: 11/10) { .hud-title { display: none; } }
.buzz-flash { position: fixed; inset: 0; z-index: 41; pointer-events: none; opacity: 0; box-shadow: inset 0 0 0 8px #ffd45a, inset 0 0 60px 10px rgba(255, 212, 90, .55); }
.buzz-flash.on { animation: buzz-flash .4s ease-out; }
@keyframes buzz-flash { 0% { opacity: 1; } 100% { opacity: 0; } }
.hud .timer { --bh: clamp(52px, 6.2vw, 104px); position: absolute; left: 50%; top: 0; transform: translateX(-50%); pointer-events: none; }
.t-num { font-size: 1.35em; color: var(--c-cinnabar); min-width: 2.4em; text-align: center; font-variant-numeric: tabular-nums; }
.t-num:empty { display: none; }
.timer.urgent .t-num { animation: pulse .5s infinite alternate; }
.hud-chips { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 30vw; pointer-events: none !important; }
.hud-chips .chip { font-size: clamp(12px, 1.05vw, 20px); text-align: right; }
.hud-left { position: absolute; left: calc(12px + var(--safe-l)); top: calc(68px + var(--safe-t)); width: clamp(150px, 17vw, 320px);
  display: flex; flex-direction: column; gap: 8px; pointer-events: none !important; }
.team-score { display: flex; gap: 6px; }
.ts { flex: 1; padding: 4px 6px; border: 2px solid var(--c-ink); border-radius: var(--radius); box-shadow: var(--shadow); color: #fff;
  display: flex; flex-direction: column; align-items: center; font-size: clamp(11px, 1vw, 18px); line-height: 1.25; }
.ts span { font-size: 1.6em; font-weight: 700; font-variant-numeric: tabular-nums; }
.ts.t0 { background: var(--c-north); } .ts.t1 { background: var(--c-south); }
.meter { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: clamp(12px, 1vw, 18px); text-shadow: 0 1px 0 #fff8; }
.meter label { flex: none; width: 2.4em; }
.mbar { flex: 1; height: clamp(14px, 1.3vw, 22px); border: 2px solid var(--c-ink); border-radius: 4px; background: rgba(255, 255, 255, .5); overflow: hidden; }
.mbar i { display: block; height: 100%; background: var(--c-sand); transition: width .2s linear; }
.mbar.foot i { background: var(--c-river); }
.mbar.warn { box-shadow: 0 0 0 3px var(--c-cinnabar); animation: pulse .5s infinite alternate; }
.hud-left .status { font-size: clamp(12px, 1vw, 18px); }
.caption { position: absolute; left: 50%; top: 20%; transform: translateX(-50%); pointer-events: none !important; max-width: 96vw; }
.caption .ui-banner { --bh: clamp(50px, 5.6vw, 100px); max-width: 96vw; }
.caption .in { font-size: calc(var(--bh) * .25); font-weight: 700; overflow: hidden; text-overflow: ellipsis; max-width: calc(96vw - var(--bh)); display: block; }
.caption.alert .in { color: var(--c-cinnabar); }
.caption.in-anim { animation: cap-in var(--t-alert); }
.hud-bottom { position: absolute; left: calc(12px + var(--safe-l)); right: calc(12px + var(--safe-r)); bottom: calc(12px + var(--safe-b));
  display: flex; align-items: flex-end; justify-content: center; gap: 14px; pointer-events: none !important; }
.hud-bottom > * { pointer-events: auto; }
.hud .gauge { position: static; transform: none; flex: 0 1 760px; width: auto; min-width: 120px; }
.hud:not(.with-ctl) .gauge { max-width: 52vw; }
.hud:not(.with-ctl) .gauge .bar { height: clamp(22px, 2.2vw, 40px); }
.hud:not(.with-ctl) .gauge .needle { height: calc(100% + 12px); }
.hud:not(.with-ctl) .gauge .lab { font-size: clamp(13px, 1.2vw, 22px); }
.with-ctl .hud-bottom { justify-content: space-between; }
.with-ctl .gauge { flex: 1 1 200px; max-width: 620px; }
.ctl-move { display: flex; gap: 10px; flex: none; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.pad, .shout-ring, .ctl-act .ui-btn { -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.ctl-move .pad { width: clamp(72px, 9vw, 104px); height: clamp(64px, 8vw, 92px); font-size: 28px; }
.ctl-act { display: grid; grid-template-columns: auto auto; gap: 8px 10px; align-items: center; justify-items: center; flex: none; }
.ctl-act .ui-btn { --bh: 62px; min-width: 0; width: 100%; }
.shout-ring { position: relative; width: 64px; height: 64px; flex: none; padding: 0; border-radius: 50%; border: 3px solid var(--c-ink); background: var(--c-sand); color: var(--c-ink);
  font: inherit; font-weight: 700; font-size: 16px; cursor: pointer; touch-action: none; user-select: none; box-shadow: var(--shadow); transition: transform var(--t-press), background var(--t-press); }
.shout-ring.held { background: var(--c-cinnabar); color: #fff; transform: translateY(3px); box-shadow: none; }
.shout-ring:focus-visible { outline: 3px solid var(--c-river); outline-offset: 3px; }
.shout-ring i { position: absolute; inset: -7px; border-radius: 50%; border: 3px solid var(--c-cinnabar); opacity: 0; pointer-events: none; }
.shout-ring.live i { animation: ring .6s infinite; }
.qr-box { position: absolute; right: calc(14px + var(--safe-r)); bottom: calc(14px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px; background: var(--c-silk); border: 3px solid var(--c-ink); border-radius: var(--radius); box-shadow: var(--shadow); }
.qr-img { width: clamp(110px, 13vw, 240px); height: clamp(110px, 13vw, 240px); display: flex; align-items: center; justify-content: center; font-size: clamp(12px, 1.1vw, 18px); line-height: 1.4; font-weight: 700; color: #2b211a; padding: 8px; box-sizing: border-box; text-align: center; background: #fff; }
.qr-img:has(img) { padding: 0; }
.qr-img img, .qr-mini img { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.qr-txt { display: flex; flex-direction: column; align-items: center; font-size: clamp(11px, 1vw, 18px); line-height: 1.3; }
.qr-txt b { font-size: 1.25em; color: var(--c-cinnabar); }
.result-side { position: absolute; right: calc(12px + var(--safe-r)); top: clamp(96px, 13vh, 160px); bottom: calc(clamp(110px, 13vw, 240px) + 96px); width: min(36vw, 620px); }
.result-side .ui-panel { --pb: 34px; height: 100%; overflow: auto; }
.host-tools { position: absolute; left: calc(12px + var(--safe-l)); bottom: calc(12px + var(--safe-b)); display: flex; gap: 6px; opacity: .6; }
.host-tools:hover, .host-tools:focus-within { opacity: 1; }
.howto { margin: 6px 0; padding-left: 1.4em; font-size: clamp(13px, 1.1vw, 20px); line-height: 1.7; }

/* ───────── 结算内容（大屏侧栏 / 弹窗共用） ───────── */
.res-head { text-align: center; padding: 2px 0 6px; }
.res-head b { display: block; font-size: clamp(22px, 2.4vw, 42px); letter-spacing: .1em; line-height: 1.3; }
.res-head span { font-size: clamp(12px, 1vw, 18px); }
.res-head.r-fail b { color: #6b5a48; } .res-head.r-win b { color: var(--c-river); } .res-head.r-grand b { color: var(--c-cinnabar); }
.res-mine { text-align: center; margin: 4px 0; font-size: clamp(14px, 1.1vw, 20px); }
.res-mine b { color: var(--c-cinnabar); font-size: 1.25em; }
.lb { list-style: none; margin: 6px 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.rank-row { display: flex; align-items: center; gap: 8px; padding: 3px 8px; border-radius: 4px; background: rgba(255, 255, 255, .45); border-left: 6px solid transparent;
  font-size: clamp(13px, 1.05vw, 20px); line-height: 1.5; }
.rank-row.t0 { border-left-color: var(--c-north); } .rank-row.t1 { border-left-color: var(--c-south); }
.rank-row i { font-style: normal; width: 1.6em; font-weight: 700; flex: none; }
.rank-row span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row.me { background: #ffe9a8; outline: 2px solid var(--c-sand); }
.promo { margin: 8px 0 2px; padding: 6px 8px; border: 2px dashed var(--c-cinnabar); border-radius: var(--radius); font-weight: 700; color: var(--c-cinnabar);
  text-align: center; font-size: clamp(13px, 1.1vw, 20px); line-height: 1.5; }
.know { font-size: clamp(12px, .95vw, 17px); opacity: .85; margin: 6px 0 2px; }
.next { text-align: center; font-weight: 700; font-size: clamp(14px, 1.2vw, 22px); color: var(--c-river); margin: 6px 0 0; min-height: 1.4em; }
.qr-mini { width: 150px; height: 150px; margin: 6px auto; background: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; text-align: center; }
.w-item { margin: 10px 0; padding-bottom: 8px; border-bottom: 2px dashed rgba(43, 33, 26, .25); }

/* ───────── 手机手柄 ───────── */
#ui > .phone { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 8px; overflow: hidden;
  padding: calc(8px + var(--safe-t)) calc(10px + var(--safe-r)) calc(10px + var(--safe-b)) calc(10px + var(--safe-l));
  background: linear-gradient(#f3e6c8, #e6cf9a); }
.ph-top { flex: none; display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.ph-timer { --bh: 54px; min-width: 0; }
.ph-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }
.ph-row .chip { padding: 4px 8px; font-size: 13px; box-shadow: none; }
.chip.t0 { background: var(--c-north); color: #fff; } .chip.t1 { background: var(--c-south); color: #fff; }
.ph-mid { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.mini { flex: 1 1 0; min-height: 84px; height: 0; width: 100%; border: 3px solid var(--c-ink); border-radius: var(--radius); box-shadow: var(--shadow); background: #5f9c8c; }
.phone .gauge { position: static; transform: none; width: 100%; flex: none; }
.phone .gauge .lab { font-size: 12px; }
.ph-meters { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ph-meters .meter { font-size: 13px; }
.task { flex: none; min-height: 40px; display: flex; align-items: center; justify-content: center; text-align: center; font-weight: 700; font-size: 14px; line-height: 1.35; box-shadow: none; }
.task.on { background: #ffe9a8; border-color: var(--c-cinnabar); }
.ph-ctl { flex: none; display: flex; flex-direction: column; gap: 8px; }
.phone .ctl-move { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.phone .ctl-move .pad { width: 100%; height: 72px; font-size: 30px; }
.phone .ctl-act { grid-template-columns: 1fr 1fr; }
.phone .ctl-act .ui-btn { --bh: 70px; font-size: 19px; }
.phone .shout-ring { width: 68px; height: 68px; }
.ph-net { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 3; background: var(--c-cinnabar); color: #fff; font-weight: 700; white-space: nowrap; pointer-events: none; }

/* ───────── 两岸较劲：主流拔河条 / 道具键 / 鼓点圈 / 泥巴 / 决战 ───────── */
.rival { display: flex; align-items: center; gap: 8px; flex: none; }
.tug { position: relative; flex: 1; min-width: 60px; height: clamp(14px, 1.3vw, 22px); border: 2px solid var(--c-ink); border-radius: 4px; background: var(--c-south); overflow: visible; }
.tug i { position: absolute; left: 0; top: 0; bottom: 0; width: 50%; background: var(--c-north); border-radius: 2px 0 0 2px; transition: width .25s linear; }
.tug b { position: absolute; top: -5px; bottom: -5px; left: 50%; width: 6px; margin-left: -3px; background: #fff; border: 2px solid var(--c-ink); border-radius: 3px; transition: left .25s linear; }
.tug.hot { box-shadow: 0 0 0 3px #ffd45a; animation: pulse .5s infinite alternate; }
.item-btn { flex: none; pointer-events: auto !important; background: #ffe9a8; border-color: var(--c-cinnabar); color: var(--c-ink); font-weight: 700; white-space: nowrap; touch-action: manipulation; }
.item-btn.new { animation: item-in .5s; }
@keyframes item-in { 0% { transform: scale(.4); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
.drum { position: absolute; left: 50%; top: calc(74px + var(--safe-t)); transform: translateX(-50%); z-index: 2; width: clamp(78px, 8vw, 150px); height: clamp(78px, 8vw, 150px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 50%; border: 4px solid var(--c-ink); background: var(--c-silk); color: var(--c-ink); pointer-events: none !important; box-shadow: var(--shadow); }
[hidden] { display: none !important; }
.drum i { position: absolute; inset: -4px; border-radius: 50%; border: 5px solid var(--c-cinnabar); pointer-events: none; }
.drum b { font-size: clamp(30px, 3.4vw, 64px); line-height: 1; color: var(--c-cinnabar); }
.drum span { font-size: clamp(11px, 1vw, 18px); font-weight: 700; }
.drum.hit { background: var(--c-cinnabar); color: #fff; } .drum.hit b { color: #fff; font-size: clamp(26px, 3vw, 56px); }
.ctl-act.mud .ui-btn { filter: sepia(1) saturate(.6) brightness(.5); pointer-events: none; }
.ctl-act.mud { position: relative; }
.ctl-act.mud::after { content: '被泥巴糊住了！'; position: absolute; left: 0; right: 0; top: 14px; text-align: center; font-weight: 700; font-size: 17px; color: #fff; text-shadow: 0 2px 0 #3d2a1c; pointer-events: none; }
.timer.final .t-num { color: #fff; background: var(--c-cinnabar); border-radius: 4px; padding: 0 6px; }
/* ───────── 表现力：飘字 / 潘公气泡 / 新河工大名 / 手机大字提示 / 泥巴糊屏 / 决战红边 ───────── */
.fl { position: absolute; left: 0; top: 0; font-weight: 700; font-size: clamp(16px, 1.9vw, 38px); color: #fff; white-space: nowrap; pointer-events: none; will-change: transform, opacity;
  text-shadow: 0 2px 0 var(--c-ink), 0 0 8px rgba(43, 33, 26, .85); }
.fl.gold { color: #ffd45a; } .fl.bad { color: #ffb39f; } .fl.big { font-size: clamp(24px, 3.2vw, 64px); }
.nameplate.mud { background: #5a3a1c !important; } .nameplate.mud::before { content: '💩 '; }
.nameplate.born { animation: plate-born 1.8s; }
@keyframes plate-born { 0%, 55% { box-shadow: 0 0 0 5px #ffd45a, 0 0 26px 12px #ffd45a; filter: brightness(1.5); } }
.pg-bubble { position: absolute; left: 0; top: 0; padding-bottom: 12px; pointer-events: none; will-change: transform; }
.pg-bubble span { display: block; position: relative; padding: .3em .8em; background: #fffaf0; color: var(--c-ink); border: 3px solid var(--c-ink); border-radius: 18px; font-weight: 700;
  font-size: clamp(15px, 1.75vw, 36px); line-height: 1.5; white-space: nowrap; box-shadow: var(--shadow); transform-origin: 50% 100%; animation: pg-pop .35s cubic-bezier(.2, 1.7, .4, 1); }
.pg-bubble::after { content: ''; position: absolute; left: 50%; bottom: 2px; margin-left: -10px; border: 10px solid transparent; border-top-color: var(--c-ink); border-bottom: 0; }
@keyframes pg-pop { 0% { transform: scale(.2) rotate(-8deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.join-pop { position: absolute; left: 0; top: 0; pointer-events: none; will-change: transform, opacity; text-align: center; white-space: nowrap; }
.join-pop .in { display: block; padding: .08em .45em .14em; border: .06em solid #fff; border-radius: .22em; color: #fff; font-weight: 700; line-height: 1.1;
  box-shadow: 0 .08em 0 rgba(43, 33, 26, .5), 0 0 .5em rgba(255, 212, 90, .9); animation: join-in .55s cubic-bezier(.2, 1.8, .4, 1); }
.join-pop.t0 .in { background: var(--c-north); } .join-pop.t1 .in { background: var(--c-south); }
.join-pop small { display: block; font-size: .26em; letter-spacing: .15em; color: #ffe9a8; }
@keyframes join-in { 0% { transform: scale(.1) rotate(-12deg); opacity: 0; } 60% { transform: scale(1.15) rotate(3deg); opacity: 1; } 80% { transform: scale(.95) rotate(-1deg); } 100% { transform: none; } }
.hud.final-on::before { content: ''; position: fixed; inset: 0; pointer-events: none; box-shadow: inset 0 0 0 6px rgba(199, 64, 45, .85), inset 0 0 90px 20px rgba(199, 64, 45, .45); animation: pulse-edge .6s infinite alternate; }
@keyframes pulse-edge { to { opacity: .35; } }
.team-score .ts.bump span { animation: score-bump .4s; display: inline-block; }
@keyframes score-bump { 40% { transform: scale(1.5); color: #ffd45a; } }
.spot { position: fixed; left: 50%; top: 36%; transform: translate(-50%, -50%); z-index: 40; pointer-events: none; width: min(92vw, 560px); text-align: center; }
.spot .in { display: block; padding: 12px 16px 14px; background: var(--c-ink); color: #fff; border: 4px solid #ffd45a; border-radius: 14px; font-weight: 700;
  font-size: clamp(20px, 5.6vw, 34px); line-height: 1.25; box-shadow: 0 8px 0 rgba(0, 0, 0, .35); animation: spot-in .45s cubic-bezier(.2, 1.7, .4, 1); }
.spot .in i { display: block; font-style: normal; font-size: 2.2em; line-height: 1.15; animation: spot-icon .35s infinite alternate ease-in-out; }
.spot.bad .in { background: #5a3a1c; border-color: var(--c-cinnabar); } .spot.good .in { background: #2c7a55; }
.spot.out .in { animation: spot-out .3s forwards; }
@keyframes spot-in { 0% { transform: scale(.2) rotate(-6deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes spot-out { to { transform: scale(.6); opacity: 0; } }
@keyframes spot-icon { to { transform: translateY(-6px) rotate(8deg) scale(1.12); } }
.mud-screen { position: fixed; inset: 0; z-index: 39; pointer-events: none; overflow: hidden; transition: opacity .4s; }
.mud-screen.out { opacity: 0; }
.mud-screen b { position: absolute; border-radius: 47% 53% 60% 40% / 55% 45% 58% 42%; background: radial-gradient(circle at 35% 30%, #8a5d36, #4a2f16 72%); box-shadow: inset -6px -8px 0 rgba(0, 0, 0, .18);
  animation-name: mud-in, mud-drip; animation-timing-function: cubic-bezier(.2, 1.8, .4, 1), ease-in; animation-fill-mode: both, forwards; }
@keyframes mud-in { 0% { transform: scale(0); } 100% { transform: scale(1); } }
@keyframes mud-drip { 0% { transform: translateY(0) scaleY(1); } 100% { transform: translateY(22vh) scaleY(1.5); } }
.ctl-act.mud .ui-btn { animation: mud-shake .28s 4; }
@keyframes mud-shake { 25% { transform: translateX(-5px) rotate(-1.5deg); } 75% { transform: translateX(5px) rotate(1.5deg); } }
@media (prefers-reduced-motion: reduce) { .spot .in i, .hud.final-on::before, .ctl-act.mud .ui-btn { animation: none; } }
.phone .rival { min-height: 44px; } .phone .tug { height: 16px; }
.ph-mid { position: relative; }
.phone .drum { top: 8px; width: 84px; height: 84px; } .phone .drum b { font-size: 34px; } .phone .drum.hit b { font-size: 28px; } .phone .drum span { font-size: 11px; }
.ui-coupon code.short { font-size: 24px; } .ui-coupon small.full { font-size: 11px; opacity: .7; letter-spacing: .04em; }
.pick-list { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pick-list button { width: 100%; text-align: left; }
canvas.scan-buf { display: none; }

/* ───────── 管理员端 ───────── */
#ui > .admin { position: absolute; inset: 0; display: flex; flex-direction: column; background: #efe0b8; }
.ad-head { flex: none; display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--safe-t)) calc(12px + var(--safe-r)) 6px calc(12px + var(--safe-l)); }
.ad-head h2 { flex: 1; margin: 0; font-size: 19px; color: var(--c-cinnabar); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-head .chip { box-shadow: none; padding: 4px 8px; font-size: 12px; }
.tabs { flex: none; display: flex; gap: 6px; padding: 0 calc(12px + var(--safe-r)) 8px calc(12px + var(--safe-l)); }
.tabs button { flex: 1; min-height: 46px; border: 2px solid var(--c-ink); border-radius: var(--radius); background: var(--c-silk); color: var(--c-ink); font: inherit; font-weight: 700; font-size: 16px; cursor: pointer; }
.tabs button.on { background: var(--c-river); color: #fff; }
.tabs button:focus-visible { outline: 3px solid var(--c-sand); outline-offset: 2px; }
.ad-body { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; padding: 4px calc(12px + var(--safe-r)) calc(16px + var(--safe-b)) calc(12px + var(--safe-l)); }
.ad-body section { display: flex; flex-direction: column; gap: 10px; max-width: 640px; margin: 0 auto; }
.ad-body section[hidden] { display: none; }
.card { background: rgba(255, 250, 240, .85); border: 2px solid var(--c-ink); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 4px; font-size: 16px; color: var(--c-river); }
.big-clock { font-size: 30px; font-weight: 700; color: var(--c-cinnabar); font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat { margin: 4px 0 0; font-size: 14px; line-height: 1.5; }
.log, .ledger { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; line-height: 1.5; }
.ledger li { padding: 4px 8px; background: rgba(255, 255, 255, .6); border-left: 5px solid var(--c-river); border-radius: 3px; display: flex; flex-wrap: wrap; gap: 2px 10px; }
.ledger code { font-weight: 700; color: var(--c-cinnabar); }
video.scan { width: 100%; max-height: 50vh; background: #000; border-radius: var(--radius); display: block; }

/* ───────── 竖屏 / 窄屏：单机试玩的操作区换行，流速表放在操作键上方 ───────── */
@media (max-aspect-ratio: 11/10), (max-width: 719px) {
  .hud .timer { --bh: 50px; top: 52px; }
  .hud-chips { max-width: 58vw; }
  .hud-left { top: calc(112px + var(--safe-t)); width: 150px; }
  .caption { top: 27%; }
  .with-ctl .hud-bottom { flex-wrap: wrap; gap: 8px 10px; }
  .with-ctl .gauge { order: -1; flex: 1 1 100%; max-width: none; }
  .with-ctl .ctl-act { flex: 1 1 0; grid-template-columns: 1fr auto; }
  .with-ctl .ctl-act .ui-btn { grid-column: 1 / -1; --bh: 54px; }
  .with-ctl .ctl-act .shout-ring { justify-self: end; }
  .with-ctl .ctl-move .pad { width: 70px; height: 70px; }
  .result-side { left: 12px; width: auto; top: 110px; }
  .qr-img { width: 96px; height: 96px; }
}
/* ───────── 手机横屏：左移动键、中间河道与状态、右操作键，一屏可见 ───────── */
@media (min-aspect-ratio: 11/10) and (max-height: 540px) {
  #ui > .phone { display: grid; grid-template-columns: minmax(150px, 24%) 1fr minmax(190px, 28%); grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "top top top" "move mid act"; gap: 6px 10px; }
  .ph-top { grid-area: top; flex-direction: row; align-items: center; }
  .ph-timer { --bh: 44px; flex: none; } .ph-row { flex: 1; justify-content: flex-end; }
  .ph-mid { grid-area: mid; } .ph-ctl { display: contents; }
  .phone .ctl-move { grid-area: move; align-self: end; } .phone .ctl-move .pad { height: 96px; }
  .phone .ctl-act { grid-area: act; align-self: end; grid-template-columns: 1fr auto; }
  .phone .ctl-act .ui-btn { grid-column: 1 / -1; --bh: 56px; font-size: 17px; }
  .phone .shout-ring { width: 60px; height: 60px; justify-self: end; }
  .ph-meters .meter label { width: 2.2em; } .task { min-height: 34px; font-size: 13px; }
  .hud-left { top: calc(58px + var(--safe-t)); }
  .hud .timer { --bh: 46px; }
  .with-ctl .ctl-act .ui-btn { --bh: 52px; }
  .with-ctl .ctl-move .pad { height: 60px; }
}
