:root {
  --gold: #C8A951; --gold-dim: #8A7035;
  --bg: #111113; --bg2: #1C1C1E; --bg3: #2C2C2E; --bg4: #3A3A3C;
  --border: #3A3A3C; --text: #F0EFE8; --text2: #888780;
  --red: #C0392B; --green: #2D9B6A; --radius: 8px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 16px; min-height: 100vh; }

/* Header */
header { background: var(--bg2); border-bottom: 1px solid var(--border); padding: 0 24px; display: flex; align-items: center; height: 56px; gap: 16px; }
header h1 { color: var(--gold); font-size: 32px; font-weight: 600; flex: 1; text-align: center; }
.nav-link, .admin-link { font-size: 12px; color: var(--text2); text-decoration: none; border: 1px solid var(--border); border-radius: 6px; padding: 5px 12px; white-space: nowrap; }
.nav-link:hover, .admin-link:hover { color: var(--text); border-color: var(--gold-dim); }

/* Sub-header bar */
.sub-bar { text-align: center; padding: 12px; background: var(--bg2); border-bottom: 1px solid var(--border); }
.sub-bar a { color: var(--gold); text-decoration: none; font-size: 14px; font-weight: 600; border: 1px solid var(--gold-dim); border-radius: 6px; padding: 7px 24px; display: inline-block; }
.sub-bar a:hover { background: var(--bg3); }

main { max-width: 860px; margin: 0 auto; padding: 28px 24px; }

/* Week tabs */
.week-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.week-tab { background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; padding: 7px 18px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text2); transition: all 0.15s; }
.week-tab:hover { border-color: var(--gold-dim); color: var(--text); }
.week-tab.active { background: var(--bg4); border-color: var(--gold); color: var(--gold); }

/* Stats */
.meta, .stats-row { display: flex; gap: 12px; margin-bottom: 20px; }
.stat { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 20px; flex: 1; text-align: center; }
.stat-num { font-size: 28px; font-weight: 700; color: var(--gold); }
.stat-label { font-size: 11px; color: var(--text2); margin-top: 2px; }

