/*#region ====== General ====== */

:root{
  --bg1:#f2efff;
  --bg2:#8b7cff;

  --card:#ffffff;
  --text:#0f1222;
  --muted:#6b6f86;

  --shadow: 0 14px 40px rgba(15, 18, 34, 0.14);
  --radius: 22px;

  --accent:#6b5cff;
  --track:#e9eaf2;
  --accent-yellow: #D4AF37;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*{
  box-sizing:border-box;
}

html {
  background-color: var(--bg2);
}

html,
body{
  margin:0;
  padding:0;
  min-height:100vh;
  overflow-x:hidden;

  font-family: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto,
             "PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  color:var(--text);

  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(
      1200px 700px at 50% 20%,
      rgba(255,255,255,.85) 0%,
      rgba(255,255,255,.25) 55%,
      rgba(255,255,255,0) 70%
    ),
    linear-gradient(180deg,var(--bg1),var(--bg2));

  background-attachment: fixed;
}

/*#endregion */

/*#region ====== Developer Warning Banner ====== */

.warning{
  position:fixed;
  top:0;
  left:0;
  right:0;
  z-index:10000;

  height:28px;
  line-height:28px;
  text-align:center;

  font-size:12px;
  letter-spacing:0.08em;
  font-weight:600;

  background:linear-gradient(
    45deg,
    #ffcc00,
    #ffcc00 12px,
    #111 12px,
    #111 24px
  );
  color:white;
}

/*#endregion */

/*#region ====== App Layout ====== */

.app{
  max-width:520px;
  margin:0 auto;

  padding:
    calc(18px + var(--safe-top) + 28px)  /* + warning height */
    16px
    calc(40px + var(--safe-bottom));
}

header{
  padding:6px 2px 18px;
}

.title{
  margin:0 0 6px;
  font-size: 32px;
  font-weight:800;
  letter-spacing:-0.02em;
}

.subtitle{
  margin:0;
  font-size:13.5px;
  color:rgba(15,18,34,.65);
}

/*#endregion */

/*#region ====== Search Bar ====== */

.search-container {
  padding: 0 2px 24px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 0 14px;
  height: 48px;
  transition: transform 0.2s ease;
}

.search-box:focus-within {
  transform: translateY(-2px);
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--muted);
  margin-right: 10px;
  flex-shrink: 0;
}

#game-search {
  border: none;
  background: transparent;
  width: 100%;
  height: 100%;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  outline: none;
}

#game-search::placeholder {
  color: rgba(15, 18, 34, 0.35);
}

.search-clear {
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: rgba(15, 18, 34, 0.1);
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 8px;
  transition: all 0.2s ease;
}

.search-clear:hover {
  background: rgba(15, 18, 34, 0.2);
}

.search-clear svg {
  width: 12px;
  height: 12px;
  color: var(--text);
}

.search-clear.visible {
  display: flex;
}

.no-results {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.no-results span {
  display: block;
  font-weight: 700;
  color: var(--text);
  margin-top: 4px;
  word-break: break-all;
}

/*#endregion */

/*#region ====== Feed ====== */

@keyframes feedRiseIn {
  from{
    transform:translateY(120%);
    opacity:0;
  }
  to{
    transform:translateY(0);
    opacity:1;
  }
}

.feed{
  display:grid;
  grid-template-columns:1fr 1fr;
  column-gap:10px;

  transform:translateY(120%);
  opacity:0;

  animation:feedRiseIn 850ms cubic-bezier(.22,.61,.36,1) both;
  will-change:transform, opacity;
}

#col-left,
#col-right{
  display:flex;
  flex-direction:column;
  gap:10px;
}

#col-right{
  margin-top:40px;
}

/*#endregion */

/*#region ====== Card ====== */

@keyframes cardPopIn {
  from{
    transform:translateY(12px) scale(0.98);
    opacity:0;
  }
  to{
    transform:translateY(0) scale(1);
    opacity:1;
  }
}

.card{
  width: 100%;
  height: 280px;

  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);

  padding: 16px;
  position: relative;
  overflow: hidden;

  display: flex;
  flex-direction: column;
}

.card::before{
  content:"";
  position:absolute;
  top:-40px;
  right:-60px;
  width:160px;
  height:160px;
  background:radial-gradient(
    circle,
    rgba(107,92,255,.22),
    rgba(107,92,255,0) 70%
  );
  transform:rotate(18deg);
}

.card.pop{
  animation:cardPopIn 420ms cubic-bezier(.22,.61,.36,1) both;
}

