:root {
  --bg-dark: #0d0d0d;
  --bg-card: #1a1a1a;
  --bg-panel: #242424;
  --border-subtle: #333;
  --gold: #ffd700;
  --gold-dark: #b8860b;
  --fire: #ff6b35;
  --water: #4dabf7;
  --earth: #51cf66;
  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --victory: #22c55e;
  --defeat: #ef4444;
  --text-primary: #f5f5f5;
  --text-secondary: #a0a0a0;
}

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

body {
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: 
    radial-gradient(ellipse at top, rgba(124, 58, 237, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(255, 107, 53, 0.05) 0%, transparent 50%),
    var(--bg-dark);
}

/* Header */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: linear-gradient(to bottom, var(--bg-panel), var(--bg-dark));
  border-bottom: 1px solid var(--border-subtle);
}

.title-text {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.1em;
}

.gold-display {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 215, 0, 0.05));
  padding: 0.5rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid rgba(255, 215, 0, 0.3);
  color: var(--gold);
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  padding: 0.5rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid var(--border-subtle);
  font-size: 0.875rem;
}

/* Navigation */
.nav-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
}

.nav-tab {
  flex: 1;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: var(--bg-panel);
}

.nav-tab.active {
  color: var(--accent-light);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(124, 58, 237, 0.1));
  border: 1px solid rgba(124, 58, 237, 0.3);
}

/* Main Content */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 4rem;
}

