:root {
  --bg-0: #0d0b08;
  --bg-1: #15110c;
  --bg-2: #1e1812;
  --bg-3: #2a2118;
  --ink: #f4ecd8;
  --ink-dim: #c4b99e;
  --ink-faint: #8a7e68;
  --gold: #d4a04c;
  --gold-bright: #f0c060;
  --gold-dark: #8b6914;
  --crimson: #c0392b;
  --crimson-dark: #7b241c;
  --emerald: #27ae60;
  --border-gold: #5a4420;
  --border-dark: #3d3020;
  --rarity-common: #8a7e68;
  --rarity-rare: #4a90d9;
  --rarity-epic: #9b59b6;
  --rarity-legendary: #f0c060;
  --rarity-mythic: #e74c3c;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg-0);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(212, 160, 76, 0.06), transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(192, 57, 43, 0.04), transparent 50%);
  color: var(--ink);
  font-family: "Georgia", "Songti SC", "STSong", "SimSun", serif;
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* Header */
.header {
  border-bottom: 1px solid var(--border-gold);
  background: rgba(13, 11, 8, 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 600px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-icon { font-size: 22px; }
.logo-text {
  font-size: 18px;
  font-weight: 700;
  font-family: "Georgia", serif;
  letter-spacing: 0.5px;
  color: var(--ink);
}
.logo-accent { color: var(--gold); }
.lang-toggle {
  background: transparent;
  border: 1px solid var(--border-gold);
  color: var(--ink-dim);
  padding: 5px 14px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.15s;
}
.lang-toggle:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: rgba(212, 160, 76, 0.08);
}

/* Hero */
.hero {
  max-width: 600px;
  margin: 0 auto;
  padding: 48px 20px 20px;
  text-align: center;
}
.hero-title {
  font-size: 42px;
  font-weight: 700;
  font-family: "Georgia", serif;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
  color: var(--ink);
  text-shadow: 0 0 30px rgba(212, 160, 76, 0.15);
}
.hero-sub {
  color: var(--ink-dim);
  font-size: 15px;
  margin-bottom: 36px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* Input */
.input-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.name-input, .desc-input {
  background: var(--bg-1);
  border: 1px solid var(--border-dark);
  border-radius: 4px;
  padding: 14px 16px;
  color: var(--ink);
  font-size: 15px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  transition: border-color 0.15s;
  width: 100%;
  resize: none;
}
.name-input::placeholder, .desc-input::placeholder {
  color: var(--ink-faint);
}
.name-input:focus, .desc-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(212, 160, 76, 0.3);
}
.desc-input {
  min-height: 90px;
  line-height: 1.6;
}
.examples {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.example-label {
  font-size: 13px;
  color: var(--ink-faint);
  margin-right: 4px;
  font-family: -apple-system, sans-serif;
}
.example-btn {
  background: transparent;
  border: 1px solid var(--border-dark);
  color: var(--ink-dim);
  padding: 4px 12px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 12px;
  font-family: -apple-system, sans-serif;
  transition: all 0.15s;
}
.example-btn:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
}
.generate-btn-secondary {
  background: transparent;
  border: 1px solid var(--border-gold);
  color: var(--ink-dim);
  padding: 14px 20px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.generate-btn-secondary:hover {
  background: rgba(212, 160, 76, 0.08);
  border-color: var(--gold);
  color: var(--gold-bright);
}
.generate-row {
  display: flex;
  gap: 8px;
}
.surprise-btn-primary {
  background: var(--gold-dark);
  background: linear-gradient(180deg, #a67c1a, #7b5a0f);
  border: 1px solid var(--gold);
  color: var(--bg-0);
  padding: 14px 32px;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 700;
  font-family: "Georgia", serif;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 6px;
  text-transform: uppercase;
  flex: 1;
}
.surprise-btn-primary:hover {
  background: linear-gradient(180deg, #c09020, #8b6914);
  box-shadow: 0 2px 12px rgba(212, 160, 76, 0.3);
}
.surprise-btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Loading — forge animation */
.loading-area {
  text-align: center;
  padding: 60px 20px;
}
.loading-forge {
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  position: relative;
}
.forge-spark {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--gold-bright);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  box-shadow: 0 0 8px var(--gold);
  animation: forge-spark 1.2s ease-in-out infinite;
}
.forge-spark:nth-child(1) { animation-delay: 0s; }
.forge-spark:nth-child(2) { animation-delay: 0.4s; }
.forge-spark:nth-child(3) { animation-delay: 0.8s; }
@keyframes forge-spark {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  30% { transform: translate(-50%, -50%) scale(1.5); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loading-area p {
  color: var(--ink-dim);
  font-size: 15px;
  font-family: "Georgia", serif;
  font-style: italic;
}
.loading-sub {
  font-size: 12px !important;
  color: var(--ink-faint) !important;
  font-style: normal !important;
  font-family: -apple-system, sans-serif !important;
  margin-top: 4px;
}

/* Card Area */
.card-area {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
}
.card-container {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

/* Trading Card — styled like a real TCG card */
.trading-card {
  width: 340px;
}
.card-frame {
  background:
    linear-gradient(165deg, #1a1510 0%, #0f0c08 100%);
  border: 2px solid var(--gold-dark);
  border-radius: 12px;
  padding: 16px;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 4px 20px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(212, 160, 76, 0.1);
}
.card-frame::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(circle at 30% 20%, rgba(212, 160, 76, 0.08), transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(192, 57, 43, 0.04), transparent 50%);
  pointer-events: none;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
}
.card-element {
  font-size: 22px;
}
.card-rarity {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 3px 10px;
  border-radius: 2px;
  background: var(--rarity-rare, var(--gold-dark));
  color: var(--bg-0);
  font-family: "Georgia", serif;
}
.card-name {
  font-size: 18px;
  font-weight: 700;
  font-family: "Georgia", serif;
  text-align: center;
  margin-bottom: 12px;
  color: var(--gold-bright);
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  position: relative;
  z-index: 1;
}
.card-art {
  background:
    linear-gradient(145deg, var(--bg-3), var(--bg-1));
  border: 1px solid var(--border-gold);
  border-radius: 8px;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}
.card-art::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(212, 160, 76, 0.02) 10px,
    rgba(212, 160, 76, 0.02) 20px
  );
}
.card-art-inner {
  text-align: center;
  position: relative;
  z-index: 1;
}
.card-art-icon {
  font-size: 52px;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}
.card-hp {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(0, 0, 0, 0.7);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-gold);
  z-index: 2;
}
.hp-label {
  font-size: 10px;
  color: var(--ink-faint);
  font-weight: 700;
  font-family: "Georgia", serif;
}
.hp-value {
  font-size: 18px;
  font-weight: 700;
  color: #e74c3c;
  font-family: "Georgia", serif;
}
.card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}
.stat-item {
  background: rgba(212, 160, 76, 0.05);
  border: 1px solid var(--border-dark);
  border-radius: 4px;
  padding: 5px 6px;
  text-align: center;
}
.stat-label {
  font-size: 9px;
  color: var(--ink-faint);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  display: block;
  font-family: "Georgia", serif;
}
.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  font-family: "Georgia", serif;
}
.card-ability {
  background: rgba(155, 89, 182, 0.08);
  border-left: 3px solid var(--rarity-epic);
  border-radius: 0 4px 4px 0;
  padding: 8px 10px;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}
.ability-name {
  font-size: 13px;
  font-weight: 700;
  color: #b987d8;
  font-family: "Georgia", serif;
  margin-bottom: 2px;
}
.ability-desc {
  font-size: 11px;
  color: var(--ink-dim);
  line-height: 1.45;
  font-family: -apple-system, sans-serif;
}
.card-weakness {
  background: rgba(192, 57, 43, 0.06);
  border-left: 3px solid var(--crimson);
  border-radius: 0 4px 4px 0;
  padding: 8px 10px;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}
.weakness-label {
  font-size: 9px;
  color: var(--crimson);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 2px;
  font-family: "Georgia", serif;
}
.weakness-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  font-family: "Georgia", serif;
  margin-bottom: 2px;
}
.weakness-desc {
  font-size: 11px;
  color: var(--ink-dim);
  line-height: 1.45;
  font-family: -apple-system, sans-serif;
}
.card-flavor {
  font-style: italic;
  font-size: 12px;
  color: var(--ink-faint);
  text-align: center;
  padding: 8px 4px 4px;
  border-top: 1px solid var(--border-dark);
  margin-top: 6px;
  position: relative;
  z-index: 1;
  font-family: "Georgia", serif;
}
.card-footer {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--ink-faint);
  padding-top: 6px;
  font-family: monospace;
  position: relative;
  z-index: 1;
}
.card-id {
  font-family: monospace;
}
.card-element-label {
  font-weight: 700;
  letter-spacing: 1px;
  font-family: "Georgia", serif;
}

