/* ============================================================
   styles.css — 拆卡模拟器 (Prizm 暗色主题)
   ============================================================ */

/* --- CSS 变量 --- */
:root {
  --bg: #0a0a12;
  --bg2: #12121f;
  --bg3: #1a1a2e;
  --bg4: #252540;
  --text: #e8e8f0;
  --text2: #9999b0;
  --text3: #666680;
  --accent: #ff69b4;
  --accent2: #9b5de5;
  --gold: #ffd700;
  --gold2: #b8860b;
  --red: #e63946;
  --green: #2ecc71;
  --blue: #457b9d;
  --orange: #f77f00;
  --nebula: #1a0533;
  --nebula2: #7b2ff7;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
  --radius: 8px;
  --radius-lg: 12px;
  --font: 'Segoe UI', 'Microsoft YaHei', sans-serif;
  --transition: 0.2s ease;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent2); }
button { cursor: pointer; font-family: inherit; }
input { font-family: inherit; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ============================================================
   Topbar
   ============================================================ */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 16px;
  background: var(--bg2); border-bottom: 1px solid var(--bg4);
  position: sticky; top: 0; z-index: 100;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 16px; }
.logo { font-size: 18px; font-weight: 700; }
#main-nav { display: flex; gap: 4px; }
.nav-link {
  padding: 6px 12px; border-radius: var(--radius);
  color: var(--text2); font-size: 14px; transition: var(--transition);
}
.nav-link:hover, .nav-link.active { color: var(--text); background: var(--bg3); }
.funds-display {
  font-size: 15px; font-weight: 600;
  background: var(--bg3); padding: 6px 14px; border-radius: var(--radius);
}

/* ============================================================
   Main Content
   ============================================================ */
#app-content {
  max-width: 1100px; margin: 0 auto; padding: 20px 16px;
  min-height: calc(100vh - 52px);
}

/* ============================================================
   Common Components
   ============================================================ */
.page-title {
  font-size: 22px; font-weight: 700; margin-bottom: 16px;
}
.section-title {
  font-size: 16px; font-weight: 600; color: var(--text2);
  margin: 20px 0 10px; text-transform: uppercase; letter-spacing: 1px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; transition: var(--transition);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #ff85c8; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-gold { background: linear-gradient(135deg, var(--gold), var(--gold2)); color: #1a1a1a; }
.btn-gold:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(255,215,0,0.3); }
.btn-outline { background: transparent; border: 1px solid var(--bg4); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { background: var(--red); color: #fff; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }

/* --- Cards grid --- */
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

/* --- Badge --- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
}
.badge-gold { background: var(--gold); color: #1a1a1a; }
.badge-purple { background: var(--accent2); color: #fff; }
.badge-pink { background: var(--accent); color: #fff; }
.badge-red { background: var(--red); color: #fff; }
.badge-green { background: var(--green); color: #fff; }

/* --- Empty state --- */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text3);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* --- Progress bar --- */
.progress-bar {
  height: 8px; background: var(--bg4); border-radius: 4px;
  overflow: hidden; margin: 8px 0;
}
.progress-fill {
  height: 100%; border-radius: 4px; transition: width 0.4s ease;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

/* --- Tooltip --- */
.tooltip {
  position: relative;
}
.tooltip::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--bg4); color: var(--text); padding: 4px 10px; border-radius: 4px;
  font-size: 12px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.tooltip:hover::after { opacity: 1; }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--bg2); border: 1px solid var(--bg4); border-radius: var(--radius-lg);
  padding: 24px; max-width: 500px; width: 90%; max-height: 80vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-box h3 { margin-bottom: 12px; font-size: 18px; }

/* ============================================================
   Toast
   ============================================================ */
#toast-container {
  position: fixed; top: 64px; right: 16px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--bg3); border: 1px solid var(--bg4); border-radius: var(--radius);
  padding: 10px 16px; font-size: 14px; box-shadow: var(--shadow);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--blue); }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ============================================================
   Page: Shop
   ============================================================ */
.shop-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.season-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
}
.season-tab {
  padding: 6px 14px; border-radius: 20px; border: 1px solid var(--bg4);
  background: transparent; color: var(--text2); font-size: 13px;
  transition: var(--transition);
}
.season-tab:hover, .season-tab.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.box-card {
  background: var(--bg2); border: 1px solid var(--bg4); border-radius: var(--radius-lg);
  padding: 20px; transition: var(--transition); cursor: pointer;
}
.box-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.box-card .box-name { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.box-card .box-price { font-size: 14px; color: var(--gold); font-weight: 600; }
.box-card .box-desc { font-size: 13px; color: var(--text2); margin: 8px 0; }
.box-card .box-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text3); }
.box-card .box-guarantee { margin-top: 8px; font-size: 12px; color: var(--accent); }

