/* Freitag Für Penner — Design Tokens */
:root {
  --bg: #0a0a0a;
  --surface: #131313;
  --surface-2: #1a1a1a;
  --surface-3: #232323;
  --border: #262626;
  --border-bright: #3a3a3a;
  --text: #fafafa;
  --text-dim: #8a8a8a;
  --text-mute: #545454;
  --accent: #7c5cff;
  --accent-2: #a085ff;
  --accent-dim: rgba(124, 92, 255, 0.14);
  --accent-border: rgba(124, 92, 255, 0.4);
  --success: #00e5a0;
  --warn: #ffb84d;
  --danger: #ff4d4d;
  --gold: #ffcb3d;
  --silver: #c8c8c8;
  --bronze: #c98b5c;
  --backdrop: rgba(10,10,10,0.92);
  --shadow: 0 1px 0 rgba(255,255,255,0.02);

  --font-display: "Archivo Narrow", "Arial Narrow", sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

[data-theme="light"] {
  --bg: #f3efe6;
  --surface: #ffffff;
  --surface-2: #ebe7dc;
  --surface-3: #ddd8cb;
  --border: #d4cfc0;
  --border-bright: #807868;
  --text: #0a0a0a;
  --text-dim: #4f4d47;
  --text-mute: #918a78;
  --accent: #5a3fe6;
  --accent-2: #3a1fce;
  --accent-dim: rgba(90, 63, 230, 0.10);
  --accent-border: rgba(90, 63, 230, 0.35);
  --success: #008c5a;
  --warn: #b87800;
  --danger: #d22a2a;
  --gold: #c79a14;
  --silver: #7a7a7a;
  --bronze: #985f30;
  --backdrop: rgba(243,239,230,0.92);
  --shadow: 0 1px 0 rgba(0,0,0,0.02);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.005em;
}

#root { min-height: 100vh; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* Typography */
.display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
  text-transform: uppercase;
}
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.tabular { font-variant-numeric: tabular-nums; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-mute);
}

/* Brutalist accents */
.hardcard {
  background: var(--surface);
  border: 1px solid var(--border);
}
.hardcard.bright { border-color: var(--border-bright); }
.hardcard.accent { border-color: var(--accent); }

.divider { height: 1px; background: var(--border); border: 0; }
.divider-v { width: 1px; background: var(--border); align-self: stretch; }

/* Tag/pill */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}
.tag.accent { color: var(--accent-2); border-color: var(--accent-border); background: var(--accent-dim); }
.tag.gold { color: var(--gold); border-color: rgba(255,203,61,0.3); }
.tag.success { color: var(--success); border-color: rgba(0,229,160,0.3); }
.tag.warn { color: var(--warn); border-color: rgba(255,184,77,0.3); }

/* Button */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-bright);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: all 0.12s ease;
}
.btn:hover { background: var(--surface-3); border-color: var(--text-mute); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0a0a;
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { border-color: var(--text-mute); }
.btn.danger { color: var(--danger); border-color: rgba(255,77,77,0.4); }
.btn.danger:hover { background: rgba(255,77,77,0.08); border-color: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: 10.5px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Input */
.input, .select, .textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 14px;
  transition: border-color 0.12s ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.input.mono { font-family: var(--font-mono); }
.label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  margin-bottom: 6px;
}

/* Table */
.tbl {
  width: 100%;
  border-collapse: collapse;
}
.tbl th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  background: var(--surface);
}
.tbl td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tbody tr { transition: background 0.1s ease; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.me { background: var(--accent-dim); }
.tbl tbody tr.me:hover { background: rgba(124,92,255,0.2); }

/* Avatar */
.avatar {
  width: 36px;
  height: 36px;
  background: var(--surface-3);
  border: 1px solid var(--border-bright);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar.xl { width: 96px; height: 96px; font-size: 32px; }

/* Stat block */
.stat {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.stat .stat-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-mute);
  margin-bottom: 8px;
}
.stat .stat-value {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.01em;
}
.stat .stat-sub {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

/* Rank cell */
.rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-dim);
}
.rank.r1 { background: var(--gold); color: #0a0a0a; }
.rank.r2 { background: var(--silver); color: #0a0a0a; }
.rank.r3 { background: var(--bronze); color: #0a0a0a; }
.rank.last {
  background: transparent;
  color: var(--text-mute);
  border: 1px dashed var(--border-bright);
}

/* Section title */
.section-title {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 16px;
}
.section-title h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  margin: 0;
}
.section-title .count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-mute);
}

/* Pages */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 32px 96px;
}

