:root {
  color-scheme: dark;
  --bg: #141713;
  --panel: #1d211c;
  --text: #f0f1ed;
  --muted: #93968e;
  --border: #2c302a;
  --accent: #4cb37e;
  --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;
}

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;
}

.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;
}

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: 1fr 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 1rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.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);
}

/* Congrats hero card */
.congrats-box {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  background: linear-gradient(135deg, var(--accent), #1f7a4d 55%, var(--accent-2));
  color: #fff;
  border: none;
  position: relative;
  overflow: hidden;
}

.congrats-box::before {
  content: "🎉";
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
  font-size: 2.5rem;
  opacity: 0.25;
  transform: rotate(12deg);
}

.congrats-box .avatar {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.congrats-box .congrats-text {
  position: relative;
  z-index: 1;
}

.congrats-box .congrats-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.85;
  margin-bottom: 0.2rem;
}

.congrats-box p {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.4;
}

.congrats-box strong {
  font-weight: 800;
}

#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;
  justify-content: space-between;
  padding: 0 0.85rem;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

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

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

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

.player-hobs {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0.6rem 0 0 2.5rem;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.player-hobs li {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.player-hobs .recent-meta {
  font-weight: 600;
}

.player-hobs .recent-detail {
  margin-top: 0;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
}

.rank-badge {
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--bg);
}

.leaderboard-row.rank-gold .rank-badge {
  background: var(--gold);
  color: #4a2f00;
}

.leaderboard-row.rank-silver .rank-badge {
  background: var(--silver);
  color: #2b2e34;
}

.leaderboard-row.rank-bronze .rank-badge {
  background: var(--bronze);
  color: #3a1f0d;
}

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

.hob-count {
  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;
}

.record-meta {
  margin: 0.15rem 0 0 2.5rem;
  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;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 520px;
  overflow-y: auto;
}

#recent-list li {
  display: flex;
  flex-direction: column;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  background: var(--bg);
  font-size: 0.95rem;
  border-left: 3px solid var(--accent);
}

.recent-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.recent-detail {
  margin-top: 0.4rem;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
}

.recent-name {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

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

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

.recent-meta {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

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