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

:root {
  --bg: #0b1020;
  --card: #151c31;
  --card2: #1c2540;
  --text: #f4f7ff;
  --muted: #9ca8c7;
  --accent: #6c63ff;
  --accent2: #8b85ff;
  --border: rgba(255,255,255,.09);
}

body {
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button, input {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(108,99,255,.18), transparent 35%),
    radial-gradient(circle at 80% 80%, rgba(139,133,255,.12), transparent 35%),
    var(--bg);
}

.device-card {
  width: min(520px, 100%);
  padding: 48px 32px;
  text-align: center;
  background: rgba(21,28,49,.92);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: 0 25px 80px rgba(0,0,0,.35);
}

.logo {
  font-size: 64px;
  margin-bottom: 12px;
}

.device-card h1 {
  font-size: 42px;
  margin-bottom: 8px;
}

.device-card p {
  color: var(--muted);
  margin-bottom: 30px;
}

.device-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.device-btn {
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text);
  padding: 24px;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 42px;
  transition: .2s;
}

.device-btn span {
  font-size: 17px;
  font-weight: bold;
}

.device-btn:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  background: #252f50;
}

.topbar {
  height: 72px;
  padding: 0 5%;
  display: flex;
  align-items: center;
  gap: 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(11,16,32,.9);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-size: 20px;
  font-weight: 800;
  white-space: nowrap;
}

nav {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-btn, .profile-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 10px;
}

.nav-btn:hover, .nav-btn.active {
  color: var(--text);
  background: var(--card2);
}

.profile-btn {
  background: var(--accent);
  color: white;
  font-weight: bold;
}

main {
  width: min(1200px, 90%);
  margin: 0 auto;
  padding: 48px 0 80px;
}

.page {
  display: none;
}

.active-page {
  display: block;
}

.hero {
  padding: 42px;
  border: 1px solid var(--border);
  border-radius: 26px;
  background:
    radial-gradient(circle at 85% 20%, rgba(108,99,255,.25), transparent 30%),
    var(--card);
  margin-bottom: 28px;
}

.eyebrow {
  color: var(--accent2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  margin-bottom: 10px;
}

.hero h1 {
  max-width: 700px;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1.05;
  margin-bottom: 16px;
}

.hero p:not(.eyebrow), .page-title p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.6;
}

.search-row {
  margin: 24px 0 14px;
}

#searchInput {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 17px 20px;
  border-radius: 14px;
  outline: none;
}

#searchInput:focus {
  border-color: var(--accent);
}

.categories {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 34px;
}

.category-btn {
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--card);
  padding: 9px 14px;
  border-radius: 999px;
}

.category-btn.active, .category-btn:hover {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-heading span {
  color: var(--muted);
  font-size: 14px;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.game-card {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 18px;
  overflow: hidden;
  transition: .2s;
}

.game-card:hover {
  transform: translateY(-4px);
  border-color: rgba(108,99,255,.6);
}

.game-thumb {
  min-height: 150px;
  display: grid;
  place-items: center;
  font-size: 64px;
  background: var(--card2);
}

.game-info {
  padding: 18px;
}

.game-info h3 {
  margin-bottom: 8px;
}

.game-info p {
  color: var(--muted);
  font-size: 14px;
  min-height: 38px;
}

.play-btn {
  margin-top: 16px;
  width: 100%;
  border: 0;
  background: var(--accent);
  color: white;
  padding: 12px;
  border-radius: 10px;
  font-weight: bold;
}

.play-btn:hover {
  background: var(--accent2);
}

.page-title {
  margin-bottom: 28px;
}

.page-title h1 {
  font-size: 42px;
  margin-bottom: 10px;
}

.game-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.game-box, .side-card, .leaderboard-card, .account-card {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 20px;
  padding: 22px;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-header h1 {
  font-size: 34px;
}

.score-box {
  color: var(--muted);
}

.score-box strong {
  color: white;
}

.game-area {
  min-height: 430px;
  margin-top: 20px;
  border-radius: 16px;
  background: #090d18;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 20px;
  color: var(--muted);
}

.game-area .play-btn {
  width: auto;
  padding: 13px 28px;
}

.back-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  margin-bottom: 18px;
}

.back-btn:hover {
  color: white;
}

.leaderboard-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.leader-tab {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 10px;
}

.leader-tab.active {
  background: var(--accent);
  color: white;
}

.rank-row {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 15px 5px;
  border-bottom: 1px solid var(--border);
}

.rank-row:last-child {
  border-bottom: 0;
}

.rank {
  font-weight: bold;
}

.score {
  font-weight: bold;
}

.account-card {
  max-width: 650px;
  text-align: center;
  margin: auto;
  padding: 42px;
}

.avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  background: var(--card2);
  font-size: 38px;
}

.account-card p {
  color: var(--muted);
}

.account-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 30px;
}

.account-stats div {
  padding: 15px;
  background: var(--card2);
  border-radius: 12px;
}

.account-stats strong, .account-stats span {
  display: block;
}

.account-stats strong {
  font-size: 22px;
}

.account-stats span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.modal-card {
  width: min(420px, 100%);
  padding: 30px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  position: relative;
}

.modal-card p, .modal-card small {
  color: var(--muted);
  display: block;
  margin: 10px 0 18px;
  line-height: 1.5;
}

.modal-card input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: white;
  padding: 13px;
  border-radius: 10px;
  outline: none;
}

.close-btn {
  position: absolute;
  right: 16px;
  top: 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 28px;
}

@media (max-width: 850px) {
  .topbar {
    padding: 0 3%;
    gap: 8px;
  }

  .brand {
    font-size: 17px;
  }

  nav {
    justify-content: center;
  }

  .nav-btn {
    font-size: 12px;
    padding: 9px 7px;
  }

  .profile-btn {
    font-size: 12px;
    padding: 9px 10px;
  }

  .games-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .game-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  main {
    width: 94%;
    padding-top: 24px;
  }

  .device-buttons {
    grid-template-columns: 1fr;
  }

  .hero {
    padding: 26px;
  }

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

  .game-area {
    min-height: 330px;
  }

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