:root {
  --twitch-purple: #9147ff;
  --twitch-dark: #18181b;
  --twitch-bg-gradient: linear-gradient(135deg, #18181b 0%, #262347 100%);
  --twitch-accent: #a970ff;
  --twitch-highlight: #f7f7fa;
  --twitch-error: #ff4b4b;
  --border-radius: 8px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  --transition: all 0.2s ease;
  --glow: 0 0 8px rgba(145, 71, 255, 0.5);
  --backdrop-blur: blur(8px);
}

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

html, body {
  width: 100%;
  min-height: 100vh;
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  background: var(--twitch-bg-gradient);
  color: var(--twitch-highlight);
  font-size: 16px;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem;
  gap: 1.5rem;
}

/* Header */
.header {
  text-align: center;
  width: 100%;
  max-width: 1200px;
  padding: 1rem;
  background: rgba(24, 24, 27, 0.9);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
}

.logo {
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 700;
  color: var(--twitch-purple);
  margin-bottom: 0.5rem;
}

.subtitle {
  font-size: clamp(0.9rem, 3vw, 1.1rem);
  color: #b0b0b0;
}

/* Headings */
h1 {
  font-size: clamp(1.75rem, 6vw, 2.25rem);
  color: var(--twitch-purple);
  text-align: center;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

h2 {
  font-size: clamp(1.25rem, 5vw, 1.5rem);
  color: var(--twitch-highlight);
  text-align: center;
  margin-bottom: 1rem;
}

h3 {
  font-size: clamp(0.9rem, 4vw, 1.1rem);
  color: var(--twitch-highlight);
  margin-bottom: 0.5rem;
}

/* Links */
a {
  color: var(--twitch-accent);
  text-decoration: none;
  transition: var(--transition);
}
a:hover {
  color: var(--twitch-purple);
  text-decoration: none;
  filter: brightness(1.2);
}

/* User Link */
.user-link {
  cursor: pointer;
  color: var(--twitch-accent);
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: var(--transition);
}
.user-link:hover {
  color: var(--twitch-purple);
  background: rgba(145, 71, 255, 0.1);
}

/* Navigation */
.nav-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  width: 100%;
  max-width: 1200px;
  padding: 0 0.5rem;
}

.nav-button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  background: var(--twitch-dark);
  border-radius: var(--border-radius);
  font-size: clamp(0.9rem, 3.5vw, 1rem);
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.nav-button:hover, .nav-button:focus {
  background: var(--twitch-purple);
  color: var(--twitch-highlight);
  box-shadow: var(--glow);
  transform: translateY(-2px);
}

/* Table */
.table-wrapper {
  width: 100%;
  max-width: 1200px;
  overflow-x: auto;
  margin: 0.5rem 0;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 320px;
  border-collapse: collapse;
  background: var(--twitch-dark);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

th, td {
  padding: 1rem 0.75rem;
  text-align: center;
  font-size: clamp(0.85rem, 3.5vw, 0.95rem);
}

th {
  background-color: var(--twitch-purple);
  color: white;
  position: sticky;
  top: 0;
  z-index: 1;
}

tr:nth-child(even) {
  background-color: #232347;
}

tr:nth-child(odd) {
  background-color: #18181b;
}

tr:hover {
  background-color: #2d1a4d;
}

/* Search bar */
.searchbar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
  width: 100%;
  max-width: 600px;
  padding: 0 0.5rem;
}

.searchbar input {
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius);
  border: 1px solid #444;
  background: #232347;
  color: white;
  width: 100%;
  font-size: clamp(0.9rem, 4vw, 1rem);
  transition: var(--transition);
}
.searchbar input:focus {
  outline: none;
  border-color: var(--twitch-purple);
  box-shadow: var(--glow);
}

.searchbar button {
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--border-radius);
  background: var(--twitch-purple);
  color: white;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  font-size: clamp(0.9rem, 4vw, 1rem);
  transition: var(--transition);
  touch-action: manipulation;
}
.searchbar button:hover, .searchbar button:focus {
  background: var(--twitch-accent);
  color: var(--twitch-dark);
  box-shadow: var(--glow);
  transform: translateY(-2px);
}

/* Info Box */
.info {
  background: rgba(24, 24, 27, 0.85);
  padding: 1.25rem;
  border-radius: var(--border-radius);
  max-width: 600px;
  width: 100%;
  margin: 0.5rem 0;
  box-shadow: var(--shadow);
  font-size: clamp(0.9rem, 3.5vw, 1rem);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  width: 100%;
}