/* Leaderboard */
.lb { display: flex; flex-direction: column; gap: 8px; }
.lb-row { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; display: flex; align-items: center; gap: 14px; cursor: pointer; transition: border-color 0.15s; }
.lb-row:hover { border-color: var(--gold-dim); }
.lb-row.dead { opacity: 0.45; }
.rank { font-size: 20px; font-weight: 700; color: var(--text2); width: 34px; text-align: center; flex-shrink: 0; }
.rank.r1 { color: #FFD700; } .rank.r2 { color: #C0C0C0; } .rank.r3 { color: #CD7F32; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--bg4); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: var(--gold); flex-shrink: 0; }
.info { flex: 1; min-width: 0; }
.info-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.info-sub { font-size: 12px; color: var(--text2); margin-top: 3px; }
.pts-block { text-align: right; flex-shrink: 0; }
.pts { font-size: 26px; font-weight: 700; color: var(--gold); }
.pts-label { font-size: 11px; color: var(--text2); }
.bar-wrap { width: 140px; flex-shrink: 0; }
.bar-bg { background: var(--bg4); border-radius: 4px; height: 6px; overflow: hidden; }
.bar { height: 6px; border-radius: 4px; background: var(--gold); transition: width 0.4s; }

/* Badges */
.badge { font-size: 10px; border-radius: 4px; padding: 2px 7px; font-weight: 600; }
.badge-dead { background: var(--red); color: #fff; }
.badge-alive { background: var(--green); color: #fff; }
.badge-cls { background: var(--bg4); color: var(--text2); border: 1px solid var(--border); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 100; display: none; align-items: flex-start; justify-content: center; padding: 48px 16px; overflow-y: auto; }
.modal-bg.open { display: flex; }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 560px; padding: 24px; }
.modal-hdr { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.modal-close { background: none; border: none; color: var(--text2); font-size: 22px; cursor: pointer; margin-left: auto; }
.cat-hdr { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; color: var(--gold-dim); text-transform: uppercase; padding: 10px 0 5px; border-bottom: 1px solid var(--border); margin-bottom: 6px; margin-top: 12px; }
.ach-item { display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-size: 13px; }
.ach-check { color: var(--green); font-size: 16px; flex-shrink: 0; }
.ach-no { color: var(--bg4); font-size: 16px; flex-shrink: 0; }
.ach-name { flex: 1; }
.ach-name.done { color: var(--text2); }
.ach-pts { font-weight: 600; font-size: 13px; color: var(--gold); flex-shrink: 0; }
.ach-pts.neg { color: var(--red); }
.week-label { font-size: 12px; color: var(--gold-dim); background: var(--bg3); border: 1px solid var(--border); border-radius: 4px; padding: 2px 7px; margin-left: 4px; }

/* Weekly achievements page */
.ach-grid { display: flex; flex-direction: column; gap: 8px; }
.ach-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; display: flex; align-items: center; gap: 16px; }
.ach-card-pts { font-size: 22px; font-weight: 700; color: var(--gold); min-width: 48px; text-align: center; flex-shrink: 0; }
.ach-card-pts.neg { color: var(--red); }
.ach-info { flex: 1; }
.ach-info-name { font-size: 22x; font-weight: 500; }
.ach-meta { display: flex; gap: 8px; margin-top: 4px; }
.ach-cat { font-size: 11px; color: var(--text2); background: var(--bg4); border-radius: 4px; padding: 2px 8px; }
.ach-week-badge { font-size: 11px; color: var(--gold-dim); background: var(--bg3); border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; }
.ach-earners { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; flex-shrink: 0; }
.earner-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--bg4); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; color: var(--gold); border: 1px solid var(--border); position: relative; cursor: default; }
.earner-avatar:hover::after { content: attr(data-name); position: absolute; bottom: 32px; left: 50%; transform: translateX(-50%); background: var(--bg3); border: 1px solid var(--border); border-radius: 4px; padding: 3px 8px; font-size: 11px; white-space: nowrap; color: var(--text); z-index: 10; }
.earner-count { font-size: 12px; color: var(--text2); }
.cat-header { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; color: var(--gold-dim); text-transform: uppercase; padding: 16px 0 6px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }

/* Search */
#player-search { width: 100%; background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; padding: 10px 14px; color: var(--text); font-size: 14px; outline: none; margin-bottom: 16px; }
#player-search:focus { border-color: var(--gold-dim); }

/* Misc */
.empty { color: var(--text2); font-size: 14px; padding: 32px 0; text-align: center; }
.refresh { font-size: 12px; color: var(--text2); text-align: center; margin-top: 24px; }

