:root {
  --bg: var(--tg-theme-bg-color, #10131c);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #1a1f2e);
  --text: var(--tg-theme-text-color, #f2f4f8);
  --hint: var(--tg-theme-hint-color, #8b93a7);
  --link: var(--tg-theme-link-color, #6ab3f3);
  --button: var(--tg-theme-button-color, #2f6fed);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --accent: #6ab3f3;
  --gold: #ffc857;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- header ------------------------------------------------------------ */
.hero { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, #2f6fed, #7a4bfd);
  display: grid; place-items: center;
  font-size: 26px; flex: 0 0 auto;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.hero h1 { margin: 0; font-size: 19px; font-weight: 650; }
.hero p { margin: 2px 0 0; color: var(--hint); font-size: 14px; }

/* --- stats ------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 12px 10px;
  text-align: center;
}
.stat-value { display: block; font-size: 20px; font-weight: 700; margin-top: 4px; }
.stat-label { color: var(--hint); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat.gold .stat-value { color: var(--gold); }
.stat.blue .stat-value { color: var(--accent); }

.progress { height: 8px; border-radius: 99px; background: var(--secondary-bg); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #2f6fed, #7a4bfd); transition: width .4s ease; }
.progress-text { color: var(--hint); font-size: 13px; margin-top: -8px; }

/* --- generic card ------------------------------------------------------ */
.card {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 16px;
}
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .05em; color: var(--hint); margin: 4px 0 0; font-weight: 600; }

.btn {
  appearance: none; border: 0; border-radius: var(--radius);
  background: var(--button); color: var(--button-text);
  font: inherit; font-weight: 600; padding: 14px 18px; width: 100%;
  cursor: pointer; transition: transform .1s ease, opacity .2s ease;
}
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--link); border: 1px solid rgba(122,140,180,.35); }
.btn.gold { background: linear-gradient(135deg, #ffb020, #ff8a00); color: #1b1200; }

/* --- games ------------------------------------------------------------- */
.game { display: flex; align-items: center; gap: 14px; }
.game .emoji { font-size: 34px; width: 52px; height: 52px; display: grid; place-items: center; background: rgba(122,140,180,.12); border-radius: 14px; flex: 0 0 auto; }
.game .meta { flex: 1 1 auto; min-width: 0; }
.game .meta h3 { margin: 0 0 2px; font-size: 17px; }
.game .meta p { margin: 0; color: var(--hint); font-size: 13.5px; }
.game .cost { color: var(--gold); font-size: 13px; font-weight: 600; }
.play {
  appearance: none; border: 0; border-radius: 12px; padding: 11px 16px;
  background: var(--button); color: var(--button-text); font: inherit; font-weight: 650;
  cursor: pointer; flex: 0 0 auto;
}
.play:active { transform: scale(.96); }

/* --- tabs & top -------------------------------------------------------- */
.tabs { display: flex; gap: 8px; }
.tabs button {
  flex: 1; appearance: none; border: 0; border-radius: 12px; padding: 10px 8px;
  background: var(--secondary-bg); color: var(--hint); font: inherit; font-weight: 600;
  cursor: pointer; font-size: 14px;
}
.tabs button.active { background: var(--button); color: var(--button-text); }

.top-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(122,140,180,.14); }
.top-row:last-child { border-bottom: 0; }
.top-row .place { width: 30px; text-align: center; font-weight: 700; color: var(--hint); }
.top-row .who { flex: 1 1 auto; min-width: 0; }
.top-row .who b { display: block; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-row .who span { color: var(--hint); font-size: 12.5px; }
.top-row .val { font-weight: 700; font-size: 15px; }
.top-row.me { background: rgba(47,111,237,.14); border-radius: 12px; padding-left: 8px; padding-right: 8px; }

.banner {
  background: linear-gradient(135deg, rgba(255,176,32,.18), rgba(255,138,0,.08));
  border: 1px solid rgba(255,176,32,.35);
  color: #ffd79a; border-radius: var(--radius); padding: 12px 14px; font-size: 14px;
}
.empty { color: var(--hint); text-align: center; padding: 22px 0; }

/* --- privacy picker ---------------------------------------------------- */
.privacy-opts { display: flex; flex-direction: column; gap: 8px; }
.privacy-opt {
  appearance: none;
  border: 1px solid rgba(122, 140, 180, .28);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  text-align: left;
  padding: 11px 13px;
  border-radius: 12px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.privacy-opt:active { transform: scale(.99); }
.privacy-opt.active {
  background: rgba(47, 111, 237, .18);
  border-color: var(--button);
  font-weight: 600;
}
.privacy-opt.active::after { content: "  ✓"; color: var(--accent); }
.privacy-note { margin: 10px 0 0; color: var(--hint); font-size: 12.5px; }

.skeleton { background: var(--secondary-bg); border-radius: var(--radius); height: 86px; }