/* ==========================================================================
   Faction Standings - Glass UI theme
   ========================================================================== */
:root {
  --bg-base: #07030a;
  --bg-deep: #0c0608;
  --text-main: #f8eef0;
  --text-muted: #bfa3a8;
  --text-dim: #8a7076;

  --accent-red: #ff4a5c;
  --accent-hot: #ff2d55;
  --accent-ember: #ff8a5c;
  --btn-red: #c8182d;
  --btn-red-hover: #e0213a;

  --status-active: #3ecf8e;
  --status-warning: #f0b429;
  --status-disbanded: #ff7a7a;

  /* Glass tokens */
  --glass-bg: rgba(255, 255, 255, 0.045);
  --glass-bg-strong: rgba(255, 255, 255, 0.07);
  --glass-bg-input: rgba(10, 4, 8, 0.55);
  --glass-border: rgba(255, 255, 255, 0.09);
  --glass-border-hot: rgba(255, 74, 92, 0.55);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.75), 0 2px 8px rgba(0, 0, 0, 0.35);
  --glass-blur: blur(18px) saturate(150%);

  /* Legacy aliases kept for compatibility */
  --panel-bg: var(--glass-bg);
  --panel-elevated: var(--glass-bg-strong);
  --border-color: var(--glass-border);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --font-display: "Big Shoulders Display", Impact, "Arial Narrow", system-ui, -apple-system, sans-serif;
  --font-body: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(200, 24, 45, 0.22), transparent 60%),
    linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-base) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

::selection {
  background: rgba(255, 74, 92, 0.45);
  color: #fff;
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 74, 92, 0.25);
  border-radius: 10px;
  border: 2px solid var(--bg-base);
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 74, 92, 0.45); }

/* ==========================================================================
   Decorative background layer
   ========================================================================== */
.bg-decor {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  will-change: transform;
}

.orb-1 {
  width: 520px;
  height: 520px;
  top: -160px;
  right: -120px;
  background: radial-gradient(circle, rgba(255, 45, 85, 0.75), rgba(200, 24, 45, 0) 70%);
  animation: drift-1 22s ease-in-out infinite alternate;
}

.orb-2 {
  width: 600px;
  height: 600px;
  bottom: -220px;
  left: -180px;
  background: radial-gradient(circle, rgba(200, 24, 45, 0.7), rgba(120, 10, 30, 0) 70%);
  animation: drift-2 28s ease-in-out infinite alternate;
}

.orb-3 {
  width: 380px;
  height: 380px;
  top: 40%;
  left: 55%;
  background: radial-gradient(circle, rgba(255, 138, 92, 0.35), rgba(255, 138, 92, 0) 70%);
  opacity: 0.35;
  animation: drift-3 34s ease-in-out infinite alternate;
}

@keyframes drift-1 { to { transform: translate(-90px, 120px) scale(1.12); } }
@keyframes drift-2 { to { transform: translate(120px, -80px) scale(1.08); } }
@keyframes drift-3 { to { transform: translate(-160px, -60px) scale(0.9); } }

/* Perspective grid fading out toward the top */
.grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 74, 92, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 74, 92, 0.06) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 20%, transparent 75%);
}

/* Faint diagonal hazard lines */
.diag-lines {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(255, 74, 92, 0.022) 0px,
    rgba(255, 74, 92, 0.022) 1px,
    transparent 1px,
    transparent 14px
  );
}

/* Film grain */
.noise {
  position: absolute;
  inset: -50%;
  opacity: 0.06;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* Floating embers */
.embers span {
  position: absolute;
  bottom: -20px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-red);
  box-shadow: 0 0 10px 2px rgba(255, 74, 92, 0.7);
  opacity: 0;
  animation: ember-rise linear infinite;
}

.embers span:nth-child(1) { left: 8%;  animation-duration: 14s; animation-delay: 0s; }
.embers span:nth-child(2) { left: 22%; animation-duration: 18s; animation-delay: 3s; width: 3px; height: 3px; }
.embers span:nth-child(3) { left: 37%; animation-duration: 16s; animation-delay: 7s; }
.embers span:nth-child(4) { left: 54%; animation-duration: 20s; animation-delay: 1s; width: 2px; height: 2px; }
.embers span:nth-child(5) { left: 68%; animation-duration: 15s; animation-delay: 5s; }
.embers span:nth-child(6) { left: 81%; animation-duration: 19s; animation-delay: 9s; width: 3px; height: 3px; }
.embers span:nth-child(7) { left: 93%; animation-duration: 17s; animation-delay: 4s; }
.embers span:nth-child(8) { left: 47%; animation-duration: 22s; animation-delay: 11s; width: 2px; height: 2px; }

