/* ========== 跑马机 H5 样式 ========== */
/* 使用项目 assets 背景，移动端优先，touch-action 优化触屏 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --gold: #f6c453;
  --gold-dark: #b8860b;
  --win-flash: #ff6b6b;
  --panel-bg: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.25);
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: #fff7ed;
  background: #a03a3a;
  overflow-x: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* 左上角返回首页 */
.back-to-home {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 6px 12px;
  font-size: 14px;
  color: #fff7ed;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.back-to-home:hover {
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
}

/* ---------- 背景层（复用 assets） ---------- */
.page {
  min-height: 100vh;
  position: relative;
  padding: 20px 16px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.page__bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.page__bg-title,
.page__bg-body,
.page__bg-end {
  position: absolute;
  left: 0;
  right: 0;
  background-position: center top;
  background-repeat: no-repeat;
  background-size: 100% auto;
}

.page__bg-title {
  top: 0;
  background-image: none;
}

.page__bg-body {
  background-image: none;
  background-repeat: repeat-y;
}

.page__bg-end {
  bottom: 0;
  background-image: none;
  background-position: center bottom;
}

/* ---------- 内容区（跑马机 + 介绍） ---------- */
.slot-wrap {
  position: relative;
  z-index: 5;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* 页头装饰：与主文案/跑马机同宽 */
.page-header {
  width: 100%;
  max-width: 336px;
  line-height: 0;
  background: #a03a3a;
}

.page-header__img {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: top;
}

/* 页尾装饰图：与主文案/跑马机同宽 */
.page-footer {
  width: 100%;
  max-width: 336px;
  line-height: 0;
  background: #a03a3a;
}

.page-footer__img {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: top;
}

/* 玩法介绍：宽度与跑马机外框对齐（跑马机 = 320 + 左右 padding 8*2 = 336px） */
.intro {
  width: 100%;
  max-width: 336px;
  padding: 12px 16px;
  background: var(--panel-bg);
  border-radius: 12px;
  border: 1px solid var(--border-light);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.intro__main {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.95);
}

/* 跑马机下方：中奖率行（文案 + 修改链接）+ 状态 */
.slot-footer {
  width: 100%;
  max-width: 336px;
  text-align: center;
}

.slot-rate-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 2em;
  margin-bottom: 6px;
}

.slot-rate {
  margin: 0;
  font-size: 13px;
  color: var(--gold);
  font-weight: 600;
}

.slot-rule {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--gold);
  font-weight: 600;
}

.slot-rate-link {
  font-size: 13px;
  color: var(--gold);
  font-weight: 600;
  text-decoration: underline;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.slot-rate-link:hover {
  color: #ffd966;
  text-decoration: underline;
}

/* 状态文案（动态：提示 / 滚动中 / 中奖 / 未中奖） */
.status {
  margin: 0;
  min-height: 28px;
  font-size: 15px;
  font-weight: 600;
  color: var(--gold);
  text-align: center;
  text-shadow: 0 0 8px rgba(246, 196, 83, 0.35);
}

/* ---------- 跑马机外框 + 灯珠 ---------- */
.machine-wrap {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}

.machine-lights {
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 344px;
  pointer-events: none;
  z-index: 2;
}

.light {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold), 0 0 12px rgba(246, 196, 83, 0.6);
  animation: light-flicker 1.2s ease-in-out infinite;
}

.light--1  { top: 0;   left: 5%;   animation-delay: 0s; }
.light--2  { top: 0;   left: 35%; animation-delay: 0.2s; }
.light--3  { top: 0;   left: 65%; animation-delay: 0.4s; }
.light--4  { top: 0;   left: 95%; animation-delay: 0.1s; }
.light--5  { right: 0; top: 20%;  left: auto; animation-delay: 0.3s; }
.light--6  { right: 0; top: 50%;  left: auto; animation-delay: 0.05s; }
.light--7  { right: 0; top: 80%;  left: auto; animation-delay: 0.25s; }
.light--8  { bottom: 0; left: 95%; animation-delay: 0.15s; }
.light--9  { bottom: 0; left: 65%; animation-delay: 0.35s; }
.light--10 { bottom: 0; left: 35%; animation-delay: 0.1s; }
.light--11 { bottom: 0; left: 5%;  animation-delay: 0.45s; }
.light--12 { left: 0;  top: 50%;  animation-delay: 0.2s; }

