/* ================================
   随机选择器 - 自定义样式
   ================================ */

:root {
  --bg: #FAFAF9;
  --bg-alt: #F5F5F4;
  --surface: #FFFFFF;
  --border: #E7E5E4;
  --border-strong: #D6D3D1;
  --text: #1E293B;
  --text-secondary: #52525B;
  --text-muted: #71717A;
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: rgba(79, 70, 229, 0.08);
  --secondary: #F97316;
  --accent: #EC4899;
  --success: #059669;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Noto Sans SC', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Toast ── */
.toast {
  position: fixed; top: 24px; right: 24px;
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 100px;
  font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  z-index: 1000;
  transform: translateX(calc(100% + 40px));
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.toast.show { transform: translateX(0); }
.toast-dot { width: 8px; height: 8px; background: var(--success); border-radius: 50%; }

/* ── Page ── */
.page { max-width: 960px; margin: 0 auto; padding: 0 32px; }

/* ── Header scroll effect ── */
#header.scrolled {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 2px 20px rgba(0,0,0,0.06);
}

/* ══════════════════════════════════════════
   Picker Section
   ══════════════════════════════════════════ */
.picker-section { padding: 8px 0 32px; }

/* ── Tab Bar ── */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: -1px;
}
.tab:hover { color: #65A30D; }
.tab.active { color: var(--text); border-bottom-color: #65A30D; font-weight: 600; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ══════════════════════════════════════════
   抛硬币
   ══════════════════════════════════════════ */
.coin-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 20px;
  gap: 20px;
}

.coin {
  width: 140px;
  height: 140px;
  position: relative;
  cursor: pointer;
  perspective: 600px;
}
.coin:hover { transform: scale(1.05); }

.coin-face {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.coin-front {
  background: linear-gradient(135deg, #FCD34D, #F59E0B);
  border: 4px solid #D97706;
  box-shadow: 0 4px 16px rgba(245,158,11,0.3);
}
.coin-front .coin-icon-large {
  font-size: 48px;
  font-weight: 900;
  color: #B45309;
}

.coin-back {
  background: linear-gradient(135deg, #FDE68A, #FCD34D);
  border: 4px solid #D97706;
  box-shadow: 0 4px 16px rgba(245,158,11,0.3);
  transform: rotateY(180deg);
}
.coin-back .coin-icon-large {
  font-size: 42px;
  color: #D97706;
}

.coin.flipping .coin-front {
  animation: coinFlipFront 1.2s ease-in-out;
}
.coin.flipping .coin-back {
  animation: coinFlipBack 1.2s ease-in-out;
}
.coin.show-tails .coin-front { transform: rotateY(180deg); }
.coin.show-tails .coin-back { transform: rotateY(0deg); }
.coin.show-heads .coin-front { transform: rotateY(0deg); }
.coin.show-heads .coin-back { transform: rotateY(180deg); }

@keyframes coinFlipFront {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(1800deg); }
}
@keyframes coinFlipBack {
  0% { transform: rotateY(180deg); }
  100% { transform: rotateY(1980deg); }
}

.coin-result {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  min-height: 28px;
}

.coin-stats {
  display: flex;
  gap: 24px;
  padding: 16px 24px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  font-family: 'SF Mono', 'Cascadia Code', monospace;
}

/* ══════════════════════════════════════════
   掷骰子
   ══════════════════════════════════════════ */
.dice-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 20px;
  gap: 20px;
}

.dice {
  width: 100px;
  height: 100px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dice:hover { transform: scale(1.05); }

.dice-face {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #FFFFFF, #F1F5F9);
  border: 3px solid #CBD5E1;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  transition: transform 0.15s ease;
}

.dice.rolling .dice-face {
  animation: diceRoll 0.6s ease-out;
}

@keyframes diceRoll {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(90deg) scale(1.1); }
  50% { transform: rotate(270deg) scale(0.95); }
  75% { transform: rotate(450deg) scale(1.05); }
  100% { transform: rotate(720deg) scale(1); }
}

.dice-result {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  min-height: 28px;
}

.dice-history {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 36px;
}

.dice-history-item {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

/* ══════════════════════════════════════════
   随机抽取
   ══════════════════════════════════════════ */
.pick-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 20px;
  gap: 24px;
}

.pick-input-area {
  width: 100%;
  max-width: 500px;
}

.pick-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.pick-textarea {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  resize: vertical;
  transition: all 0.2s ease;
  outline: none;
  line-height: 1.8;
}
.pick-textarea:focus {
  border-color: #65A30D;
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(101,163,13,0.1);
}
.pick-textarea::placeholder { color: #9CA3AF; }

.pick-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.pick-result-box {
  width: 280px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(132,204,22,0.08), rgba(250,204,21,0.08));
  border: 2px dashed rgba(132,204,22,0.25);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.pick-result-text {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  word-break: break-all;
  text-align: center;
  transition: all 0.15s ease;
}

.pick-hint {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Picker Button ── */
.picker-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: linear-gradient(135deg, #65A30D, #EAB308);
  border: none;
  border-radius: 100px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(101,163,13,0.3);
}
.picker-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(101,163,13,0.4);
}
.picker-btn:active { transform: translateY(0); }

/* ══════════════════════════════════════════
   Custom scrollbar
   ══════════════════════════════════════════ */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #A5B4FC; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #4F46E5; }

::selection { background: rgba(132, 204, 22, 0.2); color: #1E293B; }

/* ══════════════════════════════════════════
   Guide Section (accordion)
   ══════════════════════════════════════════ */
.guide-section {
  margin-top: 16px;
  margin-bottom: 64px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.guide-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 20px;
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}
.guide-toggle:hover { background: var(--bg-alt); }
.guide-toggle-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #1E293B;
}
.guide-toggle.open .toggle-arrow { transform: rotate(180deg); }
.toggle-arrow {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}
.guide-list { padding: 0 20px 20px; }
.guide-list.hidden { display: none; }
.guide-item {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}
.guide-item:first-child { border-top: 1px solid var(--border); }
.guide-item-title {
  font-size: 14px;
  font-weight: 600;
  color: #1E293B;
  margin-bottom: 6px;
}
.guide-item-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* ══════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════ */
@media (max-width: 768px) {
  .page { padding: 0 16px; }

  .tab-bar { overflow-x: auto; }
  .tab { padding: 12px 16px; font-size: 13px; white-space: nowrap; }

  .coin { width: 120px; height: 120px; }
  .coin-stats { gap: 16px; }
  .dice { width: 80px; height: 80px; }
  .pick-result-box { width: 100%; }
}
