:root {
  --bg0: #071018;
  --bg1: #0c1c28;
  --glass: rgba(255, 255, 255, 0.08);
  --glass-strong: rgba(255, 255, 255, 0.14);
  --stroke: rgba(255, 255, 255, 0.22);
  --text: #f4fbff;
  --muted: rgba(220, 236, 245, 0.68);
  --accent: #3ee0c5;
  --accent-2: #6aa8ff;
  --danger: #ff7b7b;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --radius: 28px;
  --font-display: "Syne", sans-serif;
  --font-body: "Manrope", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 700px at 10% -10%, #16364a 0%, transparent 55%),
    radial-gradient(900px 600px at 100% 0%, #1a3d55 0%, transparent 50%),
    linear-gradient(165deg, var(--bg0), var(--bg1) 45%, #08141d);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at center, black, transparent 85%);
  opacity: 0.35;
}

.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(40px);
  pointer-events: none;
  z-index: 0;
  animation: float 12s ease-in-out infinite;
}
.orb-a { width: 280px; height: 280px; left: -60px; top: 80px; background: rgba(62, 224, 197, 0.22); }
.orb-b { width: 340px; height: 340px; right: -80px; top: -40px; background: rgba(106, 168, 255, 0.2); animation-delay: -4s; }
.orb-c { width: 260px; height: 260px; left: 30%; bottom: -80px; background: rgba(120, 255, 214, 0.12); animation-delay: -7s; }

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-18px) scale(1.05); }
}

.shell {
  position: relative;
  z-index: 1;
  width: min(920px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 48px;
  display: grid;
  gap: 14px;
}

.glass {
  background: linear-gradient(145deg, var(--glass-strong), var(--glass));
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.25);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
}

.brand-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}
.brand-mark {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  object-fit: cover;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 10px 30px rgba(62, 224, 197, 0.25);
  background: #041018;
}
.brand-text {
  min-width: 0;
  flex: 1;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}
.brand-sub { color: var(--muted); font-size: 0.85rem; }

.hero {
  text-align: center;
  padding: 28px 20px 24px;
  animation: rise 0.45s ease;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.avatar-wrap {
  width: 96px;
  height: 96px;
  margin: 0 auto 14px;
  border-radius: 32px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.35);
  box-shadow: 0 12px 40px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.08);
}
.avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.avatar-wrap img.show { display: block; }
.avatar-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
}
.avatar-wrap img.show + .avatar-fallback { display: none; }

.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.tag {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 500;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.stat {
  padding: 16px;
  display: grid;
  gap: 6px;
  animation: rise 0.45s ease;
}
.stat:nth-child(2) { animation-delay: 0.05s; }
.stat:nth-child(3) { animation-delay: 0.1s; }
.stat:nth-child(4) { animation-delay: 0.15s; }
.stat-label {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.stat strong {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 800;
}
.stat em {
  font-style: normal;
  color: var(--muted);
  font-size: 0.85rem;
}
.rank-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  margin-top: 4px;
}
.rank-bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.6s ease;
}

.panel { padding: 16px 16px 12px; }
.panel-head h2, .admin-grid h3 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
}
.admin-grid h3 { margin-top: 8px; font-size: 0.95rem; color: var(--muted); }
.list { display: grid; gap: 8px; }
.list.compact { gap: 6px; }
.item {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  display: grid;
  gap: 4px;
}
.item a { color: var(--accent); text-decoration: none; }
.item .meta { color: var(--muted); font-size: 0.82rem; }