.screen-container {
  padding: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.screen-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.screen-title {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  font-weight: 700;
}

.refresh-btn {
  padding: 0.5rem 1rem;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 0.5rem;
  color: var(--text-secondary);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.refresh-btn:hover {
  border-color: var(--accent);
  color: var(--accent-light);
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.shop-card-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Card Component */
.card-container {
  position: relative;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-container:hover {
  transform: translateY(-4px) scale(1.02);
}

.card-container.selected {
  transform: translateY(-8px) scale(1.05);
}

.card-container.selected .card-glow {
  opacity: 0.8;
  animation: pulse-glow 1.5s infinite;
}

.card-container.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.card-container.disabled:hover {
  transform: none;
}

.card-glow {
  position: absolute;
  inset: -2px;
  border-radius: 14px;
  opacity: 0.5;
  z-index: 0;
  transition: opacity 0.3s;
}

.card-inner {
  position: relative;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  z-index: 1;
}

.card-image-container {
  aspect-ratio: 1;
  background: linear-gradient(135deg, var(--bg-panel), var(--bg-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.card-info {
  padding: 0.75rem;
  background: var(--bg-panel);
}

.tier-stars {
  color: var(--gold);
  font-size: 0.75rem;
  letter-spacing: 2px;
}

.card-name {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-price {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.5rem;
  color: var(--gold);
  font-size: 0.875rem;
  font-weight: 700;
}

/* Buy Button */
.buy-btn {
  width: 100%;
  padding: 0.75rem;
  background: linear-gradient(135deg, var(--accent), #5b21b6);
  border: none;
  border-radius: 0.5rem;
  color: white;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.buy-btn:hover:not(.disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

.buy-btn.disabled {
  background: var(--bg-panel);
  color: var(--text-secondary);
  cursor: not-allowed;
}

/* Battle Screen */
.difficulty-selector {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.difficulty-btn {
  flex: 1;
  min-width: 120px;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.difficulty-btn:hover {
  border-color: currentColor;
}

.difficulty-btn.active {
  border-color: currentColor;
  background: rgba(255, 255, 255, 0.05);
}

.select-prompt {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-size: 1rem;
}

.battle-select {
  margin-bottom: 1.5rem;
}

.battle-start-btn {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  padding: 1rem 2rem;
  background: linear-gradient(135deg, var(--fire), #dc2626);
  border: none;
  border-radius: 0.75rem;
  color: white;
  font-family: 'Cinzel', serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.3s;
}

.battle-start-btn:hover:not(.disabled) {
  transform: scale(1.05);
  box-shadow: 0 8px 24px rgba(255, 107, 53, 0.4);
}

.battle-start-btn.disabled {
  background: var(--bg-panel);
  color: var(--text-secondary);
  cursor: not-allowed;
}

/* Battle Arena */
.battle-phase, .result-phase {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.battle-arena {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  width: 100%;
  max-width: 700px;
}

.fighter {
  flex: 1;
  max-width: 200px;
}

.vs-indicator {
  flex-shrink: 0;
}

.vs-text {
  font-family: 'Cinzel', serif;
  font-size: 2rem;
  font-weight: 900;
  color: var(--accent-light);
  text-shadow: 0 0 20px var(--accent);
}

.clash-effect {
  margin-top: 2rem;
}

.clash-icon {
  font-size: 4rem;
  animation: clash 0.5s ease-in-out infinite;
}

@keyframes clash {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

/* Animations */
.animate-slide-left {
  animation: slideLeft 0.5s ease-out;
}

.animate-slide-right {
  animation: slideRight 0.5s ease-out;
}

@keyframes slideLeft {
  from { transform: translateX(-100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideRight {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.pulse {
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Result Phase */
.result-display {
  text-align: center;
  flex-shrink: 0;
  min-width: 120px;
}

.result-text {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.result-text.win {
  color: var(--victory);
  text-shadow: 0 0 20px var(--victory);
  animation: victory-pulse 0.5s ease-out;
}

.result-text.lose {
  color: var(--defeat);
  text-shadow: 0 0 20px var(--defeat);
}

@keyframes victory-pulse {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.reward-display {
  margin-top: 0.5rem;
}

.reward-float {
  font-size: 1.5rem;
  color: var(--gold);
  font-weight: 700;
  animation: float-up 1s ease-out;
}

@keyframes float-up {
  0% { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.fighter.winner .card-container {
  transform: scale(1.1);
}

.fighter.loser {
  opacity: 0.5;
  filter: grayscale(0.5);
}

.result-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.action-btn {
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn.primary {
  background: linear-gradient(135deg, var(--accent), #5b21b6);
  border: none;
  color: white;
}

.action-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

.action-btn.secondary {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.action-btn.secondary:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

/* Collection Screen */
.filter-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.filter-btn.fire.active {
  background: var(--fire);
  border-color: var(--fire);
}

.filter-btn.water.active {
  background: var(--water);
  border-color: var(--water);
}

.filter-btn.earth.active {
  background: var(--earth);
  border-color: var(--earth);
}

/* Stats Screen */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
  padding: 1.5rem;
  text-align: center;
  transition: transform 0.2s;
}

.stat-card:hover {
  transform: translateY(-4px);
}

.stat-card .stat-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

.stat-card.win .stat-value {
  color: var(--victory);
}

.stat-card.lose .stat-value {
  color: var(--defeat);
}

.stat-card.streak .stat-value {
  color: var(--fire);
}

.stat-card.gold .stat-value {
  color: var(--gold);
}

.element-legend {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.element-legend h3 {
  font-family: 'Cinzel', serif;
  margin-bottom: 1rem;
  text-align: center;
}

.triangle-display {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.element-rule {
  text-align: center;
  font-size: 1rem;
  padding: 0.5rem;
  background: var(--bg-panel);
  border-radius: 0.5rem;
}

.reset-btn {
  display: block;
  width: 100%;
  max-width: 200px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  background: transparent;
  border: 1px solid var(--defeat);
  border-radius: 0.5rem;
  color: var(--defeat);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.reset-btn:hover {
  background: var(--defeat);
  color: white;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  text-align: center;
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h2 {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-secondary);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease;
}

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

.daily-bonus-modal {
  background: var(--bg-card);
  border: 1px solid var(--gold);
  border-radius: 1rem;
  padding: 2rem;
  text-align: center;
  max-width: 300px;
  animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.bonus-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: bounce 0.5s ease infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-10px); }
}

.daily-bonus-modal h2 {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  margin-bottom: 0.5rem;
}

.daily-bonus-modal p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.bonus-amount {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 1.5rem;
}

.claim-btn {
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border: none;
  border-radius: 0.5rem;
  color: #1a1a1a;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s;
}

.claim-btn:hover {
  transform: scale(1.05);
}

/* Purchase Animation */
.purchase-animation {
  text-align: center;
}

.summon-effect {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 1rem;
}

.summon-ring {
  position: absolute;
  inset: 0;
  border: 2px solid var(--accent);
  border-radius: 50%;
  animation: expand 1s ease-out infinite;
}

.summon-ring.ring2 {
  animation-delay: 0.3s;
}

.summon-ring.ring3 {
  animation-delay: 0.6s;
}

@keyframes expand {
  from { transform: scale(0.5); opacity: 1; }
  to { transform: scale(1.5); opacity: 0; }
}

.summoned-card {
  max-width: 180px;
  margin: 0 auto;
  animation: cardReveal 0.5s ease-out 0.5s both;
}

@keyframes cardReveal {
  from { transform: scale(0) rotateY(180deg); opacity: 0; }
  to { transform: scale(1) rotateY(0); opacity: 1; }
}

.summon-text {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  color: var(--accent-light);
  margin-top: 1rem;
  animation: fadeIn 0.5s ease 1s both;
}

/* Footer */
.app-footer {
  padding: 1rem;
  text-align: center;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-card);
}

.app-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s;
}

.app-footer a:hover {
  color: var(--accent-light);
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .header-bar {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .title-text {
    font-size: 1.25rem;
  }
  
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  
  .battle-arena {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .fighter {
    max-width: 150px;
  }
  
  .vs-text {
    font-size: 1.5rem;
  }
  
  .result-text {
    font-size: 1.25rem;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}