:root {
  --bg: var(--platform-bg);
  --surface: var(--platform-surface);
  --surface-hover: var(--platform-surface-hover);
  --border: var(--platform-border);
  --text: var(--platform-text);
  --text-dim: var(--platform-muted);
  --accent: var(--platform-accent);
  --accent-hover: var(--platform-accent-strong);
  --success: #45b982;
  --danger: var(--platform-danger);
  --radius: var(--platform-radius);
}

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

body {
  font-family: var(--platform-font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.portal-header {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: var(--platform-header-height);
  padding: 0 var(--platform-shell-padding-x);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.portal-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0;
}

.portal-logo img { border-radius: var(--platform-radius-sm); }

.portal-nav {
  display: flex;
  gap: 6px;
  flex: 1;
}

.portal-nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  min-height: var(--platform-nav-item-height);
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: var(--platform-radius-sm);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.portal-nav a:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--border);
}

.portal-auth button {
  min-height: 36px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--platform-radius-sm);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s;
}

.portal-locale select {
  min-width: 108px;
  padding: 6px 28px 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.portal-locale select:focus {
  outline: none;
  box-shadow: var(--platform-focus);
}

.btn-login {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--accent-hover);
  border-radius: var(--platform-radius-sm);
  padding: 7px 14px;
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.btn-login:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.btn-ghost:hover { color: var(--text); }

#portalMain {
  flex: 1;
  padding: 32px 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.portal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--platform-footer-min-height);
  padding: 14px var(--platform-shell-padding-x);
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-dim);
}

.portal-footer a {
  color: var(--text-dim);
  text-decoration: none;
}

.portal-footer a:hover { color: var(--text); }

/* Home hero */
.hero {
  text-align: center;
  padding: 8px 0 36px;
}

.hero-banner {
  width: 100%;
  aspect-ratio: 3 / 1;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #070b12;
}

.hero-banner img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-copy {
  max-width: 820px;
  margin: 24px auto 0;
}

.hero h1 {
  font-size: 40px;
  font-weight: 800;
  margin-bottom: 12px;
}

.hero p {
  font-size: 18px;
  color: var(--text-dim);
  line-height: 1.6;
}

/* Stats */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-top: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--border);
}

.stat {
  min-width: 0;
  padding: 18px 12px;
  background: var(--surface);
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 13px;
  color: var(--text-dim);
}

/* Game cards */
.section-title {
  font-size: 22px;
  font-weight: 700;
  margin: 32px 0 16px;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.game-card {
  display: flex;
  flex-direction: column;
  min-height: 230px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s;
}

.game-card.has-media {
  min-height: 390px;
}

.game-card-media {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: #07111d;
}

.game-card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-card-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 18px 20px 20px;
}

.game-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.game-card.coming-soon {
  opacity: 0.72;
  cursor: default;
}

.game-card.coming-soon:hover {
  border-color: var(--border);
  transform: none;
}

.game-card h3 {
  font-size: 18px;
  margin-bottom: 6px;
}

.game-card-headline {
  margin: 10px 0 0;
  color: var(--text);
  font-size: 26px;
  font-weight: 900;
  line-height: 1.15;
}

.game-card-facts {
  display: grid;
  gap: 6px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.game-card-facts li {
  min-height: 28px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-hover);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.game-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 14px;
}

.game-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 8px;
}

.badge-live { background: var(--success); color: white; }
.badge-preview { background: #f0b84f; color: #111; }
.badge-soon { background: var(--border); color: var(--text-dim); }

.game-link-label {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 32px 0 16px;
}

.section-heading .section-title {
  margin: 0 0 6px;
}

.section-subtitle {
  color: var(--text-dim);
  font-size: 14px;
}

.segmented-control {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.segment {
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.segment:hover,
.segment.active {
  background: var(--surface-hover);
  color: var(--text);
}

/* Leaderboard table */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.leaderboard-table th {
  font-size: 13px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.leaderboard-table td { font-size: 14px; }

.rank-badge {
  display: inline-block;
  width: 28px;
  height: 28px;
  line-height: 28px;
  text-align: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 13px;
}

.rank-1 { background: #ffd700; color: #000; }
.rank-2 { background: #c0c0c0; color: #000; }
.rank-3 { background: #cd7f32; color: #000; }

/* Profile */
.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
}

/* News */
.news-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.news-item {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.news-item h3 {
  font-size: 16px;
  margin-bottom: 4px;
}

.news-item .meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.news-item p { font-size: 14px; color: var(--text-dim); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px;
  color: var(--text-dim);
}

/* Auth modal */
.auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.auth-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px;
  width: min(400px, calc(100vw - 32px));
}

.auth-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.auth-modal h2 {
  margin: 0;
  font-size: 20px;
}

.auth-modal-copy,
.auth-modal-status {
  margin: 10px 0 20px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.6;
}

.auth-modal .auth-modal-close {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.auth-modal-content,
.auth-provider-stack,
.auth-local-form {
  display: grid;
  gap: 10px;
}

.auth-local-label {
  margin: 0;
  color: var(--text-dim);
  font-size: 12px;
}

.auth-local-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.auth-modal input {
  width: 100%;
  padding: 10px;
  margin-bottom: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
}

.auth-modal button {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
}

.auth-modal .divider {
  text-align: center;
  color: var(--text-dim);
  margin: 16px 0;
  font-size: 13px;
}

.auth-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 8px;
}

@media (max-width: 720px) {
  .portal-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px 12px;
    min-height: 0;
    padding: 12px 16px;
  }

  .portal-logo {
    min-width: 0;
  }

  .portal-nav {
    grid-column: 1 / -1;
    grid-row: 3;
    width: 100%;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .portal-nav a {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .portal-locale {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    margin-left: 0;
  }

  .portal-auth {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    width: 100%;
    min-width: 0;
    margin-left: 0;
  }

  .portal-auth > * {
    max-width: 100%;
    flex-wrap: wrap;
  }

  .portal-auth a,
  .portal-auth button {
    white-space: nowrap;
  }

  #portalMain {
    min-width: 0;
    padding: 24px 16px;
  }

  .hero h1 {
    font-size: 32px;
  }

  .section-heading {
    flex-wrap: wrap;
  }

  .hero-banner {
    aspect-ratio: 16 / 9;
  }

  .hero-copy {
    margin-top: 20px;
  }

  .stats-bar {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .stat {
    grid-column: span 2;
    padding: 14px 6px;
  }

  .stat:nth-last-child(-n + 2) {
    grid-column: span 3;
  }

  .section-heading {
    align-items: flex-start;
  }
}
