:root {
  color-scheme: dark;
  --bg-0: #04070f;
  --bg-1: #0b1324;
  --bg-2: #121b2f;
  --panel: rgba(16, 24, 44, 0.78);
  --panel-strong: rgba(22, 32, 56, 0.94);
  --line: rgba(128, 160, 230, 0.32);
  --line-strong: rgba(123, 166, 255, 0.56);
  --text: #f4f8ff;
  --muted: #a8b5d4;
  --accent: #4f8cff;
  --accent-soft: #7ab0ff;
  --champion: #ffe083;
  --success: #50d69b;
  --danger: #ff7d94;
  --shadow: 0 20px 44px rgba(2, 6, 18, 0.55);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, rgba(59, 109, 230, 0.24), transparent 45%),
    radial-gradient(circle at 100% 0%, rgba(56, 108, 224, 0.15), transparent 34%),
    linear-gradient(180deg, #050910 0%, #080b14 45%, #05070d 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

body.modal-open {
  overflow: hidden;
}

.page-shell {
  width: min(1180px, 94vw);
  margin: 0 auto;
  padding: 2.2rem 0 3rem;
}

.public-shell {
  width: min(1680px, 97vw);
  min-height: 100vh;
  padding: 0.9rem 0 1.4rem;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.9rem;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 1.2rem;
  margin-bottom: 1.2rem;
  align-items: flex-start;
}

.leaderboard-hero {
  margin-bottom: 0;
  align-items: center;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--accent-soft);
  font-size: 0.76rem;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 0.3rem;
  font-size: clamp(1.8rem, 2.6vw, 2.6rem);
}

.subtext {
  margin-top: 0.5rem;
  color: var(--muted);
}

.content-grid,
.admin-layout,
.admin-console,
.leaderboard-screen {
  display: grid;
  gap: 1rem;
}

.content-grid {
  grid-template-columns: minmax(285px, 360px) minmax(0, 1fr);
}

.admin-console {
  grid-template-columns: minmax(330px, 430px) minmax(0, 1fr);
}

.leaderboard-screen {
  min-height: 0;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: linear-gradient(145deg, rgba(12, 20, 37, 0.86), rgba(15, 26, 50, 0.72));
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  padding: 1rem;
}

.submission-panel {
  align-self: start;
}

.leaderboard-panel-fullscreen {
  min-height: calc(100vh - 7rem);
  display: flex;
  flex-direction: column;
  padding: 1.2rem;
}

.stack {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.78rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.hint {
  font-size: 0.76rem;
  color: var(--muted);
}

input,
select,
textarea,
button {
  border-radius: 0.72rem;
  border: 1px solid rgba(121, 150, 215, 0.36);
  background: rgba(5, 10, 20, 0.77);
  color: var(--text);
  padding: 0.64rem 0.7rem;
  font: inherit;
}

textarea {
  resize: vertical;
  min-height: 66px;
}

button {
  cursor: pointer;
  background: linear-gradient(120deg, #1e58b8, #2d8bf3);
  border-color: var(--line-strong);
  font-weight: 700;
  transition: transform 0.15s ease, filter 0.15s ease;
}

button:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

button.secondary {
  background: rgba(9, 18, 35, 0.7);
}

button.small {
  padding: 0.35rem 0.55rem;
  font-size: 0.8rem;
}

.icon-button {
  padding-inline: 0.85rem;
}

.admin-link {
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--line);
  padding: 0.56rem 0.95rem;
  border-radius: 999px;
  font-weight: 600;
}

.admin-link:hover {
  border-color: var(--accent-soft);
  box-shadow: 0 0 22px rgba(79, 140, 255, 0.22);
}

.status {
  min-height: 1.05rem;
  font-size: 0.84rem;
  color: var(--muted);
}

.status.success {
  color: var(--success);
}

.status.error {
  color: var(--danger);
}

.leaderboard-panel .status {
  margin-bottom: 0.75rem;
}

.leaderboard-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.leaderboard-head-compact {
  align-items: end;
  margin-bottom: 1rem;
}

.leaderboard-head p {
  margin-top: 0.35rem;
  font-size: 0.84rem;
  color: var(--muted);
}

.tab-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tab {
  background: rgba(11, 21, 41, 0.8);
  border: 1px solid rgba(120, 149, 218, 0.28);
  font-size: 0.8rem;
  padding: 0.5rem 0.66rem;
  border-radius: 999px;
  font-weight: 600;
}

.tab.is-active {
  border-color: var(--line-strong);
  box-shadow: 0 0 16px rgba(74, 133, 255, 0.28);
}

.leaderboard {
  display: grid;
  gap: 0.95rem;
}

.member-card {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 92px 82px minmax(0, 1.65fr) minmax(170px, 0.8fr);
  gap: 1.1rem;
  align-items: center;
  border-radius: 1.2rem;
  border: 1px solid rgba(120, 155, 232, 0.25);
  padding: 1rem 1.05rem;
  background: linear-gradient(130deg, rgba(4, 8, 17, 0.92), rgba(14, 30, 60, 0.92));
}

.member-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(110deg, rgba(125, 165, 250, 0.08), transparent 38%, rgba(118, 177, 255, 0.12));
}

