:root {
  color-scheme: light;
  --bg: #f6e9bd;
  --surface: #fff8df;
  --surface-soft: #fff1bf;
  --text: #382515;
  --muted: #765d43;
  --line: #dcbf7a;
  --line-strong: #b98b48;
  --coral: #c94f2d;
  --coral-dark: #9d351f;
  --teal: #4d963f;
  --amber: #b9770e;
  --wood: #87522c;
  --wood-dark: #5f351d;
  --sky: #bee7f4;
  --shadow: 0 18px 32px rgba(95, 53, 29, 0.18);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 12%, rgba(255, 255, 255, 0.85) 0 42px, transparent 43px),
    linear-gradient(180deg, var(--sky) 0 235px, #a7d971 236px 320px, var(--bg) 321px);
  background-color: var(--bg);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  overflow-x: hidden;
}

body::before {
  position: fixed;
  inset: 244px 0 auto;
  height: 160px;
  pointer-events: none;
  content: "";
  background:
    repeating-linear-gradient(135deg, rgba(109, 143, 50, 0.24) 0 18px, rgba(109, 143, 50, 0) 18px 44px),
    linear-gradient(180deg, rgba(73, 128, 53, 0.18), rgba(73, 128, 53, 0));
  mask-image: linear-gradient(180deg, #000, transparent);
}

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 78px;
  padding: 0 30px;
  background:
    linear-gradient(180deg, rgba(255, 248, 223, 0.96), rgba(248, 222, 151, 0.95));
  border-bottom: 3px solid #a66b36;
  box-shadow: 0 5px 0 rgba(95, 53, 29, 0.1);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  color: #fff6d2;
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  background: linear-gradient(180deg, #9a6234, var(--wood-dark));
  border: 2px solid #cf9655;
  border-radius: 10px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.18), 0 4px 0 #4a2816;
}

.brand span {
  color: #ffd45f;
}

.nav {
  display: flex;
  gap: 8px;
  margin-right: auto;
}

.nav a {
  color: #5f351d;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 900;
  text-decoration: none;
  border: 1px solid transparent;
}

.nav a:hover,
.nav a:focus-visible,
.nav a.active {
  color: #fff8df;
  background: linear-gradient(180deg, #63a84e, #3f7f34);
  border-color: #2f6429;
  box-shadow: 0 3px 0 #2f6429;
  outline: none;
}

.app-shell {
  width: min(1480px, calc(100% - 40px));
  margin: 36px auto 56px;
}

.page[hidden] {
  display: none;
}

.page {
  display: grid;
  gap: 18px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 0 4px 8px;
}

.page-header h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(34px, 4vw, 56px);
  line-height: 1.02;
  letter-spacing: 0;
  color: #3c2718;
  text-shadow: 0 3px 0 rgba(255, 248, 223, 0.75);
}