@keyframes ember-rise {
  0%   { transform: translate(0, 0); opacity: 0; }
  10%  { opacity: 0.9; }
  50%  { transform: translate(30px, -50vh); }
  90%  { opacity: 0.5; }
  100% { transform: translate(-20px, -105vh); opacity: 0; }
}

/* Visible keyboard focus across all interactive elements */
a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-red);
  outline-offset: 2px;
}

/* ==========================================================================
   Layout
   ========================================================================== */
.site-wrapper {
  position: relative;
  z-index: 1;
  max-width: 1060px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Shared glass surface */
.site-header,
.main-nav,
.panel,
.restricted-box,
.banner,
.test-auth-bar,
.site-footer {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), var(--glass-shadow);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

/* Fallback when backdrop-filter is unsupported */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .site-header,
  .main-nav,
  .panel,
  .restricted-box,
  .banner,
  .test-auth-bar,
  .site-footer {
    background: rgba(26, 13, 17, 0.92);
  }
}

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 26px;
  margin-bottom: 18px;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* Glowing accent line along the top edge */
.site-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 8%;
  right: 8%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-red), var(--accent-ember), var(--accent-red), transparent);
  box-shadow: 0 0 18px 1px rgba(255, 74, 92, 0.6);
}

/* Soft sweeping light inside header */
.site-header::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  left: -45%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  animation: sheen 9s ease-in-out infinite;
  pointer-events: none;
}

@keyframes sheen {
  0%, 60% { left: -45%; }
  100% { left: 120%; }
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-width: 0;
}

.logo-frame {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: radial-gradient(circle at 50% 40%, rgba(255, 74, 92, 0.22), rgba(255, 74, 92, 0.02) 70%);
  border: 1px solid rgba(255, 74, 92, 0.28);
  box-shadow: 0 0 24px -4px rgba(255, 74, 92, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Rotating ring decoration */
.logo-frame::before {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 19px;
  padding: 1px;
  background: conic-gradient(from 0deg, transparent 0 70%, var(--accent-red) 85%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: spin 6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.logo-frame img,
.logo-frame canvas {
  width: 50px;
  height: 50px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 0 10px rgba(255, 74, 92, 0.55));
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.site-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.02;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffffff 0%, #ffd6db 55%, #ff8b98 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 28px rgba(255, 74, 92, 0.25);
}

.site-subtitle {
  margin: 0;
  font-size: 0.93rem;
  color: var(--text-muted);
}

.header-controls {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  flex-shrink: 0;
}

.header-actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px 7px 10px;
  border-radius: 999px;
  font-size: 0.88rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight);
}

/* Online dot */
.user-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-active);
  box-shadow: 0 0 0 3px rgba(62, 207, 142, 0.18), 0 0 10px rgba(62, 207, 142, 0.8);
}

.user-pill-name {
  font-weight: 700;
  color: var(--text-main);
}

.user-pill-role {
  color: var(--accent-red);
  font-weight: 700;
  padding-left: 10px;
  border-left: 1px solid var(--glass-border);
  text-shadow: 0 0 12px rgba(255, 74, 92, 0.45);
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 17px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.15s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

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

.btn-primary {
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent-hot) 0%, var(--btn-red) 100%);
  border-color: rgba(255, 120, 135, 0.6);
  box-shadow: 0 6px 22px -6px rgba(255, 45, 85, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #ff4a6a 0%, var(--btn-red-hover) 100%);
  box-shadow: 0 10px 28px -6px rgba(255, 45, 85, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-secondary {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--glass-border);
  box-shadow: var(--glass-highlight);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 74, 92, 0.12);
  border-color: var(--glass-border-hot);
  box-shadow: 0 0 18px -4px rgba(255, 74, 92, 0.6), var(--glass-highlight);
}

.btn-danger-outline {
  background: rgba(255, 122, 122, 0.05);
  color: var(--status-disbanded);
  border-color: rgba(255, 122, 122, 0.25);
  padding: 5px 12px;
  font-size: 0.8rem;
}

.btn-danger-outline:hover:not(:disabled) {
  border-color: var(--status-disbanded);
  background: rgba(255, 122, 122, 0.14);
  box-shadow: 0 0 14px -4px rgba(255, 122, 122, 0.7);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
}