/* Hero pagehead */
.pagehead {
  border-bottom: 1px solid var(--border);
  padding-bottom: 24px;
  margin-bottom: 32px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.pagehead h1 {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 0.95;
  text-transform: uppercase;
  margin: 12px 0 0;
}
.pagehead .pre {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* Nav */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--backdrop);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topnav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 32px;
  height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.brand-mark {
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #0a0a0a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
}
.navlink {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 8px 0;
  position: relative;
  transition: color 0.12s;
}
.navlink:hover { color: var(--text); }
.navlink.active { color: var(--text); }
.navlink.active::after {
  content: '';
  position: absolute;
  bottom: -22px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
}

/* Group switcher */
.group-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.12s;
}
.group-pill:hover { border-color: var(--text-mute); }
.group-pill.active { background: var(--accent); border-color: var(--accent); color: #0a0a0a; }

/* Group dropdown */
.group-dropdown { position: relative; }
.group-dropdown-trigger { gap: 10px; min-width: 160px; justify-content: space-between; }
.group-dropdown-trigger.open { border-color: var(--text); }
.group-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border-bright);
  box-shadow: 0 12px 28px rgba(0,0,0,0.35);
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding: 4px;
}
.group-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}
.group-dropdown-item:hover { background: var(--surface-2); }
.group-dropdown-item.active { background: var(--accent-dim); color: var(--text); }
.group-dropdown-item.active svg { color: var(--accent); }

/* Ranking drag & drop */
.ranking-row { transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s; }
.ranking-row:active { cursor: grabbing; }
.ranking-row.dragging { opacity: 0.4; }
.ranking-row.drag-over { border-color: var(--accent) !important; box-shadow: 0 0 0 2px var(--accent-border) inset; }
.drag-handle { letter-spacing: -2px; padding: 0 4px; }

/* misc */
.row { display: flex; gap: 12px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; }
.spacer { flex: 1; }
.dim { color: var(--text-dim); }
.mute { color: var(--text-mute); }
.accent-text { color: var(--accent-2); }
.center { display: flex; align-items: center; justify-content: center; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-bright); border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

/* === Grid utilities === */
.gx2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.gx3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; }
.gx4 { display: grid; grid-template-columns: repeat(4, 1fr); }
.gx6 { display: grid; grid-template-columns: repeat(6, 1fr); }
.split { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.split-radar { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; }
.split-login { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.stepper { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--border); margin-bottom: 32px; }
.stepper-cell {
  padding: 16px 20px;
  text-align: left;
  background: var(--surface);
  border: 0;
  border-right: 1px solid var(--border);
  color: var(--text-mute);
  cursor: default;
}
.stepper-cell:last-child { border-right: 0; }
.stepper-cell.active { background: var(--accent-dim); color: var(--text); }
.stepper-cell.done { color: var(--text-dim); cursor: pointer; }
.stepper-cell.clickable { cursor: pointer; }

/* Ranking card */
.rank-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: center;
}
@media (max-width: 640px) {
  .rank-card { grid-template-columns: auto 1fr; gap: 12px; row-gap: 12px; }
  .rank-card > :last-child { grid-column: 1 / -1; text-align: left; display: flex; align-items: baseline; gap: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
}

/* Per-game breakdown row */
.pg-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 16px;
  align-items: center;
  padding: 10px 0;
}
@media (max-width: 640px) {
  .pg-row { grid-template-columns: 1fr auto; row-gap: 6px; }
  .pg-row > :nth-child(2) { grid-column: 1 / -1; order: 4; }
}

/* Hero typography (login) */
.hero-h1 {
  font-size: 88px;
  line-height: 0.9;
  letter-spacing: -0.03em;
}
@media (max-width: 1023px) { .hero-h1 { font-size: 64px; } }
@media (max-width: 768px) { .hero-h1 { font-size: 52px; } }
@media (max-width: 480px) { .hero-h1 { font-size: 42px; } }

/* Scroll wrapper for tables */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* === Mobile menu (hamburger) === */
.menubtn {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
}
.menubtn:hover { background: var(--surface-2); }