/* ============================================================
   Page: Open Box (拆盒)
   ============================================================ */
.open-area {
  text-align: center; padding: 40px 0;
}
.open-area .box-3d {
  width: 240px; height: 180px; margin: 0 auto 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 72px; cursor: pointer; transition: transform 0.2s;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.open-area .box-3d:hover { transform: scale(1.05); }
.open-area .box-3d.shaking { animation: shake 0.5s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-10px) rotate(-3deg); }
  40% { transform: translateX(10px) rotate(3deg); }
  60% { transform: translateX(-6px) rotate(-1.5deg); }
  80% { transform: translateX(6px) rotate(1.5deg); }
}

/* Pack display */
.pack-row {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  margin: 16px 0;
}
.pack-item {
  width: 100px; height: 70px; background: var(--bg4); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--text2); cursor: pointer;
  transition: var(--transition); border: 2px solid transparent;
}
.pack-item:hover { border-color: var(--accent); color: var(--text); }
.pack-item.opened { border-color: var(--green); color: var(--green); }
.pack-item.active { border-color: var(--gold); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,215,0,0.4); } 50% { box-shadow: 0 0 16px 4px rgba(255,215,0,0.2); } }

/* Card flip */
.card-stage {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin: 20px 0; min-height: 150px; perspective: 1000px;
}
.card-flip {
  width: 360px; height: 504px; cursor: pointer; perspective: 1000px;
}
.card-flip .card-inner {
  width: 100%; height: 100%; position: relative;
  transform-style: preserve-3d; transition: transform 0.6s ease;
}
.card-flip.flipped .card-inner { transform: rotateY(180deg); }
.card-flip .card-front, .card-flip .card-back {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 22px; text-align: center; padding: 20px;
}
.card-flip .card-back {
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: #fff; font-size: 24px; font-weight: 700;
  border: 2px solid rgba(255,255,255,0.2);
}
.card-flip .card-front {
  transform: rotateY(180deg);
  flex-direction: column; gap: 6px; line-height: 1.4;
}