/* ==========================================================================
   Test auth bar (only visible when ALLOW_TEST_AUTH=true)
   ========================================================================== */
.test-auth-bar {
  border-radius: var(--radius-md);
  border-left: 3px solid var(--accent-red);
  padding: 12px 16px;
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.test-auth-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.test-auth-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-main);
}

.test-auth-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.test-auth-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* ==========================================================================
   Navigation (segmented glass pill)
   ========================================================================== */
.main-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 6px;
  margin: 0 auto 20px;
  border-radius: 999px;
  width: fit-content;
  max-width: 100%;
}

.nav-tab {
  position: relative;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  padding: 9px 18px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.nav-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.nav-tab.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent-hot) 0%, var(--btn-red) 100%);
  border-color: rgba(255, 120, 135, 0.55);
  box-shadow: 0 6px 20px -6px rgba(255, 45, 85, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

#staffNavTab {
  border-color: rgba(240, 180, 41, 0.3);
}

#staffNavTab:not(.active) {
  color: var(--status-warning);
}

/* ==========================================================================
   Panels & cards
   ========================================================================== */
main {
  animation: fade-up 0.45s ease both;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.panel {
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 20px;
  animation: fade-up 0.45s ease both;
}

/* Corner bracket decorations */
.panel::before,
.panel::after,
.restricted-box::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  pointer-events: none;
  border-color: rgba(255, 74, 92, 0.65);
  border-style: solid;
}

.panel::before {
  top: -1px;
  left: -1px;
  border-width: 2px 0 0 2px;
  border-top-left-radius: var(--radius-lg);
}

.panel::after {
  bottom: -1px;
  right: -1px;
  border-width: 0 2px 2px 0;
  border-bottom-right-radius: var(--radius-lg);
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(90deg, rgba(255, 74, 92, 0.45), rgba(255, 255, 255, 0.06) 60%, transparent) 1;
}

.panel-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Diamond marker before titles */
.panel-title::before {
  content: "";
  width: 9px;
  height: 9px;
  transform: rotate(45deg);
  background: linear-gradient(135deg, var(--accent-ember), var(--accent-red));
  box-shadow: 0 0 12px rgba(255, 74, 92, 0.85);
  flex-shrink: 0;
}

.panel-subtitle {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Banners
   ========================================================================== */
.banner {
  padding: 12px 16px 12px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  font-size: 0.92rem;
  overflow: hidden;
}

.banner:empty {
  display: none;
}

.banner::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}

.banner-error {
  color: var(--text-main);
  background: linear-gradient(90deg, rgba(255, 74, 92, 0.14), var(--glass-bg) 45%);
}

.banner-error::before {
  background: var(--accent-red);
  box-shadow: 0 0 14px var(--accent-red);
}

.banner-success {
  color: var(--text-main);
  background: linear-gradient(90deg, rgba(62, 207, 142, 0.14), var(--glass-bg) 45%);
}

.banner-success::before {
  background: var(--status-active);
  box-shadow: 0 0 14px var(--status-active);
}

/* ==========================================================================
   Restricted / no access
   ========================================================================== */
.restricted-box {
  border-radius: var(--radius-lg);
  padding: 34px 30px;
  margin: 8px 0 24px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 120% at 0% 50%, rgba(255, 74, 92, 0.16), transparent 60%),
    var(--glass-bg);
}

.restricted-box::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent-ember), var(--accent-red));
  box-shadow: 0 0 16px var(--accent-red);
}

.restricted-box::after {
  top: 14px;
  right: 14px;
  border-width: 2px 2px 0 0;
}

.restricted-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.restricted-message {
  margin: 0 0 20px;
  font-size: 1.02rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Controls & inputs
   ========================================================================== */
.control-inline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.control-label {
  font-size: 0.86rem;
  color: var(--text-muted);
  font-weight: 600;
}

select,
input[type="text"],
input[type="number"],
input[type="search"],
input[type="url"],
textarea {
  background: var(--glass-bg-input);
  color: var(--text-main);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
select:-webkit-autofill,
textarea:-webkit-autofill {
  -webkit-text-fill-color: var(--text-main);
  -webkit-box-shadow: 0 0 0 1000px #14161e inset;
  box-shadow: 0 0 0 1000px #14161e inset;
  caret-color: var(--text-main);
  transition: background-color 9999s ease-out 0s;
}

select option {
  background: #1a0d11;
  color: var(--text-main);
}

select:hover,
input:hover,
textarea:hover {
  border-color: rgba(255, 74, 92, 0.35);
}

select:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--glass-border-hot);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35), 0 0 0 3px rgba(255, 74, 92, 0.18);
}

