/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #111128;
  --bg-card: #161638;
  --bg-input: #1c1c42;
  --gold-primary: #d4a853;
  --gold-light: #f0d080;
  --gold-dark: #a07830;
  --text-primary: #e8e0d0;
  --text-secondary: #908878;
  --text-muted: #605848;
  --border-color: #2a2a50;
  --danger: #e74c3c;
  --success: #2ecc71;
  --warning: #f39c12;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ===== Background ===== */
.page-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(212, 168, 83, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(100, 60, 180, 0.08) 0%, transparent 60%),
    linear-gradient(180deg, #0a0a1a 0%, #0e0e28 50%, #0a0a1a 100%);
  pointer-events: none;
  z-index: 0;
}

.page-bg-mountains {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 200px;
  background:
    linear-gradient(135deg, transparent 33%, rgba(212, 168, 83, 0.03) 33%, rgba(212, 168, 83, 0.03) 66%, transparent 66%),
    linear-gradient(225deg, transparent 33%, rgba(212, 168, 83, 0.02) 33%, rgba(212, 168, 83, 0.02) 66%, transparent 66%);
  background-size: 300px 200px, 400px 200px;
  background-position: bottom left, bottom right;
  background-repeat: repeat-x;
  pointer-events: none;
  z-index: 0;
  opacity: 0.8;
}

/* ===== Container ===== */
.container {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 40px 20px 30px;
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
.header {
  text-align: center;
  margin-bottom: 30px;
  position: relative;
}

.header-decor {
  width: 120px;
  height: 2px;
  margin: 0 auto;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--gold-dark) 20%,
    var(--gold-primary) 50%,
    var(--gold-dark) 80%,
    transparent 100%);
  opacity: 0.6;
}

.header-decor:first-child { margin-bottom: 20px; }
.header-decor:last-child { margin-top: 20px; }

.game-title {
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  background: linear-gradient(180deg,
    var(--gold-light) 0%,
    var(--gold-primary) 50%,
    var(--gold-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 8px rgba(212, 168, 83, 0.3));
  line-height: 1.3;
}

.game-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  letter-spacing: 0.3em;
  margin-top: 8px;
}

/* ===== Slogan Bar ===== */
.slogan-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
  padding: 12px 20px;
  background: linear-gradient(135deg, rgba(212, 168, 83, 0.1) 0%, rgba(212, 168, 83, 0.04) 100%);
  border: 1px solid rgba(212, 168, 83, 0.2);
  border-radius: 10px;
  animation: fadeIn 0.6s ease-out 0.15s both;
}

.slogan-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.slogan-text {
  font-size: 0.88rem;
  color: var(--gold-light);
  letter-spacing: 0.04em;
  line-height: 1.5;
  font-weight: 500;
}

/* ===== Main Card ===== */
.main-card {
  background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 32px 24px;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  animation: fadeIn 0.6s ease-out;
}

.main-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--gold-dark) 20%,
    var(--gold-primary) 50%,
    var(--gold-dark) 80%,
    transparent 100%);
}

/* ===== Form ===== */
.form-group { margin-bottom: 20px; }

.form-group label {
  display: block;
  font-size: 0.9rem;
  color: var(--gold-primary);
  margin-bottom: 8px;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 16px;
  font-family: inherit;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  min-height: 48px;
}

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23908878' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
  cursor: pointer;
}

.form-group input::placeholder { color: var(--text-muted); }

.form-group input:focus,
.form-group select:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 3px rgba(212, 168, 83, 0.15);
}

.form-group input:hover,
.form-group select:hover {
  border-color: rgba(212, 168, 83, 0.4);
}

/* ===== Button ===== */
.btn-redeem {
  width: 100%;
  padding: 16px 24px;
  margin-top: 8px;
  background: linear-gradient(135deg, var(--gold-dark) 0%, var(--gold-primary) 50%, var(--gold-light) 100%);
  border: none;
  border-radius: 12px;
  color: #1a1a2e;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(212, 168, 83, 0.3);
  min-height: 52px;
  -webkit-tap-highlight-color: transparent;
}

.btn-redeem:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(212, 168, 83, 0.45);
}

.btn-redeem:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(212, 168, 83, 0.3);
}

.btn-redeem:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-redeem::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -60%;
  width: 40%;
  height: 200%;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.2) 50%,
    transparent 100%);
  transform: skewX(-20deg);
  animation: shimmer 4s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { left: -60%; }
  50% { left: 120%; }
}

/* ===== Stats Section ===== */
.stats-section {
  margin-top: 28px;
  background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  animation: fadeIn 0.6s ease-out 0.2s both;
}

.section-title {
  font-size: 1.1rem;
  color: var(--gold-primary);
  text-align: center;
  margin-bottom: 20px;
  font-weight: 600;
  letter-spacing: 0.08em;
  position: relative;
  padding-bottom: 12px;
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-primary), transparent);
}

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

.stat-item {
  text-align: center;
  padding: 16px 8px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  border: 1px solid rgba(212, 168, 83, 0.1);
  transition: border-color 0.3s ease;
}

.stat-item:hover { border-color: rgba(212, 168, 83, 0.3); }

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--gold-light);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 6px;
  letter-spacing: 0.05em;
}

