/* Fixed dark palette. The games are dark-canvas designs, so we keep one
   consistent look regardless of the user's Telegram light/dark skin (tg.js
   also tells Telegram's own chrome to match). To follow the Telegram theme
   instead, point these back at the var(--tg-theme-*, …) values. */
:root {
  /* The palette is fixed dark, so tell the browser too — otherwise native
     widgets (selects and their popups, scrollbars, date/time fields) render
     with light-theme defaults and end up dark-text-on-dark. */
  color-scheme: dark;
  --bg: #0f1216;
  --bg2: #171c23;
  --text: #eef1f5;
  --hint: #8b96a5;
  --accent: #e8b33b;
  --accent-text: #14161a;
  --card: #1b212a;
  --line: rgba(255, 255, 255, 0.07);
  --good: #4caf6d;
  --bad: #e05252;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

.wrap { max-width: 480px; margin: 0 auto; padding: 16px 16px 32px; }

/* ---------- hub header ---------- */
.hub-header { display: flex; flex-direction: column; gap: 14px; padding: 8px 0 18px; }
.hub-id { display: flex; align-items: center; gap: 12px; }
.hub-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #c77b28);
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px; color: var(--accent-text);
  flex-shrink: 0;
}
.hub-title h1 { font-size: 19px; font-weight: 700; }
.hub-title .beta { font-size: 11px; font-weight: 700; color: var(--accent); vertical-align: super; margin-left: 1px; }
.hub-title p { font-size: 13px; color: var(--hint); }
.hub-header .spacer { flex: 1; }
.icon-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 12px; padding: 9px 13px; font-size: 16px; cursor: pointer;
}
/* coin balance pill in the header */
.coin-pill {
  display: inline-flex; align-items: center; gap: 4px; font-size: 13px;
  color: var(--hint); background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 10px; white-space: nowrap;
}
.coin-pill b { color: var(--accent); font-variant-numeric: tabular-nums; }
/* 📅 button pulses while a daily reward is unclaimed */
#checkinBtn.nudge { position: relative; animation: ci-pulse 1.8s ease-in-out infinite; }
#checkinBtn.nudge::after {
  content: ''; position: absolute; top: 5px; right: 6px; width: 8px; height: 8px;
  background: var(--bad); border-radius: 50%; border: 1.5px solid var(--bg);
}
@keyframes ci-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232, 179, 59, 0.5); }
  50% { box-shadow: 0 0 0 5px rgba(232, 179, 59, 0); }
}

/* ---------- game cards ---------- */
.game-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px; margin-bottom: 14px;
}
.game-card .head { display: flex; align-items: center; gap: 12px; }
.game-emoji {
  width: 52px; height: 52px; border-radius: 14px; background: var(--bg2);
  display: grid; place-items: center; font-size: 28px; flex-shrink: 0;
}
.game-info { flex: 1; min-width: 0; }
.game-info h2 { font-size: 16px; }
.game-info p { font-size: 12.5px; color: var(--hint); margin-top: 2px; }
/* Sits at the head of the tagline, not the title: a 16px game name plus a pill
   overflows the card's text column and orphans the pill onto its own line. */
.badge-new {
  display: inline-block; font-size: 9px; font-weight: 800; letter-spacing: 0.6px;
  background: var(--accent); color: var(--accent-text);
  padding: 2px 6px; border-radius: 999px; vertical-align: 1px;
}
.badge-soon {
  font-size: 11px; color: var(--hint); border: 1px solid var(--line);
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.play-btn {
  background: var(--accent); color: var(--accent-text); border: none;
  border-radius: 12px; padding: 10px 20px; font-size: 15px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
}
.play-btn:active { transform: scale(0.96); }
.play-btn[disabled] { opacity: 0.4; cursor: default; }

/* hint on an early-access card the player can't open yet */
.early-note {
  display: block; width: 100%; margin-top: 12px; padding: 8px 10px;
  background: rgba(232, 179, 59, 0.1); border: 1px solid rgba(232, 179, 59, 0.25);
  border-radius: 10px; color: var(--accent); font: inherit; font-size: 12px;
  text-align: center; cursor: pointer;
}

.mybest {
  display: flex; gap: 14px; margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--line); font-size: 13px; color: var(--hint);
}
.mybest b { color: var(--text); font-size: 15px; display: block; }

