/* 筛宝石 / 河滩拣玉样板。令牌在 :root，页面只用变量。 */
:root {
  --touch: 48px;            /* 最小点击区（≥44） */
  --tool: 60px;             /* 工具键 */
  --ink: #f4efe4;
  --ink-dim: rgba(244, 239, 228, 0.72);
  --glass: rgba(18, 20, 22, 0.42);
  --glass-strong: rgba(18, 20, 22, 0.66);
  --tool-back: rgba(24, 22, 18, 0.82);
  --tool-active: rgba(54, 38, 15, 0.88);
  --line: rgba(255, 255, 255, 0.16);
  --gold: #f2c35b;
  --warn: #e8775a;
  --good: #8fd18b;
  --r: 16px;
  --fs-hero: 26px;
  --fs-title: 17px;
  --fs-body: 14px;
  --fs-small: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b1a17; color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
.hide { display: none !important; }
#cv { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }

/* ---------- 首页 ---------- */
#home { position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; gap: 14px; padding: calc(18px + var(--safe-t)) 16px calc(16px + var(--safe-b));
  background: radial-gradient(120% 70% at 50% 0%, #3a3527 0%, #1b1a17 60%); overflow-y: auto; }
#home > * { width: min(100%, 960px); margin-inline: auto; }
.home-head h1 { margin: 6px 0 2px; font-size: var(--fs-hero); letter-spacing: 2px; }
.home-head p { margin: 0; color: var(--ink-dim); font-size: var(--fs-body); }
.card { position: relative; flex: 1 1 0; min-height: 190px; container-type: size; border-radius: 22px; overflow: hidden; text-align: left; display: block;
  border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); transition: transform 0.15s; }
.card:active { transform: scale(0.98); }
.card.sift { background: linear-gradient(160deg, #31514c 0%, #1d2f2c 70%); }
.card.river { background: linear-gradient(160deg, #5b5446 0%, #2d2a23 70%); }
.card::before { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.42), transparent 68%); }
.card-art { position: absolute; right: clamp(8px, 2.4cqw, 32px); top: 50%; width: min(50%, 138cqh); aspect-ratio: 1.35; transform: translateY(-50%); }
.card-prop, .card-gem { position: absolute; object-fit: contain; filter: drop-shadow(0 6px 8px rgba(0,0,0,.52)); }
.card-prop { left: 4%; top: 5%; width: 92%; height: 90%; }
.card.river .card-prop { left: 0; width: 72%; }
.card-gem.g1 { left: 29%; top: 24%; width: 26%; animation: bob 3s ease-in-out infinite; }
.card-gem.g2 { left: 57%; top: 35%; width: 16%; }
.card-gem.g3 { left: 44%; top: 58%; width: 20%; }
.card-gem.j1 { left: 68%; top: 15%; width: 29%; animation: bob 3.4s ease-in-out infinite; }
.card-gem.j2 { left: 61%; top: 55%; width: 27%; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-4deg); } }
.card-text { position: absolute; left: clamp(16px, 5cqw, 48px); top: 50%; transform: translateY(-50%); right: 55%; display: flex; flex-direction: column; gap: 6px; }
.card-text b { font-size: 28px; letter-spacing: 3px; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
.card-text em { font-style: normal; font-size: var(--fs-body); line-height: 1.45; color: var(--ink-dim); text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.home-foot { margin: 0; text-align: center; color: var(--ink-dim); font-size: var(--fs-small); }

/* ---------- 顶栏、提示 ---------- */
#top { position: fixed; left: 0; right: 0; top: 0; z-index: 4; height: calc(52px + var(--safe-t)); padding: var(--safe-t) 8px 0;
  display: flex; align-items: center; gap: 8px; background: linear-gradient(rgba(0,0,0,.55), rgba(0,0,0,0)); pointer-events: none; }
#top > * { pointer-events: auto; }
.ibtn { width: var(--touch); height: var(--touch); border-radius: 50%; display: grid; place-items: center; background: var(--glass); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); flex: none; }
.ibtn svg { width: 24px; height: 24px; }
#title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
#title b { font-size: var(--fs-title); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#title span { font-size: var(--fs-small); color: var(--ink-dim); white-space: nowrap; }
#meter { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 99px; background: var(--glass); font-size: var(--fs-small); flex: none; }
#meter .bar { width: 64px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.18); overflow: hidden; }
#meter .bar i { display: block; height: 100%; background: linear-gradient(90deg, #e8a74c, #f2d36b); border-radius: 4px; transition: width 0.25s; }
#meter .bar.low i { background: var(--warn); }
#meter .drops { display: flex; gap: 2px; }
#meter .drops svg { width: 14px; height: 14px; }
#hint { position: fixed; z-index: 3; left: 50%; top: calc(56px + var(--safe-t)); transform: translateX(-50%); max-width: calc(100vw - 24px);
  padding: 7px 14px; border-radius: 99px; background: var(--glass); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  font-size: var(--fs-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; transition: opacity .3s; }
#obs { position: fixed; z-index: 3; pointer-events: none; padding: 6px 10px; border-radius: 10px; background: var(--glass-strong);
  font-size: var(--fs-body); line-height: 1.4; max-width: calc(100vw - 210px); min-width: 120px; }
