@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700;900&family=MedievalSharp&display=swap');

:root {
  --gold: #ffd700;
  --dark-gold: #b8860b;
  --parchment: #f4e4c1;
  --dark-parchment: #d4c4a1;
  --blood: #8b0000;
  --shadow: #1a1a1a;
  --steel: #4a4a4a;
  --copper: #b87333;
}

/* Champion Themes */
.theme-zealer { --primary: #ffd700; --secondary: #fff8dc; --accent: #daa520; --bg: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); }
.theme-rogue { --primary: #00bfff; --secondary: #87ceeb; --accent: #1e90ff; --bg: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%); }
.theme-willow { --primary: #ff4500; --secondary: #ff6347; --accent: #dc143c; --bg: linear-gradient(135deg, #2c0b0e 0%, #4a1c1c 50%, #1a1a2e 100%); }
.theme-gaia { --primary: #228b22; --secondary: #8fbc8f; --accent: #006400; --bg: linear-gradient(135deg, #1a2f1a 0%, #2d4a2d 50%, #1a1a1a 100%); }
.theme-necro { --primary: #8b0000; --secondary: #2f2f2f; --accent: #4a0000; --bg: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 50%, #2d0000 100%); }
.theme-berserker { --primary: #ff4500; --secondary: #ff8c00; --accent: #dc143c; --bg: linear-gradient(135deg, #2a0a0a 0%, #4a1a1a 50%, #1a0a0a 100%); }
.theme-shadow { --primary: #9400d3; --secondary: #4b0082; --accent: #8b008b; --bg: linear-gradient(135deg, #0d0d0d 0%, #1a1a2e 50%, #2d1b4e 100%); }

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

body {
  font-family: 'Cinzel', serif;
  background: #0a0a0a;
  color: var(--parchment);
  overflow-x: hidden;
  background-image: var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
}

/* Navigation */
.nav-bar {
  position: fixed;
  top: 0;
  width: 100%;
  background: rgba(0,0,0,0.95);
  border-bottom: 3px solid var(--gold);
  z-index: 1000;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.nav-champion-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  object-fit: cover;
}

.nav-links {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.nav-btn {
  background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
  border: 2px solid var(--dark-gold);
  color: var(--parchment);
  padding: 8px 16px;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  transition: all 0.3s;
  text-transform: uppercase;
  font-size: 0.8rem;
  text-decoration: none;
  display: inline-block;
}

.nav-btn:hover, .nav-btn.active {
  background: var(--gold);
  color: #000;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(255,215,0,0.3);
}

.container {
  margin-top: 80px;
  padding: 20px;
  min-height: calc(100vh - 80px);
}

/* Welcome Screen */
.welcome-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.9));
  z-index: 2000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-image: url('images/welcome_bg.png');
  background-size: cover;
  background-position: center;
}

@media (max-width: 768px) {
  .welcome-screen {
    background-image: url('images/welcome_mobile_bg.png');
  }
}

.welcome-title {
  font-size: 4rem;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255,215,0,0.5);
  margin-bottom: 20px;
  text-align: center;
}

.enter-btn {
  padding: 20px 60px;
  font-size: 1.5rem;
  background: linear-gradient(135deg, var(--gold) 0%, var(--dark-gold) 100%);
  border: 3px solid #fff;
  color: #000;
  font-family: 'Cinzel', serif;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
  letter-spacing: 3px;
}

.enter-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px rgba(255,215,0,0.6);
}

/* Hero Section */
.hero-section {
  text-align: center;
  padding: 40px 20px;
  background: rgba(0,0,0,0.6);
  border: 3px solid var(--primary);
  border-radius: 10px;
  margin-bottom: 30px;
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(255,215,0,0.03) 10px,
    rgba(255,215,0,0.03) 20px
  );
  animation: shine 20s linear infinite;
}

@keyframes shine {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.champion-portrait {
  width: 200px;
  height: 300px;
  margin: 0 auto 20px;
  border: 5px solid var(--primary);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(0,0,0,0.8);
  position: relative;
  z-index: 1;
}

.champion-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.champion-name {
  font-size: 2.5rem;
  color: var(--primary);
  text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
  margin-bottom: 10px;
}

.champion-title {
  font-size: 1.2rem;
  color: var(--secondary);
  font-style: italic;
}

.champion-tagline {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.1rem;
  color: var(--accent);
  margin-top: 10px;
}

/* Stats Bar */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  margin: 30px 0;
}

.stat-box {
  background: rgba(0,0,0,0.7);
  border: 2px solid var(--primary);
  padding: 15px;
  text-align: center;
  border-radius: 5px;
}

.stat-label {
  font-size: 0.8rem;
  color: #888;
  text-transform: uppercase;
}

.stat-value {
  font-size: 1.8rem;
  color: var(--primary);
  font-weight: 900;
}

/* Quest Categories */
.quest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin: 30px 0;
}

.quest-category {
  background: rgba(0,0,0,0.8);
  border: 2px solid var(--dark-gold);
  border-radius: 10px;
  padding: 20px;
  position: relative;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--dark-gold);
}

