/* ══════════════════════════════════════════════════════════
   幸运老虎机 —— 样式
   ══════════════════════════════════════════════════════════ */

:root {
  --row-h: clamp(64px, 17vw, 90px);
  --rows: 3;

  --gold:      #ffd36e;
  --gold-deep: #e8a52c;
  --gold-soft: #ffe9b0;

  --ink:       #f4f0ff;
  --ink-dim:   #b9b0d6;
  --ink-faint: #8b81ad;

  --bg-0: #0d0722;
  --bg-1: #1a0f3d;
  --bg-2: #2a1259;

  --card:      rgba(255, 255, 255, .055);
  --card-line: rgba(255, 255, 255, .11);

  --radius: 20px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC",
          system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding: 24px 16px calc(32px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
}

/* ─────────────── 背景装饰 ─────────────── */

.aurora {
  position: fixed;
  inset: -20% -20% -20% -20%;
  z-index: -2;
  background:
    radial-gradient(48% 38% at 18% 12%, rgba(124, 58, 237, .55), transparent 65%),
    radial-gradient(42% 34% at 84% 18%, rgba(236, 72, 153, .38), transparent 62%),
    radial-gradient(55% 45% at 50% 108%, rgba(56, 189, 248, .32), transparent 66%),
    linear-gradient(170deg, var(--bg-1) 0%, var(--bg-0) 55%, #07031a 100%);
  animation: drift 22s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(-1.5%, -1%, 0) scale(1.02); }
  to   { transform: translate3d(1.5%, 1.5%, 0) scale(1.06); }
}

.stars {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .5;
  background-image:
    radial-gradient(1.4px 1.4px at 12% 22%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 32% 68%, #ffe9b0, transparent),
    radial-gradient(1.6px 1.6px at 58% 14%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 76% 52%, #d8c9ff, transparent),
    radial-gradient(1.4px 1.4px at 88% 82%, #fff, transparent),
    radial-gradient(1.1px 1.1px at 44% 38%, #fff, transparent),
    radial-gradient(1.3px 1.3px at 8% 86%, #ffe9b0, transparent),
    radial-gradient(1.1px 1.1px at 66% 92%, #fff, transparent);
  animation: twinkle 5.5s ease-in-out infinite alternate;
}

@keyframes twinkle {
  from { opacity: .28; }
  to   { opacity: .62; }
}

/* ─────────────── 布局 ─────────────── */

.wrap {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.head { text-align: center; }

.head h1 {
  margin: 8px 0 6px;
  font-size: clamp(26px, 7.4vw, 38px);
  font-weight: 900;
  letter-spacing: .02em;
  line-height: 1.25;
  background: linear-gradient(180deg, #fff8e2 0%, var(--gold) 46%, var(--gold-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 14px rgba(255, 190, 70, .35));
}

.head p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-dim);
  letter-spacing: .04em;
}

/* ─────────────── 老虎机 ─────────────── */

.machine {
  position: relative;
  border-radius: 26px;
  padding: 14px 14px 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.02) 30%),
    linear-gradient(160deg, #3a1d6e 0%, #241046 46%, #17092f 100%);
  border: 1.5px solid rgba(255, 211, 110, .34);
  box-shadow:
    0 26px 60px -18px rgba(0, 0, 0, .85),
    0 0 0 1px rgba(0, 0, 0, .35) inset,
    0 0 70px -22px rgba(255, 190, 70, .5);
}

.machine-bar {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 6px;
  padding: 2px 6px 12px;
}

.lamp {
  height: 7px;
  border-radius: 99px;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold-deep));
  box-shadow: 0 0 10px rgba(255, 200, 90, .85);
  animation: lamp 1.35s ease-in-out infinite;
}
.lamp:nth-child(2n)   { animation-delay: .16s; }
.lamp:nth-child(3n)   { animation-delay: .32s; }
.lamp:nth-child(4n+1) { animation-delay: .48s; }

@keyframes lamp {
  0%, 100% { opacity: .32; box-shadow: 0 0 5px rgba(255, 200, 90, .4); }
  50%      { opacity: 1;   box-shadow: 0 0 14px rgba(255, 210, 110, 1); }
}

.machine.spinning .lamp { animation-duration: .5s; }

/* 滚轮窗口 */
.window {
  position: relative;
  height: calc(var(--row-h) * var(--rows));
  overflow: hidden;
  border-radius: 16px;
  background: linear-gradient(180deg, #0a0518, #150a2e 50%, #0a0518);
  border: 1px solid rgba(255, 211, 110, .22);
  box-shadow: inset 0 12px 28px -14px rgba(0,0,0,.95), inset 0 -12px 28px -14px rgba(0,0,0,.95);
}

.reel {
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

.reel-item {
  height: var(--row-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 14px;
  text-align: center;
  font-size: clamp(14px, 3.9vw, 17px);
  font-weight: 700;
  color: #efe8ff;
  letter-spacing: .01em;
  border-bottom: 1px solid rgba(255, 255, 255, .045);
}

.reel-item .ic {
  font-size: 1.5em;
  line-height: 1;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,.5));
}

.reel-item .nm {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 78%;
}

/* 中线 */
.payline {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 50%;
  height: var(--row-h);
  transform: translateY(-50%);
  border-top: 1.5px solid rgba(255, 211, 110, .55);
  border-bottom: 1.5px solid rgba(255, 211, 110, .55);
  background: linear-gradient(90deg, rgba(255,211,110,.09), rgba(255,211,110,.02) 45%, rgba(255,211,110,.09));
  pointer-events: none;
  transition: border-color .25s, background .25s;
}

.machine.result .payline {
  border-color: rgba(255, 226, 150, .95);
  background: linear-gradient(90deg, rgba(255,211,110,.24), rgba(255,211,110,.09) 45%, rgba(255,211,110,.24));
  box-shadow: 0 0 26px rgba(255, 200, 90, .5);
}

.fade {
  position: absolute;
  left: 0;
  right: 0;
  height: calc(var(--row-h) * .78);
  pointer-events: none;
}
.fade.top    { top: 0;    background: linear-gradient(180deg, rgba(8,3,20,.96), rgba(8,3,20,0)); }
.fade.bottom { bottom: 0; background: linear-gradient(0deg,   rgba(8,3,20,.96), rgba(8,3,20,0)); }

.glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255,255,255,.09) 0%, rgba(255,255,255,0) 34%, rgba(255,255,255,0) 62%, rgba(255,255,255,.05) 100%);
}

.machine.spinning .reel { filter: blur(1.5px); }
.machine.spinning .reel { transition: filter .18s linear; }
.machine:not(.spinning) .reel { filter: blur(0); transition: filter .22s ease-out .1s; }

/* 抽奖按钮 */
.spin {
  position: relative;
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 17px 20px;
  border: 0;
  border-radius: 15px;
  font-family: inherit;
  font-size: clamp(16px, 4.4vw, 19px);
  font-weight: 900;
  letter-spacing: .1em;
  color: #3a1e00;
  cursor: pointer;
  background: linear-gradient(180deg, #ffeab4 0%, var(--gold) 40%, #f0a92a 100%);
  box-shadow:
    0 6px 0 #a86f10,
    0 16px 30px -10px rgba(255, 180, 60, .6),
    inset 0 1px 0 rgba(255,255,255,.85);
  transition: transform .09s ease, box-shadow .09s ease, filter .2s;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

.spin::after {
  content: "";
  position: absolute;
  top: 0; left: -60%;
  width: 45%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.75), transparent);
  transform: skewX(-18deg);
  animation: sheen 3.2s ease-in-out infinite;
}

@keyframes sheen {
  0%, 62% { left: -60%; }
  86%, 100% { left: 130%; }
}

.spin:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #a86f10, 0 8px 18px -10px rgba(255, 180, 60, .5), inset 0 1px 0 rgba(255,255,255,.85);
}

.spin:disabled {
  cursor: not-allowed;
  filter: grayscale(.55) brightness(.78);
  box-shadow: 0 6px 0 #5c4a2a, inset 0 1px 0 rgba(255,255,255,.3);
}

.spin:disabled::after { animation: none; opacity: 0; }

.hint {
  margin: 12px 0 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-faint);
  min-height: 18px;
  letter-spacing: .02em;
}