/* Summary overlay */
.summary-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center; z-index: 500;
  flex-direction: column; gap: 16px;
}
.summary-overlay.hidden { display: none; }
.summary-box {
  background: var(--bg2); border: 1px solid var(--bg4); border-radius: var(--radius-lg);
  padding: 32px; max-width: 600px; width: 90%; max-height: 80vh; overflow-y: auto;
  text-align: center;
}
.summary-box h2 { font-size: 24px; margin-bottom: 8px; }
.summary-box .total-val { font-size: 28px; color: var(--gold); font-weight: 800; }
.summary-hit-list { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.summary-hit { display: flex; justify-content: space-between; align-items: center;
  background: var(--bg3); padding: 8px 12px; border-radius: var(--radius);
  font-size: 13px; }

/* ============================================================
   Page: Collection (卡册)
   ============================================================ */
.collection-stats {
  display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 16px;
}
.col-stat {
  background: var(--bg2); border: 1px solid var(--bg4); border-radius: var(--radius);
  padding: 12px 20px; text-align: center;
}
.col-stat .stat-num { font-size: 28px; font-weight: 800; color: var(--accent); }
.col-stat .stat-label { font-size: 12px; color: var(--text2); }

.player-card-slot {
  width: 100px; height: 140px; border-radius: var(--radius);
  border: 2px dashed var(--bg4); display: flex; align-items: center;
  justify-content: center; font-size: 11px; color: var(--text3);
  text-align: center; background: var(--bg2); transition: var(--transition);
}
.player-card-slot.collected {
  border-style: solid; border-color: var(--accent);
  background: linear-gradient(145deg, var(--bg3), var(--bg2));
  color: var(--text);
}

/* ============================================================
   Page: Alchemy (汰换工坊)
   ============================================================ */
.alchemy-panel {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
.alchemy-slot {
  background: var(--bg2); border: 1px solid var(--bg4); border-radius: var(--radius-lg);
  padding: 20px;
}
.alchemy-slot h3 { margin-bottom: 12px; }
.alchemy-dropzone {
  border: 2px dashed var(--bg4); border-radius: var(--radius);
  min-height: 120px; display: flex; flex-wrap: wrap; gap: 6px; padding: 10px;
  align-items: flex-start;
}
.alchemy-arrow { text-align: center; font-size: 32px; margin: 16px 0; }
.synth-cost { font-size: 12px; color: var(--text2); margin: 6px 0; }

/* ============================================================
   Page: Achievements
   ============================================================ */
.ach-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}
.ach-card {
  background: var(--bg2); border: 1px solid var(--bg4); border-radius: var(--radius);
  padding: 14px; display: flex; gap: 10px; align-items: center; transition: var(--transition);
}
.ach-card.locked { opacity: 0.4; }
.ach-card .ach-icon { font-size: 28px; }
.ach-card .ach-name { font-size: 14px; font-weight: 600; }
.ach-card .ach-desc { font-size: 11px; color: var(--text2); }

/* ============================================================
   Page: Profile
   ============================================================ */
.profile-section {
  background: var(--bg2); border: 1px solid var(--bg4); border-radius: var(--radius-lg);
  padding: 24px; margin-bottom: 16px;
}
.profile-section h3 { margin-bottom: 12px; }
.profile-form { display: flex; flex-direction: column; gap: 10px; max-width: 400px; }
.profile-form input, .profile-form select {
  background: var(--bg3); border: 1px solid var(--bg4); border-radius: var(--radius);
  padding: 10px 14px; color: var(--text); font-size: 14px;
}
.profile-form input:focus { border-color: var(--accent); outline: none; }
.recovery-code-display {
  font-family: monospace; font-size: 18px; font-weight: 700;
  background: var(--bg3); padding: 8px 16px; border-radius: var(--radius);
  letter-spacing: 2px; user-select: all;
}

/* ============================================================
   Card Rendering (虚拟卡面)
   ============================================================ */
.vcard {
  position: relative; width: 280px; height: 392px; border-radius: 10px;
  overflow: hidden; font-size: 16px; line-height: 1.5;
  box-shadow: var(--shadow); flex-shrink: 0;
}
.vcard-sm { width: 240px; height: 336px; font-size: 14px; }
.vcard-xs { width: 90px; height: 126px; font-size: 9px; }

.vcard .vc-bg {
  position: absolute; inset: 0; background-size: cover;
}
.vcard .vc-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.6) 70%, rgba(0,0,0,0.9) 100%);
}
.vcard .vc-content {
  position: relative; z-index: 1; height: 100%;
  display: flex; flex-direction: column; justify-content: flex-end; padding: 10px;
  color: #fff;
}
.vcard .vc-header { display: flex; justify-content: space-between; align-items: flex-start; }
.vcard .vc-name { font-size: 1.2em; font-weight: 800; text-shadow: 0 1px 4px rgba(0,0,0,0.8); }
.vcard .vc-number { font-size: 0.85em; color: rgba(255,255,255,0.7); }
.vcard .vc-tier { font-size: 0.7em; padding: 2px 6px; border-radius: 3px; background: rgba(0,0,0,0.5); }
.vcard .vc-info { display: flex; gap: 4px; margin-top: 2px; font-size: 0.75em; color: rgba(255,255,255,0.8); }
.vcard .vc-flag { font-size: 1.3em; }
.vcard .vc-serial {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  font-size: 0.65em; padding: 2px 6px; border-radius: 3px;
  font-weight: 700; background: rgba(0,0,0,0.7);
}
.vcard .vc-badge-list {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  display: flex; flex-direction: column; gap: 2px;
}
.vcard .vc-badge-item {
  font-size: 0.55em; padding: 1px 5px; border-radius: 3px;
  font-weight: 700; text-transform: uppercase;
}
.vcard .vc-footer {
  display: flex; justify-content: space-between; margin-top: 4px;
  font-size: 0.7em; color: rgba(255,255,255,0.6);
}