@keyframes light-flicker {
  0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 8px var(--gold), 0 0 12px rgba(246, 196, 83, 0.6); }
  50%     { opacity: 0.5; transform: scale(0.9); box-shadow: 0 0 4px var(--gold), 0 0 6px rgba(246, 196, 83, 0.3); }
}

.machine-frame {
  position: relative;
  width: 100%;
  max-width: 336px;
  padding: 8px;
  background: linear-gradient(145deg, rgba(0,0,0,0.35), rgba(0,0,0,0.2));
  border-radius: 16px;
  border: 2px solid var(--border-light);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255,255,255,0.08);
  z-index: 1;
}

/* 中奖高亮区：中间一行，默认呼吸灯 */
.win-zone {
  position: absolute;
  top: 50%;
  left: 8px;
  right: 8px;
  height: 80px;
  transform: translateY(-50%);
  border: 3px solid var(--gold);
  border-radius: 10px;
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 0 12px var(--gold), inset 0 0 12px rgba(246, 196, 83, 0.2);
  background: rgba(246, 196, 83, 0.12);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.win-zone.pulse {
  animation: slot-pulse 2s ease-in-out infinite;
}

.win-zone.win-flash {
  animation: slot-flash 0.15s ease-in-out infinite;
  border-color: var(--win-flash);
  background: rgba(255, 107, 107, 0.25);
}

@keyframes slot-pulse {
  0%, 100% { box-shadow: 0 0 10px var(--gold), inset 0 0 8px rgba(246, 196, 83, 0.15); opacity: 0.85; }
  50%      { box-shadow: 0 0 20px var(--gold), inset 0 0 16px rgba(246, 196, 83, 0.25); opacity: 1; }
}

@keyframes slot-flash {
  0%, 100% { box-shadow: 0 0 18px var(--win-flash), inset 0 0 10px rgba(255, 107, 107, 0.3); border-color: var(--win-flash); }
  50%      { box-shadow: 0 0 28px var(--gold), inset 0 0 14px rgba(246, 196, 83, 0.35); border-color: var(--gold); }
}

/* Canvas：固定宽高比，避免不占位；不支持 aspect-ratio 时用 min-height 兜底 */
#slot-canvas {
  display: block;
  width: 100%;
  max-width: 320px;
  min-height: 240px;
  height: auto;
  aspect-ratio: 320 / 240;
  background: #fff;
  border-radius: 8px;
  box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.12);
  vertical-align: top;
}

/* ---------- 按钮 ---------- */
.controls {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.btn {
  border: none;
  outline: none;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.btn-spin {
  padding: 14px 32px;
  font-size: 17px;
  font-weight: 700;
  color: #7a1c1c;
  background: linear-gradient(to bottom, var(--gold), var(--gold-dark));
  box-shadow: 0 4px 0 #8a6508, 0 6px 12px rgba(0, 0, 0, 0.25);
  border-radius: 999px;
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn-spin:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #8a6508, 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-spin:disabled {
  background: #666 !important;
  box-shadow: 0 2px 0 #444 !important;
  color: #ccc;
  cursor: not-allowed;
  opacity: 0.8;
}

/* ---------- 修改中奖率弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal[hidden] {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal__box {
  position: relative;
  width: 100%;
  max-width: 320px;
  padding: 20px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.modal__title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
  color: #333;
  text-align: center;
}

.modal__hint {
  margin: 0 0 16px;
  font-size: 12px;
  line-height: 1.5;
  color: #666;
}

.modal__field {
  margin-bottom: 20px;
}

.modal__field label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: #333;
}

.modal__field input {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;
  color: #333;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  box-sizing: border-box;
}

.modal__field input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(246, 196, 83, 0.3);
}

.modal__actions {
  display: flex;
  justify-content: center;
}

.btn-modal-ok {
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 600;
  color: #7a1c1c;
  background: linear-gradient(to bottom, var(--gold), var(--gold-dark));
  border-radius: 999px;
  box-shadow: 0 3px 0 #8a6508;
}

.btn-modal-ok:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 #8a6508;
}

/* 撒花画布：全屏置顶，不阻挡点击 */
.confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  pointer-events: none;
}

@media (max-width: 380px) {
  .page { padding: 16px 12px 24px; }
  .intro { padding: 10px 12px; }
  .intro__main { font-size: 13px; }
  .status { font-size: 14px; }
}
