/* --- VARIABLES & BASE STYLES --- */
:root {
  --bg-dark-900: #0f1014;
  --bg-dark-800: #1c1e24;
  --bg-dark-700: #292c35;
  --border-color: #313541;
  --text-primary: #e6e6e6;
  --text-secondary: #9a9da8;
  --accent-blue: #4a89f8;
  --gold: #ffc700;
  --silver: #b4e1ff;
  --bronze: #e29f7a;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark-900);
  color: var(--text-primary);
  overflow-x: hidden;
}

.container {
  width: 90%;
  max-width: 1100px;
  margin: 0 auto;
}
.hidden {
  display: none !important;
}

/* --- NAVBAR --- */
.navbar {
  background-color: rgba(15, 16, 20, 0.7);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 1rem 0;
}
.navbar-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo i {
  font-size: 24px;
  color: var(--accent-blue);
}
.logo h1 {
  font-size: 22px;
  font-weight: 800;
}
.nav-buttons {
  display: flex;
  gap: 1rem;
}
.btn {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary {
  background-color: var(--accent-blue);
  color: var(--bg-dark-900);
}
.btn-primary:hover {
  background-color: #6c9eff;
}
.btn-secondary {
  background-color: var(--bg-dark-700);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background-color: var(--bg-dark-800);
}

/* HERO VISIBILITY */
.hero {
  text-align: center;
  margin: 2rem 0;
  transition: all 0.3s ease;
}
#hero-heading {
  display: none;
}
#hero-tagline {
  font-size: 1.25rem;
  color: var(--text-secondary);
}
body.user-logged-in #hero-section {
  display: none;
}

/* --- PLATFORM TOGGLE --- */
.platform-toggle {
  display: flex;
  justify-content: center;
  margin: 2rem auto;
  background-color: var(--bg-dark-800);
  border-radius: 12px;
  padding: 6px;
  width: fit-content;
  border: 1px solid var(--border-color);
}
.toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.3s ease;
}
.toggle-btn.active {
  background-color: var(--bg-dark-900);
  color: var(--text-primary);
}
.toggle-btn img {
  width: 20px;
  height: 20px;
  opacity: 0.7;
}
.toggle-btn.active img {
  opacity: 1;
}

/* --- FEEDBACK VIEWS --- */
.feedback-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5rem 1rem;
  text-align: center;
  color: var(--text-secondary);
}
.loader {
  width: 50px;
  height: 50px;
  border: 5px solid var(--border-color);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- PODIUM DESIGN --- */
.podium-section {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding: 0 1rem;
}
.podium-card {
  background: var(--bg-dark-800);
  border-radius: 16px;
  padding: 1.5rem 1rem;
  text-align: center;
  width: 100%;
  max-width: 180px;
  position: relative;
  border: 1px solid var(--border-color);
}
.podium-card.rank-1 {
  order: 2;
  transform: translateY(-20px);
  background: var(--bg-dark-700);
  padding-top: 2.5rem;
  max-width: 200px;
}
.podium-card.rank-2 {
  order: 1;
}
.podium-card.rank-3 {
  order: 3;
}
.podium-avatar-wrapper {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 1rem;
}
.podium-card.rank-1 .podium-avatar-wrapper {
  width: 100px;
  height: 100px;
}
.podium-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--bg-dark-900);
}
.podium-card.rank-1 .podium-avatar {
  border-color: var(--gold);
}
.podium-card.rank-2 .podium-avatar {
  border-color: var(--silver);
}
.podium-card.rank-3 .podium-avatar {
  border-color: var(--bronze);
}
.rank-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 28px;
  height: 28px;
  background-color: var(--bg-dark-700);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  border: 2px solid;
}
.podium-card.rank-1 .rank-badge {
  border-color: var(--gold);
  color: var(--gold);
}
.podium-card.rank-2 .rank-badge {
  border-color: var(--silver);
  color: var(--silver);
}
.podium-card.rank-3 .rank-badge {
  border-color: var(--bronze);
  color: var(--bronze);
}
.crown-icon {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-90%);
  font-size: 2.5rem;
  color: var(--gold);
}
.podium-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.podium-rating {
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--text-primary);
  margin: 0.25rem 0;
}
.podium-card.rank-1 .podium-rating {
  font-size: 1.75rem;
}
.podium-card .handle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- LIST DESIGN --- */
.list-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 5rem;
}
.list-item {
  display: flex;
  align-items: center;
  background-color: var(--bg-dark-800);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  transition: background-color 0.2s;
}
.list-item:hover {
  background-color: var(--bg-dark-700);
}
.list-item.is-user {
  border-left: 4px solid var(--accent-blue);
  background-color: var(--bg-dark-700);
}

