/* ============================================================
   UPGRADER · Telegram Mini App — Design System (light theme)
   Inspired by reference photo 1 (soft, airy, blue accent).
   CLAUDE CODE: this is presentation only. All tokens live here;
   reuse var(--*) names rather than hardcoding colors.
   ============================================================ */

:root {
  /* Brand / accent */
  --accent:        #2F54FF;
  --accent-press:  #2545E0;
  --accent-soft:   #EAEEFF;
  --accent-tint:   #F3F5FF;

  /* Surfaces */
  --bg:            #FFFFFF;   /* app surface */
  --backdrop:      #E7EAF1;   /* behind the device frame */
  --card:          #F4F5F7;   /* soft grey card */
  --card-2:        #EDEEF2;   /* pressed / nested card */
  --card-line:     #ECEDF1;
  --white:         #FFFFFF;

  /* Text */
  --text:          #0E0F13;
  --text-2:        #8A8F99;
  --text-3:        #B6BAC3;

  /* Semantic */
  --green:         #1FC16B;
  --green-soft:    #E7F8EF;
  --red:           #F23E5C;
  --red-soft:      #FDECEF;
  --star:          #FFB020;   /* Telegram Stars */
  --star-2:        #FF8A00;

  /* Rarity */
  --r-common:      #9AA2AF;
  --r-rare:        #3B82F6;
  --r-epic:        #8B5CF6;
  --r-legend:      #F59E0B;
  --r-mythic:      #EC4899;

  /* Radii */
  --r-xs: 12px;
  --r-sm: 16px;
  --r-md: 20px;
  --r-lg: 26px;
  --r-xl: 32px;

  /* Shadow */
  --shadow-card:  0 1px 2px rgba(16,17,20,.04);
  --shadow-pop:   0 12px 40px rgba(16,17,20,.16);
  --shadow-btn:   0 8px 22px rgba(47,84,255,.30);

  --ease: cubic-bezier(.22,.61,.36,1);
}

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

html, body {
  margin: 0;
  height: 100%;
  font-family: 'Onest', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--backdrop);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Full-screen inside the Telegram Mini App ----------------------------- */
#root {
  min-height: 100%;
  display: flex;
}

