/* Shop, leaderboard, profile and rules: scrolling game screens with the same
   top bar (back to the lobby, page title, coin balance, language). */

/* Page heading, under the top bar */
.page-heading {
  margin: clamp(12px, 3vh, 24px) 0 clamp(10px, 2vh, 18px);
  text-align: center;
  font-size: clamp(28px, 4.4vw, 44px);
  font-weight: 800;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35), 0 0 30px rgba(139, 92, 246, 0.55);
}
.page-title {
  flex: 1;
  min-width: 0;
  font-size: clamp(22px, 3.6vw, 32px);
  font-weight: 800;
  text-align: center;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 0 24px rgba(139, 92, 246, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud .lang-toggle { flex: none; }


.page-main {
  flex: 1;
  width: 100%;
  max-width: 980px;
  margin-inline: auto;
  padding: 6px clamp(14px, 3vw, 28px) 40px;
}
.page-sub { text-align: center; color: var(--muted); font-weight: 600; }
.page-note { text-align: center; color: var(--muted); font-size: 14px; margin-top: 14px; }

.panel-box {
  border-radius: 24px;
  background:
    radial-gradient(ellipse 90% 40% at 50% 0%, rgba(255, 255, 255, 0.1), transparent 70%),
    linear-gradient(180deg, #33206b, #22134a);
  border: 2px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 0 #120634, 0 20px 40px rgba(5, 0, 20, 0.45);
}

.empty-state { padding: 34px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-state h2 { font-size: 26px; }
.empty-state .actions-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* --- Shop --- */
.earn-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  margin: 12px auto 22px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 197, 61, 0.12);
  border: 1px solid rgba(255, 197, 61, 0.35);
  color: #ffe3a1;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
}
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 18px;
}
.theme-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  text-align: center;
}
.theme-card.is-equipped { border-color: var(--gold); box-shadow: 0 8px 0 #120634, 0 0 0 2px var(--gold), 0 0 28px rgba(255, 197, 61, 0.35); }
.theme-preview { width: 100%; aspect-ratio: 1; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.5)); }
.theme-name { font: 800 20px/1.2 var(--font-display); }

/* Card theme preview: two backs fanned behind a framed ace */
.card-preview { position: relative; width: 100%; aspect-ratio: 1; display: grid; place-items: center; }
.card-preview > * {
  position: absolute;
  width: 42%;
  aspect-ratio: 224 / 313;
  border-radius: 7%;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.45);
}
.cp-back { transform: translateX(-30%) rotate(-12deg); }
.cp-back-2 { transform: translateX(-52%) translateY(4%) rotate(-22deg); }
.cp-face { display: block; overflow: hidden; background: #fff; transform: translateX(26%) rotate(9deg); }
.cp-face img { width: 100%; height: 100%; display: block; }
.cp-face::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 3px var(--card-frame, transparent), inset 0 0 12px var(--card-frame, transparent);
}
.theme-price { display: inline-flex; align-items: center; justify-content: center; gap: 5px; color: var(--gold); font: 800 17px/1 var(--font-display); }
.theme-card .btn { width: 100%; }
.theme-card .btn[disabled] { filter: grayscale(0.6) brightness(0.8); cursor: not-allowed; transform: none; }

