@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Roboto+Slab:wght@600;700;800&family=Space+Grotesk:wght@500;600;700&display=swap");

:root {
  color-scheme: dark;
  font-family: "DM Sans", sans-serif;
  color: #f4f7fb;
  background: #1768d8;
  font-synthesis: none;
  --accent: #ffb84d;
  --border: rgb(255 255 255 / 14%);
  --panel: rgb(17 25 37 / 82%);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background-color: #1768d8;
  background-image:
    url("assets/maple-sky-ship.jpg"),
    linear-gradient(180deg, #1768d8 0%, #278de5 48%, #9cdef8 100%);
  background-position: center top, center;
  background-repeat: no-repeat, no-repeat;
  background-size: cover, cover;
  background-attachment: scroll;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 0;
  padding: 16px 24px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: rgb(22 27 35 / 88%);
  box-shadow: 0 12px 32px rgb(9 29 57 / 18%);
  backdrop-filter: blur(16px);
}

.topbar-actions {
  position: absolute;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.auth-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-status {
  max-width: 220px;
  color: #c7d2df;
  font-size: 11px;
}

.auth-button,
.signout-button {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid rgb(255 184 77 / 60%);
  border-radius: 9px;
  background: rgb(255 184 77 / 13%);
  color: #fff3dc;
  cursor: pointer;
  font: 600 11px "DM Sans", sans-serif;
}

.auth-button:hover,
.signout-button:hover {
  background: rgb(255 184 77 / 24%);
}

.auth-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.auth-button:focus-visible,
.signout-button:focus-visible,
.fame-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.8px;
}

.brand-icon {
  font-size: 32px;
}

.brand-accent {
  color: var(--accent);
}

.brand {
  color: #f8fafc;
}

main {
  width: min(100% - 40px, 680px);
  margin: 36px auto 80px;
  padding: 26px 20px;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 24px 64px rgb(6 28 54 / 30%);
  backdrop-filter: blur(18px);
}

.content-layout {
  display: grid;
  width: min(100% - 40px, 1600px);
  grid-template-columns: 240px minmax(0, 900px) 240px;
  align-items: start;
  justify-content: center;
  gap: 20px;
  margin: 36px auto 80px;
}

.content-layout main,
.leaderboard-panel,
.top-category-panel {
  width: 100%;
  margin: 0;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 24px 64px rgb(6 28 54 / 30%);
  backdrop-filter: blur(18px);
}

.content-layout main {
  min-width: 0;
  padding: 26px 20px;
}

.leaderboard-panel {
  padding: 22px 16px;
}

.top-category-panels {
  display: grid;
  align-content: start;
  gap: 18px;
}

.top-category-panel {
  padding: 22px 16px;
}

.leaderboard-panel h2,
.top-category-panel h2 {
  margin: 0 0 16px;
  color: #fff3dc;
  font-family: "Roboto Slab", Georgia, serif;
  font-size: 19px;
  text-align: center;
}

.leaderboard-status {
  margin: 0;
  color: #c7d2df;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.leaderboard-list {
  display: grid;
  margin: 0;
  padding: 0;
  gap: 7px;
  list-style: none;
}

.leaderboard-entry {
  display: grid;
  min-width: 0;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 9px;
  background: rgb(255 255 255 / 6%);
}

.leaderboard-rank {
  color: var(--accent);
  font-family: "Roboto Slab", Georgia, serif;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.leaderboard-site {
  overflow: hidden;
  color: #f4f7fb;
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-site:hover,
.leaderboard-site:focus-visible {
  color: var(--accent);
  outline: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.leaderboard-score {
  color: #ffd895;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.category-filters {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.category-all-row,
.category-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.category-toggle {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 999px;
  background: rgb(255 255 255 / 6%);
  color: #c7d2df;
  cursor: pointer;
  font: 600 11px "DM Sans", sans-serif;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.category-toggle:hover {
  border-color: rgb(255 255 255 / 35%);
  color: #ffffff;
}

.category-toggle.is-active {
  border-color: rgb(255 184 77 / 65%);
  background: rgb(255 184 77 / 16%);
  color: #fff3dc;
}

.category-toggle-all {
  min-width: 76px;
  border-color: rgb(255 184 77 / 70%);
  background: rgb(255 184 77 / 12%);
  color: #fff3dc;
  font-size: 12px;
  letter-spacing: 0.06em;
}

.category-toggle-all .toggle-indicator {
  border-radius: 2px;
}

.toggle-indicator {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border: 1px solid #8290a1;
  border-radius: 50%;
  background: transparent;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.category-toggle.is-active .toggle-indicator {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 10px rgb(255 184 77 / 58%);
}

.category-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.category-help {
  margin: 12px 0 22px;
  color: #c7d2df;
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.fame-policy {
  margin: 0 0 4px;
  color: #d7e1ed;
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.site-grid {
  display: flex;
  max-width: 100%;
  flex-wrap: wrap;
  justify-content: center;
  margin: 0 auto;
  gap: 8px;
}

.site-card {
  display: flex;
  width: 190px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 12px;
  background: rgb(255 255 255 / 95%);
  box-shadow: 0 3px 12px rgb(5 26 48 / 12%);
  opacity: 0.38;
  filter: grayscale(0.7);
  transition: opacity 180ms ease, filter 180ms ease, transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.site-card.is-highlighted {
  opacity: 1;
  filter: none;
}

.site-card:hover,
.site-card:focus-within {
  position: relative;
  z-index: 1;
  transform: translateY(-3px);
  border-color: rgb(255 184 77 / 90%);
  opacity: 1;
  filter: none;
  box-shadow: 0 10px 24px rgb(5 26 48 / 26%);
}

.site-link {
  display: flex;
  width: 100%;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 10px;
  background: transparent;
  color: #273343;
  font-size: 12px;
  font-weight: 600;
  transition: background 160ms ease;
}

.site-link:hover,
.site-link:focus-visible {
  outline: none;
  background: rgb(255 255 255 / 60%);
}

.site-card:focus-within {
  border-color: rgb(255 184 77 / 90%);
  box-shadow: 0 0 0 2px rgb(255 184 77 / 40%), 0 9px 22px rgb(5 26 48 / 20%);
}

.fame-row {
  display: flex;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  padding: 0 6px 4px;
}

.fame-control {
  display: inline-flex;
  min-height: 18px;
  align-items: stretch;
  gap: 1px;
}

.fame-button {
  display: grid;
  width: 20px;
  height: 18px;
  flex: 0 0 20px;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease;
}

.fame-arrow {
  display: block;
  width: 20px;
  height: 18px;
}

.fame-count {
  display: flex;
  min-width: 18px;
  min-height: 18px;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 1px solid #827c70;
  background: linear-gradient(180deg, #eeece4 0%, #d8d5cb 100%);
  box-shadow: inset 1px 1px 0 #fffefa, inset -1px -1px 0 #c1bdb1;
  color: #24211d;
  font: 500 11px/1 "Roboto Slab", Georgia, serif;
  white-space: nowrap;
}

.fame-label {
  display: flex;
  min-width: 49px;
  min-height: 18px;
  align-items: center;
  padding: 0 5px;
  border: 1px solid #8f3158;
  background: linear-gradient(180deg, #d65b91 0%, #bd3d74 100%);
  box-shadow: inset 1px 1px 0 #f18eb4, inset -1px -1px 0 #9e2d5b;
  color: #fff4f8;
  font: 700 10px/1 "Roboto Slab", Georgia, serif;
  letter-spacing: 0.02em;
  text-shadow: 1px 1px 0 #8e2c54;
}

.fame-button:hover:not(:disabled) {
  z-index: 1;
  transform: translateY(-2px) scale(1.14);
  filter: brightness(1.12) drop-shadow(0 2px 3px rgb(102 49 12 / 55%));
}

.fame-button:focus-visible:not(:disabled) {
  outline: 2px solid #ffbd51;
  outline-offset: 2px;
  transform: translateY(-2px) scale(1.1);
  filter: drop-shadow(0 2px 3px rgb(102 49 12 / 55%));
}

.fame-button:active:not(:disabled) {
  transform: translateY(0) scale(0.96);
  filter: brightness(0.95);
}

.fame-button:disabled {
  cursor: default;
  filter: grayscale(1);
  opacity: 0.45;
}

.fame-notice-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.fame-notice {
  min-height: 16px;
  margin: 0;
  color: #d7e1ed;
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.site-icon {
  display: grid;
  width: 27px;
  height: 27px;
  flex: 0 0 27px;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  font-size: 13px;
}

.site-icon-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.site-icon-fallback {
  font-size: 13px;
}

.icon-rose { background: #ffebe5; color: #c63b32; }
.icon-violet { background: #fff1cf; color: #d77a08; }
.icon-blue { background: #e1f4ff; color: #268bc4; }
.icon-green { background: #e4f4dc; color: #4a963d; }
.icon-orange { background: #fff0d6; color: #d77a08; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

@media (max-width: 600px) {
  .topbar {
    padding: 13px 15px;
  }

  .topbar-actions {
    right: 15px;
  }

  .brand {
    gap: 6px;
    font-size: 22px;
  }

  .brand-icon {
    font-size: 26px;
  }

  .topbar-actions {
    gap: 10px;
  }

  .auth-status {
    display: none;
  }

  .auth-button,
  .signout-button {
    padding: 7px 8px;
    font-size: 10px;
  }

  main {
    width: calc(100% - 24px);
    margin-top: 24px;
    padding: 22px 12px;
    border-radius: 18px;
  }

  .content-layout {
    width: calc(100% - 24px);
    margin-top: 24px;
  }

  .content-layout main {
    width: 100%;
    padding: 22px 12px;
    border-radius: 18px;
  }

  .leaderboard-panel,
  .top-category-panels {
    width: 100%;
    margin-bottom: 16px;
  }

  .leaderboard-panel,
  .top-category-panel {
    padding: 18px 12px;
    border-radius: 18px;
  }

  .content-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .site-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 100%;
  }

  .site-card {
    width: 100%;
    min-width: 0;
  }

  .site-link {
    min-height: 48px;
    gap: 6px;
    padding: 6px;
    font-size: 11px;
  }

  .site-link > span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (min-width: 601px) and (max-width: 1199px) {
  .content-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
  }

  .leaderboard-panel,
  .top-category-panels {
    width: min(100%, 900px);
  }

  .content-layout main {
    width: min(100%, 900px);
  }
}

@media (max-width: 380px) {
  .site-icon {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