/* ==========================================================================
   Leaderboard table
   ========================================================================== */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 6px;
  text-align: left;
}

.data-table th {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 6px 14px;
  white-space: nowrap;
}

.data-table td {
  padding: 14px;
  vertical-align: middle;
  background: rgba(255, 255, 255, 0.03);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
  transition: background 0.2s ease;
}

.data-table td:first-child {
  border-top-left-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
  border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.data-table td:last-child {
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.data-table tbody tr:hover td {
  background: rgba(255, 74, 92, 0.08);
}

.data-table tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--accent-red);
}

.data-table tbody tr.row-disbanded {
  opacity: 0.45;
  filter: grayscale(0.4);
}

.rank-num {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-dim);
  width: 58px;
}

/* Podium colours by rank (tied ranks share the same medal colour) */
.rank-num.rank-1 {
  color: #ffd76a;
  text-shadow: 0 0 14px rgba(255, 200, 80, 0.6);
}

.rank-num.rank-2 {
  color: #dfe6ef;
  text-shadow: 0 0 12px rgba(220, 230, 240, 0.4);
}

.rank-num.rank-3 {
  color: #e8a26a;
  text-shadow: 0 0 12px rgba(232, 162, 106, 0.45);
}

.faction-name-cell {
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: 0.01em;
  color: var(--text-main);
}

.big-number {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Status badges
   ========================================================================== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.status-active {
  color: var(--status-active);
  background: rgba(62, 207, 142, 0.1);
  border-color: rgba(62, 207, 142, 0.35);
}

.status-warning {
  color: var(--status-warning);
  background: rgba(240, 180, 41, 0.12);
  border-color: rgba(240, 180, 41, 0.4);
}

.status-warning::before {
  animation: pulse 1.6s ease-in-out infinite;
}

.status-disbanded {
  color: var(--status-disbanded);
  background: rgba(255, 122, 122, 0.12);
  border-color: rgba(255, 122, 122, 0.4);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ==========================================================================
   Standing bar
   ========================================================================== */
.standing-bar-cell {
  min-width: 170px;
  width: 230px;
}

.standing-bar-track {
  position: relative;
  height: 10px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* Center 0 marker on the standing bar */
.standing-bar-track::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.45);
  z-index: 2;
  pointer-events: none;
}

.standing-bar-fill {
  position: relative;
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Moving shine on the bar */
.standing-bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  background-size: 60px 100%;
  background-repeat: no-repeat;
  animation: bar-shine 3s ease-in-out infinite;
}

@keyframes bar-shine {
  from { background-position: -60px 0; }
  to { background-position: calc(100% + 60px) 0; }
}

.standing-bar-fill.fill-active {
  background: linear-gradient(90deg, #1f9e68, var(--status-active));
  box-shadow: 0 0 12px rgba(62, 207, 142, 0.6);
}

.standing-bar-fill.fill-warning {
  background: linear-gradient(90deg, #c98a0c, var(--status-warning));
  box-shadow: 0 0 12px rgba(240, 180, 41, 0.6);
}

.standing-bar-fill.fill-disbanded {
  background: linear-gradient(90deg, #c8182d, var(--status-disbanded));
  box-shadow: 0 0 12px rgba(255, 122, 122, 0.6);
}

.standing-bar-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ==========================================================================
   Week change delta
   ========================================================================== */
.delta-pos,
.delta-neg,
.delta-zero {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
}

.delta-pos {
  color: var(--status-active);
  text-shadow: 0 0 12px rgba(62, 207, 142, 0.45);
}

.delta-neg {
  color: var(--status-disbanded);
  text-shadow: 0 0 12px rgba(255, 122, 122, 0.45);
}

.delta-zero {
  color: var(--text-dim);
}

/* ==========================================================================
   Stats grid (My faction)
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--glass-highlight);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Glow blob in corner */
.stat-card::before {
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  top: -60px;
  right: -40px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 74, 92, 0.35), transparent 70%);
  pointer-events: none;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 74, 92, 0.35);
  box-shadow: 0 12px 30px -12px rgba(255, 45, 85, 0.5), var(--glass-highlight);
}

.stat-label {
  position: relative;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  position: relative;
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1.05;
  color: var(--text-main);
  text-shadow: 0 0 22px rgba(255, 74, 92, 0.25);
}

.stat-meta {
  position: relative;
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Faction switcher
   ========================================================================== */
.faction-switcher {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--glass-border);
}

.switcher-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.switcher-btn {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
  padding: 6px 14px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.switcher-btn:hover {
  color: var(--text-main);
  border-color: var(--glass-border-hot);
  background: rgba(255, 74, 92, 0.1);
}

.switcher-btn.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent-hot), var(--btn-red));
  border-color: rgba(255, 120, 135, 0.55);
  box-shadow: 0 4px 16px -4px rgba(255, 45, 85, 0.8);
}