.device {
  position: relative;
  width: 100%;
  height: 100vh;
  background: var(--bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* App shell ----------------------------------------------------------- */
.app { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.scroll::-webkit-scrollbar { display: none; }

.page { padding: 18px 18px 28px; animation: fade .32s var(--ease); }
@keyframes fade { from { transform: translateY(8px); } to { transform: none; } }

/* ----- Top bar ----- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px 8px;
}
.topbar .title { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.topbar .spacer { flex: 1; }

/* Round icon button (photo-1 style) */
.iconbtn {
  width: 44px; height: 44px; flex: none;
  border: none; border-radius: 50%;
  background: var(--card);
  display: grid; place-items: center;
  color: var(--text); cursor: pointer;
  transition: background .18s, transform .12s;
}
.iconbtn:active { transform: scale(.92); background: var(--card-2); }
.iconbtn.sm { width: 38px; height: 38px; }

/* Stars balance pill */
.balance {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--card); border-radius: 999px;
  padding: 9px 14px 9px 11px; font-weight: 700; font-size: 15px;
  cursor: pointer; transition: background .18s, transform .12s;
}
.balance:active { transform: scale(.96); }
.balance .star { font-size: 16px; }
.balance .plus {
  width: 22px; height: 22px; margin-left: 2px; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  font-size: 16px; font-weight: 600; line-height: 1;
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer; font-family: inherit; font-weight: 700;
  border-radius: 999px; transition: transform .12s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--accent); color: #fff; font-size: 17px;
  padding: 17px 24px; width: 100%; box-shadow: var(--shadow-btn);
}
.btn-primary:active { background: var(--accent-press); }
.btn-primary:disabled { background: var(--card-2); color: var(--text-3); box-shadow: none; cursor: not-allowed; transform: none; }
.btn-ghost {
  background: var(--card); color: var(--text); font-size: 16px; padding: 15px 22px; width: 100%;
}
.btn-ghost:active { background: var(--card-2); }

/* ----- Cards / surfaces ----- */
.card { background: var(--card); border-radius: var(--r-md); }
.section-label { font-size: 14px; font-weight: 600; color: var(--text-2); margin: 22px 4px 12px; }

/* ----- Chips ----- */
.chips { display: flex; gap: 8px; }
.chip {
  flex: 1; border: none; cursor: pointer; font-family: inherit;
  background: var(--card); color: var(--text-2); font-weight: 700; font-size: 15px;
  border-radius: 14px; padding: 12px 0; transition: all .16s;
}
.chip:active { transform: scale(.95); }
.chip.active { background: var(--accent); color: #fff; box-shadow: var(--shadow-btn); }

/* ----- Search ----- */
.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: 16px; padding: 0 14px; height: 50px;
}
.search input {
  border: none; background: none; outline: none; font-family: inherit;
  font-size: 16px; color: var(--text); width: 100%; font-weight: 500;
}
.search input::placeholder { color: var(--text-3); }
.search svg { flex: none; color: var(--text-3); }

/* ============================================================
   Gift card / item visuals
   ============================================================ */
.gift-art {
  position: relative; display: grid; place-items: center;
  border-radius: 18px; overflow: hidden;
}
.gift-art .emoji { font-size: 2.2em; line-height: 1; filter: drop-shadow(0 4px 8px rgba(0,0,0,.12)); }
.gift-art::after { /* soft top sheen */
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(120% 80% at 50% -10%, rgba(255,255,255,.55), transparent 60%);
  pointer-events: none;
}

/* rarity badge dot */
.rdot { width: 7px; height: 7px; border-radius: 50%; flex: none; }

/* item grid card (inventory / shop) */
.icard {
  background: var(--card); border-radius: var(--r-sm); padding: 10px;
  display: flex; flex-direction: column; gap: 9px; cursor: pointer;
  transition: transform .12s, background .16s; border: 2px solid transparent;
}
.icard:active { transform: scale(.97); }
.icard.selected { border-color: var(--accent); background: var(--accent-tint); }
.icard .art { aspect-ratio: 1; width: 100%; }
.icard .nm { font-size: 13px; font-weight: 700; line-height: 1.2; letter-spacing: -.01em;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.icard .price { display: flex; align-items: center; gap: 5px; font-size: 14px; font-weight: 800; }
.icard .price .star { font-size: 13px; }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

/* ============================================================
   Bottom navigation
   ============================================================ */
.tabbar {
  flex: none; display: flex; background: var(--white);
  border-top: 1px solid var(--card-line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; border: none; background: none; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--text-3); padding: 4px 0;
}
.tab .lbl { font-size: 10px; font-weight: 700; letter-spacing: -.01em; }
.tab.active { color: var(--accent); }
.tab.active svg { transform: translateY(-1px); }

/* ============================================================
   Modals / bottom sheet
   ============================================================ */
.overlay {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(16,17,20,.46);
  display: flex; align-items: flex-end;
}
.overlay.center { align-items: center; justify-content: center; padding: 20px; }

.sheet {
  width: 100%; background: var(--bg);
  border-radius: 28px 28px 0 0; padding: 8px 18px 22px;
  max-height: 86%; display: flex; flex-direction: column;
  animation: sheetUp .34s var(--ease);
}
@keyframes sheetUp { from { transform: translateY(64px); } to { transform: none; } }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--card-2); margin: 6px auto 12px; }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.sheet-head .h { font-size: 19px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; flex: none; }

.dialog {
  width: 100%; background: var(--bg); border-radius: var(--r-xl);
  padding: 26px 22px 22px; text-align: center;
  animation: pop .4s var(--ease);
}
@keyframes pop { 0% { transform: scale(.92); } 100% { transform: scale(1); } }

/* segmented tabs (inventory/shop inside picker) */
.seg { display: flex; gap: 4px; background: var(--card); border-radius: 14px; padding: 4px; }
.seg button {
  flex: 1; border: none; background: none; font-family: inherit; cursor: pointer;
  font-weight: 700; font-size: 14px; color: var(--text-2); padding: 9px 0; border-radius: 11px;
  transition: all .16s; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.seg button.active { background: var(--white); color: var(--text); box-shadow: var(--shadow-card); }

/* empty state text */
.empty { text-align: center; color: var(--text-3); font-weight: 600; padding: 40px 20px; }

/* confetti dot */
.confetti { position: absolute; width: 9px; height: 14px; border-radius: 2px; top: -20px; will-change: transform, opacity; }

@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(440px) rotate(540deg); opacity: 0; }
}
@keyframes glowPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(47,84,255,.30); }
  50%     { box-shadow: 0 0 0 18px rgba(47,84,255,0); }
}
.win-art { animation: glowPulse 1.8s ease-out infinite; }
.flip { transform: scaleY(-1); }

/* small helpers */
.row { display: flex; align-items: center; }
.muted { color: var(--text-2); }
.b { font-weight: 800; }
.center-col { display: flex; flex-direction: column; align-items: center; }
