/* ============================================================
   THE TRIAL BOARD — a Dead by Daylight-flavored friend leaderboard
   Palette: dried blood, rusted iron, bone parchment, sickly entity green
   ============================================================ */

:root {
  color-scheme: dark;
  --void: #0a0806;
  --ash: #16120d;
  --panel: #1c1611;
  --panel-raised: #221b14;
  --line: rgba(232, 223, 201, 0.12);
  --line-strong: rgba(232, 223, 201, 0.22);
  --bone: #e9dfc8;
  --bone-dim: #a89b81;
  --bone-faint: #6f6656;
  --blood: #7a1414;
  --blood-bright: #c2261a;
  --blood-glow: rgba(194, 38, 26, 0.5);
  --rust: #4a3b28;
  --rust-light: #6b5738;
  --entity: #7c9a63;
  --entity-glow: rgba(124, 154, 99, 0.45);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  --shadow-tight: 0 8px 24px rgba(0, 0, 0, 0.45);
  --radius: 10px;

  --font-display: "Nosifer", "Crimson Text", serif;
  --font-body: "Crimson Text", Georgia, serif;
  --font-case: "Special Elite", "Courier New", monospace;
  --font-rank: "Bebas Neue", "Crimson Text", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse 60rem 40rem at 18% -10%, rgba(122, 20, 20, 0.22), transparent 60%),
    radial-gradient(ellipse 50rem 40rem at 88% 10%, rgba(124, 154, 99, 0.07), transparent 55%),
    linear-gradient(160deg, #0d0a07 0%, #120d09 45%, #0a0806 100%);
  color: var(--bone);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

button, input, textarea, select {
  font-family: inherit;
  color: inherit;
}

::selection {
  background: var(--blood-bright);
  color: var(--bone);
}

/* ---------- atmosphere layers ---------- */

.grain {
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  opacity: 0.06;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: radial-gradient(ellipse 70% 70% at 50% 40%, transparent 55%, rgba(0, 0, 0, 0.65) 100%);
}

.fog {
  position: fixed;
  inset: auto -25vw 0;
  z-index: -1;
  height: 46vh;
  background:
    radial-gradient(ellipse at 15% 75%, rgba(232, 223, 201, 0.08), transparent 38%),
    radial-gradient(ellipse at 55% 85%, rgba(124, 154, 99, 0.06), transparent 42%),
    radial-gradient(ellipse at 85% 70%, rgba(232, 223, 201, 0.05), transparent 36%),
    linear-gradient(to top, rgba(232, 223, 201, 0.05), transparent);
  filter: blur(22px);
  pointer-events: none;
  animation: fog-drift 40s ease-in-out infinite alternate;
}

@keyframes fog-drift {
  from { transform: translateX(-2%); }
  to { transform: translateX(2%); }
}

@media (prefers-reduced-motion: reduce) {
  .fog { animation: none; }
  html { scroll-behavior: auto; }
}

/* ---------- header ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 24px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--bone);
  letter-spacing: 0.04em;
}

.brand-mark {
  color: var(--blood-bright);
  display: inline-flex;
}

.brand-text {
  font-family: var(--font-case);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.admin-link {
  font-family: var(--font-case);
  font-size: 0.8rem;
  color: var(--bone-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px dotted var(--bone-faint);
  padding-bottom: 2px;
  transition: color 0.15s ease;
}

.admin-link:hover {
  color: var(--blood-bright);
  border-color: var(--blood-bright);
}

/* ---------- hero ---------- */

.shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px 96px;
}

.hero {
  padding: 56px 0 40px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  font-family: var(--font-case);
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--entity);
  margin: 0 0 14px;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2rem, 5.5vw, 3.4rem);
  line-height: 1.15;
  margin: 0 0 16px;
  color: var(--bone);
  text-shadow: 0 0 24px var(--blood-glow), 0 2px 0 rgba(0, 0, 0, 0.6);
}

.subtitle {
  font-size: 1.1rem;
  font-style: italic;
  color: var(--bone-dim);
  max-width: 46ch;
  margin: 0 auto 32px;
}

.stat-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.stat-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 22px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--shadow-tight);
}

.stat-number {
  font-family: var(--font-rank);
  font-size: 1.6rem;
  color: var(--blood-bright);
  letter-spacing: 0.02em;
}