/* ==========================================================================
   Staff forms
   ========================================================================== */
.staff-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.staff-grid > .panel {
  margin-bottom: 0;
  min-width: 0;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.form-field {
  min-width: 0;
}

.form-field input,
.form-field select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.data-table td .form-hint {
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 340px;
}

/* ==========================================================================
   Empty & loading states
   ========================================================================== */
.empty-state {
  position: relative;
  padding: 26px 20px 26px 52px;
  text-align: left;
  color: var(--text-muted);
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
}

.empty-state::before {
  content: "";
  position: absolute;
  left: 22px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border-radius: 50%;
  border: 2px solid rgba(255, 74, 92, 0.25);
  border-top-color: var(--accent-red);
  animation: spin 1s linear infinite;
}

/* ==========================================================================
   Purchased items
   ========================================================================== */
.purchases-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.purchase-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 7px 8px 7px 14px;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--glass-highlight);
}

.purchase-chip-cost {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--accent-red);
  text-shadow: 0 0 10px rgba(255, 74, 92, 0.5);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  margin-top: auto;
  padding: 16px 22px;
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  font-size: 0.88rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.site-footer a {
  color: var(--accent-red);
  text-decoration: none;
  font-weight: 700;
}

.site-footer a:hover {
  text-decoration: underline;
  text-shadow: 0 0 10px rgba(255, 74, 92, 0.6);
}

#liveConnectionStatus {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#liveConnectionStatus::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-active);
  box-shadow: 0 0 8px var(--status-active);
  animation: pulse 2s ease-in-out infinite;
}

/* Spacer so footer is not glued to content */
main {
  margin-bottom: 24px;
}

/* ==========================================================================
   Language Switcher & RTL (Arabic) support
   ========================================================================== */
.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.lang-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 5px 11px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.lang-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.lang-btn.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent-hot) 0%, var(--btn-red) 100%);
  box-shadow: 0 4px 12px -4px rgba(255, 45, 85, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

html[dir="rtl"],
html[dir="rtl"] body {
  font-family: "Cairo", var(--font-body);
}

html[dir="rtl"] .site-title,
html[dir="rtl"] .panel-title,
html[dir="rtl"] .restricted-title,
html[dir="rtl"] .lang-btn,
html[dir="rtl"] .btn,
html[dir="rtl"] .nav-tab,
html[dir="rtl"] .switcher-btn,
html[dir="rtl"] select,
html[dir="rtl"] input,
html[dir="rtl"] textarea {
  font-family: "Cairo", var(--font-body);
  letter-spacing: 0;
}

html[dir="rtl"] .data-table {
  text-align: right;
}

html[dir="rtl"] .data-table th,
html[dir="rtl"] .stat-label,
html[dir="rtl"] .form-field label,
html[dir="rtl"] .status-badge {
  letter-spacing: 0;
}

html[dir="rtl"] .data-table td:first-child {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: none;
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

html[dir="rtl"] .data-table td:last-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
  border-top-left-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
  border-left: 1px solid rgba(255, 255, 255, 0.05);
}

html[dir="rtl"] .data-table tbody tr:hover td:first-child {
  box-shadow: inset -3px 0 0 var(--accent-red);
}

html[dir="rtl"] .user-pill {
  padding: 7px 10px 7px 14px;
}

html[dir="rtl"] .user-pill-role {
  padding-left: 0;
  padding-right: 10px;
  border-left: none;
  border-right: 1px solid var(--glass-border);
}

html[dir="rtl"] .banner {
  padding: 12px 18px 12px 16px;
}

html[dir="rtl"] .banner::before,
html[dir="rtl"] .restricted-box::before {
  left: auto;
  right: 0;
}

html[dir="rtl"] .banner-error {
  background: linear-gradient(270deg, rgba(255, 74, 92, 0.14), var(--glass-bg) 45%);
}

html[dir="rtl"] .banner-success {
  background: linear-gradient(270deg, rgba(62, 207, 142, 0.14), var(--glass-bg) 45%);
}

html[dir="rtl"] .restricted-box {
  background:
    radial-gradient(ellipse 60% 120% at 100% 50%, rgba(255, 74, 92, 0.16), transparent 60%),
    var(--glass-bg);
}

html[dir="rtl"] .restricted-box::after {
  right: auto;
  left: 14px;
  border-width: 2px 0 0 2px;
}

html[dir="rtl"] .panel-header {
  border-image: linear-gradient(270deg, rgba(255, 74, 92, 0.45), rgba(255, 255, 255, 0.06) 60%, transparent) 1;
}

html[dir="rtl"] .empty-state {
  padding: 26px 52px 26px 20px;
  text-align: right;
}

html[dir="rtl"] .empty-state::before {
  left: auto;
  right: 22px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 800px) {
  .site-header {
    flex-direction: column;
    align-items: stretch;
    padding: 18px;
    gap: 16px;
  }

  .header-controls {
    width: 100%;
    padding-top: 14px;
    border-top: 1px solid var(--glass-border);
    align-items: flex-start;
  }

  .header-actions-row {
    width: 100%;
    align-items: center;
    justify-content: flex-start;
  }

  .main-nav {
    border-radius: var(--radius-md);
    width: 100%;
    justify-content: center;
  }

  .staff-grid,
  .form-row-2 {
    grid-template-columns: 1fr;
  }

  .site-title {
    font-size: 2rem;
  }

  .panel {
    padding: 18px;
  }

  .orb {
    filter: blur(60px);
  }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .embers {
    display: none;
  }
}

/* ==========================================================================
   Blurred Leaderboard Preview, How It Works, Weekly Chart & Staff Log Filter
   ========================================================================== */
.preview-blur-wrap {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--glass-border);
  background: rgba(12, 13, 18, 0.55);
}