/* Parallel-specific card borders */
.vcard.border-base { border: 2px solid #555; }
.vcard.border-prizm { border: 2px solid #c0c0c0; box-shadow: 0 0 12px rgba(192,192,192,0.3); }
.vcard.border-lazer { border: 2px solid #e8e8e8; box-shadow: 0 0 16px rgba(255,255,255,0.15); }
.vcard.border-red { border: 2px solid #e63946; box-shadow: 0 0 12px rgba(230,57,70,0.3); }
.vcard.border-blue { border: 2px solid #457b9d; box-shadow: 0 0 12px rgba(69,123,157,0.3); }
.vcard.border-purple { border: 2px solid #9b5de5; box-shadow: 0 0 12px rgba(155,93,229,0.3); }
.vcard.border-orange { border: 2px solid #f77f00; box-shadow: 0 0 12px rgba(247,127,0,0.3); }
.vcard.border-pink { border: 2px solid #ff69b4; box-shadow: 0 0 16px rgba(255,105,180,0.4); }
.vcard.border-gold { border: 2px solid #ffd700; box-shadow: 0 0 20px rgba(255,215,0,0.5); }
.vcard.border-blackgold { border: 2px solid #ffd700; box-shadow: 0 0 24px rgba(255,215,0,0.6); background: #1a1a1a; }
.vcard.border-black { border: 2px solid #000; box-shadow: 0 0 20px rgba(0,0,0,0.8); }
.vcard.border-nebula { border: 2px solid #7b2ff7; box-shadow: 0 0 30px rgba(123,47,247,0.7), 0 0 60px rgba(155,93,229,0.3); }

/* Rarity effect for card backgrounds */
.vcard.rarity-base .vc-bg { background: linear-gradient(135deg, #2a2a3a, #1a1a2e); }
.vcard.rarity-prizm .vc-bg { background: linear-gradient(135deg, #3a3a50, #2a2a40, #3a3a50); }
.vcard.rarity-numbered .vc-bg { background: linear-gradient(135deg, #1a1a3a, #0a0a20); }
.vcard.rarity-oneofone .vc-bg { animation: nebulaBg 3s ease infinite; }

@keyframes nebulaBg {
  0%,100% { background: linear-gradient(135deg, #1a0533, #2a1040, #1a0533); }
  50% { background: linear-gradient(225deg, #2a1040, #1a0533, #3a1560); }
}

/* ============================================================
   Hamburger Menu (移动端)
   ============================================================ */
.hamburger-btn {
  display: none; background: none; border: none; color: var(--text);
  font-size: 24px; padding: 4px 8px; cursor: pointer;
}
.mobile-nav { display: none; }

@media (max-width: 768px) {
  .hamburger-btn { display: inline-block; }
  #main-nav { display: none; }
  #main-nav.open {
    display: flex; flex-direction: column; position: absolute;
    top: 52px; left: 0; right: 0; background: var(--bg2);
    border-bottom: 1px solid var(--bg4); padding: 8px 16px; gap: 0;
    z-index: 99;
  }
  #main-nav.open .nav-link { padding: 10px 12px; font-size: 15px; }
  .topbar-left { gap: 4px; }
  .logo { font-size: 13px; }
  .nav-link { padding: 4px 6px; font-size: 11px; }
  .funds-display { font-size: 12px; padding: 4px 8px; }
  #app-content { padding: 10px 6px; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .box-card { padding: 14px; }
  .box-card .box-name { font-size: 15px; }
  .alchemy-panel { grid-template-columns: 1fr; }
  .vcard { width: 150px; height: 210px; font-size: 11px; }
  .vcard-sm { width: 130px; height: 182px; font-size: 10px; }
  .vcard-xs { width: 80px; height: 112px; font-size: 9px; }
  .card-flip { width: 240px; height: 336px; }
  .card-flip .card-front { font-size: 14px; padding: 12px; }
  .card-flip .card-back { font-size: 18px; }
  .open-area .box-3d { width: 160px; height: 120px; font-size: 48px; }
  .pack-item { width: 64px; height: 48px; font-size: 11px; }
  .page-title { font-size: 18px; }
  .section-title { font-size: 13px; }
  .ach-grid { grid-template-columns: 1fr; }
  .collection-stats { gap: 8px; }
  .col-stat { padding: 8px 12px; }
  .col-stat .stat-num { font-size: 22px; }
  .profile-form input, .profile-form select { font-size: 16px; }
  .season-tab { padding: 4px 10px; font-size: 11px; }
  .summary-box { padding: 20px; max-width: 95%; }
  .summary-box h2 { font-size: 18px; }
  .summary-box .total-val { font-size: 22px; }
  .modal-box { width: 95%; padding: 16px; }
}

/* Very small phones */
@media (max-width: 400px) {
  .card-grid { grid-template-columns: 1fr; }
  .vcard { width: 100px; height: 140px; font-size: 9px; }
  .card-flip { width: 60px; height: 84px; }
}
