@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700;800&family=Cinzel+Decorative:wght@700;900&family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;600&display=swap');

:root {
  --void: #08040d;
  --panel: #130a1e;
  --panel-2: #1b0f2c;
  --panel-3: #241539;
  --line: #33204f;
  --purple: #9b5cf6;
  --purple-bright: #c084fc;
  --purple-deep: #5b21b6;
  --purple-mist: rgba(155, 92, 246, 0.14);
  --bone: #ede7f6;
  --bone-dim: #b8aecb;
  --moss: #6b8f5e;
  --lantern: #d9a441;

  --tier-1: #ff4d8d;
  --tier-2: #c084fc;
  --tier-3: #9b5cf6;
  --tier-4: #7c5cbf;
  --tier-5: #574471;

  --radius: 14px;
  --shadow-glow: 0 0 40px rgba(155, 92, 246, 0.25);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(ellipse 900px 500px at 50% -10%, rgba(155,92,246,0.16), transparent 60%),
    radial-gradient(ellipse 700px 400px at 90% 20%, rgba(93,32,150,0.12), transparent 60%),
    var(--void);
  color: var(--bone);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--purple-deep); color: white; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--void); }
::-webkit-scrollbar-thumb { background: var(--purple-deep); border-radius: 10px; }

a { color: inherit; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------------- Header ---------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(8,4,13,0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 12px; padding-bottom: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; box-shadow: 0 0 18px rgba(155,92,246,0.5); }
.brand-text .title {
  font-family: 'Cinzel Decorative', serif;
  font-size: 17px; font-weight: 900; letter-spacing: 0.5px;
  background: linear-gradient(180deg, #fff, var(--purple-bright));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  line-height: 1.1;
}
.brand-text .sub { font-size: 10.5px; letter-spacing: 3px; color: var(--bone-dim); text-transform: uppercase; }

.nav-links { display: flex; gap: 6px; align-items: center; }
.nav-links a {
  text-decoration: none; color: var(--bone-dim); font-weight: 600; font-size: 14px;
  padding: 8px 14px; border-radius: 8px; transition: all .2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--bone); background: var(--purple-mist); }
.nav-links a.admin-link {
  border: 1px solid var(--line); color: var(--purple-bright);
}

/* ---------------- Hero ---------------- */
.hero {
  position: relative; padding: 56px 0 34px; text-align: center; overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(circle at 50% 0%, rgba(155,92,246,0.22), transparent 55%);
}
.hero .moon-glow {
  width: 90px; height: 90px; margin: 0 auto 18px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #d8c9f5 55%, transparent 75%);
  box-shadow: 0 0 60px 10px rgba(200,170,255,0.45);
}
.hero h1 {
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(30px, 5vw, 52px);
  margin: 0 0 10px;
  letter-spacing: 1px;
  color: var(--bone);
  text-shadow: 0 0 30px rgba(155,92,246,0.55);
}
.hero p { color: var(--bone-dim); max-width: 560px; margin: 0 auto; font-size: 15px; line-height: 1.6; }
.hero .chain-divider { margin: 26px auto 0; }

.chain-divider {
  width: 100%; max-width: 420px; height: 14px;
  background-image: repeating-linear-gradient(90deg, transparent, transparent 10px, var(--line) 10px, var(--line) 14px);
  opacity: .6; position: relative;
}
.chain-divider .chain-end {
  position: absolute; top: -9px; width: 22px; height: 22px; color: var(--purple); opacity: .8;
}
.chain-divider .chain-end.left { left: 0; }
.chain-divider .chain-end.right { right: 0; }

/* ---------------- Icon system (replaces emoji) ---------------- */
.icon { width: 16px; height: 16px; fill: none; vertical-align: -3px; }
.icon-sm { width: 14px; height: 14px; }
.icon-md { width: 22px; height: 22px; }
.icon-lg { width: 44px; height: 44px; color: var(--purple-bright); opacity: .85; animation: floaty 2s ease-in-out infinite; }
.lanterns .icon { color: var(--lantern); opacity: .85; }

/* ---------------- Section headers ---------------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 46px 0 20px; gap: 16px; flex-wrap: wrap; }
.section-head h2 {
  font-family: 'Cinzel', serif; font-size: 24px; margin: 0; color: var(--bone);
  display: flex; align-items: center; gap: 10px;
}
.section-head .eyebrow { display:block; font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: var(--purple-bright); margin-bottom: 6px; }
.section-head p { margin: 0; color: var(--bone-dim); font-size: 13.5px; }

/* ---------------- Tier list ---------------- */
.tier-row {
  display: grid; grid-template-columns: 120px 1fr;
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 16px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
}
.tier-badge {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: 'Cinzel Decorative', serif; font-weight: 900;
  padding: 14px 8px; gap: 4px; text-align: center;
  border-right: 1px solid var(--line);
}
.tier-badge .letter { font-size: 38px; line-height: 1; text-shadow: 0 0 18px currentColor; }
.tier-badge .name { font-family: 'Inter', sans-serif; font-size: 9.5px; letter-spacing: 1px; text-transform: uppercase; opacity: .85; font-weight: 700; }

.tier-row[data-tier="1"] .tier-badge { color: var(--tier-1); background: rgba(255,77,141,0.08); }
.tier-row[data-tier="2"] .tier-badge { color: var(--tier-2); background: rgba(192,132,252,0.08); }
.tier-row[data-tier="3"] .tier-badge { color: var(--tier-3); background: rgba(155,92,246,0.08); }
.tier-row[data-tier="4"] .tier-badge { color: var(--tier-4); background: rgba(124,92,191,0.08); }
.tier-row[data-tier="5"] .tier-badge { color: var(--tier-5); background: rgba(87,68,113,0.10); }

.tier-players { display: flex; flex-wrap: wrap; gap: 12px; padding: 14px; align-content: flex-start; }
.tier-empty { color: var(--bone-dim); font-size: 13px; padding: 10px; font-style: italic; opacity: .7; }

/* Player chip inside tier row */
.player-chip {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-3); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px 8px 8px; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s;
  min-width: 168px;
}
.player-chip:hover { transform: translateY(-3px); border-color: var(--purple); box-shadow: 0 6px 22px rgba(155,92,246,0.25); }
.player-chip img { width: 40px; height: 40px; border-radius: 8px; image-rendering: pixelated; background: var(--void); }
.player-chip .info { display: flex; flex-direction: column; }
.player-chip .name { font-weight: 700; font-size: 13.5px; color: var(--bone); }
.player-chip .score { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--purple-bright); }