/* --- Leaderboard --- */
.lb-tabs { display: flex; justify-content: center; margin: 4px 0 18px; }
.lb-list { list-style: none; margin: 0; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.lb-row {
  display: grid;
  grid-template-columns: 44px 44px minmax(0, 1fr) repeat(3, 64px);
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 16px;
  background: rgba(10, 4, 30, 0.35);
  color: inherit;
  text-decoration: none;
  transition: background 0.15s ease;
}
a.lb-row:hover { background: rgba(255, 255, 255, 0.08); }
.lb-row.is-head { background: none; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.6px; padding-block: 2px; }
.lb-row.is-me { background: rgba(255, 197, 61, 0.14); box-shadow: inset 0 0 0 2px rgba(255, 197, 61, 0.5); }
.lb-rank { font: 800 20px/1 var(--font-display); text-align: center; }
.lb-rank.is-1 { color: #ffd34d; }
.lb-rank.is-2 { color: #d9e2f2; }
.lb-rank.is-3 { color: #e3a26b; }
.lb-name { font: 800 17px/1.2 var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-name small { font: 700 12px var(--font-body); color: var(--gold); margin-inline-start: 6px; }
.lb-num { text-align: center; font-weight: 800; }
.lb-num.is-key { color: var(--gold); font-size: 18px; }

/* Round avatar: a photo, or the first letter on a coloured ball */
.p-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 35% 30%, #fff 0, #fff 6%, var(--violet) 32%, #3b1d8f 92%);
  font: 800 20px/1 var(--font-display);
  color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6);
}
.p-avatar img { width: 100%; height: 100%; object-fit: cover; }

@media (max-width: 600px) {
  .lb-row { grid-template-columns: 30px 36px minmax(0, 1fr) 46px 52px; gap: 8px; padding: 8px; }
  .lb-row .lb-hide { display: none; }
  .p-avatar { width: 36px; height: 36px; font-size: 16px; }
  .lb-name { font-size: 15px; }
}

/* --- Profile --- */
.profile-card { padding: 26px clamp(16px, 4vw, 32px); display: flex; flex-direction: column; gap: 20px; }
.profile-top { display: flex; align-items: center; gap: 18px; }
.profile-top .p-avatar { width: 88px; height: 88px; font-size: 40px; box-shadow: 0 0 0 4px var(--gold), 0 8px 18px rgba(0, 0, 0, 0.45); }
.profile-name { font-size: clamp(26px, 5vw, 36px); font-weight: 800; line-height: 1.1; overflow-wrap: anywhere; }
.profile-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.badge {
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 13px;
  font-weight: 800;
}
.badge.is-gold { background: linear-gradient(180deg, #ffd96b, var(--gold)); color: var(--on-gold); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat {
  padding: 12px 8px;
  border-radius: 18px;
  background: rgba(10, 4, 30, 0.45);
  text-align: center;
}
.stat b { display: block; font: 800 30px/1.1 var(--font-display); }
.stat span { color: var(--muted); font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; }
.stat.is-win b { color: #4be38a; }
.stat.is-loss b { color: #ff7a8f; }
.stat.is-coins b { color: var(--gold); }
.stat.is-streak b { color: #ff9a3d; }
.profile-top .friend-btn { margin-inline-start: auto; flex: none; }
@media (max-width: 520px) {
  .profile-top { flex-wrap: wrap; }
  .profile-top .friend-btn { width: 100%; }
}

.section-label { font: 800 14px/1 var(--font-display); color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.bio-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 17px; }
.bio-text.is-empty { color: var(--muted); font-style: italic; }
.bio-edit { display: flex; flex-direction: column; gap: 8px; }
.bio-edit textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  padding: 12px 14px;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 4, 30, 0.55);
  color: #fff;
  font: 600 16px/1.5 var(--font-body);
  outline: none;
}
.bio-edit textarea:focus { border-color: var(--gold); }
.bio-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bio-count { color: var(--muted); font-size: 13px; font-weight: 700; }
.bio-count.is-over { color: var(--danger); }
.profile-theme { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.profile-theme b { font: 800 18px var(--font-display); }
.profile-actions { display: flex; justify-content: center; }

/* --- Friends --- */
.friends { display: flex; flex-direction: column; gap: 16px; }
.friends-top { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px 28px; align-items: end; padding: 20px; }
.my-code .code-tiles { display: flex; gap: 5px; direction: ltr; margin: 6px 0 10px; }
.my-code .code-tiles span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(180deg, #fff, #e9e2ff);
  color: #2a1856;
  font: 800 22px/1 var(--font-display);
  box-shadow: 0 4px 0 #9d8ad8;
}
.add-friend .add-row { display: flex; gap: 8px; margin-top: 6px; }
.add-friend input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 4, 30, 0.55);
  color: #fff;
  font: 800 18px/1.2 var(--font-display);
  letter-spacing: 3px;
  text-transform: uppercase;
  outline: none;
}
.add-friend input:focus { border-color: var(--gold); }
.friends-section { padding: 16px; }
.friend-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.friend-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 16px; background: rgba(10, 4, 30, 0.35); }
.friend-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.friend-pic { position: relative; flex: none; }
.friend-pic.is-online::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #35d07f;
  box-shadow: 0 0 0 3px #22134a;
}
.friend-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.friend-text b { font: 800 17px var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-text small { color: var(--muted); font-weight: 700; font-size: 13px; }
.friend-actions { display: flex; gap: 6px; flex: none; }
.friend-remove { min-width: 38px; }
.friend-remove.is-armed { color: #ff8a9c; }
.friend-empty { padding: 14px; text-align: center; color: var(--muted); font-weight: 600; }
@media (max-width: 600px) {
  .friends-top { grid-template-columns: 1fr; }
  .friend-actions .btn-sm { padding: 7px 10px; font-size: 14px; }
}

/* Streak flame */
.streak { color: #ff9a3d; font-weight: 800; white-space: nowrap; }

/* --- Rules --- */
.rules { padding: 24px clamp(16px, 4vw, 34px); line-height: 1.7; }
.rules h2 { font-size: 24px; margin: 22px 0 8px; color: var(--gold); }
.rules h2:first-child { margin-top: 0; }
.rules p { margin: 0 0 10px; }
.rules ul, .rules ol { margin: 0 0 10px; padding-inline-start: 22px; }
.rules li { margin-bottom: 6px; }
.rules .card-list { list-style: none; padding: 0; display: grid; gap: 8px; }
.rules .card-list li {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(10, 4, 30, 0.4);
}
.rules .card-list b {
  display: grid;
  place-items: center;
  height: 44px;
  border-radius: 8px;
  background: #fff;
  color: #1a1030;
  font: 800 20px/1 var(--font-display);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}
.rules .tip { padding: 10px 14px; border-radius: 14px; background: rgba(255, 197, 61, 0.12); border: 1px solid rgba(255, 197, 61, 0.3); }
/* The rules are written out in both languages; show the one in use. */
html[lang="ar"] .lang-en,
html:not([lang="ar"]) .lang-ar { display: none; }

@media (max-width: 420px) {
  .hud { gap: 6px; }
  .coin-chip { font-size: 14px; padding-inline-end: 9px; }
  .coin-chip .coin { width: 20px; height: 20px; }
}
@media (max-width: 520px) {
  .shop-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .theme-card { padding: 10px; gap: 8px; }
  .theme-name { font-size: 16px; }
  .theme-card .btn { padding: 8px 6px; font-size: 15px; }
}

.rules .intro { font-size: 17px; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.rules-cta { margin-top: 22px; text-align: center; }
