/* =========================================================
 * base.css — 全局变量、复位、视图切换、通用组件
 * ========================================================= */

:root {
  /* 土耳其/异域配色 */
  --color-bg-deep: #0e0620;
  --color-bg-mid: #1a0b2e;
  --color-bg-soft: #2a1245;
  --color-gold: #d4af37;
  --color-gold-bright: #f4d03f;
  --color-gold-dim: #8a7226;
  --color-burgundy: #8b1e3f;
  --color-copper: #b87333;
  --color-parchment: #f5e6d3;
  --color-parchment-dim: #c9b895;
  --color-muted: #7a6a95;

  /* 字体：优先系统衬线，退回通用 */
  --font-serif: 'Cormorant Garamond', 'Ma Shan Zheng', 'STSong', 'Songti SC', 'Noto Serif SC', 'Times New Roman', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-decorative: 'Cinzel', 'Cormorant Garamond', 'STSong', serif;

  /* 阴影 & 光晕 */
  --shadow-gold: 0 0 20px rgba(212, 175, 55, 0.35);
  --shadow-deep: 0 8px 32px rgba(0, 0, 0, 0.5);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--color-bg-deep);
  color: var(--color-parchment);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

body {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh; /* 处理移动端浏览器工具栏 */
}

/* =========================================================
 * 视图切换：所有 .view 绝对定位重叠，通过 .is-active 显示
 * ========================================================= */
.view {
  position: fixed;
  inset: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.45s ease, transform 0.45s ease, visibility 0s linear 0.45s;
  z-index: 1;
  display: flex;
  flex-direction: column;
}

.view.is-active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 0.45s ease, transform 0.45s ease, visibility 0s;
  z-index: 2;
}

/* =========================================================
 * 全局背景装饰（星空 + 光晕）
 * ========================================================= */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(139, 30, 63, 0.25) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(212, 175, 55, 0.12) 0%, transparent 50%),
    linear-gradient(180deg, #0e0620 0%, #1a0b2e 40%, #0e0620 100%);
}

.bg-stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 15%, rgba(255, 240, 200, 0.8), transparent),
    radial-gradient(1px 1px at 40% 35%, rgba(255, 240, 200, 0.5), transparent),
    radial-gradient(1px 1px at 65% 25%, rgba(255, 240, 200, 0.7), transparent),
    radial-gradient(1px 1px at 80% 60%, rgba(255, 240, 200, 0.4), transparent),
    radial-gradient(1px 1px at 25% 75%, rgba(255, 240, 200, 0.6), transparent),
    radial-gradient(1px 1px at 55% 85%, rgba(255, 240, 200, 0.5), transparent),
    radial-gradient(1.5px 1.5px at 90% 40%, rgba(244, 208, 63, 0.7), transparent),
    radial-gradient(1.5px 1.5px at 10% 55%, rgba(244, 208, 63, 0.6), transparent);
  background-size: 100% 100%;
  animation: twinkle 6s ease-in-out infinite alternate;
}

@keyframes twinkle {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

.bg-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 140vw;
  height: 140vw;
  max-width: 900px;
  max-height: 900px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(212, 175, 55, 0.06) 0%, transparent 55%);
  animation: pulse 8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.7; }
  50% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
}

/* =========================================================
 * 装饰纹样通用
 * ========================================================= */
.ornament {
  color: var(--color-gold);
  font-family: var(--font-decorative);
  letter-spacing: 0.4em;
  text-align: center;
  opacity: 0.85;
}

.ornament-line {
  color: var(--color-gold);
  width: 60%;
  max-width: 240px;
  height: 20px;
  display: block;
  margin: 0.6rem auto;
  opacity: 0.75;
}

/* =========================================================
 * 主按钮（金色描边 + 微光扫动）
 * ========================================================= */
.btn-primary {
  position: relative;
  border: none;
  background: transparent;
  color: var(--color-gold-bright);
  font-family: var(--font-decorative);
  font-size: 1.05rem;
  letter-spacing: 0.3em;
  padding: 1rem 2.5rem;
  cursor: pointer;
  overflow: hidden;
  border-radius: 4px;
  outline: none;
  transition: transform 0.2s ease, box-shadow 0.3s ease;
  box-shadow:
    inset 0 0 0 1px var(--color-gold),
    inset 0 0 0 3px rgba(212, 175, 55, 0.15),
    0 0 20px rgba(212, 175, 55, 0.2);
}

.btn-primary::before,
.btn-primary::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 8px;
  color: var(--color-gold);
  opacity: 0.8;
}
.btn-primary::before {
  top: 3px;
  background: radial-gradient(circle, currentColor 0%, transparent 70%);
  height: 4px;
  width: 60%;
  opacity: 0.4;
}

.btn-primary-inner {
  position: relative;
  z-index: 2;
  display: inline-block;
  padding: 0 0.4rem;
  background: linear-gradient(180deg, var(--color-gold-bright) 0%, var(--color-gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.btn-primary-shine {
  position: absolute;
  top: 0; left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 240, 200, 0.35) 50%, transparent 70%);
  animation: shine 3.5s ease-in-out infinite;
}

@keyframes shine {
  0%, 100% { left: -100%; }
  50% { left: 100%; }
}

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

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: inset 0 0 0 1px var(--color-gold-dim);
}
.btn-primary:disabled .btn-primary-shine { display: none; }

.btn-primary-sm {
  padding: 0.75rem 2rem;
  font-size: 0.95rem;
}

/* =========================================================
 * 次级按钮
 * ========================================================= */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 100px;
  padding: 0.7rem 1.4rem;
  color: var(--color-parchment);
  font-family: var(--font-decorative);
  font-size: 0.9rem;
  letter-spacing: 0.25em;
  border: 1px solid rgba(212, 175, 55, 0.6);
  border-radius: 3px;
  background: rgba(42, 18, 69, 0.5);
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.btn-secondary:active {
  transform: scale(0.97);
  background: rgba(212, 175, 55, 0.15);
}

/* =========================================================
 * 视图内通用 header
 * ========================================================= */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  color: var(--color-parchment);
  min-height: 3rem;
}

.view-header h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: normal;
  letter-spacing: 0.3em;
  color: var(--color-gold);
  flex: 1;
  text-align: center;
}

.btn-back {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: 1px solid rgba(212, 175, 55, 0.4);
  background: transparent;
  color: var(--color-gold);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-back:active { background: rgba(212, 175, 55, 0.15); }

.btn-again {
  background: transparent;
  border: none;
  color: var(--color-parchment-dim);
  font-family: var(--font-serif);
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
}
.btn-again:active { color: var(--color-gold); }

/* =========================================================
 * Toast 提示
 * ========================================================= */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 0.8rem 1.4rem;
  background: rgba(14, 6, 32, 0.92);
  border: 1px solid rgba(212, 175, 55, 0.5);
  color: var(--color-parchment);
  border-radius: 4px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  transition: opacity 0.25s ease;
  max-width: 80%;
  text-align: center;
  box-shadow: var(--shadow-deep);
}
.toast.is-show { opacity: 1; }

/* =========================================================
 * 全屏遮罩
 * ========================================================= */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(14, 6, 32, 0.85);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  color: var(--color-parchment);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.mask.is-show { display: flex; }

.mask-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(212, 175, 55, 0.25);
  border-top-color: var(--color-gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
