:root {
  --ink: #1d1d1f;
  --muted: #646a73;
  --line: #e2e5e8;
  --paper: #f6f7f9;
  --panel: #ffffff;
  --accent: #d71920;
  --accent-strong: #b5121b;
  --accent-deep: #8f0e17;
  --gold: #bf8c2c;
  --danger: #9d232b;
  --shadow: 0 24px 70px rgba(35, 38, 45, 0.12);
  --soft-red: #fff0f1;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 0, rgba(215, 25, 32, 0.11), transparent 32rem),
    linear-gradient(180deg, #ffffff 0, var(--paper) 380px);
  font-family: "Aptos", "Segoe UI", Arial, Helvetica, sans-serif;
}

.celebration {
  inset: 0;
  pointer-events: none;
  position: fixed;
  z-index: 80;
}

.confetti-piece {
  border-radius: var(--radius);
  height: var(--size);
  pointer-events: none;
  position: fixed;
  transform: translate3d(0, 0, 0) rotate(0deg) scale(0.7);
  will-change: transform, opacity;
  width: calc(var(--size) * 0.72);
  z-index: 81;
}

.celebration.run .confetti-piece {
  animation: confetti-corner 1350ms ease-out forwards;
}

@keyframes confetti-corner {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0deg) scale(0.7);
  }

  8% {
    opacity: 1;
  }

  42% {
    opacity: 1;
    transform: translate3d(calc(var(--x) * 0.68), var(--y), 0) rotate(calc(var(--spin) * 0.55)) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate3d(var(--x), calc(var(--y) + 230px), 0) rotate(var(--spin)) scale(0.9);
  }
}

a {
  color: inherit;
}

.site-header {
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.site-header::before {
  background: var(--accent);
  content: "";
  display: block;
  height: 6px;
}

.nav {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1120px;
  min-height: 68px;
  padding: 0 24px;
}

.brand {
  align-items: center;
  display: inline-flex;
  gap: 10px;
  font-weight: 700;
  text-decoration: none;
}

.brand::before {
  background: var(--accent);
  border-radius: 6px;
  box-shadow: 9px 0 0 #ffffff, 18px 0 0 var(--accent);
  content: "";
  display: inline-block;
  height: 22px;
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  width: 22px;
}

.nav-links {
  display: flex;
  gap: 8px;
}

.auth-area {
  align-items: center;
  display: flex;
  gap: 10px;
}

#currentUserLabel {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.nav-links a {
  border-radius: 6px;
  color: var(--muted);
  padding: 10px 12px;
  text-decoration: none;
}

.nav-links a.active,
.nav-links a:hover {
  background: var(--soft-red);
  color: var(--accent-strong);
}

main {
  margin: 0 auto;
  max-width: 1180px;
  padding: 32px 24px 72px;
}

.intro,
.page-title {
  padding: 40px 0 28px;
}

.intro {
  align-items: center;
  display: grid;
  gap: 32px;
  grid-template-columns: minmax(0, 1.1fr) minmax(310px, 0.65fr);
}

.intro h1,
.page-title h1 {
  font-size: clamp(2.5rem, 7vw, 5.2rem);
  line-height: 0.96;
  margin: 8px 0 16px;
  max-width: 900px;
  letter-spacing: 0;
}

.page-title h1 {
  font-size: clamp(2rem, 6vw, 4rem);
}

.intro-copy,
.page-title p,
.section-heading p {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
  max-width: 720px;
}

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

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.hero-actions a {
  background: var(--ink);
  border-radius: 6px;
  color: #ffffff;
  font-weight: 700;
  min-height: 44px;
  padding: 13px 16px;
  text-decoration: none;
}