.category-icon { font-size: 1.5rem; }

.category-title {
  font-size: 1.3rem;
  color: var(--gold);
}

.quest-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quest-item {
  background: rgba(255,255,255,0.05);
  border: 1px solid #444;
  padding: 12px;
  border-radius: 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s;
}

.quest-item:hover {
  background: rgba(255,215,0,0.1);
  border-color: var(--gold);
  transform: translateX(5px);
}

.quest-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.quest-img {
  width: 40px;
  height: 40px;
  border-radius: 5px;
  object-fit: cover;
  border: 1px solid var(--dark-gold);
}

.quest-name {
  font-weight: 700;
  color: var(--parchment);
}

.quest-desc {
  font-size: 0.8rem;
  color: #888;
  margin-top: 2px;
}

.quest-xp {
  background: var(--gold);
  color: #000;
  padding: 4px 8px;
  border-radius: 3px;
  font-weight: 700;
  font-size: 0.8rem;
}

.quest-complete {
  opacity: 0.5;
  border-color: var(--gold);
}

.quest-complete .quest-name {
  text-decoration: line-through;
  color: var(--gold);
}

/* Progress Bars */
.xp-bar-container {
  width: 100%;
  height: 30px;
  background: #1a1a1a;
  border: 2px solid var(--gold);
  border-radius: 15px;
  overflow: hidden;
  margin: 10px 0;
  position: relative;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--dark-gold) 0%, var(--gold) 50%, var(--dark-gold) 100%);
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #000;
  font-size: 0.9rem;
}

/* Inventory Grid */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 15px;
  padding: 20px;
  background: rgba(0,0,0,0.8);
  border: 3px solid var(--dark-gold);
  border-radius: 10px;
}

.inventory-slot {
  aspect-ratio: 1;
  background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
  border: 2px solid #444;
  border-radius: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.3s;
  overflow: hidden;
}

.inventory-slot img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 3px;
}

.inventory-slot:hover {
  border-color: var(--gold);
  transform: scale(1.05);
  box-shadow: 0 0 10px rgba(255,215,0,0.3);
}

.inventory-slot.rarity-common { border-color: #9e9e9e; }
.inventory-slot.rarity-uncommon { border-color: #4caf50; }
.inventory-slot.rarity-rare { border-color: #2196f3; }
.inventory-slot.rarity-epic { border-color: #9c27b0; }
.inventory-slot.rarity-legendary { border-color: #ff9800; box-shadow: 0 0 10px rgba(255,152,0,0.3); }

.item-quantity {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: #000;
  color: #fff;
  padding: 2px 6px;
  font-size: 0.8rem;
  border-radius: 3px;
  font-family: Arial, sans-serif;
  font-weight: bold;
}

/* Item Tooltip */
.item-tooltip {
  position: fixed;
  background: rgba(0,0,0,0.95);
  border: 2px solid var(--gold);
  padding: 15px;
  border-radius: 5px;
  max-width: 300px;
  z-index: 1000;
  pointer-events: none;
  display: none;
  box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}

.tooltip-title {
  color: var(--gold);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 5px;
}

.tooltip-subtitle {
  color: #888;
  font-size: 0.9rem;
  font-style: italic;
  margin-bottom: 10px;
}

.tooltip-stat {
  color: #4caf50;
  font-size: 0.9rem;
  margin: 2px 0;
}

.tooltip-desc {
  color: #ccc;
  font-size: 0.85rem;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #444;
}

/* Calendar */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin: 20px 0;
}

.calendar-header {
  text-align: center;
  padding: 10px;
  background: rgba(255,215,0,0.2);
  border: 1px solid var(--gold);
  font-weight: 700;
  color: var(--gold);
}

.calendar-day {
  aspect-ratio: 1;
  background: rgba(0,0,0,0.6);
  border: 1px solid #444;
  padding: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
}

.calendar-day:hover {
  border-color: var(--gold);
  background: rgba(255,215,0,0.1);
}

.calendar-day.today {
  border: 2px solid var(--gold);
  background: rgba(255,215,0,0.2);
}

.calendar-day.completed {
  background: rgba(76,175,80,0.2);
  border-color: #4caf50;
}

.day-number {
  font-size: 0.9rem;
  font-weight: 700;
}

.day-champion {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  margin-top: 2px;
  object-fit: cover;
  border: 1px solid var(--dark-gold);
}

/* Forms */
.form-container {
  max-width: 600px;
  margin: 0 auto;
  background: rgba(0,0,0,0.8);
  border: 2px solid var(--gold);
  padding: 30px;
  border-radius: 10px;
}

.form-group { margin-bottom: 20px; }

.form-label {
  display: block;
  color: var(--gold);
  margin-bottom: 5px;
  font-weight: 700;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px;
  background: #1a1a1a;
  border: 1px solid #444;
  color: var(--parchment);
  font-family: 'Cinzel', serif;
  border-radius: 5px;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--gold);
}

.file-input-wrapper {
  position: relative;
  overflow: hidden;
  display: inline-block;
  width: 100%;
}

.file-input-wrapper input[type=file] {
  position: absolute;
  left: -9999px;
}

.file-input-label {
  display: block;
  padding: 10px;
  background: #2a2a2a;
  border: 2px dashed var(--dark-gold);
  border-radius: 5px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
}

.file-input-label:hover {
  border-color: var(--gold);
  background: rgba(255,215,0,0.1);
}

.image-preview {
  max-width: 200px;
  max-height: 200px;
  margin-top: 10px;
  border: 2px solid var(--gold);
  border-radius: 5px;
  display: none;
}

.btn-submit {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--dark-gold) 100%);
  border: none;
  color: #000;
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: 1.1rem;
  cursor: pointer;
  border-radius: 5px;
  transition: all 0.3s;
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(255,215,0,0.4);
}

/* =========================
   Ladder/Leaderboard (UPDATED)
   ========================= */

.ladder-container {
  background: rgba(0,0,0,0.8);
  border: 3px solid var(--gold);
  border-radius: 10px;
  overflow: hidden;
}

.ladder-header {
  background: linear-gradient(90deg, transparent 0%, rgba(255,215,0,0.2) 50%, transparent 100%);
  padding: 20px;
  text-align: center;
  border-bottom: 2px solid var(--gold);
}

.ladder-row {
  display: grid;
  /* Rank | Champion block | Level | XP (separate columns, tighter + fills space) */
  grid-template-columns: 56px 1fr 92px 92px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid #333;
  transition: all 0.3s;
  column-gap: 10px;
}

.ladder-row:hover {
  background: rgba(255,215,0,0.05);
}

.ladder-rank {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--gold);
  text-align: center;
}