.stat-label {
  font-family: var(--font-case);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--bone-dim);
}

.vote-hint {
  font-family: var(--font-case);
  font-size: 0.82rem;
  color: var(--bone-faint);
  margin: 0;
}

/* ---------- leaderboard ---------- */

.leaderboard {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 40px;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

.loading, .empty-state {
  text-align: center;
  padding: 60px 20px;
  font-family: var(--font-case);
  color: var(--bone-dim);
  letter-spacing: 0.04em;
}

.entry {
  position: relative;
  display: grid;
  grid-template-columns: 60px 54px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 20px 14px 14px;
  background: linear-gradient(160deg, var(--panel) 0%, var(--panel-raised) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-tight);
  animation: entry-in 0.5s ease backwards;
}

.entry:nth-child(1) { animation-delay: 0.02s; }
.entry:nth-child(2) { animation-delay: 0.06s; }
.entry:nth-child(3) { animation-delay: 0.1s; }
.entry:nth-child(4) { animation-delay: 0.14s; }
.entry:nth-child(5) { animation-delay: 0.18s; }

@keyframes entry-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.entry.rank-1 {
  border-color: rgba(194, 38, 26, 0.45);
  box-shadow: var(--shadow-tight), 0 0 0 1px rgba(194, 38, 26, 0.15), 0 0 32px -6px var(--blood-glow);
}

/* rank tag: a rusty hook-tag shape hanging on the left of each entry */
.rank-tag {
  position: relative;
  width: 52px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--rust-light), var(--rust));
  clip-path: polygon(50% 0%, 100% 16%, 100% 100%, 0% 100%, 0% 16%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4), 0 4px 10px rgba(0, 0, 0, 0.5);
}

.rank-tag::before {
  content: "";
  position: absolute;
  top: 9px;
  left: 50%;
  transform: translateX(-50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--void);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.8);
}

.rank-num {
  font-family: var(--font-rank);
  font-size: 1.5rem;
  color: var(--bone);
  margin-top: 6px;
  letter-spacing: 0.02em;
}

.entry.rank-1 .rank-tag {
  background: linear-gradient(160deg, #8a2620, var(--blood));
  animation: heartbeat 2.4s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.4), 0 0 0 rgba(194,38,26,0); }
  10% { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.4), 0 0 18px 2px var(--blood-glow); }
  22% { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.4), 0 0 0 rgba(194,38,26,0); }
}

@media (prefers-reduced-motion: reduce) {
  .entry { animation: none; }
  .entry.rank-1 .rank-tag { animation: none; }
}

.entry-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--line-strong);
  background: var(--void);
}

.entry-body {
  min-width: 0;
}

.entry-name {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.15rem;
  margin: 0 0 3px;
  color: var(--bone);
  overflow-wrap: anywhere;
}

.entry-note {
  font-family: var(--font-case);
  font-size: 0.82rem;
  color: var(--bone-dim);
  margin: 0;
  overflow-wrap: anywhere;
}

/* vote controls, next to each name as requested */
.vote-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.vote-btn {
  width: 30px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  background: var(--ash);
  color: var(--bone-dim);
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: transform 0.08s ease, color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.vote-btn:hover:not(:disabled) {
  color: var(--bone);
  border-color: var(--bone-faint);
}

.vote-btn:active:not(:disabled) {
  transform: scale(0.9);
}

.vote-btn.up:hover:not(:disabled) { color: var(--entity); border-color: var(--entity); }
.vote-btn.down:hover:not(:disabled) { color: var(--blood-bright); border-color: var(--blood-bright); }

.vote-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.vote-btn.voted-up { color: var(--entity); border-color: var(--entity); background: rgba(124,154,99,0.1); }
.vote-btn.voted-down { color: var(--blood-bright); border-color: var(--blood-bright); background: rgba(194,38,26,0.1); }

.vote-score {
  font-family: var(--font-rank);
  font-size: 1.05rem;
  min-width: 2ch;
  text-align: center;
  color: var(--bone);
}

.vote-score.positive { color: var(--entity); }
.vote-score.negative { color: var(--blood-bright); }

@media (max-width: 560px) {
  .entry {
    grid-template-columns: 44px 44px 1fr auto;
    padding: 12px 12px 12px 10px;
    gap: 10px;
  }
  .rank-tag { width: 42px; height: 50px; }
  .rank-num { font-size: 1.2rem; }
  .entry-avatar { width: 44px; height: 44px; }
  .entry-name { font-size: 1rem; }
}

/* ---------- footer ---------- */

.site-footer {
  text-align: center;
  padding: 40px 24px 60px;
  font-family: var(--font-case);
  font-size: 0.78rem;
  color: var(--bone-faint);
}

/* ============================================================
   ADMIN PANEL
   ============================================================ */

.admin-page .shell {
  max-width: 1080px;
}

.login-panel {
  max-width: 380px;
  margin: 90px auto;
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.login-panel h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.6rem;
  margin: 8px 0 24px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.stack label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-case);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bone-dim);
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea,
select {
  background: var(--ash);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: var(--font-body);
  color: var(--bone);
}