/* ---------------- Leaderboard ---------------- */
.leaderboard { display: flex; flex-direction: column; gap: 10px; margin-bottom: 40px; }

.lb-row {
  display: grid; grid-template-columns: 46px 52px 1fr auto;
  align-items: center; gap: 14px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px;
  cursor: pointer; transition: border-color .15s, transform .15s;
}
.lb-row:hover { border-color: var(--purple); transform: translateX(3px); }
.lb-rank { font-family: 'Cinzel Decorative', serif; font-size: 20px; text-align: center; color: var(--bone-dim); }
.lb-row.rank-1 .lb-rank { color: #ffd76e; text-shadow: 0 0 14px rgba(255,215,110,0.7); }
.lb-row.rank-2 .lb-rank { color: #d7d7e6; text-shadow: 0 0 12px rgba(215,215,230,0.5); }
.lb-row.rank-3 .lb-rank { color: #e2a76a; text-shadow: 0 0 12px rgba(226,167,106,0.5); }
.lb-avatar img { width: 42px; height: 42px; border-radius: 8px; image-rendering: pixelated; background: var(--void); border: 1px solid var(--line); }
.lb-name { font-weight: 700; font-size: 15px; }
.lb-name .tag { display: inline-block; margin-left: 8px; font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 6px; vertical-align: middle; }
.lb-stats { display: none; }
.lb-score { text-align: right; }
.lb-score .num { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 18px; color: var(--purple-bright); }
.lb-score .label { font-size: 9.5px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--bone-dim); display: block; }

/* ---------------- Modal (player detail) ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5,2,10,0.75); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center; z-index: 200; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal-card {
  width: 100%; max-width: 460px; background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 18px; padding: 26px; position: relative;
  box-shadow: var(--shadow-glow);
  max-height: 88vh; overflow-y: auto;
}
.modal-close {
  position: absolute; top: 14px; right: 14px; background: var(--panel-3); border: 1px solid var(--line);
  color: var(--bone-dim); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 16px;
}
.modal-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.modal-head img { width: 76px; height: 76px; border-radius: 12px; image-rendering: pixelated; background: var(--void); border: 1px solid var(--line); }
.modal-head .name { font-family: 'Cinzel', serif; font-size: 21px; margin: 0 0 4px; }
.modal-tier { display: inline-block; font-size: 11px; font-weight: 800; padding: 3px 10px; border-radius: 7px; }
.modal-desc { font-size: 13.5px; line-height: 1.7; color: var(--bone-dim); margin: 0 0 18px; padding: 12px 14px; background: var(--purple-mist); border-left: 3px solid var(--purple); border-radius: 8px; }
.stat-row { margin-bottom: 12px; }
.stat-row .top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }
.stat-row .top .lab { color: var(--bone-dim); font-weight: 600; }
.stat-row .top .val { font-family: 'JetBrains Mono', monospace; color: var(--purple-bright); font-weight: 700; }
.bar-track { height: 8px; border-radius: 6px; background: var(--panel-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--purple-deep), var(--purple-bright)); box-shadow: 0 0 10px rgba(192,132,252,0.6); }

/* tier text/bg helpers */
.t-1 { color: var(--tier-1); background: rgba(255,77,141,0.14); }
.t-2 { color: var(--tier-2); background: rgba(192,132,252,0.14); }
.t-3 { color: var(--tier-3); background: rgba(155,92,246,0.14); }
.t-4 { color: var(--tier-4); background: rgba(124,92,191,0.14); }
.t-5 { color: var(--tier-5); background: rgba(87,68,113,0.18); }

/* ---------------- Player title badge ---------------- */
.player-title-badge {
  display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .5px;
  color: var(--lantern); background: rgba(217,164,65,0.12); border: 1px solid rgba(217,164,65,0.3);
  padding: 2px 8px; border-radius: 6px; margin-top: 3px;
}
.modal-head .player-title-badge { margin: 4px 0 6px; }

/* ---------------- Gallery (bukti/hiasan) ---------------- */
.gallery-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.gallery-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--line); cursor: pointer; transition: transform .15s;
}
.gallery-grid img:hover { transform: scale(1.04); border-color: var(--purple); }
.gallery-title { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--bone-dim); margin-top: 18px; }