/* ---------- leaderboard ---------- */
.lb-toggle {
  margin-top: 10px; background: none; border: none; color: var(--hint);
  font-size: 13px; cursor: pointer; padding: 4px 0;
}
.lb { margin-top: 8px; }
.lb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 10px; font-size: 14px;
}
.lb-row.me { background: rgba(232, 179, 59, 0.12); }
.lb-rank { width: 26px; color: var(--hint); font-variant-numeric: tabular-nums; }
.lb-row:nth-child(1) .lb-rank, .lb-row:nth-child(2) .lb-rank, .lb-row:nth-child(3) .lb-rank { color: var(--accent); }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-streak { font-size: 11px; color: var(--accent); font-variant-numeric: tabular-nums; }
.lb-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.lb-empty { color: var(--hint); font-size: 13px; padding: 8px 10px; }
/* an open multiplayer lobby, rendered as a tappable leaderboard-style row */
.lb-row.table-row {
  width: 100%; background: var(--bg2); border: 1px solid var(--line);
  color: var(--text); font: inherit; font-size: 14px; text-align: left;
  cursor: pointer; margin-bottom: 6px;
}

/* ---------- modal (shop) ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55);
  display: none; align-items: flex-end; justify-content: center; z-index: 50;
}
.modal-back.open { display: flex; }
.modal {
  background: var(--bg2); border-radius: 20px 20px 0 0; width: 100%;
  max-width: 480px; padding: 20px 16px 28px; max-height: 80vh; overflow-y: auto;
}
.modal h3 { font-size: 17px; margin-bottom: 4px; }
.modal .sub { font-size: 13px; color: var(--hint); margin-bottom: 16px; }
.shop-item {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; margin-bottom: 10px;
}
.swatch { width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; }
.shop-item .name { flex: 1; font-size: 14.5px; }
.shop-item .price { font-size: 13px; color: var(--hint); }
.buy-btn {
  background: var(--accent); color: var(--accent-text); border: none;
  border-radius: 10px; padding: 8px 14px; font-weight: 700; font-size: 13.5px; cursor: pointer;
}
.buy-btn.owned { background: var(--bg2); color: var(--text); border: 1px solid var(--line); }
.buy-btn.selected { background: var(--good); color: #fff; }
.shop-note { font-size: 12.5px; color: var(--hint); text-align: center; margin-top: 10px; }

.footer-note { text-align: center; font-size: 12px; color: var(--hint); margin-top: 22px; }

/* ---------- leave-the-round dialog (webapp/js/api.js) ---------- */
/* Centred rather than a bottom sheet: it interrupts a game rather than being
   opened deliberately, so it reads as a question, not a drawer. */
#leaveModal.modal-back { align-items: center; z-index: 120; }
#leaveModal .modal { border-radius: 20px; margin: 16px; max-width: 340px; text-align: center; }
#leaveModal .sub { margin-bottom: 18px; }
.leave-btns { display: flex; flex-direction: column; gap: 8px; }
.leave-btns button {
  width: 100%; border: none; border-radius: 12px; padding: 13px;
  font-size: 15px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.leave-btns button[hidden] { display: none; }
.leave-save { background: var(--accent); color: var(--accent-text); }
.leave-save:disabled { opacity: 0.6; cursor: default; }
/* Losing the round is the destructive choice, and it is not the default one. */
.leave-drop { background: var(--card); color: var(--bad); border: 1px solid var(--line) !important; }
.leave-stay { background: transparent; color: var(--hint); }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(80px);
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  padding: 10px 18px; border-radius: 12px; font-size: 14px; z-index: 100;
  transition: transform 0.25s ease; max-width: 90vw; text-align: center;
}
#toast.show { transform: translateX(-50%) translateY(0); }
