:root {
  color-scheme: dark;
  --bg: #12141a;
  --panel: #1a1d24;
  --text: #f0f1ed;
  --muted: #93969e;
  --border: #292d36;
  --accent: #4f9ce0;
  --accent-2: #e0b13a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px rgba(0, 0, 0, 0.35);
  --gold: #e8b14a;
  --silver: #9ea4b0;
  --bronze: #b8794f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.site-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.7rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.site-brand {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 1.25rem;
}

.site-nav-link {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease;
}

.site-nav-link:hover {
  color: var(--text);
}

.site-nav-link.active {
  color: var(--accent);
}

header {
  padding: 2rem 1.5rem 1.25rem;
  text-align: center;
}

header h1 {
  margin: 0 0 1.1rem;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.tabs {
  display: inline-flex;
  gap: 0.2rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.25rem;
  box-shadow: var(--shadow);
}

.tab-button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 1.25rem;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab-button:hover {
  color: var(--text);
}

.tab-button.active {
  background: var(--accent);
  color: #fff;
}

@media (max-width: 420px) {
  .tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .tab-button {
    padding: 0.5rem 0.75rem;
    text-align: center;
  }
}

.subtabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
  flex-wrap: wrap;
}

.subtab-button {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.subtab-button:hover {
  color: var(--text);
}

.subtab-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.season-tabs {
  display: flex;
  gap: 0.1rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.season-tab-button {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  flex-shrink: 0;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.55rem 0.85rem 0.6rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.season-tab-year {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
}

.season-tab-button:hover {
  color: var(--text);
}

.season-tab-button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.goal-tabs {
  display: flex;
  gap: 0.1rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.goal-tab-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  gap: 0.3rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 0.55rem 1rem 0.6rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.goal-tab-icon {
  width: 22px;
  height: 22px;
}

.goal-tab-button:hover {
  color: var(--text);
}

.goal-tab-button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.home-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: stretch;
}

.home-columns > .panel {
  display: flex;
  flex-direction: column;
}

@media (max-width: 700px) {
  .home-columns {
    grid-template-columns: 1fr;
  }
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 1.25rem;
}

.tab-panel.active {
  display: flex;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.season-range {
  margin: -0.1rem 0 0.85rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.season-range:empty {
  display: none;
}

/* FAQ */
.faq-item {
  padding-top: 1.1rem;
  margin-top: 1.1rem;
  border-top: 1px solid var(--border);
}

.faq-item:first-of-type {
  padding-top: 0.75rem;
  margin-top: 0;
  border-top: none;
}

.faq-item h3 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
  font-weight: 700;
}

.faq-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.link-button {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.link-button:hover {
  text-decoration: underline;
}

.expand-button {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}

/* Latest achievement hero bar */
.latest-hero {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.latest-hero-link {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  min-height: 92px;
  color: inherit;
  text-decoration: none;
}

.latest-hero-badge {
  flex-shrink: 0;
  align-self: stretch;
  width: 90px;
  background: linear-gradient(135deg, #7dc4fb, #3f7fb8 55%, #0c2a4d);
  clip-path: polygon(0 0, 100% 0, 78% 100%, 0 100%);
}

.latest-hero-link .avatar {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 12px;
}

.latest-hero .highlight-text p {
  white-space: normal;
  font-size: 1.05rem;
}

/* Home highlight cards */
.highlight-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.highlight-card {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.highlight-card-link:hover {
  border-color: var(--accent);
}

.highlight-card .avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  align-self: center;
}

.mystery-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px dashed var(--border);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--muted);
}

.highlight-text {
  min-width: 0;
}

.highlight-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.highlight-text p {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.highlight-detail {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.highlight-card.placeholder .highlight-text p {
  font-weight: 600;
  color: var(--muted);
  font-style: italic;
  white-space: normal;
}

@media (max-width: 700px) {
  .highlight-grid {
    grid-template-columns: 1fr;
  }
}

#leaderboard-search,
#recent-search {
  width: 100%;
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#leaderboard-search:focus,
#recent-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

/* Leaderboard */
.leaderboard-columns {
  display: flex;
  align-items: center;
  position: relative;
  padding: 0 0.6rem 0 3.6rem;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.col-rank {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.col-player {
  min-width: 0;
}

.col-value {
  width: 4.5rem;
  flex-shrink: 0;
  margin-left: auto;
  text-align: center;
}

.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.leaderboard-row {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  padding: 0.5rem 0.6rem;
  border-radius: 9px;
  transition: background 0.15s ease;
}

.leaderboard-row-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-left: 3rem;
  cursor: pointer;
}

.leaderboard-row-link {
  color: inherit;
  text-decoration: none;
}

.leaderboard-row-main .leaderboard-row-link {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.leaderboard-row:hover {
  background: var(--bg);
}

.rank-badge {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  clip-path: polygon(0 0, 100% 0, 78% 100%, 0 100%);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--bg);
}

.leaderboard-row.rank-gold .rank-badge {
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  background: linear-gradient(135deg, #ffe28c 0%, #d99a1f 55%, #a86e0f 100%);
}

.leaderboard-row.rank-silver .rank-badge {
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  background: linear-gradient(135deg, #eef1f6 0%, #a7adb8 55%, #767c88 100%);
}

.leaderboard-row.rank-bronze .rank-badge {
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  background: linear-gradient(135deg, #e8ab77 0%, #b06a35 55%, #7d431e 100%);
}

.leaderboard-row.rank-gold,
.leaderboard-row.rank-silver,
.leaderboard-row.rank-bronze {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

.hob-count {
  width: 4.5rem;
  flex-shrink: 0;
  margin-left: auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--bg);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.85rem;
  text-align: center;
}

.hob-count-toggle {
  border: none;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.hob-count-toggle:hover {
  background: color-mix(in srgb, var(--accent) 18%, var(--bg));
}

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

.leaderboard-row.expanded .hob-count-toggle {
  background: var(--accent);
  color: #fff;
}

.leaderboard-breakdown-row {
  padding: 0.5rem 0.6rem 0.6rem 3.6rem;
  border-radius: 9px;
  background: var(--bg);
}

.hob-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.hob-list::-webkit-scrollbar {
  width: 6px;
}

.hob-list::-webkit-scrollbar-track {
  background: transparent;
}

.hob-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

.hob-list::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.hob-list-season-header {
  padding: 0.5rem 0 0.15rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hob-list-season-header:first-child {
  padding-top: 0;
}

.hob-list-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.25rem 0;
}

.hob-list-icon {
  flex-shrink: 0;
  border-radius: 4px;
  image-rendering: pixelated;
}

.hob-list-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.hob-list-meta {
  font-size: 0.82rem;
  font-weight: 600;
}

.hob-list-detail {
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
}

.record-meta {
  margin: 0.15rem 0 0 3rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.player-cell {
  min-width: 0;
}

.player-cell span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Recent hobs */
#recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  padding-right: 0.5rem;
  display: flex;
  flex-direction: column;
  max-height: 520px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#recent-list::-webkit-scrollbar {
  width: 6px;
}

#recent-list::-webkit-scrollbar-track {
  background: transparent;
}

#recent-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

#recent-list::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.recent-group {
  display: flex;
  gap: 0.7rem;
}

.recent-group-marker {
  flex-shrink: 0;
  width: 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.recent-group-marker::before {
  content: '';
  width: 0.6rem;
  height: 0.6rem;
  flex-shrink: 0;
  margin-top: 0.3rem;
  border-radius: 50%;
  background: var(--accent);
}

.recent-group-marker::after {
  content: '';
  flex: 1;
  width: 2px;
  margin-top: 0.3rem;
  background: var(--border);
}

.recent-group:last-child .recent-group-marker::after {
  display: none;
}

.recent-group-body {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  padding-bottom: 1.1rem;
}

.recent-group-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.recent-group-title {
  font-weight: 700;
  font-size: 0.85rem;
}

.recent-group-time {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.recent-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.4rem;
  border-radius: 10px;
  background: var(--bg);
  color: inherit;
  text-decoration: none;
  font-size: 0.9rem;
}

.recent-row:last-child {
  margin-bottom: 0;
}

.recent-row-main {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
  flex: 1;
}

.recent-row-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.recent-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.recent-row-detail {
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  overflow-wrap: break-word;
  min-width: 0;
}

.recent-icon-large {
  flex-shrink: 0;
  margin-left: auto;
  border-radius: 6px;
  image-rendering: pixelated;
}

.player-cell {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.avatar {
  border-radius: 6px;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.empty {
  color: var(--muted);
  font-style: italic;
  padding: 0.5rem 0;
  text-align: center;
}