/* ===== Daily Stats ===== */
.daily-stats {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.daily-stats.has-data { max-height: 600px; }

.daily-stats-title {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  letter-spacing: 0.05em;
}

.daily-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.daily-stat-row .date {
  color: var(--text-primary);
  font-weight: 500;
  min-width: 90px;
}

.daily-stat-row .info {
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-align: right;
}

.daily-stat-row .info .highlight {
  color: var(--gold-primary);
  font-weight: 600;
}

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal {
  background: linear-gradient(145deg, #1e1e45 0%, var(--bg-card) 100%);
  border: 1px solid var(--gold-dark);
  border-radius: 16px;
  padding: 0;
  max-width: 400px;
  width: 90%;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(212, 168, 83, 0.1);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s ease;
  overflow: hidden;
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 20px 24px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.modal-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  width: 60%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dark), transparent);
}

.modal-header h3 {
  font-size: 1.2rem;
  color: var(--gold-primary);
  font-weight: 600;
  letter-spacing: 0.08em;
}

.modal-body {
  padding: 24px;
  text-align: center;
}

.modal-body p {
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: 8px;
}

.modal-body p:last-child { margin-bottom: 0; }

.code-display {
  background: rgba(0, 0, 0, 0.4);
  border: 2px dashed var(--gold-primary);
  border-radius: 10px;
  padding: 16px 20px;
  margin: 16px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

#codeText {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.15em;
  font-family: "SF Mono", "Fira Code", "Courier New", monospace;
  user-select: all;
  word-break: break-all;
}

.btn-copy {
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--gold-primary);
  border-radius: 8px;
  color: var(--gold-primary);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.btn-copy:hover {
  background: var(--gold-primary);
  color: var(--bg-primary);
}

.code-reminder {
  font-size: 0.82rem !important;
  color: var(--warning) !important;
  margin-top: 12px !important;
  padding: 8px 12px;
  background: rgba(243, 156, 18, 0.08);
  border-radius: 6px;
  border: 1px solid rgba(243, 156, 18, 0.15);
  line-height: 1.5 !important;
}

.modal-footer {
  padding: 0 24px 24px;
  text-align: center;
}

.btn-close {
  padding: 14px 40px;
  background: transparent;
  border: 1px solid var(--gold-primary);
  border-radius: 10px;
  color: var(--gold-primary);
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 0.05em;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}

.btn-close:hover {
  background: var(--gold-primary);
  color: var(--bg-primary);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 24px;
  color: var(--text-primary);
  font-size: 0.9rem;
  z-index: 2000;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  max-width: 90%;
  text-align: center;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); color: #ff6b6b; }
.toast.success { border-color: var(--success); color: #5dde8e; }
.toast.warning { border-color: var(--warning); color: var(--warning); }

/* ===== Footer ===== */
.footer {
  margin-top: auto;
  padding-top: 30px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .container { padding: 24px 16px 20px; }
  .game-title { font-size: 2.2rem; }
  .game-subtitle { font-size: 0.85rem; letter-spacing: 0.2em; }
  .slogan-bar { padding: 10px 14px; gap: 6px; margin-bottom: 18px; }
  .slogan-text { font-size: 0.82rem; }
  .main-card { padding: 24px 18px; border-radius: 12px; }
  .stats-section { padding: 18px; border-radius: 12px; }
  .stats-grid { gap: 8px; }
  .stat-item { padding: 12px 6px; }
  .stat-value { font-size: 1.4rem; }
  .stat-label { font-size: 0.72rem; }
  .modal { width: 94%; max-width: none; }
  .modal-body { padding: 20px 16px; }
  #codeText { font-size: 1.1rem; letter-spacing: 0.08em; word-break: break-all; }
  .code-display { flex-direction: column; gap: 10px; padding: 16px; }
  .btn-copy { width: 100%; text-align: center; }
  .overlay-content { padding: 24px 16px; }
  .overlay-title { font-size: 1.15rem; }
  .overlay-desc { font-size: 0.85rem; }
  .cs-info { padding: 14px 16px; }
  .cs-row { font-size: 0.82rem; line-height: 1.9; }
}

@media (max-width: 360px) {
  .game-title { font-size: 1.9rem; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .slogan-bar { padding: 8px 10px; }
  .slogan-text { font-size: 0.78rem; }
  .main-card { padding: 20px 14px; }
}

/* ===== Customer Service ===== */
.cs-info {
  margin-top: 20px;
  background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px 20px;
  animation: fadeIn 0.6s ease-out 0.3s both;
}

.cs-row {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

.cs-row .cs-icon {
  margin-right: 6px;
}

.cs-row strong {
  color: var(--gold-primary);
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* ===== System Overlay ===== */
.system-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 26, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 16px;
  animation: overlayFadeIn 0.4s ease-out;
}

.overlay-content {
  text-align: center;
  padding: 32px 28px;
  max-width: 340px;
}

.overlay-icon {
  font-size: 2.8rem;
  margin-bottom: 16px;
  opacity: 0.9;
}

.overlay-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.1em;
  margin-bottom: 14px;
}

.overlay-desc {
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1.7;
  margin-bottom: 10px;
}

.overlay-time-hint {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
  padding-top: 10px;
  border-top: 1px solid rgba(212, 168, 83, 0.15);
}

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

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }

/* ===== Selection ===== */
::selection {
  background: rgba(212, 168, 83, 0.3);
  color: var(--gold-light);
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