.preview-blur-content {
  filter: blur(5px);
  opacity: 0.65;
  user-select: none;
  pointer-events: none;
}

.preview-blur-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
  background: radial-gradient(circle at center, rgba(12, 13, 18, 0.55), rgba(12, 13, 18, 0.85));
}

.how-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.how-card {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
}

.how-card-title {
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.how-card-body {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.chart-card {
  margin-bottom: 20px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.02);
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.log-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.log-filter-bar input,
.log-filter-bar select {
  max-width: 260px;
}

.shop-balance-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(230, 57, 70, 0.35);
  background: rgba(230, 57, 70, 0.12);
  font-weight: 700;
  color: var(--text-primary);
}

.shop-row-locked .faction-name-cell,
.shop-row-locked .big-number,
.shop-row-locked .control-label {
  opacity: 0.55;
}

.shop-need-more {
  color: #fcd34d;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 3px;
}

.standing-zone-disband {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: rgba(255, 100, 100, 0.75);
  z-index: 1;
}

.standing-zone-warning {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: rgba(240, 180, 41, 0.25);
  border-right: 1px dashed rgba(240, 180, 41, 0.7);
  z-index: 1;
}

.standing-zone-bonus {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.09);
  z-index: 1;
}

.standing-zero-tick {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: rgba(255, 255, 255, 0.75);
  z-index: 3;
}

.standing-start-tick {
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 1.5px;
  background: rgba(110, 231, 183, 0.65);
  z-index: 3;
}

.standing-ghost-marker {
  position: absolute;
  top: 1px;
  bottom: 1px;
  width: 3px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 2px;
  z-index: 2;
}

.standing-bar-scale-markers {
  position: relative;
  height: 16px;
  margin-top: 4px;
  font-size: 0.68rem;
  color: var(--text-dim);
}

.standing-bar-scale-markers span {
  position: absolute;
  white-space: nowrap;
}

.safety-bar-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  margin-top: 8px;
  overflow: hidden;
}

.safety-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #f59e0b, #3ecf8e);
  transition: width 0.4s ease;
}

.banner-warning {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.45);
  color: #fde68a;
}

.no-anim .panel {
  animation: none !important;
}

.form-feedback {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
}

.form-feedback.is-success {
  background: rgba(62, 207, 142, 0.14);
  border: 1px solid rgba(62, 207, 142, 0.4);
  color: #86efac;
}

.form-feedback.is-error {
  background: rgba(255, 74, 92, 0.14);
  border: 1px solid rgba(255, 74, 92, 0.4);
  color: #fca5a5;
}

.footer-credit {
  margin-left: 6px;
  font-size: 0.74rem;
  opacity: 0.4;
}
