/* ===== Tokens ===== */
:root {
  --navy-900: #050f24;
  --navy-800: #0a1f47;
  --navy-700: #0d2a5e;
  --navy-line: #1b3b74;
  --gold: #ffe59f;
  --gold-grad: linear-gradient(180deg, #ecd2ad, #dfb788);
  --text-dim: #c9d6f2;
  --serif: "Cinzel", Georgia, serif;
}

/* ===== Base ===== */
body {
  font-family: "Montserrat", system-ui, sans-serif;
  color: #fff;
  background: var(--navy-900) url("../img/bg.jpg") top center / cover no-repeat;
  overflow-x: clip;
  padding: 0 16px 80px;
}
img { max-width: 100%; height: auto; }
.gold { color: var(--gold); }

/* ===== Header ===== */
.site-header {
  max-width: 1248px;
  margin: 0 auto;
  padding-top: 30px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.logo { grid-column: 2; width: clamp(130px, 14vw, 230px); }
.btn-how {
  grid-column: 3;
  justify-self: end;
  width: clamp(150px, 16vw, 268px);
  aspect-ratio: 268 / 72;
  border: 0;
  background: url("../img/btn-frame.png") center / contain no-repeat;
  container-type: inline-size;
  position: relative;
  padding: 0;
  transition: transform .2s, filter .2s;
}
.btn-how span {
  position: absolute;
  inset: 0 15% 0 35%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 4.9cqw;
  color: #fff;
  white-space: nowrap;
}
.btn-how:hover { transform: translateY(-2px); filter: brightness(1.15); }

/* ===== BGM toggle ===== */
.btn-music {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 1000001; /* above snowstorm.js flakes (1000000) */
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  background: none;
  transition: transform .2s, filter .2s;
}
.btn-music img { width: 100%; height: 100%; }
.btn-music:hover { transform: scale(1.08); filter: brightness(1.15); }
.btn-music .icon-off,
.btn-music.is-off .icon-on { display: none; }
.btn-music.is-off .icon-off { display: block; }
/* keep "How it works?" clear of the fixed music button when the header reaches the edge */
@media (max-width: 1439.98px) {
  .site-header { padding-right: 72px; }
}

/* ===== Hero ===== */
.hero { max-width: 1248px; margin: -10px auto 0; text-align: center; }

/* ===== Profile ===== */
.profile {
  max-width: 917px;
  margin: 30px auto 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 24px;
  padding: 30px 40px;
  border: 2px solid var(--navy-line);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(13, 42, 94, .92), rgba(8, 26, 62, .92));
  box-shadow: 0 0 30px rgba(40, 110, 220, .25), inset 0 1px 0 rgba(255, 255, 255, .08);
}
.profile-user, .profile-chips { display: flex; align-items: center; gap: 28px; }
.profile-chips { border-left: 3px solid #b88a35; padding-left: 60px; }
.profile-chips img { width: 100px; flex: none; }
.profile dl {
  display: grid;
  grid-template-columns: auto auto;
  gap: 14px 28px;
  margin: 0;
  font-size: 15px;
}
.profile dt { font-weight: 500; }
.profile dd { margin: 0; font-weight: 600; }
.profile dd.gold { font-size: 20px; font-weight: 800; line-height: 1; }
.profile .label { font-size: 15px; font-weight: 500; }
.profile .value { font-size: 22px; font-weight: 800; line-height: 1.3; }
.profile small { font-size: 11px; line-height: 1.3; display: block; }

/* ===== Board (leaderboard + reward pool) ===== */
.board { position: relative; max-width: 1180px; margin: 76px auto 0; }
/* Frame = PSD "Frame" shape: fill #023261, radius 25,
   Stroke 10px inside #01254c over Stroke 13px inside #fcd78e @61% (shows as a 3px gold line),
   Inner Shadow #021d3f 35% size 150 choke 39%, Drop Shadow #1b0101 70% size 24 */
.panel {
  position: relative;
  height: 100%;
  padding: 0 22px 26px;
  background: #023261;
  border: 10px solid #01254c;
  border-radius: 25px;
  box-shadow:
    inset 0 0 0 3px rgba(252, 215, 142, .61),
    inset 0 0 92px 58px rgba(2, 29, 63, .35),
    0 0 24px rgba(27, 1, 1, .7);
  container-type: inline-size;
}

/* Section ribbon titles (image frame + live text) */
.ribbon {
  position: relative;
  z-index: 1;
  width: 76%;
  max-width: 434px;
  aspect-ratio: 434 / 90;
  margin: -7.5% auto 0;
  background: center / contain no-repeat;
  container-type: inline-size;
}
.ribbon span {
  position: absolute;
  inset: 0 7% 0 27%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ribbon-lb { background-image: url("../img/ribbon-lb.png"); }
.ribbon-rp { background-image: url("../img/ribbon-rp.png"); }
.ribbon-rp span { left: 30%; }
.ribbon span, .rules-title span {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 7.8cqw;
  line-height: 1;
  white-space: nowrap;
  background: var(--gold-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .6));
}

/* Leaderboard */
.lb-info {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin: 18px 4px 26px;
  font-size: 13px;
  font-weight: 500;
}
.lb-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.lb-tabs button {
  flex: 1 0 auto;
  min-width: 64px;
  padding: 15px 4px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: #081631;
  border: 1px solid #142a55;
  border-radius: 4px;
  transition: border-color .2s, box-shadow .2s;
}
.lb-tabs button:hover { border-color: #3d7fc8; }
.lb-tabs button.active {
  background: #0d2c5a;
  border-color: #5cc0ff;
  box-shadow: 0 0 10px rgba(92, 192, 255, .6), inset 0 0 8px rgba(92, 192, 255, .35);
}

.lb-scroll {
  max-height: 652px;
  margin-top: 26px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #b88a35 transparent;
}
.lb-table { width: 100%; font-size: 15px; }
.lb-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px;
  font-size: 11px;
  font-weight: 600;
  background: #023261;
}
.lb-table th:last-child, .lb-table td.earned { text-align: right; }
.lb-table td { height: 62px; padding: 0; border-top: 1px solid rgba(91, 132, 205, .35); }
.lb-table td.rank { width: 70px; padding-left: 4px; font-size: 18px; font-weight: 500; text-align: center; }
.lb-table td.rank img { width: 50px; }
.lb-table td.player img { width: 40px; margin: 0 18px 0 12px; }
.lb-table td.earned {font-weight: 500;color: var(--gold);padding-right: 6px;}
.lb-table td.earned img { width: 24px; margin-right: 14px; }

/* Reward pool */
.pool { text-align: center; margin-top: 16px; }
.pool-label { font-size: clamp(15px, 3.8cqw, 22px); font-weight: 500; }
.pool-amount {
  font-size: clamp(36px, 12cqw, 68px);
  font-weight: 700;
  line-height: 1.1;
  background: linear-gradient(180deg, #ffffb4 0%, #fdeba0 50%, #af6d26 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 #3a2508) drop-shadow(0 0 12px rgba(0, 0, 0, .5));
}
.pool img { width: 25%; max-width: 141px; }

/* Podium: positions taken from the PSD (510 x 363 box) */
.podium { position: relative; aspect-ratio: 510 / 363; max-width: 510px; margin: 8px auto 18px; }
.podium img { position: absolute; }
.podium .p1 { left: 27.4%; top: 0;     width: 44.1%; z-index: 1; }
.podium .p2 { left: 0;     top: 20.1%; width: 33.7%; }
.podium .p3 { left: 64.7%; top: 20.9%; width: 35.3%; }
.podium .p4 { left: 15.7%; top: 62%;   width: 34.1%; }
.podium .p5 { left: 50.6%; top: 62%;   width: 34.5%; }

/* Rank tiers (image bar + live text) */
.tiers { list-style: none; padding: 0; margin: 0 auto; max-width: 470px; }
.tier {
  position: relative;
  aspect-ratio: 470 / 68;
  margin-bottom: 4px;
  background: url("../img/tier-bar.png") center / 100% 100% no-repeat;
  container-type: inline-size;
}
.tier-rank {
  position: absolute;
  left: 2%;
  width: 22%;
  top: 30%;
  text-align: center;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 5.6cqw;
  line-height: .95;
  color: #fff3d0;
  text-shadow: 0 2px 2px rgba(0, 0, 0, .6);
}
.tier-rank small { display: block; font-size: 1.7cqw; font-weight: 700; color: #fff; }
.tier-info {
  position: absolute;
  left: 43%;
  right: 2%;
  top: 22%;
  bottom: 16%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: 2.6cqw;
  line-height: 1.5;
  white-space: nowrap;
}
.tier-info span:first-child { text-align: center; }
.tier-info b { font-size: 3.5cqw; font-weight: 800; color: var(--gold); }
.tier-info .each { padding-left: 9.5cqw; color: #9fd0ff; }

/* Floating GIF decorations (only where there's room beside the cards) */
.float { position: absolute; display: none; pointer-events: none; }
@media (min-width: 1400px) {
  .float { display: block; }
  .float-snow-l { width: 150px; left: -130px; top: 80px; }
  .float-chip-l { width: 130px; left: -95px;  top: 445px; }
  .float-snow-r { width: 140px; right: -145px; top: 150px; }
  .float-gift-r { width: 150px; right: -110px; top: 285px; }
}

/* ===== Rules ===== */
.rules { max-width: 1258px; margin: 70px auto 0; }
.rules-title {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 838px;
  aspect-ratio: 838 / 135;
  margin: 0 auto;
  background: url("../img/rules-title.png") center / contain no-repeat;
  container-type: inline-size;
}
/* text band centred at 61% of the frame height, as in the PSD */
.rules-title span {
  position: absolute;
  inset: 24% 0 2% 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4.1cqw;
}
.rules-body {
  display: grid;
  gap: 24px;
  margin-top: -30px;
  padding: 50px 24px 30px;
  border: 2px solid #c9a24f;
  border-radius: 26px;
  background: linear-gradient(180deg, var(--navy-700), var(--navy-800));
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
.rule { display: flex; align-items: center; gap: 12px; }
.rule img { width: 96px; flex: none; }
.rule h3 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 19px;
  margin: 0 0 6px;
  color: var(--gold);
}
.rule p { font-size: 12.5px; line-height: 1.35; margin: 0; }

@media (min-width: 768px) {
  .rules-body { grid-template-columns: repeat(3, 1fr); gap: 0; }
  .rule { padding: 0 14px; }
  .rule + .rule { border-left: 2px solid #b88a35; }
}

/* PSD ornamental frame on wide screens */
@media (min-width: 1200px) {
  .rules-body {
    aspect-ratio: 1258 / 265;
    margin-top: -6.2%;
    padding: 6.5% 10.7% 5.2% 10.25%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: url("../img/rules-frame.png") center / contain no-repeat;
  }
}

@media (max-width: 991.98px) {
  .profile { padding: 26px 24px; }
  .profile-chips { padding-left: 32px; }
  .profile .label { white-space: nowrap; }
}

/* ===== Small screens ===== */
@media (max-width: 767.98px) {
  .btn-music { top: 10px; right: 10px; width: 48px; height: 48px; }
  .site-header { padding-right: 52px; }
  .site-header { grid-template-columns: auto 1fr; padding-top: 16px; }
  .logo { grid-column: 1; }
  .btn-how { grid-column: 2; }
  .hero { margin-top: 10px; }
  .profile { flex-direction: column; align-items: stretch; padding: 22px; }
  .profile-user, .profile-chips { gap: 18px; }
  .profile-chips { border-left: 0; padding-left: 0; padding-top: 20px; border-top: 2px solid #b88a35; }
  .profile-user img, .profile-chips img { width: 72px; }
  .panel { padding: 0 8px 18px; }
  .lb-table { font-size: 13px; }
  .lb-table td { height: 54px; }
  .lb-table td.rank { width: 48px; }
  .lb-table td.rank img { width: 40px; }
  .lb-table td.player img { width: 32px; margin: 0 10px 0 4px; }
  .lb-table td.earned img { display: none; }
}

/* ===== Modal ===== */
.modal-content {
  background: linear-gradient(180deg, var(--navy-700), var(--navy-800));
  border: 2px solid #c9a24f;
  border-radius: 18px;
}
.modal-title { font-family: var(--serif); font-weight: 700; color: var(--gold); }
.modal-body { font-size: 14px; line-height: 1.6; }
.modal-body li { margin-bottom: 8px; }