@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Outfit:wght@500;700&display=swap');

:root {
  --bg-color: #18151c;
  --card-bg: #2b2633;
  --card-border: #40394a;
  --text-main: #f5f3f7;
  --text-muted: #b8b1c2;
  --accent-1: #6a95e0;
  --accent-2: #8a73cc;
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  background-image: linear-gradient(rgba(24, 21, 28, 0.75), rgba(24, 21, 28, 0.75)), url('https://fischipedia.org/wiki/Special:FilePath/Trade_Plaza.png');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  padding: 4rem 2rem;
  max-width: 96%;
  margin: 0 auto;
  width: 100%;
}

@media only screen and (max-width: 768px) {
  main {
    padding-bottom: 120px;
  }
}

h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 3.5rem;
  margin-bottom: 1rem;
  color: var(--text-main);
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

p {
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1.6;
  max-width: 600px;
}

.bg-shape {
  display: none;
}

.page-header {
  text-align: center;
  margin-bottom: 2rem;
  margin-top: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 1.5rem 1.5rem;
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.page-header h1 {
  font-size: 2.5rem;
  margin-bottom: 0.2rem;
  text-align: center;
}

.page-header p {
  margin: 0 auto;
}

.controls-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  align-items: center;
  transition: all 0.3s ease;
}

@media (min-width: 769px) {
  .controls-bar {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    background: rgba(25, 25, 25, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 0.8rem 1.5rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    gap: 1rem;
    align-items: center;
    width: fit-content;
    max-width: 90%;
    flex-wrap: nowrap;
  }
}

.mobile-text {
  display: none;
}

.filters-wrapper {
  display: contents;
}

.search-input {
  flex: 1;
  min-width: 250px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: white;
  padding: 0 1.5rem;
  height: 48px;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--accent-1);
}

.sort-select {
  padding: 0 1.5rem;
  height: 48px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  outline: none;
  box-sizing: border-box;
  white-space: nowrap;
}

.filter-btn {
  padding: 0 1.5rem;
  height: 48px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  outline: none;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.filter-btn:hover, .filter-btn.active {
  background: #322d3b;
  border-color: #5d536b;
}

.filter-btn.active {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(99, 102, 241, 0.2));
  border-color: #a855f7;
}