/* Rarity borders */
.card-frame[data-rarity="Common"] {
  border-color: var(--rarity-common);
}
.card-frame[data-rarity="Rare"] {
  border-color: var(--rarity-rare);
}
.card-frame[data-rarity="Epic"] {
  border-color: var(--rarity-epic);
  box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 15px rgba(155, 89, 182, 0.15), inset 0 1px 0 rgba(212, 160, 76, 0.1);
}
.card-frame[data-rarity="Legendary"] {
  border-color: var(--rarity-legendary);
  box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 20px rgba(240, 192, 96, 0.25), inset 0 1px 0 rgba(212, 160, 76, 0.1);
}
.card-frame[data-rarity="Mythic"] {
  border-color: var(--rarity-mythic);
  box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 25px rgba(231, 76, 60, 0.3), inset 0 1px 0 rgba(212, 160, 76, 0.1);
}
.card-rarity[data-rarity="Common"] { background: var(--rarity-common); color: var(--bg-0); }
.card-rarity[data-rarity="Rare"] { background: var(--rarity-rare); color: var(--bg-0); }
.card-rarity[data-rarity="Epic"] { background: var(--rarity-epic); color: var(--ink); }
.card-rarity[data-rarity="Legendary"] { background: var(--rarity-legendary); color: var(--bg-0); }
.card-rarity[data-rarity="Mythic"] { background: var(--rarity-mythic); color: var(--ink); }

/* Actions */
.card-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}
.action-btn {
  background: var(--bg-1);
  border: 1px solid var(--border-gold);
  color: var(--ink-dim);
  padding: 10px 18px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: -apple-system, sans-serif;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.action-btn:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: var(--bg-2);
}

/* Upgrade */
.upgrade-area {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
}
.upgrade-box {
  background: var(--bg-1);
  border: 1px solid var(--border-gold);
  border-radius: 8px;
  padding: 28px 24px;
  text-align: center;
  position: relative;
}
.upgrade-box::before {
  content: '';
  position: absolute;
  top: -1px; left: -1px; right: -1px;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  border-radius: 8px 8px 0 0;
}
.upgrade-box h2 {
  font-size: 24px;
  font-weight: 700;
  font-family: "Georgia", serif;
  margin-bottom: 8px;
  color: var(--gold-bright);
}
.upgrade-box > p {
  color: var(--ink-dim);
  font-size: 14px;
  margin-bottom: 20px;
  font-family: -apple-system, sans-serif;
}
.upgrade-features {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  text-align: left;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}
.upgrade-feature {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--ink-dim);
  font-family: -apple-system, sans-serif;
}
.payment-box {
  background: var(--bg-0);
  border: 1px solid var(--border-dark);
  border-radius: 6px;
  padding: 20px;
}
.price-tag {
  font-size: 36px;
  font-weight: 700;
  color: var(--gold-bright);
  margin-bottom: 8px;
  font-family: "Georgia", serif;
}
.price-unit {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-dim);
  font-family: -apple-system, sans-serif;
}
.wallet-address {
  font-family: monospace;
  font-size: 13px;
  color: var(--ink-dim);
  background: var(--bg-1);
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 8px;
  margin-top: 12px;
  word-break: break-all;
  border: 1px solid var(--border-dark);
}
.copy-wallet-btn {
  background: var(--gold-dark);
  background: linear-gradient(180deg, #a67c1a, #7b5a0f);
  border: 1px solid var(--gold);
  color: var(--bg-0);
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  font-family: -apple-system, sans-serif;
  margin-bottom: 12px;
  margin-top: 8px;
  transition: all 0.15s;
}
.copy-wallet-btn:hover {
  background: linear-gradient(180deg, #c09020, #8b6914);
}
.payment-note {
  font-size: 12px;
  color: var(--ink-faint);
  line-height: 1.5;
  text-align: left;
  max-width: 360px;
  margin: 12px auto 0;
  font-family: -apple-system, sans-serif;
}

/* Footer */
.footer {
  text-align: center;
  padding: 40px 20px;
  border-top: 1px solid var(--border-dark);
  margin-top: 40px;
}
.footer p {
  font-size: 13px;
  color: var(--ink-faint);
  font-family: -apple-system, sans-serif;
}
.footer a {
  color: var(--gold);
  text-decoration: none;
}
.footer-sub {
  margin-top: 6px;
  font-size: 12px;
}

/* Responsive */
@media (max-width: 480px) {
  .hero-title { font-size: 32px; }
  .trading-card { width: 290px; }
  .card-art { height: 110px; }
  .card-art-icon { font-size: 44px; }
}