.lightbox-backdrop {
  position: fixed; inset: 0; background: rgba(5,2,10,0.9); z-index: 300;
  display: none; align-items: center; justify-content: center; padding: 24px;
}
.lightbox-backdrop.open { display: flex; }
.lightbox-backdrop img { max-width: 100%; max-height: 85vh; border-radius: 10px; border: 1px solid var(--line); }

/* ---------------- Title Board page ---------------- */
.title-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 40px; }
.title-card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2)); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px; text-align: center; cursor: pointer; transition: transform .15s, border-color .15s;
}
.title-card:hover { transform: translateY(-3px); border-color: var(--purple); }
.title-card img { width: 56px; height: 56px; border-radius: 10px; image-rendering: pixelated; margin-bottom: 10px; background: var(--void); }
.title-card .tt { font-family: 'Cinzel', serif; font-size: 14px; color: var(--purple-bright); margin: 2px 0 6px; }
.title-card .nm { font-size: 12.5px; color: var(--bone-dim); }

/* ---------------- Chat room ---------------- */
.chat-shell {
  max-width: 720px; margin: 0 auto 50px; background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
}
.chat-messages { height: 440px; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { display: flex; flex-direction: column; max-width: 82%; }
.chat-msg .bubble { background: var(--panel-3); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 13.5px; line-height: 1.5; word-break: break-word; }
.chat-msg .who { font-size: 11px; font-weight: 700; color: var(--purple-bright); margin-bottom: 3px; display: flex; align-items: center; gap: 6px; }
.chat-msg .when { font-size: 9.5px; color: var(--bone-dim); margin-top: 3px; }
.chat-msg.is-admin .bubble { background: rgba(217,164,65,0.1); border-color: rgba(217,164,65,0.3); }
.chat-msg.is-admin .who { color: var(--lantern); }
.admin-tag-small { font-size: 8.5px; font-weight: 800; background: var(--lantern); color: #1c1200; padding: 1px 6px; border-radius: 5px; }
.chat-input-row { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); background: var(--panel); }
.chat-input-row input { flex: 1; }
.chat-input-row button { width: auto; margin-top: 0; padding: 0 18px; }
.chat-name-row { display: flex; gap: 8px; padding: 12px 14px 0; }
.chat-name-row input { max-width: 220px; }
.chat-del-btn { background: none; border: none; color: var(--bone-dim); cursor: pointer; font-size: 10.5px; opacity: .6; margin-top: 3px; text-align: left; padding: 0; }
.chat-del-btn:hover { color: #ff9db8; opacity: 1; }
footer {
  border-top: 1px solid var(--line); margin-top: 60px; padding: 26px 0 40px;
  text-align: center; color: var(--bone-dim); font-size: 12px;
}
footer b { color: var(--purple-bright); }
footer .lanterns { font-size: 18px; margin-bottom: 10px; opacity: .8; letter-spacing: 30px; }

/* ---------------- Loading / empty states ---------------- */
.loading-state, .empty-state {
  text-align: center; padding: 50px 20px; color: var(--bone-dim);
}
.loading-state .skull { font-size: 34px; animation: floaty 2s ease-in-out infinite; }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ---------------- Admin ---------------- */
.admin-shell { max-width: 640px; margin: 60px auto; padding: 0 20px; }
.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 16px; padding: 28px;
  box-shadow: var(--shadow-glow);
}
.card h2 { font-family: 'Cinzel', serif; margin-top: 0; }
label { display: block; font-size: 12.5px; font-weight: 700; color: var(--bone-dim); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .5px; }
input, textarea, select {
  width: 100%; background: var(--void); border: 1px solid var(--line); color: var(--bone);
  padding: 11px 13px; border-radius: 9px; font-family: 'Inter', sans-serif; font-size: 14px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-mist); }
