:root {
  --bg: #f4efe4;
  --bg-2: #ece4d3;
  --panel: #fffdf8;
  --panel-2: #f6f1e6;
  --line: #ddd2bc;
  --text: #2e2a22;
  --muted: #8a7f6b;
  --gold: #c8941f;
  --silver: #9aa0a8;
  --bronze: #b1773c;
  --accent: #1f6f5c;
  --accent-dark: #185847;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(60, 48, 24, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* The hidden attribute must always win over display rules like flex/grid. */
[hidden] { display: none !important; }

body {
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.site-header {
  width: 100%;
  padding: 26px 40px;
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  background: var(--panel);
  border-bottom: 2px solid var(--line);
}

.site-header .header-actions { margin-left: auto; }

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  font-size: 30px;
  width: 54px; height: 54px;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
}

.brand-text h1 { font-size: 23px; font-weight: 800; letter-spacing: -0.01em; }
.brand-text p { color: var(--muted); font-size: 13px; font-weight: 500; }

.header-actions { display: flex; gap: 10px; align-items: center; }

.search {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  width: 200px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search::placeholder { color: var(--muted); }
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31, 111, 92, 0.15); }

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 11px 18px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: var(--accent-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: progress; }

.btn.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line);
}
.btn.ghost:hover { background: var(--panel-2); border-color: var(--accent); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.user-chip { display: flex; align-items: center; gap: 8px; }
.user-name { font-size: 13px; font-weight: 700; color: var(--text); max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.auth-toggle { margin-right: auto; }

/* Layout — full width */
.container { width: 100%; padding: 24px 40px 60px; }

/* Podium */
.podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 8px 0 28px;
}

.podium-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 16px 18px;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow);
}
.podium-card.first { border-color: var(--gold); border-width: 2px; }
.podium-card.second { border-color: var(--silver); }
.podium-card.third { border-color: var(--bronze); }

.medal { font-size: 30px; line-height: 1; }
.podium-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  margin: 10px auto 8px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 22px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.podium-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.podium-card .p-name { font-weight: 700; font-size: 16px; }
.podium-card .p-user { color: var(--muted); font-size: 12px; }
.podium-card .p-gold { color: var(--gold); font-weight: 800; font-size: 18px; margin-top: 6px; }
.podium-card .p-builds { color: var(--text); font-size: 13px; font-weight: 600; margin-top: 2px; }
.podium-card .p-sub { color: var(--muted); font-size: 12px; margin-top: 6px; }
.rank-pill {
  position: absolute; top: 12px; left: 12px;
  font-size: 12px; font-weight: 800; color: var(--muted);
}

/* Board */
.board-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.board-head, .row {
  display: grid;
  grid-template-columns: 64px 1fr 220px 160px 96px;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
}

.board-head {
  background: var(--bg-2);
  border-bottom: 2px solid var(--line);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}
.col-stat, .col-gold { text-align: right; }

.board { list-style: none; }

.row {
  border-bottom: 1px solid var(--line);
  transition: background 0.12s;
}
.row:last-child { border-bottom: none; }
.row:nth-child(even) { background: var(--panel-2); }
.row:hover { background: var(--bg-2); }

.r-rank { font-weight: 800; color: var(--muted); font-size: 16px; }

.r-player { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.flag {
  height: 18px;
  width: auto;
  flex-shrink: 0;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
  vertical-align: middle;
}
.p-sub .flag { height: 22px; }
.r-names { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.r-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-user { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.r-stat { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.r-gold { text-align: right; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }

.r-actions { display: flex; justify-content: flex-end; gap: 6px; }
.row-edit, .row-del {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.row-edit:hover { background: var(--panel); color: var(--accent); border-color: var(--accent); }
.row-del:hover { background: #fcebe9; color: #c0392b; border-color: #e3a59d; }

.empty {
  list-style: none;
  text-align: center;
  color: var(--muted);
  padding: 48px 24px;
  font-size: 15px;
}
.empty strong { color: var(--accent); }

.hidden { display: none; }

/* Add-user modal */
.modal {
  margin: auto; /* re-center: the `* { margin:0 }` reset removed the UA centering */
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(40, 30, 12, 0.3);
  width: min(92vw, 380px);
}
.modal::backdrop { background: rgba(30, 24, 12, 0.45); }

.modal-form { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.modal-form h2 { font-size: 19px; font-weight: 800; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 92, 0.15);
}

.field-hint { color: var(--muted); font-size: 11px; font-weight: 500; }

.form-error {
  color: #c0392b;
  background: #fcebe9;
  border: 1px solid #f0c6c0;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
}

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.form-success {
  color: #1f6f5c;
  background: #e6f4ef;
  border: 1px solid #b9e0d4;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
}
.modal-note { color: var(--muted); font-size: 13px; margin-top: -4px; }

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #c0392b;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  margin-left: 4px;
}

.submit-preview {
  max-height: 180px;
  width: auto;
  align-self: flex-start;
  border-radius: 8px;
  border: 1px solid var(--line);
}

/* Review queue */
.modal-wide { width: min(94vw, 620px); }
.review-list { display: flex; flex-direction: column; gap: 14px; max-height: 64vh; overflow-y: auto; padding: 2px; }
.review-empty { color: var(--muted); text-align: center; padding: 24px; }
.review-card {
  display: flex;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--panel-2);
}
.review-shot { flex-shrink: 0; }
.review-shot img {
  width: 150px;
  height: 110px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: block;
}
.review-info { display: flex; flex-direction: column; gap: 8px; min-width: 0; flex: 1; }
.review-who { display: flex; align-items: center; gap: 10px; }
.review-stat { font-size: 13px; color: var(--text); font-weight: 600; }
.review-buttons { display: flex; gap: 8px; margin-top: auto; }
.btn.approve { background: var(--accent); }
.btn.reject:hover { background: #fcebe9; color: #c0392b; border-color: #e3a59d; }

/* Footer */
.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 10px 40px 40px;
}

/* Responsive */
@media (max-width: 640px) {
  .site-header { padding: 20px; }
  .container { padding: 20px; }
  .brand-text p { display: none; }
  .search { width: 130px; }
  .board-head, .row { grid-template-columns: 40px 1fr 80px 80px; padding: 12px 14px; }
  .col-stat, .r-stat { display: none; }
  .review-card { flex-direction: column; }
  .review-shot img { width: 100%; height: 160px; }
  .podium { gap: 8px; }
}