/* ── Admin-only styles ───────────────────────────────────────── */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.login-box { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 32px; width: 100%; max-width: 360px; }
.login-title { color: var(--gold); font-size: 18px; font-weight: 600; margin-bottom: 24px; text-align: center; }
.login-err { background: rgba(192,57,43,0.15); border: 1px solid var(--red); border-radius: 6px; padding: 8px 12px; font-size: 13px; color: #e57368; margin-bottom: 16px; }
header h1.admin-h1 { font-size: 24px; }
.user-badge { font-size: 12px; color: var(--text2); }
nav { display: flex; gap: 4px; }
nav button { background: none; border: none; color: var(--text2); cursor: pointer; padding: 6px 14px; border-radius: var(--radius); font-size: 13px; font-weight: 500; transition: background 0.15s, color 0.15s; }
nav button:hover { background: var(--bg3); color: var(--text); }
nav button.active { background: var(--bg4); color: var(--gold); }
.logout-btn { font-size: 12px; color: var(--text2); background: none; border: 1px solid var(--border); border-radius: 6px; padding: 5px 12px; cursor: pointer; }
.logout-btn:hover { border-color: var(--red); color: var(--red); }
.page { display: none; max-width: 1100px; margin: 0 auto; padding: 24px; }
.page.active { display: block; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.sec-title { font-size: 16px; font-weight: 600; color: var(--gold); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.sec-title span { font-size: 12px; color: var(--text2); font-weight: 400; }
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 4px; font-weight: 500; }
.form-group { margin-bottom: 12px; }
input[type=text], input[type=number], input[type=password], select { width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; color: var(--text); font-size: 13px; outline: none; transition: border-color 0.15s; }
input:focus, select:focus { border-color: var(--gold-dim); }
.btn { background: var(--bg4); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 8px 16px; cursor: pointer; font-size: 13px; font-weight: 500; transition: background 0.15s, border-color 0.15s; }
.btn:hover { background: var(--bg3); border-color: var(--gold-dim); }
.btn-gold { background: var(--gold); color: #111; border-color: var(--gold); font-weight: 600; }
.btn-gold:hover { background: #d4b05a; }
.btn-danger { background: none; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: rgba(192,57,43,0.1); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-dead { border-color: var(--red); color: var(--red); }
.btn-dead:hover { background: rgba(192,57,43,0.1); }
.btn-alive { border-color: var(--green); color: var(--green); }
.btn-alive:hover { background: rgba(45,155,106,0.1); }
.item-list { display: flex; flex-direction: column; gap: 6px; max-height: 480px; overflow-y: auto; margin-top: 10px; }
.item-row { background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; display: flex; align-items: center; gap: 8px; }
.item-name { flex: 1; font-size: 13px; }
.item-sub { font-size: 11px; color: var(--text2); }
.pts-badge { background: var(--bg4); border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; font-size: 12px; font-weight: 700; color: var(--gold); flex-shrink: 0; }
.pts-badge.neg { color: var(--red); }
.cat-hdr { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; color: var(--gold-dim); text-transform: uppercase; padding: 8px 4px 4px; }
.ach-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 6px; cursor: pointer; transition: background 0.1s; }
.ach-row:hover { background: var(--bg3); }
.ach-row input[type=checkbox] { accent-color: var(--gold); width: 16px; height: 16px; cursor: pointer; flex-shrink: 0; }
.ach-row-name { flex: 1; font-size: 13px; }
.ach-row-name.done { color: var(--text2); text-decoration: line-through; }
.ach-pts { font-size: 13px; font-weight: 600; color: var(--gold); flex-shrink: 0; }
.ach-pts.neg { color: var(--red); }
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 10px 18px; font-size: 13px; z-index: 300; opacity: 0; transition: opacity 0.2s; pointer-events: none; }
.toast.show { opacity: 1; }
.edit-modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 300; display: none; align-items: center; justify-content: center; padding: 24px; }
.edit-modal-bg.open { display: flex; }
.edit-modal { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 460px; padding: 24px; }
.edit-modal-title { font-size: 15px; font-weight: 600; color: var(--gold); margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; }


/* ── Activity Sidebar ────────────────────────────────────────── */
.activity-sidebar { width: 240px; flex-shrink: 0; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; position: sticky; top: 20px; max-height: calc(100vh - 120px); overflow-y: auto; }
.activity-title { color: var(--gold); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 10px; text-align: center; }
.activity-item { background: var(--bg3); border-radius: 6px; padding: 8px 10px; margin-bottom: 6px; }
.activity-player { color: var(--text); font-size: 12px; font-weight: 600; }
.activity-ach { color: var(--text2); font-size: 11px; margin-top: 2px; }
.activity-meta { display: flex; justify-content: space-between; margin-top: 4px; }
.activity-pts { color: var(--gold); font-size: 11px; font-weight: 700; }
.activity-time { color: var(--text2); font-size: 10px; }
@media (max-width: 860px) { .activity-sidebar { display: none; } }

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 600px) {
  header h1 { font-size: 20px; }
  main { padding: 16px 12px; }

  /* Stats: 2 per row on mobile */
  .meta, .stats-row { flex-wrap: wrap; gap: 8px; }
  .stat { flex: 1 1 calc(50% - 4px); min-width: 0; padding: 10px 8px; }
  .stat-num { font-size: 22px; }

  /* Week tabs scroll horizontally */
  .week-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .week-tab { flex-shrink: 0; padding: 6px 14px; }

  /* Leaderboard rows: stack info, hide bar */
  .lb-row { padding: 10px 12px; gap: 10px; flex-wrap: wrap; }
  .bar-wrap { display: none; }
}

.profile-btn { font-size:11px; color:var(--gold); text-decoration:none; border:1px solid var(--gold-dim); border-radius:6px; padding:4px 10px; white-space:nowrap; flex-shrink:0; font-weight:600; }
.profile-btn:hover { color:var(--text); border-color:var(--gold); background:var(--bg3); }

@media (max-width:600px) {
  .profile-btn { display: none; }
  .rank { width: 24px; font-size: 16px; }
  .avatar { width: 36px; height: 36px; font-size: 12px; }
  .info-name { font-size: 14px; gap: 6px; }
  .pts { font-size: 20px; }

  /* Modal full screen on mobile */
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal { border-radius: 12px 12px 0 0; max-width: 100%; padding: 20px 16px; max-height: 90vh; overflow-y: auto; }

  /* Sub bar */
  .sub-bar a { padding: 6px 16px; font-size: 13px; }
}

/* ── Main Layout ─────────────────────────────────────────────── */
.main-layout { max-width:1200px; margin:0 auto; padding:20px 24px; display:flex; gap:20px; align-items:flex-start; }
.main-left { flex:1; min-width:0; }

/* ── Activity Ticker ─────────────────────────────────────────── */
.ticker-wrap { background:var(--bg2); border-bottom:1px solid var(--border); padding:0 16px; display:flex; align-items:center; gap:12px; height:36px; overflow:hidden; }
.ticker-label { color:var(--gold); font-size:10px; font-weight:700; letter-spacing:0.08em; text-transform:uppercase; white-space:nowrap; flex-shrink:0; background:var(--bg4); border-radius:4px; padding:2px 8px; }
.ticker-track { flex:1; overflow:hidden; height:100%; display:flex; align-items:center; }
.ticker-inner { display:flex; align-items:center; gap:16px; width:max-content; animation:ticker-scroll 170s linear infinite; white-space:nowrap; }
.ticker-inner:hover { animation-play-state:paused; }
@keyframes ticker-scroll { 0% { transform:translateX(0); } 100% { transform:translateX(-50%); } }
.ticker-item { display:inline-flex; align-items:center; gap:8px; white-space:nowrap; }
.ticker-player { color:var(--text); font-weight:600; font-size:16px; }
.ticker-ach { color:var(--text2); font-size:14px; }
.ticker-pts { color:var(--gold); font-size:12px; font-weight:700; }
.ticker-sep { color:var(--border); margin:0 8px; }

/* ── Screenshot Lightbox ─────────────────────────────────────── */
.lightbox-sidebar { width:550px; flex-shrink:0; background:var(--bg2); border:1px solid var(--border); border-radius:var(--radius); overflow:hidden; align-self:flex-start; position:sticky; top:20px; }
.lightbox-title { color:var(--gold); font-size:10px; font-weight:700; letter-spacing:0.08em; text-transform:uppercase; padding:10px 12px 8px; border-bottom:1px solid var(--border); text-align:center; }
.lightbox-featured { width:100%; height:500px; background:var(--bg3); position:relative; overflow:hidden; cursor:pointer; }
.lightbox-featured img { width:100%; height:100%; object-fit:cover; transition:transform 0.3s; display:block; }
.lightbox-featured img:hover { transform:scale(1.03); }
.lightbox-empty { display:flex; align-items:center; justify-content:center; height:100%; color:var(--text2); font-size:12px; }
.lightbox-caption { position:absolute; bottom:0; left:0; right:0; background:rgba(17,17,19,0.85); padding:6px 10px; }
.lightbox-caption-name { font-size:11px; color:var(--text); font-weight:600; }
.lightbox-nav { display:flex; align-items:center; justify-content:space-between; padding:8px 10px; border-bottom:1px solid var(--border); }
.lightbox-btn { background:var(--bg3); border:1px solid var(--border); border-radius:4px; color:var(--text2); font-size:13px; padding:3px 10px; cursor:pointer; }
.lightbox-btn:hover { border-color:var(--gold-dim); color:var(--text); }
.lightbox-dots { display:flex; gap:5px; }
.lightbox-dot { width:6px; height:6px; border-radius:50%; background:var(--bg4); cursor:pointer; transition:background 0.2s; }
.lightbox-dot.active { background:var(--gold); }
.lightbox-thumbs { display:grid; grid-template-columns:repeat(3,1fr); gap:3px; padding:8px; }
.lightbox-thumb { height:100px; background:var(--bg3); border-radius:4px; overflow:hidden; cursor:pointer; border:1px solid transparent; transition:border-color 0.15s; }
.lightbox-thumb.active { border-color:var(--gold); }
.lightbox-thumb img { width:100%; height:100%; object-fit:cover; display:block; }

/* Fullscreen */
.fs-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.92); z-index:500; display:none; align-items:center; justify-content:center; }
.fs-overlay.open { display:flex; }
.fs-close { position:fixed; top:20px; right:24px; background:var(--bg3); border:1px solid var(--border); border-radius:6px; color:var(--text); font-size:18px; padding:4px 14px; cursor:pointer; z-index:501; }
.fs-close:hover { border-color:var(--gold-dim); }

