/* 推币机 · 街机投币机箱原生视窗
   左：投币滑轨与力度推杆（非对称） / 中：玻璃观察窗舞台 / 右：奖品陈列柜 */

:root {
  --ink: #eaf0ff;
  --ink-dim: #9aa8c8;
  --neon-pink: #ff5f9e;
  --neon-cyan: #42e2ff;
  --gold: #f6c33c;
  --gold-hi: #ffe9a8;
  --cab-hi: #38425f;
  --cab-lo: #12172450;
  --plate: rgba(30, 38, 60, 0.72);
  --plate-line: rgba(140, 175, 255, 0.16);
  --wood: #6d4522;
  --wood-hi: #9a6733;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 640px at 18% -10%, rgba(255, 95, 158, 0.16), transparent 62%),
    radial-gradient(900px 620px at 88% 6%, rgba(66, 226, 255, 0.14), transparent 60%),
    radial-gradient(1200px 800px at 50% 118%, rgba(246, 195, 60, 0.12), transparent 62%),
    linear-gradient(178deg, #0d1220 0%, #131a2c 48%, #0a0e18 100%);
  background-attachment: fixed;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='160' height='160' filter='url(%23n)' opacity='0.7'/></svg>");
  mix-blend-mode: overlay;
}

#cabinet {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 14px 14px max(18px, env(safe-area-inset-bottom));
}

/* ---------------- 霓虹招牌 ---------------- */

#marquee {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-radius: var(--radius) var(--radius) 6px 6px;
  background: linear-gradient(180deg, #2b3450 0%, #1a2135 100%);
  border: 1px solid rgba(150, 185, 255, 0.18);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -12px 26px rgba(0, 0, 0, 0.45),
    0 14px 34px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

#marquee::after {
  content: "";
  position: absolute;
  inset: -40% -10% auto -10%;
  height: 70%;
  background: linear-gradient(96deg, transparent 20%, rgba(255, 255, 255, 0.13) 48%, transparent 74%);
  animation: marqueeSheen 7.5s linear infinite;
  pointer-events: none;
}

@keyframes marqueeSheen {
  0% { transform: translateX(-60%); }
  100% { transform: translateX(60%); }
}

#stage-title {
  flex: 1;
  margin: 0;
  font-size: clamp(20px, 3.4vw, 30px);
  letter-spacing: 0.24em;
  text-align: center;
  color: #fff4d8;
  text-shadow:
    0 0 6px rgba(255, 95, 158, 0.9),
    0 0 18px rgba(255, 95, 158, 0.55),
    0 0 34px rgba(66, 226, 255, 0.35);
}

#back-home {
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 13px;
  padding: 7px 11px;
  border-radius: 9px;
  border: 1px solid var(--plate-line);
  background: rgba(12, 18, 32, 0.6);
  white-space: nowrap;
  transition: color 0.16s, border-color 0.16s, transform 0.16s;
}

#back-home:hover { color: var(--ink); border-color: rgba(255, 95, 158, 0.6); transform: translateY(-2px); }

.marquee-actions { display: flex; gap: 7px; }

.bar-btn {
  font: inherit;
  font-size: 13px;
  min-width: 36px;
  padding: 7px 10px;
  color: var(--ink);
  background: linear-gradient(180deg, #3c4767, #232b42);
  border: 1px solid rgba(150, 185, 255, 0.24);
  border-radius: 9px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 3px 8px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s, filter 0.12s;
}

.bar-btn:hover { transform: translateY(-2px); filter: brightness(1.12); }
.bar-btn:active { transform: translateY(1px); }

/* ---------------- 机箱主体 ---------------- */

#cab-body {
  display: grid;
  grid-template-columns: minmax(158px, 196px) minmax(0, 1fr) minmax(190px, 244px);
  gap: 14px;
  align-items: start;
  margin-top: 12px;
}

.plate {
  position: relative;
  padding: 11px 12px;
  border-radius: 12px;
  background: var(--plate);
  border: 1px solid var(--plate-line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 10px 22px rgba(0, 0, 0, 0.34);
  margin-bottom: 12px;
}

.plate-label {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--gold-hi);
  text-transform: uppercase;
}

