/* ==================== 抽奖演示 H5 - 移动端样式 ==================== */
:root {
  --ink: #3B2A1C;
  --ink-soft: #8A7566;
  --line: rgba(150, 110, 80, 0.16);
  --red: #E8443A;
  --led: #5CE1A0;
  --console: #221F27;
  --accent: #FFCE4A;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(120% 55% at 50% 0%, #FFFDF9 0%, rgba(255, 253, 249, 0) 62%),
    linear-gradient(175deg, #FFF8F0 0%, #FFEBD9 44%, #FFDCC5 100%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  /* 手机安全区适配 */
  padding: calc(env(safe-area-inset-top) + 20px) 0
    calc(env(safe-area-inset-bottom) + 20px) 0;
}

body {
  display: flex;
  flex-direction: column;
}

.app {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ---------- header ---------- */
.hd {
  text-align: center;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: #B79A82;
  font-weight: 600;
}

.hd h1 {
  margin: 0;
  font-size: clamp(26px, 7.4vw, 32px);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #3A2A1B;
}

.hd .sub {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-soft);
}

/* 提示文案（核心理念） */
.tip {
  margin: 10px 0 4px;
  font-size: 12px;
  color: #B79A82;
  text-align: center;
  line-height: 1.5;
}

/* ---------- stage ---------- */
.stage {
  margin-top: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wheel-wrap {
  position: relative;
  width: min(88vw, 392px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}

.wheel-wrap::before {
  content: "";
  position: absolute;
  inset: -9%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0) 68%);
  z-index: 0;
}

.wheel-wrap::after {
  content: "";
  position: absolute;
  inset: 1.5%;
  border-radius: 50%;
  box-shadow: 0 15px 30px rgba(178, 108, 58, 0.30);
  z-index: 0;
  pointer-events: none;
}

#wheel {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  will-change: transform;
  z-index: 1;
  transform: rotate(0deg);
}

.pointer {
  position: absolute;
  top: -1.5%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 15px solid transparent;
  border-right: 15px solid transparent;
  border-top: 32px solid #E8443A;
  filter: drop-shadow(0 3px 4px rgba(90, 40, 20, 0.32));
  z-index: 3;
}

.pointer::after {
  content: "";
  position: absolute;
  left: -15px;
  top: -30px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(180deg, #FF8A6B, #E8443A);
  box-shadow: 0 2px 6px rgba(120, 40, 20, 0.35);
}

.spin-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 28%;
  aspect-ratio: 1 / 1;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #FF8064 0%, #E8443A 100%);
  color: #fff;
  font-family: inherit;
  font-size: clamp(18px, 5vw, 24px);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-indent: 0.08em;
  box-shadow: 0 6px 0 #BE2E26, 0 12px 22px rgba(190, 50, 35, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  cursor: pointer;
  touch-action: manipulation;
  z-index: 4;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.2s ease;
}

.spin-btn:active:not(:disabled) {
  transform: translate(-50%, -50%) translateY(4px);
  box-shadow: 0 2px 0 #BE2E26, 0 6px 12px rgba(190, 50, 35, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.spin-btn:disabled {
  filter: saturate(0.55) brightness(0.94);
  cursor: default;
}

.spin-btn:focus-visible {
  outline: 3px solid #FFCE4A;
  outline-offset: 3px;
}

/* ---------- result ---------- */
.result {
  min-height: 76px;
  text-align: center;
  margin-top: 16px;
  padding: 0 4px;
}

.result-main {
  font-size: clamp(21px, 5.8vw, 26px);
  font-weight: 800;
  line-height: 1.35;
  color: #3A2A1B;
  transition: color 0.2s ease;
}

.result-main.pop {
  animation: pop 0.46s cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
}

@keyframes pop {
  0% {
    transform: scale(0.84);
    opacity: 0;
  }
  62% {
    transform: scale(1.05);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.result-sub {
  margin-top: 8px;
  font-size: 11.5px;
  letter-spacing: 0.05em;
  color: #A08B79;
  line-height: 1.5;
}

/* ---------- stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 16px;
  padding: 12px 6px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 6px 16px rgba(170, 120, 80, 0.09);
  backdrop-filter: blur(6px);
}

.stat {
  text-align: center;
  position: relative;
}

.stat + .stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14%;
  height: 72%;
  width: 1px;
  background: var(--line);
}

.stat b {
  display: block;
  font-size: 21px;
  font-weight: 800;
  color: #3A2A1B;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat span {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: #A08B79;
  letter-spacing: 0.04em;
}

/* ---------- history ---------- */
.history {
  margin-top: 16px;
}

.h-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
  padding: 0 2px;
}

.h-head span {
  font-size: 12px;
  font-weight: 700;
  color: #7C6857;
  letter-spacing: 0.08em;
}

.h-head button {
  appearance: none;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 11.5px;
  color: #B09A87;
  padding: 4px 6px;
  cursor: pointer;
  touch-action: manipulation;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  min-height: 30px;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  animation: pop 0.3s ease both;
}

.chip.win {
  background: #FFF1CB;
  color: #8A5D00;
}

.chip.lose {
  background: #EDE9F3;
  color: #847A93;
}

.chips .empty {
  font-size: 12px;
  color: #BCA897;
  padding: 6px 2px;
}

/* ---------- footer ---------- */
.ft {
  margin-top: auto;
  padding: 16px 4px 0;
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.85;
  color: #A08B79;
  text-align: center;
}

/* ==================== 管理页专用 ==================== */
.admin-card {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 6px 16px rgba(170, 120, 80, 0.09);
}

.admin-card h2 {
  margin: 0 0 14px;
  font-size: 17px;
  color: var(--ink);
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 6px;
  font-weight: 600;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px;
  border: 1px solid #D9CAB8;
  border-radius: 12px;
  background: #fff;
  font-size: 14px;
  color: var(--ink);
}

.form-group input:focus,
.form-group select:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.mode-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.mode-btn {
  appearance: none;
  border: 1.5px solid #D9CAB8;
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.16s ease;
}

.mode-btn:active {
  transform: scale(0.97);
}

.mode-btn.active {
  background: var(--accent);
  border-color: #FFD766;
  color: #2A1E00;
}

.win-rate-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.win-rate-row input[type="range"] {
  flex: 1;
  accent-color: var(--red);
}

.save-btn {
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #FF8064 0%, #E8443A 100%);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.save-btn:active {
  transform: translateY(2px);
}

.meta {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: #A08B79;
  text-align: center;
}

.login-card {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px 16px;
  max-width: 320px;
  margin: 40px auto;
  text-align: center;
}

.login-card h2 {
  margin: 0 0 16px;
  font-size: 18px;
  color: var(--ink);
}

.logout-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}

.logout-btn:active {
  background: #F5EFE7;
}

[hidden] {
  display: none !important;
}

@media (max-width: 340px) {
  .result-main {
    font-size: 20px;
  }
  .mode-btn {
    font-size: 12px;
    padding: 9px 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .result-main.pop,
  .chip {
    animation: none;
  }
}