.border-limited {
  border: 2px solid #1d4ed8 !important;
  box-shadow: 0 0 10px rgba(29, 78, 216, 0.3);
}
.border-unobtainable {
  border: 2px solid #ef4444 !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

.sort-select:focus {
  border-color: var(--accent-1);
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 1.5rem;
  width: 100%;
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.item-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}

.item-list .item-card {
  flex-direction: row;
  height: 80px;
  align-items: center;
  border-radius: 8px;
}

.item-card:hover {
  transform: translateY(-4px);
  border-color: #5d536b;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

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

.item-image {
  width: 100%;
  height: 120px;
  background: rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  border-bottom: 1px solid var(--card-border);
}

.item-list .item-image {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}

.item-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 10px;
  transition: transform 0.5s ease;
}

.item-card:hover .item-image img {
  transform: scale(1.05);
}

.item-content {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.item-list .item-content {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
}

.item-content h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  color: #fff;
  margin-bottom: 0.8rem;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 0.6rem;
}

.item-list .item-content h2 {
  margin: 0;
  border: none;
  padding: 0;
  text-align: left;
  flex: 1;
  font-size: 1.2rem;
}

.item-stats {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.item-list .item-stats {
  flex-direction: row;
  gap: 2rem;
  flex: 2;
  justify-content: flex-end;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  gap: 0.5rem;
}

.stat-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.stat-value {
  font-weight: 700;
  color: var(--text-main);
  text-align: right;
}

.stat-value.highlight {
  color: #34d399;
  font-size: 0.95rem;
}

.stat-value.robux {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.horizontal-card {
  flex-direction: row;
  align-items: stretch;
}

.horizontal-image {
  width: 140px;
  height: auto;
  border-bottom: none;
  border-right: 1px solid var(--card-border);
  flex-shrink: 0;
}

.horizontal-content {
  display: flex;
  flex-direction: column;
  padding: 1.2rem;
  flex: 1;
  min-width: 0;
}

.horizontal-content h2 {
  text-align: left;
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0.8rem;
  font-size: 1.2rem;
}

.values-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.stat-box {
  flex: 1;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.5rem;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,0.05);
}

.other-stats-box {
  background: rgba(0, 0, 0, 0.15);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: auto;
  border: 1px solid rgba(255,255,255,0.05);
}

.other-stats-box .stat-row {
  flex-direction: row;
  justify-content: space-between;
  background: transparent;
  padding: 0;
  border-radius: 0;
}

.trend-badge {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  display: inline-block;
  text-transform: capitalize;
}

.trend-stable { background: #198754; }
.trend-unstable { background: #fd7e14; }
.trend-doing-well { background: #20c997; }
.trend-rising { background: #0d6efd; }
.trend-dropping { background: #dc3545; }
.trend-skyrocketing { background: #0dcaf0; color: #000; }
.trend-imploding { background: #ff0000; }
.trend-hoarded { background: #495057; }
.trend-hyped { background: #d63384; }
.trend-new { background: #6f42c1; }
.trend-manipulated { background: #ffc107; color: #000; }
.trend-recovering { background: #8b4513; }
.trend-unknown { background: #6c757d; }

.hero-section {
  text-align: center;
  margin-top: 4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.fan-made-badge {
  background: rgba(236, 72, 153, 0.15);
  color: #f472b6;
  padding: 0.4rem 1rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(236, 72, 153, 0.3);
}

.hero-desc {
  font-size: 1.2rem;
  max-width: 700px;
  margin: 0 auto 1.5rem auto;
  color: #cbd5e1;
}

.data-credits {
  font-size: 0.9rem;
  color: #64748b;
  margin-bottom: 3rem;
  max-width: 700px;
  text-align: center;
}

.data-credits a {
  color: #38bdf8;
  text-decoration: none;
  transition: color 0.3s ease;
}

.data-credits a:hover {
  color: #818cf8;
  text-decoration: underline;
}

.social-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}

.social-btn {
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: white;
}

.social-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.social-btn.wiki {
  background: #322d3b;
  border: 1px solid var(--card-border);
}
.social-btn.wiki:hover {
  background: #40394a;
}

.social-btn.discord {
  background: #5865F2;
}
.social-btn.discord:hover {
  background: #4752C4;
}

.social-btn.twitter {
  background: #000000;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.social-btn.twitter:hover {
  background: #111111;
}

.social-btn.roblox {
  background: #25212b;
  border: 1px solid var(--card-border);
}
.social-btn.roblox:hover {
  background: #322d3b;
}

.social-btn.game {
  background: #25212b;
  border: 1px solid var(--card-border);
}
.social-btn.game:hover {
  background: #322d3b;
}

.social-btn.youtube {
  background: #FF0000 !important;
}
.social-btn.youtube:hover {
  background: #CC0000 !important;
}

.load-more-container {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
  width: 100%;
}

.load-more-btn {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  padding: 0.8rem 2rem;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.load-more-btn:hover {
  background: #322d3b;
  border-color: #5d536b;
  transform: translateY(-2px);
}

.load-more-btn.hidden {
  display: none;
}

.loading, .error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  font-size: 1.2rem;
  color: #94a3b8;
  background: rgba(30, 41, 59, 0.5);
  border-radius: 20px;
}
.error {
  color: #ef4444;
}

.wiki-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    margin: 2rem auto;
    padding: 0 1rem;
}

.wiki-category {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .wiki-category {
        flex-direction: row;
    }
}

.wiki-category-header {
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    min-width: 150px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--card-border);
}

@media (min-width: 768px) {
    .wiki-category-header {
        border-bottom: none;
        border-right: 1px solid var(--card-border);
    }
}

.wiki-items {
    display: flex;
    flex-wrap: wrap;
    padding: 1rem;
    gap: 0.8rem;
    flex: 1;
}

.wiki-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    flex-grow: 1;
    justify-content: center;
}

.wiki-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

.wiki-item i {
    font-size: 1.1rem;
    opacity: 0.8;
}

.floating-back-btn {
    position: fixed;
    bottom: 30px;
    left: 30px;
    background: linear-gradient(135deg, #a855f7, #6366f1);
    color: white;
    width: 65px;
    height: 45px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    z-index: 1000;
}

.floating-back-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.6);
}

.back-link { display: inline-block; color: var(--text-muted); text-decoration: none; margin-bottom: 1rem; margin-top: 1.5rem; font-size: 0.95rem; transition: color 0.2s ease; }
.back-link:hover { color: #fff; }


@media (max-width: 768px) {
  main {
    padding: 4rem 0.5rem 130px 0.5rem;
    width: 100%;
    max-width: 100%;
  }
  .floating-back-btn {
    display: none;
  }
  .item-grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }

  .horizontal-image {
     width: 110px;
  }
  .page-header {
    margin: 1rem 0.5rem 2rem 0.5rem;
  }
  .controls-bar {
    position: sticky;
    top: 10px;
    z-index: 999;
    background: rgba(25, 25, 25, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 12px;
    margin: 10px 10px 1.5rem 10px !important;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap !important;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
  }
  .controls-bar .search-input {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
    margin: 0 !important;
  }
  .filters-wrapper {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    width: auto;
    justify-content: flex-end;
  }
  .filters-wrapper > * {
    flex: 0 0 52px !important;
    width: 52px !important;
    min-width: 52px !important;
    max-width: 52px !important;
    height: 48px;
    padding: 0 !important;
    margin: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    color: transparent !important;
    appearance: none !important;
    -webkit-appearance: none !important;
  }
  .filters-wrapper select option {
    color: #ffffff !important;
    background-color: #1c1921 !important;
  }
  #sort-select {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23b8b1c2" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21 16-4 4-4-4"/><path d="M17 20V4"/><path d="m3 8 4-4 4 4"/><path d="M7 4v16"/></svg>') !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: 20px !important;
  }
  #stage-filter {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23b8b1c2" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"/></svg>') !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: 20px !important;
  }
  #toggle-borders-btn {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23b8b1c2" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><rect x="7" y="7" width="10" height="10" rx="1" ry="1"/></svg>') !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: 20px !important;
  }
  .desktop-text {
    display: none !important;
  }
  .mobile-text {
    display: none;
  }
}

.updates-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    width: 100%;
    margin: 2rem auto 4rem auto;
    padding: 0 1rem;
}

@media (min-width: 768px) {
    .updates-section {
        grid-template-columns: 1fr 1fr;
    }
}

.update-card {
    background: linear-gradient(145deg, var(--card-bg), rgba(30, 41, 59, 0.8));
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.update-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.update-card-header h3 {
    color: #60a5fa;
    margin: 0;
    font-size: 1.3rem;
}

.update-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.update-desc {
    color: var(--text-main);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

.update-btn {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 0.8rem;
    text-align: center;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

.update-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}