/* ─────────────── 卡片 ─────────────── */

.card {
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  background: var(--card);
  border: 1px solid var(--card-line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.card-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--gold-soft);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.card-title small {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-faint);
  letter-spacing: 0;
}

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

.prize {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .055);
  font-size: 14px;
}

.prize.gone { opacity: .38; }

.prize .ic { font-size: 20px; line-height: 1; width: 24px; text-align: center; flex: none; }
.prize .nm { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.prize .pct {
  flex: none;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 13px;
  color: var(--gold);
  background: rgba(255, 211, 110, .1);
  border: 1px solid rgba(255, 211, 110, .22);
  padding: 2px 8px;
  border-radius: 99px;
}

.prize .left {
  flex: none;
  font-size: 11.5px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  min-width: 46px;
  text-align: right;
}

.prize .left.low { color: #ff9f6e; }

.recent li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 4px;
  font-size: 13px;
  color: var(--ink-dim);
  border-bottom: 1px dashed rgba(255, 255, 255, .07);
}
.recent li:last-child { border-bottom: 0; }
.recent .who { color: var(--ink-faint); font-size: 12px; flex: none; }
.recent .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent .what.win { color: var(--gold-soft); font-weight: 600; }
.recent .when { flex: none; font-size: 11.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.recent .empty { justify-content: center; color: var(--ink-faint); border: 0; padding: 10px 0; }

.foot {
  text-align: center;
  font-size: 11.5px;
  color: rgba(255, 255, 255, .26);
  line-height: 1.7;
  padding-top: 4px;
}

/* ─────────────── 中奖弹窗 ─────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(6, 2, 16, .74);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: fadeIn .22s ease;
}

.modal[hidden] { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  position: relative;
  width: 100%;
  max-width: 340px;
  padding: 30px 24px 24px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(170deg, #2c1560 0%, #1a0b3a 60%, #12062a 100%);
  border: 1.5px solid rgba(255, 211, 110, .48);
  box-shadow: 0 30px 70px -20px rgba(0,0,0,.9), 0 0 80px -20px rgba(255, 190, 70, .55);
  animation: pop .42s cubic-bezier(.2, 1.5, .4, 1);
}

@keyframes pop {
  from { transform: scale(.82) translateY(16px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-icon {
  font-size: 60px;
  line-height: 1;
  margin-bottom: 12px;
  animation: bob 1.5s ease-in-out infinite;
  filter: drop-shadow(0 8px 18px rgba(255, 190, 70, .55));
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-9px) rotate(4deg); }
}

.modal-title {
  margin: 0 0 10px;
  font-size: 21px;
  font-weight: 900;
  letter-spacing: .06em;
  background: linear-gradient(180deg, #fff8e2, var(--gold) 55%, var(--gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.modal-prize {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  line-height: 1.5;
  word-break: break-word;
}

.modal-sub {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--ink-faint);
  min-height: 17px;
}

.modal-btn {
  margin-top: 22px;
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 13px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .06em;
  color: #3a1e00;
  cursor: pointer;
  background: linear-gradient(180deg, #ffeab4, var(--gold) 45%, #f0a92a);
  box-shadow: 0 5px 0 #a86f10, inset 0 1px 0 rgba(255,255,255,.8);
  transition: transform .09s;
}

.modal-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #a86f10, inset 0 1px 0 rgba(255,255,255,.8); }

/* ─────────────── 彩带 & 提示 ─────────────── */

.confetti {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s;
}
.confetti.on { opacity: 1; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%) translateY(10px);
  z-index: 80;
  max-width: 88vw;
  padding: 12px 20px;
  border-radius: 99px;
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  background: rgba(28, 12, 58, .95);
  border: 1px solid rgba(255, 211, 110, .3);
  box-shadow: 0 14px 34px -12px rgba(0,0,0,.9);
  opacity: 0;
  transition: opacity .24s, transform .24s;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[hidden] { display: none; }

/* ─────────────── 登录 / 注册 ─────────────── */

.auth {
  width: 100%;
  max-width: 400px;
  min-height: calc(100vh - 90px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth[hidden] { display: none; }

.auth-card {
  width: 100%;
  padding: 30px 24px 26px;
  border-radius: 24px;
  background: linear-gradient(170deg, rgba(255,255,255,.075), rgba(255,255,255,.025));
  border: 1px solid var(--card-line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 26px 60px -22px rgba(0,0,0,.85);
  text-align: center;
}

.auth-logo {
  font-size: 46px;
  line-height: 1;
  margin-bottom: 10px;
  filter: drop-shadow(0 8px 18px rgba(255, 190, 70, .45));
}

.auth-title {
  margin: 0 0 6px;
  font-size: 25px;
  font-weight: 900;
  letter-spacing: .03em;
  background: linear-gradient(180deg, #fff8e2, var(--gold) 50%, var(--gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-sub {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--ink-dim);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  border-radius: 12px;
  background: rgba(0, 0, 0, .28);
  border: 1px solid rgba(255,255,255,.07);
}

.auth-tab {
  padding: 10px;
  border: 0;
  border-radius: 9px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-dim);
  background: transparent;
  cursor: pointer;
  transition: background .18s, color .18s;
}

.auth-tab.is-on {
  color: #3a1e00;
  background: linear-gradient(180deg, #ffeab4, var(--gold) 55%, #f0a92a);
  box-shadow: 0 2px 0 #a86f10;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
  text-align: left;
}

.auth-form[hidden] { display: none; }

.field { display: flex; flex-direction: column; gap: 6px; }

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-faint);
  letter-spacing: .04em;
}

.field input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: rgba(0, 0, 0, .3);
  border: 1px solid rgba(255,255,255,.12);
  transition: border-color .18s, background .18s;
  -webkit-appearance: none;
  appearance: none;
}

.field input::placeholder { color: rgba(255,255,255,.25); }

.field input:focus {
  outline: none;
  border-color: rgba(255, 211, 110, .6);
  background: rgba(0, 0, 0, .42);
}

.auth-btn {
  margin-top: 6px;
  padding: 14px;
  border: 0;
  border-radius: 13px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .06em;
  color: #3a1e00;
  cursor: pointer;
  background: linear-gradient(180deg, #ffeab4, var(--gold) 45%, #f0a92a);
  box-shadow: 0 5px 0 #a86f10, inset 0 1px 0 rgba(255,255,255,.8);
  transition: transform .09s, box-shadow .09s;
}

.auth-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #a86f10, inset 0 1px 0 rgba(255,255,255,.8);
}

.auth-btn:disabled { cursor: not-allowed; filter: grayscale(.5) brightness(.8); }

.auth-note {
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-faint);
  text-align: center;
}

.auth-msg {
  margin: 16px 0 0;
  padding: 11px 14px;
  border-radius: 11px;
  font-size: 13px;
  line-height: 1.6;
  text-align: left;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .12);
  color: var(--ink-dim);
}

.auth-msg[hidden] { display: none; }
.auth-msg.is-warn { background: rgba(255, 90, 90, .13); border-color: rgba(255, 120, 120, .35); color: #ffc9c9; }
.auth-msg.is-ok   { background: rgba(80, 220, 140, .13); border-color: rgba(90, 230, 150, .35); color: #b6f5cf; }

/* ─────────────── 顶部用户栏 & 次数 ─────────────── */

.userbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
}

.userbar .who {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--gold-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.userbar .who::before { content: '👤 '; }

.userbar .logout {
  flex: none;
  padding: 6px 14px;
  border-radius: 99px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-dim);
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .14);
  cursor: pointer;
  transition: background .18s, color .18s;
}

.userbar .logout:hover { background: rgba(255, 255, 255, .14); color: var(--ink); }
.userbar .logout:disabled { opacity: .5; cursor: not-allowed; }

.quotas {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
}

.quota {
  padding: 13px 16px;
  border-radius: 15px;
  background: var(--card);
  border: 1px solid var(--card-line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.quota[hidden] { display: none; }

.quota-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--ink-faint);
}

.quota-value {
  font-size: 21px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  line-height: 1.15;
}

.quota.is-low .quota-value { color: #ffb066; }
.quota.is-out { border-color: rgba(255, 120, 120, .3); }
.quota.is-out .quota-value { color: #ff8f8f; }

/* ─────────────── 音效开关 ─────────────── */

.sound {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  z-index: 30;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-size: 17px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  color: var(--ink);
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background .2s, opacity .2s;
}

.sound:hover { background: rgba(255, 255, 255, .13); }
.sound[aria-pressed="false"] { opacity: .45; }

/* ─────────────── 无障碍 / 动效偏好 ─────────────── */

@media (prefers-reduced-motion: reduce) {
  .aurora, .stars, .lamp, .spin::after, .modal-icon { animation: none !important; }
  .modal-card { animation: none !important; }
}

button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}