.stat-card {
  background: var(--twitch-dark);
  border-radius: var(--border-radius);
  padding: 0.75rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--glow);
}

.stat-icon {
  font-size: 1.5rem;
  color: var(--twitch-purple);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: clamp(1rem, 4vw, 1.25rem);
  font-weight: 700;
  color: var(--twitch-accent);
  transition: opacity 0.3s ease;
}
.stat-value.loaded {
  opacity: 1;
}
.stat-value.error {
  color: var(--twitch-error);
}

.stats-note {
  color: #888;
  font-size: clamp(0.8rem, 3vw, 0.9rem);
  text-align: center;
  margin: 1rem 0;
}

/* Back Link */
.back-link {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: clamp(0.9rem, 3.5vw, 1rem);
  transition: var(--transition);
}
.back-link:hover, .back-link:focus {
  color: var(--twitch-purple);
  transform: translateX(-3px);
}

/* Footer */
.footer {
  text-align: center;
  padding: 1rem;
  color: #888;
  font-size: clamp(0.8rem, 3vw, 0.9rem);
  width: 100%;
  max-width: 1200px;
}

.footer a {
  color: var(--twitch-accent);
}
.footer a:hover {
  color: var(--twitch-purple);
}

/* User Stats Modal */
.user-stats-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: var(--backdrop-blur);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
}
.user-stats-modal.loaded {
  opacity: 1;
}

.user-stats-content {
  background: var(--twitch-dark);
  border: 1px solid var(--twitch-purple);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow), var(--glow);
  padding: 1rem;
  position: relative;
  width: 80%;
  max-width: 400px;
  max-height: 70vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: scale(0.7);
  transition: transform var(--transition), opacity var(--transition);
}
.user-stats-modal.loaded .user-stats-content {
  transform: scale(1);
  opacity: 1;
}

.close-button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--twitch-purple);
  border: none;
  border-radius: 50%;
  color: var(--twitch-highlight);
  font-size: 0.9rem;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
.close-button:hover, .close-button:focus {
  background: var(--twitch-accent);
  color: var(--twitch-dark);
  box-shadow: var(--glow);
  transform: scale(1.1);
}

/* Not Found Message */
.notfound {
  color: var(--twitch-error);
  font-size: clamp(0.9rem, 3.5vw, 1rem);
  text-align: center;
  margin: 1rem 0;
}

/* Responsive Design */
@media (min-width: 1200px) {
  body {
    padding: 2rem;
  }

  .header, .nav-links, .stats-grid, .table-wrapper, .footer {
    max-width: 1000px;
  }

  .nav-links {
    grid-template-columns: repeat(5, 1fr);
  }

  th, td {
    padding: 1.25rem 1rem;
    font-size: clamp(0.9rem, 2vw, 1rem);
  }

  .searchbar {
    flex-direction: row;
    gap: 0.75rem;
  }

  .searchbar input, .searchbar button {
    width: auto;
  }

  .user-stats-content {
    max-width: 600px;
    padding: 1.5rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-icon {
    font-size: 2rem;
  }

  .stat-value {
    font-size: clamp(1.25rem, 4vw, 1.5rem);
  }
}

@media (max-width: 768px) {
  body {
    padding: 0.75rem;
  }

  .header {
    padding: 0.75rem;
  }

  h1 {
    font-size: clamp(1.5rem, 5vw, 1.75rem);
  }

  h2 {
    font-size: clamp(1rem, 4vw, 1.25rem);
  }

  h3 {
    font-size: clamp(0.85rem, 3.5vw, 1rem);
  }

  .table-wrapper {
    margin: 0;
  }

  table {
    min-width: 100%;
  }

  th, td {
    padding: 0.75rem 0.5rem;
    font-size: clamp(0.8rem, 3vw, 0.9rem);
  }

  .searchbar {
    max-width: 100%;
  }

  .searchbar input, .searchbar button {
    padding: 0.65rem 0.75rem;
    font-size: clamp(0.85rem, 3.5vw, 0.95rem);
  }

  .info, .stat-card {
    margin: 0.5rem;
    padding: 0.75rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .user-stats-content {
    width: 80%;
    max-width: 400px;
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .nav-links {
    grid-template-columns: 1fr;
  }

  .nav-button {
    padding: 0.65rem;
  }

  th, td {
    padding: 0.5rem 0.25rem;
  }

  .stat-card {
    padding: 0.5rem;
  }

  .stat-icon {
    font-size: 1.25rem;
  }

  .stat-value {
    font-size: clamp(0.9rem, 3.5vw, 1.1rem);
  }
}