.admin-grid { display: grid; gap: 16px; }
.admin-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
}
.admin-form input, .admin-form button {
  border-radius: 14px;
  border: 1px solid var(--stroke);
  padding: 10px 12px;
  font: inherit;
}
.admin-form input {
  background: rgba(0,0,0,0.25);
  color: var(--text);
  outline: none;
}
.admin-form button {
  background: linear-gradient(135deg, var(--accent), #2bb8d8);
  color: #041018;
  font-weight: 700;
  cursor: pointer;
  border: none;
}
.admin-form button.ghost {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid var(--stroke);
}

.hidden { display: none !important; }

.tabs {
  display: flex;
  gap: 6px;
  padding: 6px;
}
.tab {
  flex: 1;
  border: none;
  border-radius: 18px;
  padding: 12px 10px;
  font: inherit;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.tab.active {
  color: #041018;
  background: linear-gradient(135deg, var(--accent), #2bb8d8);
}
.tab-panels { display: grid; gap: 14px; }
.tab-panel { display: none; gap: 14px; }
.tab-panel.active { display: grid; animation: rise 0.35s ease; }

.account-panel { display: grid; gap: 14px; }
.account-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.account-head h2 { margin: 0; }
.account-identity {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}
.account-identity strong {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
}
.account-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.account-status .badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  font-weight: 600;
}
.account-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
}
.account-status .dot.ok { background: var(--accent); }

.login-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}
.login-form { margin-top: 0; }
.login-error {
  min-height: 1.2em;
  color: var(--danger) !important;
  margin: 8px 0 0;
}
.btn-ghost, .login-cancel {
  border-radius: 14px;
  border: 1px solid var(--stroke);
  padding: 10px 12px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: rgba(255,255,255,0.08);
  cursor: pointer;
}
.login-cancel { width: 100%; margin-top: 8px; }

.leaderboard {
  display: grid;
  gap: 10px;
}
.lb-card {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px;
  animation: rise 0.35s ease;
}
.lb-rank {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--accent);
  min-width: 2ch;
}
.lb-avatar {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  object-fit: cover;
  background: rgba(255,255,255,0.08);
}
.lb-avatar.fallback {
  display: grid;
  place-items: center;
  font-weight: 700;
}
.lb-body { display: grid; gap: 2px; }
.lb-total {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin-top: 4px;
}

.sessions-list { gap: 8px; }
.session-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  padding: 12px 14px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.session-row:active { transform: scale(0.98); }
.session-row-body { display: grid; gap: 2px; flex: 1; }
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255,123,123,0.15);
}
.status-dot.on {
  background: #3ee0c5;
  box-shadow: 0 0 0 4px rgba(62,224,197,0.18);
  animation: pulse 2s ease infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.session-meta { display: grid; gap: 8px; margin-bottom: 12px; }
.session-stats { margin-bottom: 8px; }

.nft-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.nft-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
}
.nft-card img, .nft-ph {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 14px;
  background: rgba(255,255,255,0.06);
}
.nft-body { display: grid; gap: 4px; font-size: 0.9rem; }
.nft-body a { color: var(--accent); text-decoration: none; font-weight: 600; }
.nft-timer {
  font-variant-numeric: tabular-nums;
  color: var(--accent-2);
  font-weight: 700;
}

.worker-row {
  display: grid;
  gap: 10px;
  align-items: start;
}
.worker-row-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.worker-row-main strong {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.worker-budget-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: baseline;
}
.worker-budget-line .pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.worker-budget-line .pill em {
  color: var(--text);
  font-style: normal;
  font-weight: 700;
}
.worker-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}
.worker-actions .btn-ghost {
  width: 100%;
  min-height: 40px;
  touch-action: manipulation;
}

.workers-panel { display: grid; gap: 14px; }
.worker-form {
  display: grid;
  gap: 10px;
}
.worker-form .field {
  display: grid;
  gap: 6px;
}
.worker-form .field span {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.worker-form input,
.worker-form button {
  width: 100%;
  box-sizing: border-box;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  padding: 12px 14px;
  font: inherit;
  min-height: 46px;
}
.worker-form input {
  background: rgba(0,0,0,0.25);
  color: var(--text);
  outline: none;
}
.worker-form button {
  background: linear-gradient(135deg, var(--accent), #2bb8d8);
  color: #041018;
  font-weight: 700;
  cursor: pointer;
  border: none;
  touch-action: manipulation;
}
.workers-list { gap: 10px; }

.tabs {
  display: flex;
  gap: 6px;
  padding: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab { white-space: nowrap; flex: 1 0 auto; }

@media (min-width: 560px) {
  .worker-form {
    grid-template-columns: 1.2fr 1fr auto;
    align-items: end;
  }
  .worker-form button {
    width: auto;
    min-width: 150px;
  }
  .worker-row {
    grid-template-columns: 1fr auto;
    align-items: center;
  }
  .worker-actions {
    width: auto;
    grid-template-columns: auto auto;
  }
  .worker-actions .btn-ghost {
    width: auto;
    padding-inline: 14px;
  }
}

@media (min-width: 760px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .admin-grid { grid-template-columns: 1.1fr 1fr 1.1fr; }
  .nft-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
