/* 弹珠台 —— 黑金柠檬,照 Scenario 出的设计稿(design/dark-neon/plinko-screen)一比一排。
 * 图片只有右上角探头的孔雀;钉板、球、格子、筹码、滑条、按钮全是 CSS + canvas。
 * 设计稿 1024 宽对应 375 的手机屏,尺寸一律除以 2.73 换算。
 */
.plinko {
  position: fixed; inset: 0; z-index: 10; overflow: hidden;
  display: flex; flex-direction: column;
  padding: var(--safe-t, 0px) 0 calc(var(--safe-b, 0px) + 8px);
  --bg: #0a0a0a; --surface: #151515; --surface-2: #1c1c1c; --line: #242424;
  --ink: #fff; --ink-2: #8a8a8a; --ink-3: #5c5c5c; --neon: #e8ff00; --neon-ink: #0a0a0a; --bad: #ff5a5a;
  --sans: system-ui, -apple-system, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink); font-family: var(--sans);
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.plinko[hidden] { display: none; }
.plinko p, .plinko h2 { margin: 0; }
.plinko :where(button) { appearance: none; border: 0; margin: 0; padding: 0; font: inherit; color: inherit; background: none; cursor: pointer; }
.plinko button:focus-visible { outline: 2px solid var(--neon); outline-offset: 2px; }
.plinko img { -webkit-user-drag: none; pointer-events: none; }

/* ---------- 顶栏:返回、余额胶囊、帮助圆钮 ---------- */
.pk-top { position: relative; z-index: 3; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px 6px; }
/* 右边多了音符钮:左右两边各包一层、一样宽(flex 1 1 0),余额那颗才会一直在正中间;位子真的不够时余额自己省略,两边的钮不缩 */
.pk-top-start, .pk-top-end { flex: 1 1 0; display: flex; align-items: center; gap: 8px; }
.pk-top-end { justify-content: flex-end; }
/* 背景音乐开关:跟问号同一颗圆钮,开着点缀黄、关了灰(跟大厅、小鸡顶栏那颗一样) */
.pk-music { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border: 0; border-radius: 50%; background: var(--surface-2); box-shadow: inset 0 0 0 1px #2a2a2a; cursor: pointer; color: var(--gold); }
.pk-music[aria-pressed="false"] { color: var(--ink-2); }
.pk-music svg { width: 18px; height: 18px; }
/* regal.css 给所有 button 最少 44px 高:这两颗是 36px 的正圆,不拿掉会变成竖的椭圆 */
.pk-help, .pk-music { min-height: 0; }
.pk-back, .pk-help { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%; }
.pk-back svg { width: 22px; height: 22px; }
.pk-help { background: var(--surface-2); box-shadow: inset 0 0 0 1px #2a2a2a; font-size: 16px; font-weight: 700; }
.pk-bal { flex: 0 1 auto; min-width: 0; max-width: 56%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 7px 18px; border-radius: 999px; background: var(--surface-2); box-shadow: inset 0 0 0 1px #2a2a2a; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* 孔雀:右上角探头,压在钉板的右上角上 */
.pk-peacock { position: absolute; right: 2px; top: calc(var(--safe-t, 0px) + 40px); width: 86px; height: auto; z-index: 4; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .7)); }

/* ---------- 钉板 + 右侧最近结果 ---------- */
.pk-stage { flex: 1; min-height: 240px; display: flex; gap: 8px; padding: 4px 12px 0 16px; }
.pk-board {
  position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column;
  padding: 6px; border-radius: 16px;
  background: #1a1a1a;
  box-shadow: inset 0 0 0 1px #2a2a2a, inset 0 2px 0 rgba(255, 255, 255, .05), 0 10px 30px rgba(0, 0, 0, .6);
}
.pk-field { position: relative; flex: 1; min-height: 0; border-radius: 12px; background: #111; overflow: hidden; }
.pk-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pk-bins { flex: none; display: grid; grid-template-columns: repeat(var(--n, 17), minmax(0, 1fr)); gap: 1px; padding: 4px 0 0; }
.pk-bin {
  display: grid; place-items: center; min-width: 0; height: 20px; border-radius: 4px;
  background: var(--c, var(--neon)); color: var(--neon-ink);
  font-size: var(--fs, 8px); font-weight: 800; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1;
  overflow: hidden; white-space: nowrap;
}
.pk-bin.is-light { color: #fff; }
.pk-bin.is-hit { animation: pk-hit 420ms cubic-bezier(.2, .8, .3, 1); }
@keyframes pk-hit { 0% { transform: translateY(0); filter: brightness(1); } 25% { transform: translateY(4px); filter: brightness(1.6); box-shadow: 0 0 14px rgba(232, 255, 0, .7); } 100% { transform: translateY(0); filter: brightness(1); } }

.pk-recent { flex: none; width: 36px; display: flex; flex-direction: column; align-items: center; gap: 6px; align-self: flex-start; margin-top: 76px; padding: 8px 3px; border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px #2a2a2a; }
.pk-recent small { font-size: 9px; line-height: 1.1; color: var(--ink-2); text-align: center; white-space: nowrap; }
.pk-res { display: grid; place-items: center; width: 30px; height: 24px; border-radius: 6px; background: var(--c, var(--neon)); color: var(--neon-ink); font-size: 9px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pk-res.is-light { color: #fff; }
.pk-res:first-of-type { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .85); }
.pk-res.is-new { animation: pk-in 260ms cubic-bezier(.2, .8, .3, 1); }
@keyframes pk-in { from { transform: scale(.4); opacity: 0; } }

/* ---------- 控制区(设计稿下半) ---------- */
/* 只有一栏而且不准比面板宽(minmax(0, 1fr)):不然筹码那排的最小宽度会把整块撑出屏幕(320 宽的手机以前就超出 16px,八颗筹码之后更明显) */
.pk-panel { flex: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin: 8px 16px 0; padding: 10px 14px 12px; border-radius: 16px; background: var(--surface-2); box-shadow: inset 0 0 0 1px #262626; }
.pk-panel.pk-busy .pk-seg, .pk-panel.pk-busy .pk-slider { opacity: .55; pointer-events: none; }
.pk-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--ink-2); }
.pk-rowhead { position: relative; display: flex; align-items: center; height: 14px; }
.pk-rowval { position: absolute; left: max(64px, calc(14px + (100% - 28px) * var(--p, 1))); transform: translateX(-50%); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pk-slider { display: flex; align-items: center; gap: 10px; height: 26px; }
.pk-slider > span { flex: none; width: 18px; font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pk-slider > span:last-child { text-align: right; }
.pk-range { flex: 1; min-width: 0; height: 26px; margin: 0; appearance: none; -webkit-appearance: none; background: transparent; }
.pk-range::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--neon) 0, var(--neon) calc(var(--p, 1) * 100%), #3a3a3a calc(var(--p, 1) * 100%), #3a3a3a 100%); }
.pk-range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .6); }
.pk-range::-moz-range-track { height: 6px; border-radius: 3px; background: #3a3a3a; }
.pk-range::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--neon); }
.pk-range::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .6); }