.ladder-champion {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ladder-avatar {
  width: 44px;
  height: 66px;
  border: 2px solid var(--primary);
  border-radius: 6px;
  overflow: hidden;
  flex: 0 0 auto;
}

.ladder-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ladder-info h3 {
  color: var(--parchment);
  margin: 0;
  line-height: 1.05;
  font-size: 1.05rem;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ladder-info p {
  margin: 3px 0 0;
  font-size: 0.78rem;
  color: #888;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ladder-stat {
  text-align: right;
  line-height: 1.05;
  justify-self: end;
}

.ladder-stat-value {
  font-size: 1.15rem;
  color: var(--gold);
  font-weight: 800;
  margin: 0;
}

.ladder-stat-label {
  font-size: 0.62rem;
  color: #666;
  text-transform: uppercase;
  margin-top: 3px;
}

/* Champion Cards */
.champion-card {
  background: rgba(0,0,0,0.8);
  border: 2px solid var(--dark-gold);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  transition: all 0.3s;
}

.champion-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.champion-card-img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 5px;
  margin-bottom: 15px;
  border: 2px solid var(--primary);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.9);
  z-index: 3000;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: linear-gradient(135deg, #1a1a2e 0%, #0f0f1e 100%);
  border: 3px solid var(--gold);
  border-radius: 10px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-header {
  background: rgba(255,215,0,0.1);
  padding: 20px;
  border-bottom: 2px solid var(--gold);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  color: var(--gold);
  font-size: 1.3rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
}

/* Responsive */
@media (max-width: 768px) {
  .welcome-title { font-size: 2.5rem; }
  .nav-links { gap: 5px; }
  .nav-btn { padding: 6px 10px; font-size: 0.7rem; }
  .nav-champion-img { width: 30px; height: 30px; }
  .quest-grid { grid-template-columns: 1fr; }
  .calendar-grid { gap: 2px; }
  .calendar-day { font-size: 0.8rem; }
  .champion-portrait { width: 150px; height: 225px; }

  /* Ladder: tighter but still 4 columns */
  .ladder-row {
    grid-template-columns: 44px 1fr 72px 72px;
    padding: 10px 10px;
    column-gap: 8px;
  }

  .ladder-rank { font-size: 1.15rem; }
  .ladder-avatar { width: 38px; height: 56px; }
  .ladder-info h3 { font-size: 0.95rem; }
  .ladder-info p { font-size: 0.72rem; }
  .ladder-stat-value { font-size: 1.05rem; }
  .ladder-stat-label { font-size: 0.58rem; }
}

/* Extra small: keep Level & XP as separate columns but move under champion */
@media (max-width: 480px) {
  .ladder-row {
    grid-template-columns: 40px 1fr;
    grid-template-areas:
      "rank champ"
      "rank stats";
    row-gap: 6px;
  }

  .ladder-rank { grid-area: rank; }

  .ladder-champion { grid-area: champ; }

  /* Create a 2-column stats row (Level | XP) under champion */
  .ladder-stat {
    grid-area: stats;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    justify-items: end;
    text-align: right;
  }

  /* When two .ladder-stat blocks exist, each will be a grid item.
     To support this, wrap Level and XP in a parent in your HTML if you can.
     If you can't, this still looks better than squeezing columns. */
}

/* Utility Classes */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mb-20 { margin-bottom: 20px; }
.mt-20 { margin-top: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }