/* Festify WebApp Shared Styles */
:root {
  --vh: 100vh;
  --bg1: #5228a3;
  --bg2: #ff8a3d;
  --festify-bg:
    radial-gradient(1200px 900px at 20% -10%, #6e3bd1 0%, transparent 60%),
    radial-gradient(1000px 800px at 120% 20%, #ffb36b 0%, transparent 60%),
    linear-gradient(180deg, var(--bg1, #5228a3) 0%, var(--bg2, #ff8a3d) 100%);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial;
  color: #0f172a;
  background: #ffffff;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Page-specific styles will follow */

.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-weight: 900;
  font-size: 20px;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  transition: transform 0.08s ease, background 0.08s ease;
}

.back-button:active {
  transform: translateY(1px);
  background: rgba(255, 255, 255, 0.24);
}

.back-button.light {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(15, 23, 42, 0.12);
  color: #1f2937;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
}

/* === Download Page === */
body.page-download {
  --bg-top: #fff7ed;
  --bg-mid: #ffe3c9;
  --bg-bottom: #ffcda5;
  --ink: #172136;
  --muted: rgba(23, 33, 54, 0.56);
  --accent: #5450f6;
  --accent-alt: #2eb8ff;
  --accent-soft: rgba(84, 80, 246, 0.16);
  --stroke: rgba(84, 80, 246, 0.18);
  --shadow-card: 0 20px 48px rgba(214, 120, 76, 0.18);
  --shadow-soft: 0 16px 32px rgba(84, 80, 246, 0.16);
  --cta: #ffd278;
  --ctaDark: #ffb654;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 48%, var(--bg-bottom) 100%) fixed;
  min-height: 100vh;
  display: flex;
  justify-content: flex-start;
  padding: 18px clamp(12px, 4vw, 24px) calc(40px + env(safe-area-inset-bottom));
}

body.page-download .wrap {
  width: min(960px, 100% - 24px);
  margin: 0 auto;
}

body.page-download .download-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

body.page-download .gallery-title {
  margin: 0;
  font-weight: 800;
  font-size: 20px;
  color: var(--ink);
  flex: 1;
  text-align: center;
}

/* spacer for centering (same as gallery/editor) */
body.page-download .header-spacer { width: var(--backw, 96px); height: 1px; display: block; }

/* back button visual (same as gallery) */
body.page-download .header-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  width: auto;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(84, 80, 246, 0.28);
  color: var(--accent);
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 6px 16px rgba(84, 80, 246, 0.12);
}
body.page-download .header-back:active { transform: translateY(1px); }
body.page-download .header-back span[aria-hidden] { font-size: 17px; line-height: 1; }

body.page-download .card {
  background: var(--surface, rgba(255, 255, 255, 0.96));
  border-radius: 20px;
  border: 1px solid var(--stroke);
  padding: 20px;
  box-shadow: var(--shadow-card);
  text-align: center;
}

body.page-download .frame {
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-soft);
}

body.page-download .frame img {
  max-width: 100%;
  height: auto;
  display: block;
}

body.page-download .actions {
  margin-top: 16px;
  display: flex;
}

body.page-download button {
  flex: 1;
  border: none;
  border-radius: 14px;
  padding: 16px 14px;
  font-weight: 900;
  cursor: pointer;
}

body.page-download .primary {
  background: linear-gradient(180deg, var(--cta), var(--ctaDark));
  color: #2a2100;
  box-shadow: 0 14px 32px rgba(214, 120, 76, 0.22);
}

body.page-download .primary:active {
  transform: translateY(1px);
}

body.page-download button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(30%);
}

body.page-download .hint {
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
}
body.page-download .hint.error { color: #a94531; }

body.page-download .download-overlay {
  pointer-events: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 15;
}

body.page-download .token-spark {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ffe9a8, #ffd278 70%, #c8851f 100%);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: scale(0.4);
  animation: tokenBurst 1200ms ease-out forwards;
}

@keyframes tokenBurst {
  0% { opacity: 0; transform: translate(0, 0) scale(0.4); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.2); }
}


/* === Wallet Page === */
body.page-wallet {
  --bg-top: #fff7ed;
  --bg-mid: #ffe3c9;
  --bg-bottom: #ffcda5;
  --ink: #172136;
  --ink-muted: rgba(23, 33, 54, 0.56);
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: rgba(255, 244, 228, 0.94);
  --accent: #5450f6;
  --stroke: rgba(84, 80, 246, 0.18);
  --cta: #ffd278;
  --ctaDark: #ffb654;
  --shadow-card: 0 20px 48px rgba(214, 120, 76, 0.18);
  --shadow-soft: 0 16px 32px rgba(84, 80, 246, 0.16);
  --shadow-sm: 0 12px 32px rgba(214, 120, 76, 0.16);
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 48%, var(--bg-bottom) 100%) fixed;
}

body.page-wallet .wrap { width: min(960px, 100% - 24px); margin: 0 auto; padding: 18px clamp(12px, 4vw, 24px) calc(80px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 18px; }

/* Header: match shared compact layout */
body.page-wallet .wallet-header { display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 8px; }
body.page-wallet .gallery-title { margin: 0; font-weight: 800; font-size: 20px; color: var(--ink); flex: 1; text-align: center; }
body.page-wallet .header-spacer { width: var(--backw, 96px); height: 1px; display: block; }
body.page-wallet .header-back { display: inline-flex; align-items: center; gap: 6px; height: 38px; width: auto; padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid rgba(84, 80, 246, 0.28); color: var(--accent); font-weight: 800; font-size: 15px; box-shadow: 0 6px 16px rgba(84, 80, 246, 0.12); }
body.page-wallet .header-back:active { transform: translateY(1px); }
body.page-wallet .header-back span[aria-hidden] { font-size: 17px; line-height: 1; }

body.page-wallet .wallet-header .back-button {
  flex-shrink: 0;
}

body.page-wallet .title-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

body.page-wallet .title-block h1 {
  margin: 0;
  font-size: clamp(24px, 6vw, 30px);
  font-weight: 900;
}

body.page-wallet .title-block p { margin: 0; color: var(--ink-muted); font-weight: 600; opacity: 0.95; }

body.page-wallet .wallet-card { background: var(--surface); border: 1px solid var(--stroke); border-radius: 22px; padding: 20px; box-shadow: var(--shadow-card); display: flex; gap: 16px; flex-wrap: wrap; position: relative; }

body.page-wallet .wallet-profile {
  align-items: center;
  justify-content: space-between;
}

body.page-wallet .wallet-profile .identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

body.page-wallet .wallet-profile .identity .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.72;
  font-weight: 700;
}

body.page-wallet .wallet-profile .name {
  font-weight: 900;
  font-size: 18px;
  max-width: min(260px, 60vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.page-wallet .wallet-profile .avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; background: #fff; border: 1px solid var(--stroke); box-shadow: var(--shadow-sm); overflow: hidden; }

body.page-wallet .wallet-profile .avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

body.page-wallet .tier-pill { padding: 6px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--stroke); color: var(--accent); font-weight: 900; font-size: 13px; box-shadow: var(--shadow-sm); }

body.page-wallet .wallet-balance {
  flex-direction: column;
  gap: 18px;
}

body.page-wallet .wallet-balance-head {
  display: flex;
  align-items: center;
  gap: 16px;
}

body.page-wallet .wallet-balance .coin {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: transparent;
  box-shadow: none;
  font-size: 0;
}

body.page-wallet .wallet-balance .label {
  font-size: 12px;
  letter-spacing: 0.08em;
  opacity: 0.72;
  font-weight: 700;
  text-transform: uppercase;
}

body.page-wallet .amount {
  font-weight: 1000;
  font-size: clamp(24px, 6.5vw, 30px);
  letter-spacing: 0.1px;
  margin-top: 4px;
}

body.page-wallet .subline {
  margin-top: 6px;
  display: grid;
  gap: 2px;
  font-weight: 700;
}

/* Smaller USD estimate text so it fits comfortably in the card */
body.page-wallet #approxLine,
body.page-wallet #priceLine {
  font-size: 14px;
  line-height: 1.15;
}

body.page-wallet .subline small {
  opacity: 0.85;
  font-weight: 700;
}

body.page-wallet .wallet-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

body.page-wallet .wallet-meta .muted {
  opacity: 0.8;
  font-weight: 700;
}

body.page-wallet .wallet-meta .cta {
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 900;
  color: #2a2100;
  background: linear-gradient(180deg, var(--cta), var(--ctaDark));
  box-shadow: 0 16px 32px rgba(214, 120, 76, 0.22);
  cursor: pointer;
  transition: transform 0.08s ease;
}

body.page-wallet .wallet-meta .cta:active {
  transform: translateY(1px);
}

body.page-wallet .wallet-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* Make wallet actions look like home nav chips */
body.page-wallet .wallet-card.action { background: rgba(255,255,255,0.92); border: 1px solid rgba(84,80,246,0.18); border-radius: 18px; box-shadow: 0 12px 24px rgba(84,80,246,0.12); cursor: pointer; transition: transform 0.12s ease, box-shadow 0.12s ease; padding: 14px 14px; display:flex; flex-direction: column; align-items: center; gap:12px; text-align:center; }
body.page-wallet .wallet-card.action .icon { width:40px; height:40px; border-radius:12px; display:grid; place-items:center; font-size:20px; font-weight:900; color:#2a2466; background: linear-gradient(180deg, #e9e7ff, #d6d3ff); border: 1px solid rgba(84,80,246,0.2); flex:0 0 auto; }
body.page-wallet .wallet-card.action .copy { display:flex; flex-direction:column; gap:4px; min-width:0; align-items:center; }
/* Per-card icon theme */
body.page-wallet .wallet-card.action[data-href*="leaderboard.html"] .icon { background: linear-gradient(180deg, #fff4d1, #ffe7a1); border-color: rgba(214,168,76,0.35); color:#6a4a00; }
body.page-wallet .wallet-card.action[data-href*="referral.html"] .icon { background: linear-gradient(180deg, #eafff3, #ccf9e2); border-color: rgba(16,185,129,0.28); color:#065f46; }
body.page-wallet .wallet-card.action[data-href*="mining.html"] .icon { background: linear-gradient(180deg, #ffe9d6, #ffd9b8); border-color: rgba(214,120,76,0.32); color:#7a3f00; }

body.page-wallet .wallet-card.action .title {
  font-weight: 1000;
  font-size: 17px;
}

body.page-wallet .wallet-card.action .hint { margin-top: 4px; color: var(--ink-muted); font-weight: 600; opacity: 0.95; }

body.page-wallet .wallet-card.action .chev {
  font-size: 22px;
  opacity: 0.9;
  flex-shrink: 0;
}

body.page-wallet .wallet-card.action:hover { transform: translateY(-1px); box-shadow: 0 18px 32px rgba(84,80,246,0.16); }
body.page-wallet .wallet-card.action:active { transform: translateY(1px); box-shadow: 0 12px 26px rgba(84,80,246,0.12); }

body.page-wallet .wallet-tip {
  flex-direction: column;
  gap: 10px;
}

body.page-wallet .wallet-tip h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
}

body.page-wallet .wallet-tip p { margin: 0; color: var(--ink-muted); font-weight: 600; }

@media (max-width: 420px) {
  body.page-wallet .wrap {
    gap: 16px;
  }

  body.page-wallet .wallet-meta {
    align-items: stretch;
  }

  body.page-wallet .wallet-meta .cta {
    width: 100%;
  }
}

/* === Home Page === */
body.page-index {
  --bg-top: #fff7ed;
  --bg-mid: #ffe3c9;
  --bg-bottom: #ffcda5;
  --ink: #172136;
  --ink-soft: rgba(23, 33, 54, 0.72);
  --ink-muted: rgba(23, 33, 54, 0.56);
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: rgba(255, 244, 228, 0.94);
  --accent: #5450f6;
  --accent-alt: #2eb8ff;
  --accent-soft: rgba(84, 80, 246, 0.16);
  --shadow-md: 0 20px 48px rgba(84, 80, 246, 0.18);
  --shadow-sm: 0 12px 32px rgba(214, 120, 76, 0.16);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 48%, var(--bg-bottom) 100%) fixed;
  color: var(--ink);
  min-height: 100vh;
}

body.page-index .wrap {
  width: min(960px, 100% - 24px);
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 32px) calc(120px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

body.page-index .header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 4px 4px;
}

body.page-index .brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

body.page-index .logo-badge {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.page-index .logo-badge svg {
  display: block;
  width: 100%;
  height: 100%;
}

body.page-index .brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

body.page-index .brand-copy strong {
  font-size: 20px;
  font-weight: 800;
}

body.page-index .brand-copy span {
  font-size: 12px;
  color: var(--ink-muted);
}

body.page-index .header-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-alt) 100%);
  color: #ffffff;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: transform 0.12s ease;
}

body.page-index .header-btn:active {
  transform: translateY(1px);
}

body.page-index .card {
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid rgba(84, 80, 246, 0.14);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  display: flex;
  gap: 12px;
}

body.page-index .hero-card {
  align-items: center;
  justify-content: space-between;
  /* Match nav-chip style background seen elsewhere */
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(84, 80, 246, 0.18);
  box-shadow: var(--shadow-sm);
}

body.page-index .hero-card .hero-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

body.page-index .hero-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

body.page-index .hero-card h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 800;
}

body.page-index .hero-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.5;
}

body.page-index .hero-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

body.page-index .btn {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.12s ease;
}

body.page-index .hero-actions .btn {
  width: 100%;
  text-align: center;
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.3;
}

body.page-index .btn.primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-alt) 100%);
  color: #ffffff;
  box-shadow: var(--shadow-md);
}

body.page-index .btn.ghost {
  background: rgba(255, 255, 255, 0.9);
  color: var(--accent);
  border: 1px solid rgba(84, 80, 246, 0.2);
}

body.page-index .btn:active {
  transform: translateY(1px);
}

body.page-index .hero-visual {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.page-index .poster-preview {
  border-radius: 20px;
  padding: 0;
  background: var(--surface-strong);
  border: 1px solid rgba(255, 200, 160, 0.32);
  box-shadow: var(--shadow-sm);
  overflow: hidden;              /* clip to rounded corners */
  width: 100%;
  aspect-ratio: 4 / 3;
}

/* Telegram join card matches strong surface styling */
body.page-index .tg-join-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(84, 80, 246, 0.18);
  box-shadow: var(--shadow-sm);
}

body.page-index .poster-preview svg {
  display: block;
  width: 100%;
  height: 100%;
}

body.page-index .progress-card {
  flex-direction: column;
  gap: 16px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(84, 80, 246, 0.18);
  box-shadow: var(--shadow-sm);
}

body.page-index .progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: nowrap;
}

body.page-index .progress-title {
  font-weight: 700;
  font-size: clamp(14px, 4vw, 16px);
  white-space: nowrap;
}

body.page-index .progress-note {
  font-size: clamp(11px, 3.2vw, 12px);
  color: var(--ink-muted);
  white-space: nowrap;
}

body.page-index .progress-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(84, 80, 246, 0.12);
  overflow: hidden;
}

body.page-index .progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent) 0%, #66ffcc 100%);
  box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.24);
}

body.page-index .progress-foot {
  font-size: 13px;
  color: var(--ink-muted);
}

body.page-index .wallet-card {
  flex-direction: column;
  gap: 18px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(84, 80, 246, 0.18);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

body.page-index .wallet-card:active {
  transform: translateY(1px);
}

body.page-index .wallet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

body.page-index .wallet-user {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

body.page-index .wallet-user img {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-sm);
}

body.page-index .wallet-handle {
  font-weight: 600;
  font-size: 16px;
}

body.page-index .wallet-power {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
}

body.page-index .wallet-balance {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

body.page-index .wallet-amount {
  font-size: 22px;
  font-weight: 700;
}

body.page-index .wallet-label {
  font-size: 12px;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

body.page-index .wallet-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--ink-muted);
}

body.page-index .section {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 24px;
  border: 1px solid rgba(84, 80, 246, 0.18);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

body.page-index .section-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

body.page-index .section-header h3 {
  margin: 0;
  font-size: 20px;
}

body.page-index .section-header p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

body.page-index .category-boxes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

body.page-index .category-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
  padding: 18px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 204, 170, 0.32);
  box-shadow: 0 12px 24px rgba(214, 120, 76, 0.14);
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

body.page-index .category-box:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 32px rgba(214, 120, 76, 0.18);
}