#obs.wide { max-width: calc(100vw - 96px); }
#obs b { color: var(--gold); font-weight: 600; }
#banner { position: fixed; z-index: 3; left: 16px; right: 16px; top: 34%; text-align: center; pointer-events: none; }
#banner b { display: block; font-size: 34px; letter-spacing: 4px; color: var(--gold); text-shadow: 0 0 18px rgba(242,195,91,.7), 0 3px 10px rgba(0,0,0,.8); }
#banner.meh b { color: var(--ink); text-shadow: 0 3px 10px rgba(0,0,0,.8); }
#banner.bad b { color: #c9c3b6; text-shadow: 0 3px 10px rgba(0,0,0,.8); }
#banner span { display: inline-block; margin-top: 6px; padding: 5px 12px; border-radius: 99px; background: var(--glass-strong); font-size: var(--fs-body); }
#banner.show { animation: pop .5s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
#toast { position: fixed; z-index: 6; left: 50%; bottom: calc(112px + var(--safe-b)); transform: translateX(-50%); padding: 9px 16px; border-radius: 99px;
  background: rgba(40, 24, 18, 0.85); border: 1px solid rgba(232,119,90,.5); font-size: var(--fs-body); white-space: nowrap; pointer-events: none; }

/* ---------- 工具键：图标 + 一行小字，半透明 ---------- */
#tools { position: fixed; z-index: 4; left: 0; right: 0; bottom: 0; padding: 0 10px calc(14px + var(--safe-b)); height: calc(100px + var(--safe-b));
  display: flex; align-items: flex-end; justify-content: center; gap: 8px; pointer-events: none; }
#tools .gap { flex: 1; }
.tool { pointer-events: auto; width: var(--tool); height: calc(var(--tool) + 4px); border-radius: 18px; background: var(--tool-back);
  border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; transition: transform .12s, background .2s; flex: none; position: relative; }
.tool svg { width: 26px; height: 26px; }
.tool span { font-size: var(--fs-small); line-height: 1; white-space: nowrap; }
.tool:active { transform: scale(.92); }
.tool.main { border-color: rgba(242,195,91,.7); }
.tool.on { background: var(--tool-active); border-color: rgba(242,195,91,.85); }
.tool.glow { animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 6px rgba(242,195,91,.25), 0 0 18px rgba(242,195,91,.5); } }
.tool i.badge { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px; background: var(--gold); color: #2a2216;
  font-style: normal; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
#tools.rail-on { justify-content: space-between; }
/* 拿在手里时，验石头的四个键竖着排在右边 */
#rail { position: fixed; z-index: 4; right: 10px; display: flex; flex-direction: column; gap: 10px; }
#rail .tool { width: 58px; height: 58px; }
#bagbar { pointer-events: none; flex: 1; min-width: 0; height: 52px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); padding: 6px 10px;
  display: flex; align-items: center; gap: 8px; align-self: center; margin-bottom: 4px; }
#bagbar img { height: 36px; }
#bagbar .bb { flex: 1; min-width: 0; }
#bagbar .bb div { height: 9px; border-radius: 5px; background: rgba(255,255,255,.18); overflow: hidden; margin-top: 4px; }
#bagbar .bb i { display: block; height: 100%; background: linear-gradient(90deg, #9bc77c, #e8c45c); transition: width .3s; }
#bagbar .bb span { font-size: var(--fs-small); white-space: nowrap; }
#bagbar.full .bb i { background: var(--warn); }
#bagbar.shake { animation: shake .4s; }
@keyframes shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

