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

:root {
  --bg: #fff8ee;
  --bg2: #ffe9cf;
  --ink: #3b2417;
  --ink-soft: #8a6a55;
  --primary: #ff7a2f;
  --primary-dark: #e0560f;
  --card: #ffffff;
  --line: #f2ddc6;
}

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(120% 60% at 50% 0%, var(--bg2) 0%, var(--bg) 55%);
  display: flex;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 460px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) 16px max(10px, env(safe-area-inset-bottom));
  position: relative;
}

/* 顶部 */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.title .sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-left: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 10px rgba(180, 110, 60, 0.18);
  font-size: 17px;
  cursor: pointer;
  color: var(--ink);
}

/* 数据源切换 */
.tabs {
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 12px;
  padding: 4px;
  margin-top: 12px;
  flex-shrink: 0;
}

.tabs button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 0;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.2s;
}

.tabs button.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 122, 47, 0.35);
}

/* 转盘区 */
main.wheel-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 0;
}

.pointer {
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 22px solid var(--primary-dark);
  position: relative;
  z-index: 3;
  margin-bottom: -14px;
  filter: drop-shadow(0 2px 3px rgba(160, 60, 10, 0.35));
}

.wheel-wrap {
  position: relative;
  width: min(80vw, 340px);
  aspect-ratio: 1;
  filter: drop-shadow(0 14px 30px rgba(200, 110, 50, 0.3));
}

#wheel {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
}

.spin-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 26%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 4px solid #fff;
  background: linear-gradient(160deg, #ff9a52, var(--primary-dark));
  color: #fff;
  font-size: clamp(20px, 6vw, 26px);
  font-weight: 800;
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 6px 16px rgba(200, 80, 20, 0.4);
  transition: transform 0.15s;
}

.spin-btn:active { transform: translate(-50%, -50%) scale(0.94); }
.spin-btn:disabled { opacity: 0.65; cursor: default; }

.hint {
  margin: 24px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
  min-height: 18px;
}

/* 筛选 */
.filters {
  flex-shrink: 0;
  padding-top: 4px;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 2px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.chip.on {
  background: #ffe4cf;
  border-color: var(--primary);
  color: var(--primary-dark);
}

.chip.off {
  opacity: 0.4;
}

/* 结果弹层 */
.sheet {
  position: fixed;
  inset: 0;
  background: rgba(59, 36, 23, 0);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  transition: background 0.25s;
  z-index: 50;
}

.sheet.show {
  background: rgba(59, 36, 23, 0.45);
  pointer-events: auto;
}

.sheet-card {
  width: 100%;
  max-width: 460px;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 26px 22px calc(22px + env(safe-area-inset-bottom));
  transform: translateY(110%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
}

.sheet.show .sheet-card { transform: translateY(0); }

.sheet-kicker {
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 4px;
}

.result-name {
  font-size: 30px;
  font-weight: 800;
  margin: 10px 0 6px;
  color: var(--primary-dark);
  line-height: 1.2;
}

.result-meta { font-size: 14px; color: var(--ink-soft); }

.result-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 12px;
  min-height: 4px;
}

.result-tags span {
  font-size: 12px;
  background: #fff1e2;
  color: var(--primary-dark);
  padding: 4px 10px;
  border-radius: 999px;
}

.sheet-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

/* 按钮 */
.btn {
  flex: 1;
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.2s;
}

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

.btn.primary {
  background: linear-gradient(160deg, #ff9a52, var(--primary-dark));
  color: #fff;
  box-shadow: 0 6px 16px rgba(255, 122, 47, 0.35);
}

.btn.ghost {
  background: #fff3e6;
  color: var(--primary-dark);
}

/* 设置弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(59, 36, 23, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 60;
}

.modal.show { display: flex; }

.modal-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 20px;
  padding: 24px 22px;
}

.modal-card h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.modal-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 14px 0 8px;
}

.modal-card input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 15px;
  outline: none;
  background: #fffaf4;
}

.modal-card input[type="text"]:focus {
  border-color: var(--primary);
}

.tip {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.6;
  margin: 10px 0 0;
}

.switch-row {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  font-size: 15px !important;
  color: var(--ink) !important;
  margin-top: 20px !important;
}

.switch-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translate(-50%, 20px);
  background: rgba(59, 36, 23, 0.92);
  color: #fff;
  font-size: 14px;
  padding: 11px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 80;
  max-width: 80vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 桌面端：模拟手机卡片 */
@media (min-width: 520px) {
  body { align-items: center; background: #f3e6d6; }
  .app {
    height: min(92dvh, 880px);
    border-radius: 32px;
    box-shadow: 0 24px 60px rgba(120, 70, 30, 0.25);
    background: radial-gradient(120% 60% at 50% 0%, var(--bg2) 0%, var(--bg) 55%);
  }
  .sheet.align-center { align-items: center; }
  .sheet-card { border-radius: 24px; max-width: 400px; margin-bottom: 8dvh; }
}