.page-header p {
  max-width: 720px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.leaderboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

.single-page {
  max-width: 680px;
  margin: 0 auto;
}

.form-panel {
  padding: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.side-rail {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 16px;
}

.main-stage {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.panel {
  min-width: 0;
  background:
    linear-gradient(180deg, rgba(255, 248, 223, 0.98), rgba(255, 240, 186, 0.98));
  border: 2px solid #c9954f;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.side-rail .panel,
.rules-panel {
  padding: 22px;
}

.panel h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.panel h2 {
  font-size: 20px;
  font-weight: 900;
}

.panel-copy,
.section-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: #202938;
  font-size: 13px;
  font-weight: 800;
}

input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 2px solid #d8ad66;
  border-radius: var(--radius);
  background: #fffdf2;
  color: var(--text);
  font-size: 15px;
  outline: none;
  box-shadow: inset 0 2px 0 rgba(95, 53, 29, 0.05);
}

input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(77, 150, 63, 0.18);
}

.input-with-prefix {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  overflow: hidden;
  border: 2px solid #d8ad66;
  border-radius: var(--radius);
  background: #fffdf2;
}

.input-with-prefix span {
  color: var(--muted);
  font-size: 15px;
  text-align: center;
}

.input-with-prefix input {
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
}

form button {
  height: 44px;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 800;
}

form button {
  color: #fff;
  background: linear-gradient(180deg, #63a84e, #3f7f34);
  box-shadow: 0 5px 0 #2f6429, 0 12px 22px rgba(47, 100, 41, 0.22);
}

form button:hover {
  background: linear-gradient(180deg, #70b95a, #438538);
}

.form-message {
  min-height: 20px;
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.form-message.success {
  color: #057771;
}

.form-message.error {
  color: var(--coral-dark);
}

.rules-panel ul {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0 0 0 18px;
  color: var(--muted);
  font-size: 14px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
  border-bottom: 2px solid rgba(185, 139, 72, 0.5);
}

.table-wrap {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  font-size: 14px;
}

.compact table {
  min-width: 760px;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: #4b311e;
  background: #f8d47a;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

tbody tr {
  transition: background 160ms ease, box-shadow 160ms ease;
}

.leader-row:hover,
.leader-row:focus-visible {
  background: #fff4c8;
  outline: none;
}

.leader-row.stale {
  color: #6d4a13;
  background: #fffaf0;
}

.rank-pill {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #f6d77a;
  font-weight: 900;
  border: 1px solid #b98b48;
}

.medal-1 {
  color: #744f03;
  background: #ffe39b;
}

.medal-2 {
  color: #495262;
  background: #dfe5ee;
}

.medal-3 {
  color: #7c3f10;
  background: #f3bf83;
}

.score,
.accent {
  color: var(--teal);
}

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

.handle-link:hover,
.handle-link:focus-visible {
  color: var(--coral-dark);
  text-decoration: underline;
  outline: none;
}

.freshness {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #057771;
  font-weight: 800;
}

.freshness.stale {
  color: var(--amber);
}

.freshness small {
  padding: 2px 6px;
  border-radius: 999px;
  background: #fff0cf;
}

.empty-state,
.detail-empty {
  padding: 42px 22px;
  color: var(--muted);
  text-align: center;
}

.empty-state h3 {
  color: var(--text);
}

.ranking-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.ranking-card {
  min-height: 190px;
  padding: 16px;
  border: 2px solid #d0a05a;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 253, 242, 0.96), rgba(255, 239, 180, 0.96));
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.5);
}

.ranking-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 900;
}

.ranking-card h3::before {
  display: inline-block;
  width: 12px;
  height: 18px;
  border-radius: 9px 9px 3px 3px;
  content: "";
  background: linear-gradient(180deg, #79ba45, #4d963f);
  box-shadow: 5px 4px 0 -1px #f2c455;
  transform: rotate(-8deg);
}

.ranking-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px dashed rgba(135, 82, 44, 0.28);
  color: var(--muted);
  font-size: 13px;
}

.ranking-row strong {
  color: var(--text);
}

.muted {
  color: var(--muted);
}

.detail-content {
  padding: 16px;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff8f7;
}

.avatar {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--coral), var(--teal));
  font-weight: 900;
}

.player-card h3,
.player-card p {
  margin: 0;
}

.player-card p {
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 980px) {
  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 14px 18px 18px;
  }

  .brand {
    width: 100%;
    justify-content: center;
  }

  .nav {
    width: 100%;
    justify-content: center;
    margin-right: 0;
  }

  .app-shell {
    width: min(100% - 24px, 760px);
    margin-top: 14px;
  }

  .page-header,
  .leaderboard-layout,
  .workspace {
    display: grid;
    grid-template-columns: 1fr;
  }

  .side-rail {
    position: static;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

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

@media (max-width: 560px) {
  .topbar {
    min-height: 0;
  }

  .brand {
    font-size: 22px;
  }

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

  .nav a {
    padding: 9px 8px;
    text-align: center;
  }

  .page-header h1 {
    font-size: 34px;
  }

  .side-rail .panel,
  .form-panel,
  .rules-panel,
  .section-heading {
    padding: 18px;
  }

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