body.page-index .category-box .cat-face {
  font-size: 24px;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: rgba(255, 198, 125, 0.2);
}

body.page-index .category-box .cat-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}

body.page-index .category-box .cat-copy strong {
  font-size: 15px;
  color: var(--ink);
}

body.page-index .category-box .cat-copy span {
  font-size: 12px;
  color: var(--ink-muted);
}

body.page-index .nav-list {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

body.page-index .nav-chip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(84, 80, 246, 0.18);
  box-shadow: 0 12px 24px rgba(84, 80, 246, 0.12);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  text-decoration: none;
}

body.page-index .nav-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 32px rgba(84, 80, 246, 0.16);
}

body.page-index .nav-icon {
  font-size: 20px;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(84, 80, 246, 0.1);
}

/* Feature-specific icon backgrounds (card stays white) */
body.page-index .nav-chip[data-k="gallery"]   .nav-icon { background: linear-gradient(180deg, #d9d7ff, #c6c3ff); color: #3c2cc9; }
body.page-index .nav-chip[data-k="streak"]    .nav-icon { background: linear-gradient(180deg, #ffe3b3, #ffd08a); color: #8a5200; }
body.page-index .nav-chip[data-k="leaderboard"] .nav-icon { background: linear-gradient(180deg, #cfeaff, #a9d6ff); color: #0b5aa6; }
body.page-index .nav-chip[data-k="referral"]  .nav-icon { background: linear-gradient(180deg, #d7ffe6, #b7f7d2); color: #0c7a49; }
body.page-index .nav-chip[data-k="power"]     .nav-icon { background: linear-gradient(180deg, #ffd7f1, #ffc0e7); color: #a01466; }
body.page-index .nav-chip[data-k="wallet"]    .nav-icon { background: linear-gradient(180deg, #dffcff, #c4f2f6); color: #0a6970; }
body.page-index .nav-chip[data-k="mining"]    .nav-icon { background: linear-gradient(180deg, #ffe9c7, #ffd9a3); color: #8a5b00; }

body.page-index .nav-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

body.page-index .nav-copy strong {
  font-size: 15px;
  color: var(--ink);
  margin: 0;
}

body.page-index .nav-copy span {
  font-size: 12px;
  color: var(--ink-muted);
}

body.page-index .nav-arrow {
  font-size: 18px;
  color: var(--accent-strong);
  opacity: 0.6;
}

@media (max-width: 520px) {
  body.page-index .hero-card {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  body.page-index .hero-visual {
    width: 100%;
    margin-top: 4px;
  }

  body.page-index .poster-preview {
    width: min(240px, 85%);
    margin: 0 auto;
    display: grid;
    place-items: center;
  }

  body.page-index .hero-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  body.page-index .wrap {
    padding-inline: 14px;
  }
  body.page-index .card { padding: 14px; }
  body.page-index .hero-card .hero-content { gap: 10px; }
  body.page-index .hero-label { padding: 5px 10px; }
  body.page-index .hero-card h2 { font-size: 22px; }
  body.page-index .hero-card p { font-size: 13px; }

  body.page-index .header-btn {
    padding: 10px 16px;
  }

  body.page-index .section {
    padding: 20px;
  }

  body.page-index .nav-grid,
  body.page-index .categories-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 360px){
  body.page-index .card { padding: 12px; }
  body.page-index .hero-card h2 { font-size: 20px; }
}
/* === Gallery Page === */
body.page-gallery {
  --bg-top: #fff7ed;
  --bg-mid: #ffe3c9;
  --bg-bottom: #ffcda5;
  --ink: #172136;
  --ink-soft: rgba(23, 33, 54, 0.72);
  --ink-muted: rgba(23, 33, 54, 0.56);
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: rgba(255, 244, 228, 0.94);
  --accent: #5450f6;
  --accent-alt: #2eb8ff;
  --accent-soft: rgba(84, 80, 246, 0.16);
  --stroke: rgba(84, 80, 246, 0.18);
  --shadow-card: 0 20px 48px rgba(214, 120, 76, 0.18);
  --shadow-soft: 0 16px 32px rgba(84, 80, 246, 0.16);
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 48%, var(--bg-bottom) 100%) fixed;
  min-height: 100vh;
}

/* container */
body.page-gallery .wrap {
  width: min(960px, 100% - 24px);
  margin: 0 auto;
  padding: 18px clamp(12px, 4vw, 24px) calc(84px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ===== HEADER ===== */
body.page-gallery .gallery-header {
  position: relative;
  display: flex;
  flex-direction: row;            /* title and back in one row */
  align-items: center;
  justify-content: center;        /* center the title block */
  gap: 8px;
  padding: 0;
  margin-bottom: 8px;
  background: transparent;
  box-shadow: none;
}

/* Center title style */
body.page-gallery .gallery-title {
  margin: 0;
  font-weight: 800;
  font-size: 20px;
  color: var(--ink);
  flex: 1;                        /* take remaining space to center text */
  text-align: center;
}

/* Back button - top-left floating */
body.page-gallery .header-back {
  position: static;              /* participate in row layout */
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  width: auto;                  /* override base .back-button width */
  padding: 6px 12px;            /* smaller pill padding */
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent);
  font-weight: 800;
  font-size: 15px;              /* smaller text */
  border: 1px solid rgba(84, 80, 246, 0.28);
  box-shadow: 0 6px 16px rgba(84, 80, 246, 0.12);
}
body.page-gallery .header-back:active {
  transform: translateY(1px);
}
body.page-gallery .header-back span[aria-hidden] {
  font-size: 17px;
  line-height: 1;
  margin: 0;
  color: var(--accent);
}

/* On very small screens, keep a small pill (not a circle) */
@media (max-width: 380px) {
  body.page-gallery .header-back {
    height: 34px;
    padding: 4px 10px;
    width: auto;
    gap: 4px;
    font-size: 14px;
  }
}

/* Download: keep small pill on narrow screens */
@media (max-width: 380px) {
  body.page-download .header-back {
    height: 34px;
    padding: 4px 10px;
    width: auto;
    gap: 4px;
    font-size: 14px;
  }
}

/* Editor: keep same size as gallery on small screens */
@media (max-width: 380px) {
  body.page-editor .header-back {
    height: 34px;
    padding: 4px 10px;
    width: auto;
    gap: 4px;
    font-size: 14px;
  }
}
/* show and style the text label */
body.page-gallery .header-back span:not([aria-hidden]) {
  display: inline;
  color: var(--accent);
}

/* Centered brand logo + title */
/* brand removed on gallery */
body.page-gallery .brand { display: none !important; }

/* Spacer to balance the back button width so title stays centered */
body.page-gallery .header-spacer {
  display: block;
  width: var(--backw, 96px);
  height: 1px;                    /* minimal vertical footprint */
}

body.page-gallery .logo-badge {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
}
body.page-gallery .logo-badge svg {
  width: 100%;
  height: 100%;
  display: block;
}

body.page-gallery .brand-copy { display: none !important; }
body.page-gallery .brand-copy strong {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
}
body.page-gallery .brand-copy span {
  font-size: 13px;
  color: var(--ink-muted);
}

/* Removed template count chip completely */
body.page-gallery .count-chip { display: none !important; }

/* ===== FILTERS ===== */
body.page-gallery .card {
  background: var(--surface);
  border-radius: 20px;
  border: 1px solid rgba(84, 80, 246, 0.14);
  box-shadow: var(--shadow-card);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  color: var(--ink);
}

body.page-gallery .filters-head h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
}
body.page-gallery .filters-head p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-muted);
}

body.page-gallery .filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
@media (max-width: 420px) {
  body.page-gallery .filters { grid-template-columns: 1fr; }
}

body.page-gallery .select {
  position: relative;
  background: #fff;
  color: #1b1b1f;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-soft);
}
body.page-gallery .select label {
  font-size: 12px;
  font-weight: 800;
  color: #5b5b66;
}
body.page-gallery .select select {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-weight: 700;
  font-size: 14px;
  color: #1b1b1f;
  appearance: none;
  padding-right: 22px;
  cursor: pointer;
}
body.page-gallery .select .chev {
  font-weight: 900;
  color: var(--accent);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 520px) {
  body.page-gallery .wrap {
    padding: 10px 12px calc(80px + env(safe-area-inset-bottom));
    gap: 12px;
  }
  body.page-gallery .logo-badge {
    width: 48px;
    height: 48px;
  }
  body.page-gallery .brand-copy strong {
    font-size: 18px;
  }
}

/* ===== Remove top spacing on first card ===== */
body.page-gallery .card.filters-card {
  margin-top: 0 !important;
}

/* === Template Cards & Thumbnails === */
body.page-gallery .template-card {
  background: #fff;
  border-radius: 20px;
  border: 1px solid rgba(84, 80, 246, 0.18);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  position: relative; /* allow caption overlay inside card */
}
body.page-gallery .template-card:active {
  transform: translateY(1px);
  box-shadow: 0 12px 24px rgba(214, 120, 76, 0.22);
}
body.page-gallery .template-card:focus-visible {
  outline: 3px solid rgba(84, 80, 246, 0.35);
}

/* ✅ Thumbnails – show full image, no crop */
body.page-gallery .thumb {
  aspect-ratio: 3 / 4;            /* default to portrait; JS will update to real ratio */
  display: grid;
  place-items: center;
  background: #fdfdfd;
  border-radius: 16px;
  overflow: hidden;
}

body.page-gallery .thumb.img {
  background: #f7f7fb;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

body.page-gallery .thumb.img img {
  width: 100%;
  height: 100%;
  object-fit: cover;          /* fill container; no side gaps */
  object-position: center;
  display: block;
  border-radius: 16px;        /* match container rounding for tidy corners */
  transform: scale(1.04);     /* bleed slightly past edges to avoid any halo */
  will-change: transform;
}

body.page-gallery .thumb.brand {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-alt) 100%);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px;
  text-align: center;
  color: #fff;
  font-weight: 900;
  font-size: 22px;
}

/* Caption overlay inside the image box */
body.page-gallery .cap { display: none !important; }

/* ✅ Grid: 2 columns on phones, 3+ on wider screens */
body.page-gallery .template-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
@media (max-width: 520px) {
  body.page-gallery .template-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
    gap: 12px;
  }
}
@media (max-width: 360px) {
  body.page-gallery .template-grid {
    grid-template-columns: 1fr;
  }
}

/* === Leaderboard Page === */
body.page-leaderboard {
  --bg-top: #fff7ed;
  --bg-mid: #ffe3c9;
  --bg-bottom: #ffcda5;
  --ink: #172136;
  --muted: rgba(23, 33, 54, 0.56);
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: rgba(255, 244, 228, 0.94);
  --accent: #5450f6;
  --accent-alt: #2eb8ff;
  --line: rgba(84, 80, 246, 0.18);
  --cta: #ffd278;
  --ctaDark: #ffb654;
  --shadow-soft: 0 16px 32px rgba(84, 80, 246, 0.16);
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 48%, var(--bg-bottom) 100%) fixed;
}

body.page-leaderboard .wrap {
  width: min(960px, 100% - 24px);
  margin: 0 auto;
  padding: 18px clamp(12px, 4vw, 24px) calc(80px + env(safe-area-inset-bottom));
}

/* Header */
body.page-leaderboard .leaderboard-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}
body.page-leaderboard .gallery-title { margin: 0; font-weight: 800; font-size: 20px; color: var(--ink); flex: 1; text-align: center; }
body.page-leaderboard .header-spacer { width: var(--backw, 96px); height: 1px; display: block; }
body.page-leaderboard .header-back { display: inline-flex; align-items: center; gap: 6px; height: 38px; width: auto; padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid rgba(84, 80, 246, 0.28); color: var(--accent); font-weight: 800; font-size: 15px; box-shadow: 0 6px 16px rgba(84, 80, 246, 0.12); }
body.page-leaderboard .header-back:active { transform: translateY(1px); }
body.page-leaderboard .header-back span[aria-hidden] { font-size: 17px; line-height: 1; }


body.page-leaderboard .title {
  font-weight: 900;
  font-size: 26px;
}

body.page-leaderboard .me { display: flex; align-items: center; justify-content: space-between; gap: 14px; background: var(--surface-strong); border: 1px solid rgba(255, 204, 170, 0.38); border-radius: 18px; padding: 14px 16px; margin: 6px 0 20px; box-shadow: var(--shadow-soft); }

body.page-leaderboard .left {
  display: flex;
  align-items: center;
  gap: 12px;
}

body.page-leaderboard .avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ffd278;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #3b2200;
}

body.page-leaderboard .me .name {
  font-weight: 800;
}

body.page-leaderboard .me .sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

body.page-leaderboard .tokens {
  font-weight: 900;
}

body.page-leaderboard .list {
  margin: 6px 0;
  border-top: 1px solid var(--line);
}

body.page-leaderboard .row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}

body.page-leaderboard .rank {
  width: 40px;
  text-align: center;
  color: var(--muted);
  font-weight: 800;
}

body.page-leaderboard .user {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

body.page-leaderboard .user .name {
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.page-leaderboard .user .ava {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffd278;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #3b2200;
}

body.page-leaderboard .val {
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

body.page-leaderboard .foot { position: sticky; bottom: 0; padding: 8px 0 8px; background: transparent; }

body.page-leaderboard .btn { display: block; width: 100%; text-align: center; background: linear-gradient(180deg, var(--cta), var(--ctaDark)); color: #3b2200; border: none; border-radius: 14px; padding: 14px 16px; font-weight: 900; font-size: 16px; cursor: pointer; box-shadow: 0 14px 28px rgba(214, 120, 76, 0.22); text-decoration: none; }

body.page-leaderboard .btn:active {
  transform: translateY(1px);
  background: var(--ctaDark);
}

/* === Mining Page === */
body.page-mining {
  --bg-top: #fff7ed;
  --bg-mid: #ffe3c9;
  --bg-bottom: #ffcda5;
  --ink: #172136;
  --ink-muted: rgba(23, 33, 54, 0.56);
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: rgba(255, 244, 228, 0.94);
  --stroke: rgba(84, 80, 246, 0.18);
  --accent: #5450f6;
  --cta: #ffd278;
  --ctaDark: #ffb654;
  --shadow-card: 0 20px 48px rgba(214, 120, 76, 0.18);
  --shadow-soft: 0 16px 32px rgba(84, 80, 246, 0.16);
  --shadow-sm: 0 12px 32px rgba(214, 120, 76, 0.16);
  --ok: #10b981;
  --err: #ef4444;
  --warn: #f59e0b;
  --track: #ece7ff;
  --trackFillStart: #66ffa1;
  --trackFillEnd: #3de29f;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 48%, var(--bg-bottom) 100%) fixed;
}

body.page-mining .wrap { width: min(960px, 100% - 24px); margin: 0 auto; padding: 18px clamp(12px, 4vw, 24px) calc(120px + env(safe-area-inset-bottom)); }

body.page-mining .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Header (compact pattern) */
body.page-mining .mining-header { display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 8px; margin-bottom: 4px; }
body.page-mining .gallery-title { margin: 0; font-weight: 800; font-size: 20px; color: var(--ink); flex: 1; text-align: center; }
body.page-mining .header-spacer { width: var(--backw, 96px); height: 1px; display: block; }
body.page-mining .header-back { display: inline-flex; align-items: center; gap: 6px; height: 38px; width: auto; padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid rgba(84, 80, 246, 0.28); color: var(--accent); font-weight: 800; font-size: 15px; box-shadow: 0 6px 16px rgba(84, 80, 246, 0.12); }
body.page-mining .header-back:active { transform: translateY(1px); }
body.page-mining .header-back span[aria-hidden] { font-size: 17px; line-height: 1; }


body.page-mining .title h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0.2px;
}

body.page-mining .title p { margin: 2px 0 0; font-size: 13px; color: var(--ink-muted); }

body.page-mining .ghostBtn { padding: 10px 14px; border-radius: 12px; border: 1px solid var(--stroke); background: #fff; color: var(--accent); font-weight: 800; cursor: pointer; box-shadow: var(--shadow-soft); }

body.page-mining .card { background: var(--surface); border: 1px solid var(--stroke); border-radius: 20px; padding: 16px; box-shadow: var(--shadow-card); margin-top: 16px; }

body.page-mining .pill { display: inline-flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--stroke); padding: 6px 10px; border-radius: 999px; font-size: 13px; font-weight: 800; color: var(--accent); }

body.page-mining .badge { font-weight: 900; font-size: 12px; padding: 6px 10px; border-radius: 999px; background: #fff; border: 1px solid var(--stroke); color: var(--accent); }

body.page-mining .badge.ok {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(16, 185, 129, 0.35);
}

body.page-mining .badge.err {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
}

body.page-mining .badge.warn {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.35);
}

body.page-mining .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

body.page-mining .cell { background: #fff; border: 1px solid var(--stroke); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow-soft); }

body.page-mining .cell .k {
  font-size: 12px;
  opacity: 0.9;
}

body.page-mining .cell .v {
  font-weight: 1000;
  font-size: 22px;
  margin-top: 2px;
  position: relative;
}

body.page-mining .cell .v small {
  opacity: 0.85;
  font-size: 12px;
  font-weight: 700;
  margin-left: 2px;
}

body.page-mining .divider { height: 1px; background: linear-gradient(90deg, transparent, var(--stroke), transparent); margin: 12px 0; }

body.page-mining .rows {
  font-size: 14px;
}

body.page-mining .rows .r {
  display: flex;
  justify-content: space-between;
  margin: 6px 0;
}

body.page-mining .subtle {
  opacity: 0.85;
}

body.page-mining .bar {
  height: 12px;
  background: var(--track);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 2px;
}

body.page-mining .bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--trackFillStart), var(--trackFillEnd));
}

body.page-mining .btns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}
body.page-mining .btns .btn { width: 100%; }

body.page-mining .btn { background: linear-gradient(180deg, var(--cta), var(--ctaDark)); color: #3b2200; font-weight: 900; border: none; padding: 12px 16px; border-radius: 12px; cursor: pointer; box-shadow: 0 6px 16px rgba(214, 120, 76, 0.22); }
/* Tighter buttons so labels don’t wrap */
body.page-mining .btn { font-size: 14px; padding: 10px 12px; line-height: 1.1; white-space: nowrap; }
@media (max-width: 380px) {
  body.page-mining .btn { font-size: 13px; padding: 8px 10px; }
}

body.page-mining .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

body.page-mining .btn.secondary { background: #fff; color: var(--accent); border: 1px solid var(--stroke); box-shadow: 0 6px 16px rgba(84, 80, 246, 0.12); }

body.page-mining .how h3 { margin: 0 0 10px; }
/* Redesigned instructions list */
body.page-mining .how ul {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;               /* tighter vertical spacing */
  counter-reset: step;
}
body.page-mining .how li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--surface-strong);                /* higher-contrast background */
  border: 1px solid rgba(255, 204, 170, 0.38);      /* warm stroke used elsewhere */
  box-shadow: var(--shadow-sm);
  border-radius: 12px;
  padding: 8px 10px;      /* smaller padding for compact card */
  line-height: 1.3;
  font-size: 13px;        /* smaller text */
}
body.page-mining .how li::before {
  content: counter(step);
  counter-increment: step;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(84, 80, 246, 0.12);
  color: var(--accent);
  font-weight: 900;
  border: 1px solid var(--stroke);
  font-size: 12px;
}

@media (max-width: 380px) {
  body.page-mining .how li { font-size: 12.5px; padding: 7px 9px; }
  body.page-mining .how li::before { flex-basis: 20px; width: 20px; height: 20px; font-size: 11px; }
}

/* Make the How card itself use the contrast background */
body.page-mining .card.how { background: var(--surface); border: 1px solid var(--stroke); }

@media (max-width: 520px) {
  body.page-mining .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

body.page-mining .coin-fx {
  position: absolute;
  right: -2px;
  top: 0.1em;
  width: 18px;
  height: 18px;
  pointer-events: none;
  animation: coinPop 900ms ease-out forwards;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
}

@keyframes coinPop {
  0% {
    transform: translateY(0) scale(0.9);
    opacity: 0;
  }
  10% {
    opacity: 1;
    transform: translateY(-4px) scale(1);
  }
  70% {
    opacity: 1;
    transform: translateY(-22px) scale(1.02);
  }
  100% {
    opacity: 0;
    transform: translateY(-34px) scale(1.02);
  }
}

/* === Power Page === */
body.page-power {
  --bg-top: #fff7ed;
  --bg-mid: #ffe3c9;
  --bg-bottom: #ffcda5;
  --ink: #172136;
  --ink-muted: rgba(23, 33, 54, 0.56);
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: rgba(255, 244, 228, 0.94);
  --accent: #5450f6;
  --accent-alt: #2eb8ff;
  --stroke: rgba(84, 80, 246, 0.18);
  --cta: #ffd278;
  --ctaDark: #ffb654;
  --shadow-card: 0 20px 48px rgba(214, 120, 76, 0.18);
  --shadow-soft: 0 16px 32px rgba(84, 80, 246, 0.16);
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 48%, var(--bg-bottom) 100%) fixed;
}

body.page-power .wrap { width: min(960px, 100% - 24px); margin: 0 auto; padding: 18px clamp(12px, 4vw, 24px) calc(80px + env(safe-area-inset-bottom)); }

/* Header */
body.page-power .power-header { display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 8px; margin-bottom: 8px; }
body.page-power .gallery-title { margin: 0; font-weight: 800; font-size: 20px; color: var(--ink); flex: 1; text-align: center; }
body.page-power .header-spacer { width: var(--backw, 96px); height: 1px; display: block; }
body.page-power .header-back { display: inline-flex; align-items: center; gap: 6px; height: 38px; width: auto; padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid rgba(84, 80, 246, 0.28); color: var(--accent); font-weight: 800; font-size: 15px; box-shadow: 0 6px 16px rgba(84, 80, 246, 0.12); }
body.page-power .header-back:active { transform: translateY(1px); }
body.page-power .header-back span[aria-hidden] { font-size: 17px; line-height: 1; }


body.page-power .title {
  font-weight: 900;
  font-size: 26px;
}

body.page-power .card { background: var(--surface); border: 1px solid var(--stroke); border-radius: 20px; padding: 20px; margin-top: 18px; box-shadow: var(--shadow-card); }
body.page-power .card.hero { background: var(--surface); border-color: rgba(255, 204, 170, 0.38); }

body.page-power .hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

body.page-power .pLabel { font-weight: 800; color: var(--ink); }

body.page-power .pValue {
  font-weight: 900;
  font-size: 28px;
}

body.page-power .pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
}

body.page-power .tiny { font-size: 12px; color: var(--ink-muted); }

body.page-power .h2 {
  font-weight: 900;
  margin: 0 0 6px;
}

body.page-power .sub { margin: 0 0 10px; color: var(--ink-muted); }

body.page-power .bar { height: 12px; background: #fff; border-radius: 999px; overflow: hidden; border: 1px solid var(--stroke); box-shadow: var(--shadow-soft); }

body.page-power .bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-alt)); }

body.page-power .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

body.page-power .badge { padding: 6px 10px; border-radius: 999px; background: #fff; border: 1px solid var(--stroke); font-weight: 800; font-size: 12px; color: var(--accent); }

body.page-power .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: linear-gradient(180deg, var(--cta), var(--ctaDark)); color: #2a2100; border: none; border-radius: 14px; padding: 12px 14px; font-weight: 900; cursor: pointer; box-shadow: 0 14px 28px rgba(214, 120, 76, 0.22); text-decoration: none; }

body.page-power .btn:disabled {
  opacity: 0.6;
  filter: grayscale(20%);
  cursor: not-allowed;
  box-shadow: none;
}

body.page-power .btn:active {
  transform: translateY(1px);
  background: var(--ctaDark);
}

body.page-power .btn.ghost { background: #fff; color: var(--accent); border: 1px solid var(--stroke); box-shadow: none; }

body.page-power .btn.block {
  display: block;
  width: 100%;
}

body.page-power .grid2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (max-width: 420px) {
  body.page-power .grid2 {
    grid-template-columns: 1fr;
  }
}

body.page-power .benefits {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 10px;
}

body.page-power .benefit { display: flex; gap: 10px; align-items: flex-start; background: var(--surface-strong); border: 1px solid rgba(255, 204, 170, 0.38); border-radius: 12px; padding: 10px; }

body.page-power .benefit b {
  font-size: 14px;
}

body.page-power .benefit small {
  color: var(--muted);
}

body.page-power .tierlist {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 8px;
}

body.page-power .tiercard { position: relative; overflow: hidden; border: 1px solid var(--stroke); border-radius: 14px; background: #fff; padding: 12px; box-shadow: var(--shadow-soft); }
body.page-power .tiercard.upcoming { background: var(--surface-strong); border-color: rgba(255, 204, 170, 0.38); box-shadow: var(--shadow-soft); }

body.page-power .tierhdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

body.page-power .powerbig {
  font-weight: 900;
  font-size: 18px;
}

body.page-power .ribbon { display: inline-block; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--stroke); background: #fff; font-weight: 900; font-size: 12px; color: var(--accent); }

body.page-power .namechip { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; padding: 6px 10px; border-radius: 999px; background: #fff; border: 1px solid var(--stroke); }

body.page-power .tierchips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

body.page-power .chip { font-size: 12px; font-weight: 800; padding: 6px 10px; border-radius: 999px; background: #fff; border: 1px solid var(--stroke); color: var(--accent); }

/* Upcoming chips with no background (outlined only) */
body.page-power .chip.soft {
  background: transparent !important;
  border-color: var(--stroke);
  color: var(--accent);
}

body.page-power .tierfoot {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

body.page-power .tiercard.achieved {
  border-color: rgba(21, 195, 154, 0.45);
}

body.page-power .tiercard.achieved .ribbon {
  background: rgba(21, 195, 154, 0.15);
  border-color: rgba(21, 195, 154, 0.45);
}

/* === Referral Page === */
body.page-referral {
  --bg-top: #fff7ed;
  --bg-mid: #ffe3c9;
  --bg-bottom: #ffcda5;
  --ink: #172136;
  --ink-muted: rgba(23, 33, 54, 0.56);
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: rgba(255, 244, 228, 0.94);
  --accent: #5450f6;
  --accent-alt: #2eb8ff;
  --stroke: rgba(84, 80, 246, 0.18);
  --cta: #ffd278;
  --ctaDark: #ffb654;
  --shadow-card: 0 20px 48px rgba(214, 120, 76, 0.18);
  --shadow-soft: 0 16px 32px rgba(84, 80, 246, 0.16);
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 48%, var(--bg-bottom) 100%) fixed;
}

body.page-referral .wrap { width: min(960px, 100% - 24px); margin: 0 auto; padding: 18px clamp(12px, 4vw, 24px) calc(80px + env(safe-area-inset-bottom)); }

body.page-referral h1 { margin: 0 0 10px; }

body.page-referral .sub { color: var(--ink-muted); font-size: 14px; margin: 0 0 14px; }

body.page-referral .card { background: var(--surface); border: 1px solid var(--stroke); border-radius: 20px; padding: 18px; margin: 16px 0; box-shadow: var(--shadow-card); }

body.page-referral .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

body.page-referral .code { font-weight: 900; letter-spacing: 0.5px; background: #fff; border: 1px solid var(--stroke); padding: 8px 12px; border-radius: 12px; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }

body.page-referral .btn { background: linear-gradient(180deg, var(--cta), var(--ctaDark)); color: #3b2200; font-weight: 900; border: none; border-radius: 12px; padding: 10px 16px; cursor: pointer; box-shadow: 0 12px 28px rgba(214, 120, 76, 0.22); transition: transform 0.08s ease; }

body.page-referral .btn:active {
  transform: translateY(1px);
}

body.page-referral .btn.copy { background: #fff; border: 1px solid var(--stroke); color: var(--accent); box-shadow: none; }

body.page-referral .muted { color: var(--ink-muted); }

body.page-referral .list .item { display: flex; align-items: center; justify-content: space-between; padding: 10px 6px; border-bottom: 1px solid var(--stroke); gap: 10px; }

body.page-referral .badge { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: #fff; border: 1px solid var(--stroke); color: var(--accent); font-weight: 800; }

body.page-referral input { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--stroke); background: #fff; color: var(--ink); }

body.page-referral .hint { font-size: 12px; color: var(--ink-muted); margin-top: 6px; }

body.page-referral .label { font-size: 12px; color: var(--ink-muted); margin-bottom: 6px; }

body.page-referral .pill { display: inline-flex; align-items: center; justify-content: center; padding: 4px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--stroke); font-weight: 800; font-size: 12px; color: var(--accent); min-width: 32px; }

/* Header (match other pages) */
body.page-referral .referral-header { display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 8px; margin-bottom: 8px; }
body.page-referral .gallery-title { margin: 0; font-weight: 800; font-size: 20px; color: var(--ink); flex: 1; text-align: center; }
body.page-referral .header-spacer { width: var(--backw, 96px); height: 1px; display: block; }
body.page-referral .header-back { display: inline-flex; align-items: center; gap: 6px; height: 38px; width: auto; padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid rgba(84, 80, 246, 0.28); color: var(--accent); font-weight: 800; font-size: 15px; box-shadow: 0 6px 16px rgba(84, 80, 246, 0.12); }
body.page-referral .header-back:active { transform: translateY(1px); }
body.page-referral .header-back span[aria-hidden] { font-size: 17px; line-height: 1; }


/* === Streak Page === */
body.page-streak {
  --bg-top: #fff7ed;
  --bg-mid: #ffe3c9;
  --bg-bottom: #ffcda5;
  --ink: #172136;
  --ink-soft: rgba(23, 33, 54, 0.72);
  --ink-muted: rgba(23, 33, 54, 0.56);
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: rgba(255, 244, 228, 0.94);
  --accent: #5450f6;
  --accent-soft: rgba(84, 80, 246, 0.16);
  --stroke: rgba(84, 80, 246, 0.18);
  --shadow-card: 0 20px 48px rgba(214, 120, 76, 0.18);
  --shadow-soft: 0 16px 32px rgba(84, 80, 246, 0.16);
  --shadow-sm: 0 12px 32px rgba(214, 120, 76, 0.16);
  --cta: #ffd278;
  --cta2: #ffb654;
  --pillInk: #3b2200;
  --ringTrack: rgba(84, 80, 246, 0.14);
  --ringProg: #ffd278;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 48%, var(--bg-bottom) 100%) fixed;
}

body.page-streak .wrap {
  width: min(960px, 100% - 24px);
  margin: 0 auto;
  padding: 18px clamp(12px, 4vw, 24px) calc(80px + env(safe-area-inset-bottom));
}

/* Header — match gallery/editor/download */
body.page-streak .streak-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}
body.page-streak .gallery-title {
  margin: 0;
  font-weight: 800;
  font-size: 20px;
  color: var(--ink);
  flex: 1;
  text-align: center;
}
body.page-streak .header-spacer { width: var(--backw, 96px); height: 1px; display: block; }
body.page-streak .header-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  width: auto;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(84, 80, 246, 0.28);
  color: var(--accent);
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 6px 16px rgba(84, 80, 246, 0.12);
}
body.page-streak .header-back:active { transform: translateY(1px); }
body.page-streak .header-back span[aria-hidden] { font-size: 17px; line-height: 1; }

body.page-streak .top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}


body.page-streak .title {
  font-weight: 900;
  font-size: clamp(20px, 6vw, 28px);
}

body.page-streak .card {
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  padding: 20px;
  margin: 18px 0;
  box-shadow: var(--shadow-card);
}

body.page-streak .card h3 {
  margin: 0 0 6px;
  font-size: clamp(18px, 5vw, 22px);
}

body.page-streak .card p { margin: 0; color: var(--ink-muted); font-weight: 600; }

body.page-streak .ringWrap {
  display: grid;
  place-items: center;
  margin: 8px 0 12px;
}

body.page-streak .ring {
  width: min(78vw, 420px);
  aspect-ratio: 1 / 1;
  position: relative;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, transparent 62%, var(--ringTrack) 62% 63%, transparent 63%),
    conic-gradient(from -90deg, var(--ringProg) var(--pct, 0%), transparent 0);
  -webkit-mask:
    radial-gradient(circle at 50% 50%, #000 62%, transparent 63%),
    linear-gradient(#000, #000) content-box;
  mask:
    radial-gradient(circle at 50% 50%, #000 62%, transparent 63%),
    linear-gradient(#000, #000) content-box;
  padding: 12px;
}

body.page-streak .ringCenter {
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.68));
  display: grid;
  place-items: center;
  text-align: center;
  padding: 8%;
  border: 1px solid var(--stroke);
}

body.page-streak .dayNum {
  font-weight: 1000;
  line-height: 1;
  text-align: center;
  font-size: clamp(36px, 12vw, 72px);
}

body.page-streak .label {
  font-weight: 800;
  letter-spacing: 0.08em;
  opacity: 0.92;
  font-size: clamp(11px, 2.8vw, 14px);
  color: var(--ink-muted);
}

body.page-streak .claimRow {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

body.page-streak .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(180deg, var(--cta), var(--cta2));
  color: var(--pillInk);
  font-weight: 1000;
  border: none;
  border-radius: 999px;
  padding: 12px 16px;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(214, 120, 76, 0.22);
  text-decoration: none;
  min-width: 220px;
}

/* Daily reward: high-contrast theme button */
/* removed custom claimBtn overrides; use default streak .btn styles */

body.page-streak .btn.ghost { background: #fff; color: var(--accent); border: 1px solid var(--stroke); box-shadow: none; }

body.page-streak .btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  filter: grayscale(0.15);
}

body.page-streak .btn:active {
  transform: translateY(1px);
}

body.page-streak .secHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

body.page-streak .sub {
  color: var(--ink-muted);
  font-weight: 600;
  margin: 6px 0 0;
}

body.page-streak .milist {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}

body.page-streak .mi {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(255, 204, 170, 0.38);
  background: var(--surface-strong);
  border-radius: 14px;
  padding: 12px;
  box-shadow: var(--shadow-sm);
}

body.page-streak .mi .pill {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: #fff;
  font-weight: 800;
}

body.page-streak .mi .kicker {
  font-weight: 900;
}

body.page-streak .mi small { color: var(--ink-muted); }

body.page-streak .mi .ok {
  color: #d4ffd1;
  font-weight: 900;
}

body.page-streak .social {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}

body.page-streak .soc {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(255, 204, 170, 0.38);
  background: var(--surface-strong);
  border-radius: 14px;
  padding: 12px;
  width: 100%;
  box-shadow: var(--shadow-sm);
}

body.page-streak .soc .ico {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--stroke);
  font-weight: 900;
}

body.page-streak .soc .r {
  min-width: 0;
}

body.page-streak .soc .title {
  color: var(--ink);
  font-weight: 900;
  text-decoration: none;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.page-streak .soc .meta {
  color: var(--ink-muted);
  font-size: 13px;
  display: block;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.page-streak .soc .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

body.page-streak .soc .follow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(180deg, var(--cta), var(--cta2));
  color: var(--pillInk);
  font-weight: 1000;
  box-shadow: 0 12px 26px rgba(214, 120, 76, 0.22);
}

@media (max-width: 460px) {
  body.page-streak .soc {
    grid-template-columns: 48px 1fr;
  }

  body.page-streak .soc .actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  body.page-streak .soc .actions > * {
    flex: 1;
  }

  body.page-streak .soc .title {
    white-space: normal;
  }
}

@media (max-width: 420px) {
  body.page-streak .claimRow {
    flex-direction: column;
    align-items: stretch;
  }

  body.page-streak .btn {
    width: 100%;
    min-width: 0;
  }
}

/* Streak header: small screens keep pill rectangular */
@media (max-width: 380px) {
  body.page-streak .header-back {
    height: 34px;
    padding: 4px 10px;
    width: auto;
    gap: 4px;
    font-size: 14px;
  }
}

/* === Buy with Stars Page === */
body.page-buywithstars {
  --bg-top: #fff7ed;
  --bg-mid: #ffe3c9;
  --bg-bottom: #ffcda5;
  --ink: #172136;
  --ink-muted: rgba(23, 33, 54, 0.56);
  --surface: rgba(255, 255, 255, 0.96);
  --accent: #5450f6;
  --accent-alt: #2eb8ff;
  --stroke: rgba(84, 80, 246, 0.18);
  --chip: #fff;
  --btn: #ffd278;
  --btn2: #ffb654;
  --star: #ffd278;
  --starInk: #2a2100;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 48%, var(--bg-bottom) 100%) fixed;
}

body.page-buywithstars .wrap { width: min(960px, 100% - 24px); margin: 0 auto; padding: 18px clamp(12px, 4vw, 24px) calc(80px + env(safe-area-inset-bottom)); }

/* Header */
body.page-buywithstars .buy-header { display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 8px; margin-bottom: 8px; }
body.page-buywithstars .gallery-title { margin: 0; font-weight: 800; font-size: 20px; color: var(--ink); flex: 1; text-align: center; }
body.page-buywithstars .header-spacer { width: var(--backw, 96px); height: 1px; display: block; }
body.page-buywithstars .header-back { display: inline-flex; align-items: center; gap: 6px; height: 38px; width: auto; padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid rgba(84, 80, 246, 0.28); color: var(--accent); font-weight: 800; font-size: 15px; box-shadow: 0 6px 16px rgba(84, 80, 246, 0.12); }
body.page-buywithstars .header-back:active { transform: translateY(1px); }
body.page-buywithstars .header-back span[aria-hidden] { font-size: 17px; line-height: 1; }


body.page-buywithstars .title {
  font-weight: 1000;
  font-size: clamp(20px, 6vw, 28px);
}

body.page-buywithstars .card { background: var(--surface); border: 1px solid var(--stroke); border-radius: 20px; padding: 18px; box-shadow: 0 20px 48px rgba(214, 120, 76, 0.18); }

body.page-buywithstars .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

body.page-buywithstars .h1 {
  font-weight: 1000;
  font-size: 26px;
  letter-spacing: 0.3px;
}

body.page-buywithstars .sub { color: var(--ink-muted); margin-top: 6px; font-weight: 600; }

body.page-buywithstars .badge { display: inline-flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--stroke); border-radius: 12px; padding: 8px 10px; font-weight: 900; color: var(--accent); }

body.page-buywithstars .badge .bolt {
  font-size: 18px;
}

body.page-buywithstars .offer {
  margin-top: 16px;
}

body.page-buywithstars .offerHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

body.page-buywithstars .tierLine {
  font-weight: 900;
}

body.page-buywithstars .price { display: inline-flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--stroke); border-radius: 999px; padding: 6px 10px; font-weight: 900; color: var(--accent); }

body.page-buywithstars .price .star,
body.page-buywithstars .btn .star {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--star);
  color: var(--starInk);
  font-weight: 1000;
}

body.page-buywithstars .btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  margin-top: 12px;
  padding: 14px 16px;
  font-weight: 1000;
  background: linear-gradient(180deg, var(--btn), var(--btn2));
  color: #fff;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.25);
}

body.page-buywithstars .btn:active {
  transform: translateY(1px);
}

body.page-buywithstars .hint {
  margin-top: 10px;
  color: var(--muted);
  text-align: center;
}

/* === Editor Page === */
body.page-editor {
  --bg-top: #fff7ed;
  --bg-mid: #ffe3c9;
  --bg-bottom: #ffcda5;
  --ink: #172136;
  --ink-soft: rgba(23, 33, 54, 0.72);
  --muted: rgba(23, 33, 54, 0.56);
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: rgba(255, 244, 228, 0.94);
  --accent: #5450f6;
  --accent-alt: #2eb8ff;
  --accent-soft: rgba(84, 80, 246, 0.16);
  --chip-bg: rgba(255, 255, 255, 0.9);
  --chip-stroke: rgba(84, 80, 246, 0.24);
  --line: rgba(15, 23, 42, 0.16);
  --stroke: rgba(15, 23, 42, 0.16);
  --shadow-card: 0 20px 48px rgba(214, 120, 76, 0.18);
  --shadow-soft: 0 16px 32px rgba(84, 80, 246, 0.16);
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 48%, var(--bg-bottom) 100%) fixed;
  min-height: 100vh;
  overflow: auto;
}

body.page-editor .wrap {
  width: min(960px, 100% - 24px);
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 28px) calc(200px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
}

body.page-editor .editor-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px 0 8px;
}

body.page-editor .header-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  height: 38px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(84, 80, 246, 0.28);
  background: #ffffff;
  color: var(--accent);
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 6px 16px rgba(84, 80, 246, 0.12);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}

body.page-editor .header-back span[aria-hidden] {
  font-size: 17px;
  line-height: 1;
}

body.page-editor .header-back:active {
  transform: translateY(1px);
  background: rgba(255, 255, 255, 0.92);
}

/* brand removed in editor header */
body.page-editor .brand { display: none !important; }

body.page-editor .logo-badge {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.page-editor .logo-badge svg {
  width: 100%;
  height: 100%;
  display: block;
}

body.page-editor .brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

body.page-editor .brand-copy strong {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
}

body.page-editor .brand-copy span {
  font-size: 12px;
  color: var(--ink-soft);
}

/* session chip not used in the new header */
body.page-editor .session-chip { display: none !important; }

@media (max-width: 360px) {
  body.page-editor .editor-header { gap: 8px; }
}

/* Center title and balance with spacer like gallery */
body.page-editor .gallery-title {
  margin: 0;
  font-weight: 800;
  font-size: 20px;
  color: var(--ink);
  flex: 1;
  text-align: center;
}

body.page-editor .header-spacer {
  display: block;
  width: var(--backw, 96px);
  height: 1px;
}

body.page-editor .card {
  background: var(--surface);
  border-radius: 24px;
  border: 1px solid rgba(84, 80, 246, 0.14);
  box-shadow: var(--shadow-card);
  padding: 24px;
  color: var(--ink);
}

body.page-editor .editor-stage {
  position: relative;
  overflow: visible;
}

body.page-editor .canvasBox {
  position: sticky;
  top: 96px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

body.page-editor #stage {
  width: 100%;
  aspect-ratio: 1080 / 1350;
  display: block;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(255, 246, 236, 0.92));
  border-radius: 20px;
  touch-action: none;
  box-shadow: 0 14px 34px rgba(214, 120, 76, 0.22);
}

body.page-editor .hint {
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
  margin: 0 4px;
}

body.page-editor .primary {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(88px + env(safe-area-inset-bottom));
  width: min(540px, calc(100% - 24px));
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-alt) 100%);
  color: #ffffff;
  border: none;
  border-radius: 18px;
  padding: 16px 18px;
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  z-index: 8;
  transition: opacity 0.12s ease, transform 0.12s ease;
}