.update-badge{
  position:absolute;
  top:12px;
  left:12px;

  padding:4px 10px;
  font-size:12px;
  font-weight:700;
  letter-spacing:.04em;

  background: linear-gradient(90deg,#ff8a00,#ff3d00);
  color:white;

  border-radius:999px;
  box-shadow:0 4px 10px rgba(255,61,0,.4);
}

/*#endregion */

/*#region ====== Card Content ====== */

.row{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
}

.icon{
  width: 110px;
  height: 110px;
  border-radius:16px;

  background:linear-gradient(
    180deg,
    rgba(107,92,255,.22),
    rgba(107,92,255,.08)
  );

  display:grid;
  place-items:center;
  flex-shrink:0;

  cursor: pointer;
}

.icon svg{
  width: 60px;
  height: 60px;
}

.game-logo{
  width:100%;
  height:100%;
  object-fit:contain;
  border-radius:12px;
  pointer-events:none;
}

.meta{
  flex:1;
  width:100%;
  display: flex;
  flex-direction: column;
}

.game-title{
  margin:0 0 4px;
  font-size:16px;
  font-weight:780;
}

.desc{
  height: 2.8em;
  line-height: 1.4;

  overflow: hidden;

  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;

  margin:0 0 10px;
  font-size:12.8px;
  color:rgba(15,18,34,.7);
}

.rank-badge{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;

  color: var(--accent);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;

  cursor: pointer;
}

.rank-trophy svg{
  width: 20px;
  height: 20px;
  display: block;
}

/*#endregion */

/*#region ====== Progress Bar ====== */

.progress-wrap{
  margin-bottom: 8px;

  display: flex;
  flex-direction: column;
}

.progress-label{
  display:flex;
  justify-content:space-between;
  margin-bottom: 5px;

  font-size:12px;
  color:rgba(15,18,34,.6);
}

.segbar{
  display: grid;
  grid-template-columns: repeat(6,1fr);
  gap: 6px;
}

.seg{
  height:8px;
  border-radius:999px;
  background:var(--track);
}

.seg.on{
  background:linear-gradient(
    90deg,
    var(--accent),
    rgba(107,92,255,.55)
  );
  transform-origin:left center;
  transform:scaleX(0);
}

@keyframes progressReveal {
  from{ transform:scaleX(0); }
  to{ transform:scaleX(1); }
}

.card.pop .seg.on{
  animation:progressReveal 1100ms cubic-bezier(.3,0,.2,1) both;
  animation-delay:700ms;
}

/*#endregion */

/*#region ====== Reduced Motion ====== */

@media (prefers-reduced-motion: reduce){
  .feed,
  .card.pop,
  .card.pop .seg.on{
    animation:none;
    transform:none;
    opacity:1;
  }
}

/*#endregion */

/*#region ====== Leaderboard ====== */

.overlay{
  position: fixed;
  inset: 0;
  z-index: 9000;

  background: rgba(15,18,34,.45);
  backdrop-filter: blur(6px);

  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay.hidden{
  display: none;
}

.overlay-panel{
  width: 100%;
  max-width: 420px;
  height: 80vh;

  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow);

  display: flex;
  flex-direction: column;
}

.overlay-header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(0,0,0,.06);
}

.overlay-content{
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

.overlay-footer{
  display: flex;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid rgba(0,0,0,.06);
}

.overlay-btn{
  flex: 1;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: #eee;
  font-weight: 600;
  cursor: pointer;
}

.overlay-btn.primary{
  background: var(--accent);
  color: white;
}

/* ------ Current User ------ */

.lb-sticky-player {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
  
  padding: 12px 16px;
  margin: 0 16px;
  margin-bottom: 0;
  
  background: #f3f2ff;
  border-radius: 16px;

   box-shadow:
    0 8px 20px rgba(107,92,255,0.25),
    0 0 0 2px rgba(107,92,255,0.35);
}

.lb-sticky-player .avatar{
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.lb-sticky-player .info{
  display: flex;
  align-items: center;
  gap: 2px;
}

.lb-sticky-player .name{
  font-weight: 600;
}

.lb-sticky-player .meta{
  font-size: 14px;
  color: #666;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.lb-sticky-player .meta .score,
.lb-sticky-player .meta .rank{
  font-weight: 600;
  color: #6b5cff;
}

.you-badge{
  margin-left: 6px;
  margin-right: 6px;
  padding: 2px 6px;
  font-size: 12px;
  border-radius: 999px;
  background: rgba(107,92,255,.15);
  color: #6b5cff;
}


/* ------ Top 3 ------ */
.lb-podium{
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  align-items: end;
  gap: 12px;
  margin-bottom: 24px;
  text-align: center;
  color: var(--text);
}

.lb-podium-item{
  position: relative;
  text-align: center;
  padding: 12px 10px;
  border-radius: 18px;
  background: rgba(107,92,255,0.12);
}

.lb-podium-item.lb-item-player{
  background: #e6e4ff;
  border: 2px solid #7a72ff; 
}

.lb-podium-item .avatar{
  width: 56px;
  height: 56px;
  border-radius: 999px;
  margin: 0 auto 8px;
  background: rgba(107,92,255,.18);
}

.lb-podium-item .name{
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lb-podium-item .you-badge {
  margin: 0;
  font-size: 12px;
  padding: 1px 6px;
}

.lb-podium-item .score{
  font-weight: 900;
  color: var(--accent);
}

.lb-rank-1{
  transform: translateY(-8px);
}

.lb-rank-1 .avatar{
  width: 88px;
  height: 88px;
}

.lb-rank-2 .avatar,
.lb-rank-3 .avatar{
  width: 64px;
  height: 64px;
  opacity: 0.9;
}

.crown{
  color: gold;
  font-size: 20px;
  margin-bottom: 6px;
}

.podium-rank{
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.08em;
  opacity: 0.65;
  margin-bottom: 6px;
}

/* ------ 4th - 10th ------ */
.lb-list{
  list-style: none;
  padding: 0;
  margin: 0;
}

.lb-item{
  display: grid;
  grid-template-columns: 28px 36px 1fr auto;
  align-items: center;

  padding: 10px 12px;
  margin-bottom: 8px;
  column-gap: 12px;

  background: rgba(15,18,34,0.04);
  border: 1px solid rgba(15,18,34,0.06);
  border-radius: 14px;
}

.lb-item .rank{
  font-weight: 800;
  color: rgba(15,18,34,.55);
}

.lb-item .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}

.lb-item .name{
  font-weight: 700;
}

.lb-item .score{
  font-weight: 900;
  color: var(--accent);
}

.lb-item-player{
  background: rgba(107,92,255,0.12);
  border: 1px solid rgba(107,92,255,0.30);
  font-weight: 700;
}

/*#endregion */

.hidden{
  display: none !important;
}