.lcd {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #d9ffef;
  text-shadow: 0 0 8px rgba(80, 255, 200, 0.45);
}

.readout {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--ink-dim);
}

.readout .lcd { font-size: 15px; }

/* ---------------- 左：投币口示意（固定口 + 挡杆，不可瞄准） ---------------- */

#chute-diagram {
  position: relative;
  height: 88px;
  border-radius: 9px;
  background: linear-gradient(180deg, #0b1020, #141c30);
  border: 1px solid rgba(150, 185, 255, 0.22);
  box-shadow: inset 0 3px 9px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

#chute-diagram > span { position: absolute; }

.chute-slot {
  top: 9px;
  left: 50%;
  width: 36px;
  height: 12px;
  margin-left: -18px;
  border-radius: 4px 4px 8px 8px;
  background: linear-gradient(180deg, #7d8dad, #262f44);
  border: 1px solid rgba(255, 206, 130, 0.62);
}

.chute-peg {
  top: 34px;
  width: 5px;
  height: 15px;
  border-radius: 3px;
  background: linear-gradient(90deg, #2b3448, #d7e2f7 45%, #3d4761);
  box-shadow: 0 0 6px rgba(160, 200, 255, 0.35);
}

#chute-diagram > .chute-peg:nth-child(2) { left: calc(50% - 30px); }
#chute-diagram > .chute-peg:nth-child(3) { left: calc(50% - 2px); }
#chute-diagram > .chute-peg:nth-child(4) { left: calc(50% + 26px); }

.chute-drop {
  top: 20px;
  left: 50%;
  width: 11px;
  height: 8px;
  margin-left: -6px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fff3c9, #e8b13c 58%, #a06f10);
  box-shadow: 0 0 10px rgba(255, 190, 90, 0.55);
  animation: chute-drop 2.4s ease-in infinite;
}

@keyframes chute-drop {
  0% { top: 20px; opacity: 0; }
  15% { opacity: 1; }
  100% { top: 78px; opacity: 0; }
}

#effect-lamps { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }

.lamp {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--ink-dim);
  background: rgba(12, 18, 32, 0.7);
  border: 1px solid var(--plate-line);
  transition: color 0.18s, box-shadow 0.18s, border-color 0.18s;
}

.lamp.on {
  color: #0d1220;
  font-weight: 800;
  border-color: rgba(255, 225, 150, 0.85);
  background: linear-gradient(180deg, #ffe9a8, #f6c33c);
  box-shadow: 0 0 16px rgba(246, 195, 60, 0.7);
}

#ladder { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }

#ladder li {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 7px;
  color: var(--ink-dim);
  background: rgba(12, 18, 32, 0.55);
  border-left: 3px solid rgba(150, 185, 255, 0.22);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

#ladder li.on {
  color: #1a1206;
  font-weight: 800;
  background: linear-gradient(90deg, #ffd166, #ff9d4d);
  border-left-color: #ff5f9e;
}

/* ---------------- 中：玻璃观察窗 ---------------- */

#glass-stage { min-width: 0; }

#hud-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 9px 10px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(24, 31, 50, 0.9), rgba(14, 19, 32, 0.9));
  border: 1px solid var(--plate-line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 10px 22px rgba(0, 0, 0, 0.34);
}

.hud-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hud-cell i { font-style: normal; font-size: 10px; letter-spacing: 0.1em; color: var(--ink-dim); }
.hud-cell b { font-size: clamp(13px, 1.7vw, 19px); }

#mode-line {
  margin: 9px 2px;
  font-size: 12px;
  color: var(--ink-dim);
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

#mode-line .dot { opacity: 0.5; }

#glass-wrap {
  position: relative;
  border-radius: 16px;
  padding: 10px;
  background: linear-gradient(180deg, #232c45, #131a2b);
  border: 1px solid rgba(150, 185, 255, 0.2);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.1),
    inset 0 -18px 40px rgba(0, 0, 0, 0.55),
    0 18px 40px rgba(0, 0, 0, 0.5);
}

#table {
  display: block;
  /* 斜俯视 2.5D 投影后的可视比例 ≈ 1.1290（见 render.mjs 的 viewAspect()）
     竖向刻意留足：机顶灯箱 / 投币滑道 / 挡杆帘 / 落币竖井 / 托盘都在画面里 */
  width: min(100%, calc((100vh - 318px) * 1.129));
  width: min(100%, calc((100dvh - 318px) * 1.129));
  max-width: 100%;
  aspect-ratio: 14.56 / 12.9;
  margin: 0 auto;
  border-radius: 12px;
  background: #0e1422;
  box-shadow: inset 0 0 0 1px rgba(150, 185, 255, 0.16), inset 0 0 40px rgba(0, 0, 0, 0.7);
  touch-action: none;
  overscroll-behavior: none;
  cursor: crosshair;
}

#toast {
  position: absolute;
  left: 50%;
  top: 10%;
  transform: translate(-50%, -8px);
  max-width: 84%;
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: #1a1206;
  background: linear-gradient(180deg, #ffe9a8, #f6c33c);
  box-shadow: 0 8px 26px rgba(246, 195, 60, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  text-align: center;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.warn { background: linear-gradient(180deg, #ffc0d5, #ff5f9e); box-shadow: 0 8px 26px rgba(255, 95, 158, 0.45); }

/* ---------------- 浮层 ---------------- */

.overlay {
  position: absolute;
  inset: 10px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  text-align: center;
  background: linear-gradient(180deg, rgba(9, 13, 23, 0.93), rgba(15, 21, 36, 0.95));
  backdrop-filter: blur(7px);
  overflow-y: auto;
  z-index: 5;
}

.overlay h2 {
  margin: 0;
  font-size: clamp(19px, 2.8vw, 26px);
  letter-spacing: 0.12em;
  color: #fff4d8;
  text-shadow: 0 0 10px rgba(255, 95, 158, 0.7), 0 0 26px rgba(66, 226, 255, 0.3);
}

.overlay p { margin: 0; font-size: 13px; line-height: 1.6; max-width: 46em; color: var(--ink-dim); }

.dim { color: var(--ink-dim); }

.menu-label {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--ink-dim);
}

#credit-grid { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.credit-btn {
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  min-width: 96px;
  padding: 12px 18px;
  color: var(--ink);
  background: linear-gradient(180deg, #36415f, #202839);
  border: 1px solid rgba(150, 185, 255, 0.24);
  border-radius: 11px;
  cursor: pointer;
  transition: transform 0.14s, filter 0.14s, border-color 0.14s, box-shadow 0.14s;
}

.credit-btn:hover { transform: translateY(-2px); filter: brightness(1.12); }
.credit-btn:active { transform: translateY(1px); }
.credit-btn.active {
  color: #fff;
  border-color: rgba(255, 206, 130, 0.9);
  box-shadow: 0 0 20px rgba(255, 190, 90, 0.45);
  background: linear-gradient(180deg, #5a4a26, #33280f);
}

.menu-footer { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--ink-dim); }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ---------------- 右：掉落记录（得分的唯一去处） ---------------- */

#drop-log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 30px;
}

.drop-row {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 7px;
  padding: 4px 7px;
  border-radius: 7px;
  background: rgba(12, 18, 32, 0.66);
  border: 1px solid var(--plate-line);
  animation: drop-in 0.26s ease-out;
}

@keyframes drop-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.drop-row .chip { width: 14px; height: 14px; }
.drop-gain { font-size: 12.5px; color: var(--gold-hi); letter-spacing: 0.02em; }
.drop-meta { font-style: normal; font-size: 11px; color: var(--ink-dim); }
.drop-row.kind-gold .drop-gain { color: #ffd97a; }
.drop-row.kind-gem .drop-gain { color: #8fe6ff; }
.drop-row.kind-tower .drop-gain { color: #fff0b8; }

/* ---------------- 木制操作托盘 ---------------- */

#deck {
  display: flex;
  gap: 9px;
  margin-top: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--wood-hi), var(--wood) 62%, #4a2d13);
  border: 1px solid rgba(255, 220, 170, 0.24);
  box-shadow: inset 0 1px 0 rgba(255, 226, 180, 0.3), inset 0 -10px 22px rgba(0, 0, 0, 0.4), 0 12px 26px rgba(0, 0, 0, 0.4);
}

.deck-btn {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  flex: 1;
  padding: 12px 10px;
  color: #f6ecdc;
  background: linear-gradient(180deg, #4a3a2a, #2c2318);
  border: 1px solid rgba(255, 226, 180, 0.28);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 4px 10px rgba(0, 0, 0, 0.4);
  transition: transform 0.12s, filter 0.12s;
}

.deck-btn:hover { transform: translateY(-2px); filter: brightness(1.12); }
.deck-btn:active { transform: translateY(2px); }
.deck-btn:disabled { opacity: 0.42; cursor: not-allowed; transform: none; filter: none; }

.deck-btn.primary {
  color: #23180a;
  background: linear-gradient(180deg, #ffe9a8, #f6c33c 58%, #d79a12);
  border-color: rgba(120, 74, 4, 0.6);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.deck-btn.insert { flex: 1.6; font-size: 17px; letter-spacing: 0.16em; }

#key-tip, #touch-tip { margin: 9px 2px 0; font-size: 11.5px; line-height: 1.5; text-align: center; }
#touch-tip { display: none; }

/* ---------------- 右：奖品陈列柜 ---------------- */

#prize-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }

.prize-item {
  display: grid;
  grid-template-columns: 20px 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  padding: 6px 7px;
  border-radius: 9px;
  background: rgba(12, 18, 32, 0.5);
  border: 1px solid rgba(150, 185, 255, 0.1);
}

.chip {
  grid-row: span 2;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.4), 0 0 8px rgba(0, 0, 0, 0.4);
}

.coin-norm { background: radial-gradient(circle at 34% 30%, #ffe9a8, #e8b13c 60%, #a76f14); }
.coin-gold { background: radial-gradient(circle at 34% 30%, #fff6cf, #f7c945 58%, #c07f0c); }
.coin-gem { background: radial-gradient(circle at 34% 30%, #e6fbff, #63d3f0 58%, #1668a8); }
.tok-card { border-radius: 4px; background: linear-gradient(135deg, #ffd166, #c8860c); }
.tok-launch { background: radial-gradient(circle at 50% 50%, #ff9d4d, #4a2d13 70%); }
.tok-magnet { background: radial-gradient(circle at 34% 30%, #cfe2ff, #2b4b8a 62%, #101a2e); }
.tok-tower { background: radial-gradient(circle at 34% 30%, #fff8d6, #f6c33c 52%, #8d5a04); }

.prize-name { font-size: 12px; font-weight: 700; color: var(--ink); }
.prize-val { font-size: 10.5px; color: var(--ink-dim); }

/* ---------------- 响应式 ---------------- */

@media (max-width: 1024px) {
  #cab-body { grid-template-columns: minmax(140px, 172px) minmax(0, 1fr); }
  #prize-panel { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; align-items: start; }
  #prize-panel .plate { margin-bottom: 0; }
}

@media (max-width: 768px) {
  #cabinet { padding: 10px 10px max(68px, calc(16px + env(safe-area-inset-bottom))); }
  #cab-body { display: flex; flex-direction: column; gap: 10px; }
  #glass-stage { order: 1; }
  #rail-panel { order: 2; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: start; }
  #rail-panel .plate { margin-bottom: 0; }
  #prize-panel { order: 3; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; align-items: start; }
  #stage-title { letter-spacing: 0.12em; }
  #table { width: min(100%, calc((100dvh - 300px) * 1.129)); }
  #key-tip { display: none; }
  #touch-tip { display: block; }
  .overlay { inset: 6px; padding: 14px 12px; }
  #chute-diagram { height: 62px; }
  #hud-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
  #deck { flex-wrap: wrap; }
  .deck-btn.insert { flex-basis: 100%; }
  #credit-grid { flex-direction: column; }
  .credit-btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  #marquee::after { animation: none; }
  *, *::before, *::after { transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
  .bar-btn:hover, .deck-btn:hover, .credit-btn:hover { transform: none; }
}