/* ---------- 背篓托盘 ---------- */
#tray { position: fixed; z-index: 7; left: 0; right: 0; bottom: 0; max-height: 62vh; padding: 14px 14px calc(16px + var(--safe-b)); border-radius: 20px 20px 0 0;
  background: rgba(28, 26, 22, 0.96); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.tray-head { display: flex; align-items: center; gap: 10px; }
.tray-head b { font-size: var(--fs-title); }
.tray-head span { flex: 1; color: var(--ink-dim); font-size: var(--fs-body); }
#trayList { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; overflow-y: auto; }
#trayList button { height: 96px; border-radius: 14px; background: rgba(255,255,255,.06); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
#trayList img { width: 64px; height: 64px; object-fit: contain; }
#trayList span { font-size: var(--fs-small); color: var(--ink-dim); }
.tray-tip { margin: 0; font-size: var(--fs-small); color: var(--ink-dim); text-align: center; }

/* ---------- 揭晓 ---------- */
#reveal { position: fixed; inset: 0; z-index: 8; display: flex; flex-direction: column; padding: calc(14px + var(--safe-t)) 14px calc(14px + var(--safe-b));
  background: radial-gradient(120% 60% at 50% 0%, #4a3e28 0%, #1d1913 65%); }
.rv-head { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.rv-head img { height: 52px; transform-origin: 70% 50%; }
.rv-head img.pour { animation: pour 1s ease-in-out both; }
@keyframes pour { 0% { transform: rotate(0); } 40%, 70% { transform: rotate(-38deg) translateY(4px); } 100% { transform: rotate(0); } }
.rv-head b { display: block; font-size: 20px; }
.rv-head span { font-size: var(--fs-body); color: var(--ink-dim); }
#rvList { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 10px 0; align-content: start; }
.rc { perspective: 700px; height: 176px; }
.rc .in { position: relative; width: 100%; height: 100%; transition: transform .55s cubic-bezier(.3,1.3,.5,1); transform-style: preserve-3d; }
.rc.open .in { transform: rotateY(180deg); }
.rc .f, .rc .b { position: absolute; inset: 0; border-radius: 16px; backface-visibility: hidden; -webkit-backface-visibility: hidden; border: 1px solid var(--line); overflow: hidden; }
.rc .f { background: radial-gradient(circle at 50% 40%, #3b3428, #211d17); display: grid; place-items: center; }
.rc .f img { width: 70%; max-height: 70%; object-fit: contain; filter: drop-shadow(0 6px 8px rgba(0,0,0,.6)); }
.rc .f i { position: absolute; bottom: 8px; font-style: normal; font-size: var(--fs-small); color: var(--ink-dim); }
.rc .b { transform: rotateY(180deg); background: #2a251c; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.rc .b .row { display: flex; align-items: center; gap: 8px; }
.rc .b img { width: 46px; height: 46px; object-fit: contain; flex: none; }
.rc .b b { font-size: 15px; line-height: 1.25; }
.rc .b .p { font-size: 18px; font-weight: 700; color: var(--gold); }
.rc .b .p.zero { color: #a59e90; font-size: 14px; font-weight: 400; }
.rc .b p { margin: 2px 0 0; font-size: var(--fs-small); line-height: 1.45; color: var(--ink-dim); }
.rc.win .b { background: linear-gradient(160deg, #4b3d1e, #2a251c); border-color: rgba(242,195,91,.6); box-shadow: 0 0 18px rgba(242,195,91,.25) inset; }
.rc.dud .b { background: #24211d; }
.rv-empty { grid-column: 1 / -1; text-align: center; color: var(--ink-dim); padding: 40px 0; }
.rv-foot { display: flex; flex-direction: column; gap: 10px; }
#rvTotal { text-align: center; font-size: 18px; min-height: 26px; }
#rvTotal b { color: var(--gold); font-size: 26px; }
.rv-btns { display: flex; gap: 10px; }
.pill { flex: 1; height: var(--touch); border-radius: 99px; background: var(--glass); border: 1px solid var(--line); font-size: 16px; }
.pill.main { background: rgba(242,195,91,.85); color: #2a2216; font-weight: 700; border: 0; }