.list-rank {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-secondary);
  width: 50px;
  text-align: center;
  flex-shrink: 0;
}
.list-avatar {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 1rem;
  flex-shrink: 0;
}

/* MODIFICATION: Switched to a robust CSS Grid layout for item content */
.list-item-content {
  flex-grow: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr auto; /* Left column grows, right column is auto-sized */
  grid-template-rows: auto auto;
  align-items: baseline; /* Aligns content nicely on their baselines */
  column-gap: 1rem;
}

.list-item-content .name {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item-content .rating {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  justify-self: end; /* Aligns to the right of the cell */
  font-weight: 700;
  font-size: 1.1rem;
}
.list-item-content .handle {
  grid-column: 1 / 2;
  grid-row: 2 / 3;
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item-content .extra-data {
  grid-column: 2 / 3;
  grid-row: 2 / 3;
  justify-self: end; /* Aligns to the right of the cell */
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}
.list-item-content .extra-data i {
  font-size: 0.7rem;
}

/* --- My Rank Banner & Modal --- */
#my-rank-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(
    to top,
    rgba(15, 16, 20, 1),
    rgba(15, 16, 20, 0.7)
  );
  border-top: 1px solid var(--border-color);
  z-index: 40;
  backdrop-filter: blur(10px);
  animation: slideInUp 0.5s ease-out;
}
#my-rank-banner .list-item {
  max-width: 1100px;
  margin: 0.5rem auto;
  width: 90%;
}
@keyframes slideInUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-content {
  background-color: var(--bg-dark-800);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  width: 90%;
  max-width: 450px;
  padding: 2rem;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.modal-header h2 {
  font-size: 1.5rem;
}
.close-btn {
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--text-secondary);
  cursor: pointer;
}
.modal-subtitle {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}
.input-group {
  margin-bottom: 1rem;
}
.input-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}
.input-group input {
  width: 100%;
  background-color: var(--bg-dark-900);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 12px;
  font-size: 1rem;
}
.input-group input:focus {
  outline: none;
  border-color: var(--accent-blue);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.8rem;
  margin-top: 1.5rem;
}
#modal-feedback {
  font-size: 0.9rem;
  min-height: 20px;
}
.feedback-success {
  color: #3fb950;
}
.feedback-error {
  color: #f85149;
}
.spinner-small {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* RESPONSIVE FIX FOR PODIUM */
@media (max-width: 640px) {
  .podium-section {
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
    margin-top: 2rem;
  }
  .podium-card {
    max-width: 250px;
  }
  .podium-card.rank-1 {
    order: 1;
    transform: translateY(0);
  }
  .podium-card.rank-2 {
    order: 2;
  }
  .podium-card.rank-3 {
    order: 3;
  }
}

.logo img {
  height: 40px;
  width: auto;
  box-shadow: 0 2px 8px rgba(74, 137, 248, 0.15);
  padding: 4px;
  transition: transform 0.2s;
}
.logo img:hover {
  transform: scale(1.07) rotate(-2deg);
  box-shadow: 0 4px 16px rgba(74, 137, 248, 0.25);
}