input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--blood-bright);
  outline-offset: 2px;
}

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

.primary-button, .ghost-button, .danger-button, .small-button, .icon-button {
  font-family: var(--font-case);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 6px;
  padding: 10px 18px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
  border: 1px solid var(--line-strong);
  background: var(--ash);
}

.primary-button {
  background: linear-gradient(160deg, var(--blood-bright), var(--blood));
  border-color: var(--blood-bright);
  color: var(--bone);
}

.primary-button:hover { filter: brightness(1.1); }

.ghost-button:hover, .small-button:hover { border-color: var(--bone-faint); color: var(--bone); }

.danger-button {
  color: var(--blood-bright);
  border-color: rgba(194, 38, 26, 0.4);
}
.danger-button:hover { background: rgba(194, 38, 26, 0.12); }

.primary-button:active, .ghost-button:active, .danger-button:active, .small-button:active, .icon-button:active {
  transform: scale(0.97);
}

.primary-button:disabled, .ghost-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-message {
  min-height: 1.2em;
  font-family: var(--font-case);
  font-size: 0.82rem;
  color: var(--blood-bright);
}

.form-message.success { color: var(--entity); }

.hidden { display: none !important; }

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 32px 0 24px;
  border-bottom: 1px solid var(--line);
}

.admin-topbar h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.8rem;
  margin: 4px 0 0;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.file-button {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  font-family: var(--font-case);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 10px 18px;
  cursor: pointer;
  background: var(--ash);
}
.file-button:hover { border-color: var(--bone-faint); }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-top: 24px;
}

@media (min-width: 860px) {
  .admin-grid { grid-template-columns: 1fr 1.3fr; }
}

.admin-grid-left {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.editor-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

.editor-panel h2 {
  font-family: var(--font-case);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bone-dim);
  margin: 0 0 16px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title h2 { margin: 0; }

/* friend list rows in the admin panel */
.friend-roster {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 560px;
  overflow-y: auto;
  padding-right: 4px;
}

.roster-row {
  display: grid;
  grid-template-columns: auto 40px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.roster-row.selected {
  border-color: var(--blood-bright);
  box-shadow: 0 0 0 1px var(--blood-bright);
}

.roster-move {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.roster-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line-strong);
}

.roster-info {
  min-width: 0;
}

.roster-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.roster-meta {
  font-family: var(--font-case);
  font-size: 0.72rem;
  color: var(--bone-faint);
}

.roster-score {
  font-family: var(--font-rank);
  font-size: 1.1rem;
  text-align: center;
  min-width: 2.5ch;
}

.icon-button {
  width: 30px;
  height: 26px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* add / edit friend form */
.friend-editor {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dropzone {
  border: 2px dashed var(--line-strong);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
  cursor: pointer;
  font-family: var(--font-case);
  font-size: 0.8rem;
  color: var(--bone-dim);
  position: relative;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover, .dropzone.drag-over {
  border-color: var(--blood-bright);
  background: rgba(194, 38, 26, 0.06);
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 10px;
  border: 2px solid var(--line-strong);
  display: block;
}

.tier-board.compact,
.preview-board {
  margin-top: 8px;
}

.save-state {
  font-family: var(--font-case);
  font-size: 0.78rem;
  color: var(--bone-faint);
  margin: 0;
}

.save-state.dirty { color: var(--blood-bright); }
.save-state.saved { color: var(--entity); }

.empty-roster {
  text-align: center;
  padding: 30px 10px;
  font-family: var(--font-case);
  font-size: 0.85rem;
  color: var(--bone-faint);
}