.hero-actions a + a {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.hero-panel {
  background:
    linear-gradient(145deg, #ffffff 0 48%, #fff2f2 48% 100%);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 420px;
  overflow: hidden;
  padding: 24px;
  position: relative;
}

.hero-panel::before {
  background: var(--accent);
  content: "";
  height: 100%;
  position: absolute;
  right: 0;
  top: 0;
  width: 10px;
}

.hero-panel-header {
  color: var(--ink);
  display: grid;
  gap: 7px;
  position: relative;
  z-index: 1;
}

.hero-panel-header span,
.hero-rank-card span,
.hero-stat-grid span,
.quick-stats span,
.entry-summary span {
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hero-panel-header strong {
  color: var(--accent);
  font-size: 1.9rem;
  line-height: 1.08;
}

.hero-rank-card {
  background: var(--ink);
  border-radius: 8px;
  box-shadow: 0 18px 35px rgba(61, 0, 7, 0.24);
  color: #ffffff;
  display: grid;
  gap: 6px;
  left: 24px;
  padding: 20px;
  position: absolute;
  top: 116px;
  width: calc(100% - 48px);
  z-index: 1;
}

.hero-rank-card strong {
  font-size: 3rem;
  line-height: 1;
}

.hero-rank-card small {
  color: rgba(255, 255, 255, 0.72);
  font-weight: 700;
}

.hero-stat-grid {
  bottom: 24px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  position: absolute;
  left: 24px;
  right: 24px;
  z-index: 1;
}

.hero-stat-grid div {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.hero-stat-grid strong {
  color: var(--ink);
  display: block;
  font-size: 1.05rem;
  margin-top: 5px;
}

.hero-stat-grid span {
  color: var(--accent);
}

.quick-stats {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 0 24px;
}

.quick-stats div {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(35, 38, 45, 0.06);
  padding: 18px;
}

.quick-stats span {
  color: var(--accent);
}

.quick-stats strong {
  display: block;
  font-size: 1.06rem;
  margin-top: 7px;
}

.form-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: 0;
}

.form-section::before {
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
  content: "";
  display: block;
  height: 8px;
}

.section-heading {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 24px;
  padding: 26px 28px 20px;
}

.section-heading h2 {
  font-size: 1.45rem;
  margin: 0 0 8px;
}

.section-heading a {
  background: var(--soft-red);
  border-radius: 6px;
  color: var(--accent-strong);
  font-weight: 800;
  padding: 11px 13px;
  text-decoration: none;
  white-space: nowrap;
}

.nomination-form {
  display: grid;
  gap: 22px;
  padding: 0 28px 28px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 20px;
}

legend {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 900;
  padding: 0 8px;
  text-transform: uppercase;
}

.field-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

label {
  color: var(--ink);
  display: grid;
  font-size: 0.92rem;
  font-weight: 700;
  gap: 8px;
}

input,
select,
textarea {
  background: #fbfbfc;
  border: 1px solid #d4d8dd;
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  padding: 12px 13px;
  width: 100%;
}

input::placeholder {
  color: #9ca3aa;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(215, 25, 32, 0.12);
  outline: none;
}

.form-actions,
.table-tools {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.entry-summary {
  background: linear-gradient(90deg, var(--ink), #34363b);
  border-radius: 8px;
  color: #ffffff;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 18px;
}

.entry-summary div {
  border-left: 4px solid var(--accent);
  padding-left: 14px;
}

.entry-summary strong {
  display: block;
  font-size: 1.45rem;
  margin-top: 5px;
}

button {
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 44px;
  padding: 0 16px;
}

.small-button {
  min-height: 38px;
  padding: 0 13px;
}

.icon-button {
  background: #f3f4f6;
  border: 1px solid var(--line);
  color: var(--ink);
  min-height: 34px;
  padding: 0 10px;
}

.link-button {
  background: transparent;
  border: 0;
  color: var(--accent);
  font-weight: 800;
  min-height: 0;
  padding: 0;
  text-align: left;
}

.link-button:hover {
  background: transparent;
  color: var(--accent-strong);
  text-decoration: underline;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  background: #ffffff;
  color: var(--ink);
}

button.secondary:hover {
  background: #f5f5f6;
}

button.danger {
  border-color: #e1b8b8;
  color: var(--danger);
}

.form-message,
.empty-message {
  color: var(--accent-strong);
  font-weight: 700;
  margin: 0;
}

.login-required {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 24px;
  padding: 24px;
}

.login-required h2 {
  margin: 6px 0 8px;
}

.login-required p {
  color: var(--muted);
  margin: 0;
}

.login-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.preview-link {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.preview-link:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.modal-backdrop {
  align-items: center;
  background: rgba(20, 20, 24, 0.48);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  padding: 20px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 30;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.28);
  max-width: 420px;
  padding: 22px;
  width: 100%;
}

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

.modal-header h2 {
  margin: 0;
}

.modal-form {
  display: grid;
  gap: 14px;
}

.admin-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-card {
  box-shadow: 0 14px 34px rgba(35, 38, 45, 0.08);
}

.admin-wide {
  grid-column: 1 / -1;
}

.admin-list {
  display: grid;
  gap: 12px;
  padding: 0 28px 28px;
}

.admin-list-item {
  align-items: center;
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 14px;
}

.admin-list-item strong,
.admin-list-item span {
  display: block;
}

.admin-list-item span {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.role-pill {
  background: var(--soft-red);
  border-radius: 999px;
  color: var(--accent-strong) !important;
  font-weight: 800;
  margin: 0 !important;
  padding: 7px 10px;
}

.helper-text {
  color: var(--muted);
  margin: 0;
}

.dashboard-stats {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 20px;
}

.dashboard-stat-card,
.dashboard-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(35, 38, 45, 0.08);
}

.dashboard-stat-card {
  padding: 18px;
}

.dashboard-stat-card span,
.dashboard-card-heading .eyebrow {
  color: var(--accent);
}

.dashboard-stat-card strong {
  display: block;
  font-size: 1.55rem;
  margin: 8px 0 5px;
}

.dashboard-stat-card small {
  color: var(--muted);
  line-height: 1.4;
}

.dashboard-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-card {
  padding: 20px;
}

.dashboard-card-heading {
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  padding-bottom: 14px;
}

.dashboard-card-heading h2 {
  margin: 6px 0 0;
}

.bar-chart,
.metric-list {
  display: grid;
  gap: 14px;
}

.bar-row {
  display: grid;
  gap: 8px;
}

.bar-row-label,
.metric-list-item {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.bar-row-label span,
.metric-list-item span {
  color: var(--muted);
  font-size: 0.9rem;
}

.bar-track {
  background: #f0f1f3;
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
}

.bar-track span {
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
  border-radius: inherit;
  display: block;
  height: 100%;
}

.metric-list-item {
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
}

.metric-list-item strong,
.metric-list-item span {
  display: block;
}

.metric-list-item b {
  color: var(--accent-strong);
  white-space: nowrap;
}

.admin-wipe-tools {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.admin-wipe-tools label {
  min-width: 180px;
}

.category-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.category-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(35, 38, 45, 0.08);
  overflow: hidden;
  padding: 0;
}

.category-card::before {
  background: var(--accent);
  content: "";
  display: block;
  height: 6px;
}

.category-card h2 {
  margin: 0;
  padding: 20px 22px 4px;
}

.top-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0 22px 22px;
}

.top-item {
  align-items: start;
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: 42px 1fr auto;
  padding: 14px;
}

.rank-badge {
  align-items: center;
  background: var(--soft-red);
  border-radius: 50%;
  color: var(--accent);
  display: inline-flex;
  font-weight: 800;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.score-pill {
  background: #1d1d1f;
  border-radius: 999px;
  color: #ffffff;
  font-weight: 800;
  padding: 7px 10px;
}

.top-item h3 {
  font-size: 1rem;
  margin: 0 0 5px;
}

.top-item p {
  color: var(--muted);
  line-height: 1.45;
  margin: 0;
}

.table-tools {
  align-items: end;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(35, 38, 45, 0.08);
  margin-bottom: 16px;
  padding: 14px;
}

.table-tools label {
  min-width: 180px;
}

.table-tools input {
  max-width: 340px;
}

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 980px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 14px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--accent);
  color: #ffffff;
  font-size: 0.82rem;
  text-transform: uppercase;
}

.sort-header {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: #ffffff;
  display: inline-flex;
  font-size: inherit;
  justify-content: flex-start;
  min-height: 0;
  padding: 0;
  text-align: left;
  text-transform: uppercase;
}

.sort-header:hover {
  background: transparent;
  color: #ffffff;
  text-decoration: underline;
}

.sort-header.active::after {
  content: attr(data-sort-direction);
  font-size: 0.72rem;
  margin-left: 6px;
}

td {
  color: #26332f;
  line-height: 1.45;
}

tbody tr:nth-child(even) {
  background: #fafafa;
}

.empty-state {
  background: var(--panel);
  border: 1px dashed #d5a4a8;
  border-radius: 8px;
  color: var(--muted);
  padding: 24px;
}

@media (max-width: 760px) {
  .nav {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 14px;
    padding-top: 14px;
  }

  .nav-links {
    overflow-x: auto;
    width: 100%;
  }

  .auth-area {
    justify-content: space-between;
    width: 100%;
  }

  .field-grid,
  .category-grid,
  .intro,
  .quick-stats,
  .premium-grid,
  .entry-summary,
  .admin-grid,
  .dashboard-stats,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .login-required,
  .admin-list-item,
  .admin-wipe-tools {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-section {
    padding: 0;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    padding: 22px 20px 16px;
  }

  .nomination-form {
    padding: 0 20px 20px;
  }

  .hero-panel {
    min-height: 420px;
  }

  .hero-rank-card {
    left: 20px;
    right: 20px;
    width: auto;
  }

  .hero-stat-grid {
    grid-template-columns: 1fr;
    left: 20px;
    right: 20px;
    bottom: 20px;
  }

  .top-item {
    grid-template-columns: 38px 1fr;
  }

  .score-pill {
    grid-column: 2;
    justify-self: start;
  }
}