.pk-seg { display: flex; padding: 3px; border-radius: 999px; background: #111; box-shadow: inset 0 0 0 1px #2a2a2a; }
.pk-seg button { flex: 1; min-width: 0; min-height: 30px; border-radius: 999px; font-size: 14px; font-weight: 700; color: var(--ink); }
.pk-seg button + button { position: relative; }
.pk-seg button + button::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 1px; background: #2e2e2e; }
.pk-seg button.is-on { background: var(--neon); color: var(--neon-ink); }
.pk-seg button.is-on::before, .pk-seg button.is-on + button::before { display: none; }

/* 圆筹码:深灰饼 + 柠檬色虚线边,数字白色(设计稿) */
.pk-coins { display: flex; justify-content: space-between; gap: 4px; }
.pk-coin {
  position: relative; flex: 1; min-width: 0; min-height: 0; max-width: 40px; aspect-ratio: 1; border-radius: 50%; /* min-height 0:regal.css 给所有 button 44px,窄的时候筹码会被撑成椭圆 */
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 36%, #303030 0%, #1b1b1b 74%);
  box-shadow: inset 0 0 0 1.5px rgba(232, 255, 0, .35), 0 2px 6px rgba(0, 0, 0, .6);
  font-size: 13px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums;
}
.pk-coin::before {
  content: ''; position: absolute; inset: 2px; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, var(--neon) 0 14deg, transparent 14deg 45deg);
  -webkit-mask-image: radial-gradient(circle, transparent 66%, #000 67%);
  mask-image: radial-gradient(circle, transparent 66%, #000 67%);
  opacity: .8;
}
.pk-coin.is-on { background: radial-gradient(circle at 50% 36%, #181818 0%, #0a0a0a 74%); box-shadow: inset 0 0 0 1.5px var(--neon), 0 0 10px rgba(232, 255, 0, .35); }
.pk-coin.is-on::before { opacity: 1; }
.pk-coin:active { transform: translateY(1px) scale(.94); }
.pk-coin:disabled { opacity: .3; }

.pk-betrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pk-amt { display: flex; align-items: center; gap: 4px; padding: 3px; border-radius: 999px; background: #111; box-shadow: inset 0 0 0 1px #2a2a2a; }
.pk-step { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #2a2a2a; font-size: 18px; font-weight: 700; line-height: 1; }
.pk-step:active { transform: scale(.94); }
.pk-input-wrap { display: flex; align-items: center; gap: 4px; min-width: 110px; justify-content: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.pk-input-wrap span { font-size: 13px; color: var(--ink-2, #9a9a9a); }
/* 字号一定 ≥16px:小于 16 的话 iOS 一聚焦就把整页放大 */
.pk-input { width: 76px; background: none; border: 0; color: #fff; font: inherit; font-size: 16px; font-weight: 800; text-align: center; outline: none; padding: 4px 0; }
.pk-input:focus { color: var(--neon); }
.pk-limit { margin: -4px 0 8px; text-align: right; font-size: 12px; color: var(--ink-2, #9a9a9a); }

.pk-drop {
  margin-top: 4px; min-height: 46px; border-radius: 999px;
  background: var(--neon); color: var(--neon-ink); font-size: 20px; font-weight: 800; letter-spacing: .04em;
  box-shadow: 0 0 22px rgba(232, 255, 0, .35), inset 0 -2px 0 rgba(0, 0, 0, .18);
}
.pk-drop:active:not(:disabled) { transform: scale(.985); box-shadow: 0 0 10px rgba(232, 255, 0, .25); }
.pk-drop:disabled { opacity: .35; box-shadow: none; }

/* 赢大了那一下:落格时在板上飘一行 */
.pk-flash { position: absolute; left: 50%; top: 42%; z-index: 2; transform: translate(-50%, -50%); padding: 8px 16px; border-radius: 999px; background: rgba(21, 21, 21, .92); box-shadow: inset 0 0 0 1px var(--line), 0 10px 30px rgba(0, 0, 0, .7); font-size: 22px; font-weight: 800; color: var(--neon); font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; animation: pk-flash 1.6s cubic-bezier(.2, .8, .3, 1) forwards; }
@keyframes pk-flash { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.8); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -80%); } }
/* 球落在 1x 以下:同一个位置飘一行净输的钱,比赢的那行小、红字、散得快 */
.pk-flash.is-loss { padding: 5px 12px; font-size: 15px; color: var(--bad); animation-duration: 1.1s; }

/* 规则页里的倍数表(弹层在 .plinko 外面,所以不加前缀) */
.pk-table { display: grid; grid-template-columns: repeat(var(--n, 17), minmax(0, 1fr)); gap: 2px; margin: 8px 0 12px; }
.pk-table .pk-bin { height: 22px; }
.pk-limits { list-style: none; padding: 0; margin: 6px 0 10px; display: grid; gap: 4px; font-size: 14px; }
.pk-limits li { display: flex; justify-content: space-between; gap: 8px; }
.pk-limits b { font-variant-numeric: tabular-nums; }
.pk-seedbox { display: grid; gap: 8px; margin: 10px 0; padding: 12px; border-radius: 14px; background: var(--surface, #151515); box-shadow: inset 0 0 0 1px var(--line, #242424); }
.pk-seedbox input { width: 100%; min-height: 40px; padding: 0 12px; border: 0; border-radius: 10px; background: #0f0f0f; color: #fff; font: inherit; font-size: 14px; box-shadow: inset 0 0 0 1px #2a2a2a; }
.pk-seedbox input:focus { outline: 0; box-shadow: inset 0 0 0 1px var(--neon, #e8ff00); }
.pk-seedbox .mono { word-break: break-all; }
.pk-check { display: flex; align-items: center; gap: 8px; padding: 8px 0; font-size: 14px; border-top: 1px dashed var(--line, #242424); }
.pk-check.ok b { color: var(--neon, #e8ff00); }
.pk-check.bad b { color: var(--bad, #ff5a5a); }

@media (prefers-reduced-motion: reduce) { .pk-bin.is-hit, .pk-res.is-new, .pk-flash { animation: none; } }
@media (max-height: 700px) {
  .pk-panel { gap: 4px; padding: 8px 12px 10px; }
  .pk-drop { min-height: 42px; }
  .pk-coin { max-width: 36px; }
  .pk-stage { min-height: 220px; }
}

/* 一次丢几颗:小号四段 */
.pk-countrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 8px; }
.pk-seg-s { flex: 0 0 auto; min-width: 184px; } /* 四段:1 / 5 / 10 / 20 */
.pk-seg-s button { padding: 6px 0; font-size: 14px; }
/* 320 宽的小手机:八颗筹码一颗不到 30px,三位数(100 / 200 / 500)字缩一号才不压到虚线边;丢几颗那排也收窄一点 */
@media (max-width: 340px) { .pk-coins { gap: 3px; } .pk-coin { font-size: 11px; } .pk-seg-s { min-width: 164px; } }