input[type="range"] { padding: 0; accent-color: var(--purple); }
textarea { resize: vertical; min-height: 80px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--purple-deep), var(--purple));
  color: white; border: none; padding: 12px 20px; border-radius: 10px;
  font-weight: 700; font-size: 14px; cursor: pointer; transition: filter .15s, transform .15s;
  width: 100%; margin-top: 18px;
}
.btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.secondary { background: var(--panel-3); border: 1px solid var(--line); }
.btn.danger { background: linear-gradient(135deg, #7a1f3d, #c0356b); }
.btn.small { width: auto; padding: 8px 14px; font-size: 12.5px; margin-top: 0; }

.msg { font-size: 13px; padding: 10px 12px; border-radius: 8px; margin-top: 14px; display: none; }
.msg.show { display: block; }
.msg.error { background: rgba(255,77,141,0.14); color: #ff9db8; border: 1px solid rgba(255,77,141,0.3); }
.msg.ok { background: rgba(107,143,94,0.18); color: #9fd88a; border: 1px solid rgba(107,143,94,0.35); }

.admin-picker { display: flex; flex-direction: column; gap: 10px; }
.admin-pick-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--panel-3); border: 1px solid var(--line); color: var(--bone);
  padding: 14px 16px; border-radius: 10px; cursor: pointer; text-align: left;
  transition: border-color .15s, transform .15s;
}
.admin-pick-btn:hover:not(:disabled) { border-color: var(--purple); transform: translateY(-1px); }
.admin-pick-btn:disabled { opacity: .55; cursor: not-allowed; }
.admin-pick-btn.loading { border-color: var(--purple); }
.admin-pick-btn .icon { color: var(--purple-bright); width: 22px; height: 22px; flex-shrink: 0; }
.admin-pick-btn span { display: flex; flex-direction: column; font-weight: 700; font-size: 14px; }
.admin-pick-btn span small { font-weight: 500; font-size: 11.5px; color: var(--bone-dim); margin-top: 2px; }

.otp-boxes { display: flex; gap: 8px; }
.otp-boxes input { text-align: center; font-size: 20px; font-family: 'JetBrains Mono', monospace; letter-spacing: 2px; }

.range-value { float: right; font-family: 'JetBrains Mono', monospace; color: var(--purple-bright); }

.admin-topbar {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px;
}
.admin-topbar .who { font-size: 12.5px; color: var(--bone-dim); }
.admin-topbar .who b { color: var(--purple-bright); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .two-col { grid-template-columns: 1fr; } }

.admin-player-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.admin-player-row {
  display: flex; align-items: center; gap: 12px; background: var(--panel-3);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.admin-player-row img { width: 38px; height: 38px; border-radius: 8px; image-rendering: pixelated; }
.admin-player-row .meta { flex: 1; }
.admin-player-row .meta .n { font-weight: 700; font-size: 13.5px; }
.admin-player-row .meta .t { font-size: 11px; color: var(--bone-dim); }
.admin-player-row .actions { display: flex; gap: 6px; }

.head-preview { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.head-preview img { width: 56px; height: 56px; border-radius: 10px; background: var(--void); border: 1px solid var(--line); image-rendering: pixelated; }

@media (max-width: 640px) {
  .tier-row { grid-template-columns: 76px 1fr; }
  .tier-badge .letter { font-size: 26px; }
  .nav-links a span.txt { display: none; }
  .lb-stats { display: none; }
}