.sub-bar a + a { border-color:var(--gold-dim); color:var(--gold); }

@media (max-width:900px) { .lightbox-sidebar { display:none; } .ticker-wrap { display:none; } .main-layout { padding:16px 12px; } }

/* ── Achievement Photo Button & Modal ───────────────────────── */
.ach-photo-btn { background:var(--bg3); border:1px solid var(--border); border-radius:4px; color:var(--gold); font-size:11px; padding:2px 8px; cursor:pointer; transition:border-color 0.15s; }
.ach-photo-btn:hover { border-color:var(--gold); }
.ach-photo-modal-bg { position:fixed; inset:0; background:rgba(0,0,0,0.95); z-index:400; display:none; align-items:center; justify-content:center; padding:20px; }
.ach-photo-modal-bg.open { display:flex; }
.ach-photo-modal { background:var(--bg2); border:1px solid var(--border); border-radius:12px; padding:20px; max-width:800px; width:100%; position:relative; display:flex; flex-direction:column; gap:12px; }
.ach-photo-main { width:100%; height:480px; position:relative; border-radius:8px; overflow:hidden; background:var(--bg3); }
.ach-photo-main img { width:100%; height:100%; object-fit:contain; display:block; }
.ach-photo-main-nav { position:absolute; top:50%; transform:translateY(-50%); display:flex; justify-content:space-between; width:100%; padding:0 10px; pointer-events:none; }
.ach-photo-main-nav button { pointer-events:all; background:rgba(17,17,19,0.75); border:1px solid var(--border); border-radius:6px; color:var(--text); font-size:18px; padding:6px 14px; cursor:pointer; }
.ach-photo-main-nav button:hover { border-color:var(--gold-dim); }
.ach-photo-info { display:flex; align-items:center; justify-content:space-between; }
.ach-photo-modal-caption { color:var(--text); font-size:13px; }
.ach-photo-modal-counter { color:var(--text2); font-size:12px; }
.ach-photo-carousel { display:flex; gap:6px; overflow-x:auto; padding-bottom:4px; }
.ach-photo-carousel::-webkit-scrollbar { height:4px; }
.ach-photo-carousel::-webkit-scrollbar-thumb { background:var(--bg4); border-radius:2px; }
.ach-photo-thumb { width:80px; height:60px; flex-shrink:0; border-radius:6px; overflow:hidden; cursor:pointer; border:2px solid transparent; transition:border-color 0.15s; }
.ach-photo-thumb.active { border-color:var(--gold); }
.ach-photo-thumb img { width:100%; height:100%; object-fit:cover; display:block; }