.menupanel { display: none; }
.menupanel.open {
  display: block;
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 100;
  padding: 20px;
  overflow-y: auto;
}
.menupanel .menulink {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 8px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 20px;
  text-transform: uppercase;
  color: var(--text);
}
.menupanel .menulink.active { color: var(--accent); }
.menupanel-foot {
  margin-top: 24px;
  padding: 16px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

/* === Adaptive — desktop default already set above === */
.topnav-nav { display: flex; gap: 24px; align-items: center; }
.topnav-right { display: flex; gap: 12px; align-items: center; }
.topnav-groups-inline { display: flex; gap: 4px; }
.topnav-userchip {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

/* Hide-on-mobile / show-on-mobile utilities */
.mobile-only { display: none; }
.desktop-only { display: initial; }

/* === Tablet (<= 1023px) === */
@media (max-width: 1023px) {
  .page { padding: 28px 24px 80px; }
  .pagehead h1 { font-size: 44px; }
  .split { grid-template-columns: 1fr; gap: 24px; }
  .split-radar { grid-template-columns: 1fr; gap: 16px; }
  .adminlayout { grid-template-columns: 1fr; gap: 16px; }
  .sidenav {
    position: relative;
    top: 0;
    flex-direction: row;
    gap: 0;
    overflow-x: auto;
    border: 1px solid var(--border);
  }
  .sidenav .sidehead { display: none; }
  .sidenav .sidelink {
    border-left: 0;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    padding: 12px 16px;
  }
  .sidenav .sidelink.active {
    border-left: 0;
    border-bottom-color: var(--accent);
  }
  .sidenav .sidelink .ic-chev { display: none; }
}

/* === Mobile (<= 768px) === */
@media (max-width: 768px) {
  body { font-size: 13px; }
  .page { padding: 20px 16px 100px; }

  /* Nav */
  .topnav-inner {
    padding: 0 16px;
    height: 56px;
    gap: 12px;
  }
  .brand span:last-child { display: none; }
  .topnav-nav, .topnav-userchip, .topnav-groups-inline, .group-dropdown { display: none; }
  .topnav-right .btn { display: none; }
  .menubtn { display: inline-flex; }
  .mobile-only { display: initial; }
  .desktop-only { display: none; }

  /* Pagehead */
  .pagehead {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding-bottom: 16px;
    margin-bottom: 20px;
  }
  .pagehead h1 { font-size: 36px; line-height: 0.92; }
  .pagehead .pre { font-size: 10px; }

  /* Section title */
  .section-title h2 { font-size: 20px; }

  /* Stat blocks */
  .stat { padding: 14px 16px; }
  .stat .stat-value { font-size: 28px; }
  .stat .stat-label { font-size: 9.5px; }
  .stat .stat-sub { font-size: 10px; }

  /* Grid utilities */
  .gx2 { grid-template-columns: 1fr; gap: 12px; }
  .gx3 { grid-template-columns: 1fr; gap: 12px; }
  .gx4 { grid-template-columns: 1fr 1fr; }
  .gx4 > * { border-right: 1px solid var(--border) !important; border-bottom: 1px solid var(--border) !important; border-left: 0 !important; }
  .gx4 > *:nth-child(2n) { border-right: 0 !important; }
  .gx4 > *:nth-last-child(-n+2) { border-bottom: 0 !important; }
  .gx6 { grid-template-columns: 1fr 1fr; }
  .gx6 > * { border-right: 1px solid var(--border) !important; border-bottom: 1px solid var(--border) !important; border-left: 0 !important; }
  .gx6 > *:nth-child(2n) { border-right: 0 !important; }
  .gx6 > *:nth-last-child(-n+2) { border-bottom: 0 !important; }

  /* Login stacks */
  .split-login { grid-template-columns: 1fr; min-height: auto; }
  .split-login > * { border-right: 0; border-bottom: 1px solid var(--border); padding: 32px 24px !important; }

  /* Stepper compresses */
  .stepper { grid-template-columns: 1fr 1fr; }
  .stepper-cell { border-bottom: 1px solid var(--border); padding: 12px 14px; }
  .stepper-cell:nth-child(2n) { border-right: 0; }
  .stepper-cell:nth-last-child(-n+2) { border-bottom: 0; }
  .stepper-cell .display { font-size: 12px; }

  /* Buttons */
  .btn { padding: 10px 14px; font-size: 11px; }
  .btn.sm { padding: 6px 8px; font-size: 10px; }

  /* Avatar */
  .avatar.xl { width: 64px; height: 64px; font-size: 22px; }
  .avatar.lg { width: 44px; height: 44px; font-size: 15px; }

  /* Tables scrollable */
  .scroll-x .tbl { min-width: 620px; }
  .tbl th, .tbl td { padding: 10px 12px; }
  .tbl th { font-size: 9.5px; }

  /* Modal */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; max-height: 92vh; border-bottom: 0; }
  .modal-head { padding: 16px 20px; }
  .modal-body { padding: 16px 20px; }
  .modal-foot { padding: 12px 20px; flex-wrap: wrap; }
  .modal-foot > * { flex: 1; justify-content: center; }
}

/* === Small mobile (<= 480px) === */
@media (max-width: 480px) {
  .gx4 { grid-template-columns: 1fr; }
  .gx4 > * { border-right: 0 !important; }
  .gx6 { grid-template-columns: 1fr; }
  .gx6 > * { border-right: 0 !important; }
  .pagehead h1 { font-size: 30px; }
}

/* Sidebar (admin) */
.adminlayout { display: grid; grid-template-columns: 240px 1fr; gap: 32px; }
.sidenav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 96px; align-self: start; }
.sidenav .sidelink {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  border-left: 2px solid transparent;
}
.sidenav .sidelink:hover { color: var(--text); background: var(--surface); }
.sidenav .sidelink.active { color: var(--text); background: var(--surface); border-left-color: var(--accent); }
.sidenav .sidehead {
  padding: 14px 14px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-mute);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.modal {
  background: var(--bg);
  border: 1px solid var(--border-bright);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body { padding: 24px; }
.modal-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