body.editor-sheet-open #saveBtn {
  opacity: 0;
  pointer-events: none;
}

body.page-editor .primary:active {
  transform: translateX(-50%) translateY(1px);
  background: linear-gradient(135deg, var(--accent-alt) 0%, var(--accent) 100%);
}

body.page-editor #saveBtn.is-loading {
  opacity: 0.75;
}

body.page-editor #saveBtn.is-loading::after {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.28);
  border-top-color: rgba(255, 255, 255, 0.82);
  animation: editorSpin 0.9s linear infinite;
}

@keyframes editorSpin {
  to { transform: rotate(360deg); }
}

body.page-editor .dock {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 0;
  z-index: 7;
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid rgba(84, 80, 246, 0.18);
  padding: 12px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 44px rgba(214, 120, 76, 0.16);
  backdrop-filter: blur(16px);
  width: min(540px, calc(100% - 24px));
  transform: translateX(-50%);
  border-radius: 20px 20px calc(20px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-bottom));
}

body.page-editor .dock .row {
  display: flex;
  align-items: center;
  gap: 10px;
}

body.page-editor .dock .tool {
  appearance: none;
  border: none;
  background: rgba(84, 80, 246, 0.08);
  color: var(--accent);
  border: 1px solid rgba(84, 80, 246, 0.18);
  flex: 1 1 0;
  min-width: 60px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 900;
  cursor: pointer;
}