.member-card.recent-update {
  animation: card-pulse 1.5s ease;
}

@keyframes card-pulse {
  0% {
    box-shadow: 0 0 0 rgba(114, 171, 255, 0);
  }
  40% {
    box-shadow: 0 0 0 2px rgba(114, 171, 255, 0.45);
  }
  100% {
    box-shadow: 0 0 0 rgba(114, 171, 255, 0);
  }
}

.member-card.rank-1 {
  border-color: rgba(255, 224, 131, 0.65);
  background: linear-gradient(130deg, rgba(24, 19, 3, 0.9), rgba(43, 31, 4, 0.9), rgba(15, 33, 66, 0.94));
}

.member-card.rank-2,
.member-card.rank-3 {
  border-color: rgba(143, 178, 255, 0.52);
}

.rank-pill {
  width: 92px;
  min-height: 92px;
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(78, 127, 230, 0.3);
  border: 1px solid rgba(147, 183, 255, 0.5);
  font-weight: 700;
}

.rank-number {
  font-size: 1.85rem;
  line-height: 1;
}

.rank-label {
  margin-top: 0.35rem;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.member-card.rank-1 .rank-pill {
  background: rgba(255, 224, 131, 0.26);
  border-color: rgba(255, 224, 131, 0.65);
  color: var(--champion);
}

.member-card.rank-1 .rank-label {
  color: rgba(255, 235, 183, 0.8);
}

.member-photo {
  width: 82px;
  height: 82px;
  border-radius: 1rem;
  border: 1px solid rgba(141, 174, 250, 0.65);
  object-fit: cover;
}

.member-main {
  min-width: 0;
}

.member-name {
  font-weight: 700;
  font-size: 1.22rem;
}

.badge-row {
  margin-top: 0.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.badge {
  border: 1px solid rgba(123, 166, 255, 0.45);
  background: rgba(46, 74, 129, 0.4);
  color: #dce8ff;
  border-radius: 999px;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
}

.metrics {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-chip {
  display: grid;
  gap: 0.18rem;
  padding: 0.68rem 0.8rem;
  border-radius: 0.95rem;
  border: 1px solid rgba(119, 154, 223, 0.2);
  background: rgba(9, 15, 30, 0.58);
}

.stat-chip span {
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-chip strong {
  font-size: 1.03rem;
  color: var(--text);
}

.stat-chip-wide {
  grid-column: 1 / -1;
}

.metric-highlight {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.95rem 1rem;
  border-radius: 1rem;
  border: 1px solid rgba(118, 151, 221, 0.24);
  background: rgba(7, 13, 24, 0.62);
  text-align: right;
  font-size: 1.45rem;
  font-weight: 700;
}

.metric-highlight span {
  display: block;
  margin-top: 0.28rem;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.floating-action-button {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 20;
  padding: 0.95rem 1.2rem;
  border-radius: 1rem;
  box-shadow: 0 18px 38px rgba(2, 7, 20, 0.45);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(1, 4, 10, 0.74);
  backdrop-filter: blur(10px);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(540px, 100%);
  padding: 1.15rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.modal-header .subtext {
  margin-top: 0.32rem;
}

.modal-actions {
  margin-top: 0.1rem;
}

.metric-row,
.button-row,
.filters {
  display: grid;
  gap: 0.5rem;
}

.metric-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.button-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.filters {
  margin-top: 0.7rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  font-weight: 500;
}

.switch-row input {
  width: 1rem;
  height: 1rem;
}

.table-wrap {
  margin-top: 0.75rem;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th,
td {
  text-align: left;
  padding: 0.5rem 0.35rem;
  border-bottom: 1px solid rgba(114, 146, 212, 0.22);
  vertical-align: top;
}

.reviewed-toggle {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.table-actions {
  display: flex;
  gap: 0.34rem;
}

.hidden {
  display: none;
}

@media (max-width: 980px) {
  .content-grid,
  .admin-console {
    grid-template-columns: 1fr;
  }

  .member-card {
    grid-template-columns: 82px 68px minmax(0, 1fr);
  }

  .metric-highlight {
    grid-column: 1 / -1;
    text-align: left;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    font-size: 1.15rem;
  }

  .metric-row,
  .filters {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .public-shell {
    width: min(100%, 100vw);
    padding-inline: 0.75rem;
  }

  .leaderboard-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .leaderboard-panel-fullscreen {
    min-height: calc(100vh - 9.5rem);
    padding: 0.95rem;
  }

  .member-card {
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 0.8rem;
  }

  .rank-pill {
    width: 68px;
    min-height: 68px;
  }

  .rank-number {
    font-size: 1.35rem;
  }

  .member-photo {
    width: 68px;
    height: 68px;
  }

  .member-main {
    grid-column: 2;
  }

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

  .stat-chip-wide {
    grid-column: auto;
  }

  .floating-action-button {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.85rem;
    width: auto;
  }

  .modal {
    padding: 0.75rem;
  }

  .modal-header,
  .modal-actions,
  .button-row {
    grid-template-columns: 1fr;
    display: grid;
  }
}