body.page-editor .dock .tool.active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-alt) 100%);
  color: #ffffff;
  border-color: rgba(84, 80, 246, 0.22);
}

body.page-editor .dock .tool:active {
  transform: translateY(1px);
}

body.page-editor .dock .ico {
  font-size: 16px;
  line-height: 0;
}

body.page-editor .sheet {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 0;
  z-index: 7;
  background: rgba(255, 255, 255, 0.96);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  box-shadow: 0 -20px 48px rgba(214, 120, 76, 0.18);
  width: min(540px, calc(100% - 24px));
  transform: translate(-50%, 100%);
  transition: transform 180ms ease-out;
  max-height: calc(var(--vh) - 140px);
  overflow: auto;
  border-top: 1px solid rgba(84, 80, 246, 0.14);
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

body.page-editor .sheet.open {
  transform: translate(-50%, 0);
}

body.page-editor .sheet .hd {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.98);
  z-index: 1;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(84, 80, 246, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

body.page-editor .sheet .title {
  font-weight: 900;
  color: var(--ink);
}

body.page-editor .sheet .close {
  appearance: none;
  border: 1px solid rgba(84, 80, 246, 0.14);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 800;
  color: var(--accent);
  cursor: pointer;
}

body.page-editor .sheet .sec {
  padding: 12px 14px;
  color: var(--ink);
}

body.page-editor .pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(241, 245, 249, 0.82);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  padding: 8px 10px;
  font-weight: 800;
  font-size: 13px;
  margin: 6px 6px 0 0;
}

body.page-editor .row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

body.page-editor .input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 16px;
  background: #fff;
}

body.page-editor .chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

body.page-editor .chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
}

body.page-editor .chip.active {
  background: rgba(84, 80, 246, 0.12);
  color: var(--accent);
  border-color: rgba(84, 80, 246, 0.2);
}

body.page-editor .swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

body.page-editor .sw {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--line);
  cursor: pointer;
}

body.page-editor .sw.active {
  outline: 3px solid rgba(84, 80, 246, 0.35);
}

body.page-editor .stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

body.page-editor .stepper button {
  width: 36px;
  height: 36px;
  border: none;
  background: #fff;
  font-weight: 900;
  cursor: pointer;
}

body.page-editor .stepper .val {
  min-width: 48px;
  text-align: center;
  font-weight: 900;
}

body.page-editor .guide {
  position: absolute;
  pointer-events: none;
  left: 50%;
  top: 24px;
  width: 1px;
  height: calc(100% - 48px);
  background: rgba(84, 80, 246, 0.38);
  transform: translateX(-50%);
  display: none;
}

body.page-editor .guide.show {
  display: block;
}

@media (max-width: 520px) {
  body.page-editor .canvasBox {
    top: 88px;
  }
}

@media (max-width: 420px) {
  body.page-editor .primary {
    width: calc(100% - 24px);
    padding: 14px 16px;
    font-size: 15px;
  }

  body.page-editor .dock {
    padding: 12px 14px calc(18px + env(safe-area-inset-bottom));
  }

  body.page-editor .dock .tool {
    min-width: 0;
    height: 42px;
    font-size: 14px;
  }
}

/* === 404 Page === */
body.page-404 {
  color: #ffffff;
  background: var(--festify-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 32px 16px;
  text-align: center;
  gap: 24px;
}

body.page-404 .error-card {
  max-width: 360px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  padding: 32px 24px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(10px);
}

body.page-404 .error-code {
  font-size: 52px;
  font-weight: 900;
  color: #ffd278;
}

body.page-404 .error-title {
  margin: 12px 0 8px;
  font-size: 26px;
  font-weight: 800;
}

body.page-404 .error-text {
  margin: 0 0 18px;
  font-size: 15px;
  color: #f4ecff;
}

body.page-404 .error-action {
  display: inline-block;
  padding: 14px 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd278, #ffb654);
  color: #2a2100;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.25);
}

body.page-404 .error-action:active {
  transform: translateY(1px);
}

body.page-404 .error-footer {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}
