/* Ludus: the look of Telegram for iOS (its gift screens, lists, the "send
   stars" slider and sheets), in the colors the client hands the mini app. */

:root {
  --bg: var(--tg-theme-secondary-bg-color, #efeff4);
  --plain: var(--tg-theme-bg-color, #ffffff);
  --block: var(--tg-theme-section-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --accent: var(--tg-theme-accent-text-color, var(--tg-theme-link-color, #007aff));
  --button: var(--tg-theme-button-color, #007aff);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --section-header: var(--tg-theme-section-header-text-color, #6d6d72);
  --separator: var(--tg-theme-section-separator-color, #c8c7cc);
  --destructive: var(--tg-theme-destructive-text-color, #ff3b30);
  --bottom-bar: var(--tg-theme-bottom-bar-bg-color, var(--bg));
  --star-text: #d3720a;
  --star-fill: rgba(255, 200, 61, 0.2);
  --slider: #ffb10d;
  --track: rgba(0, 0, 0, 0.07);
  --dim: rgba(0, 0, 0, 0.4);
  --close: rgba(128, 128, 132, 0.1);
  --positive: #34c759;
  --shimmer: rgba(0, 0, 0, 0.06);
  --safe-bottom: max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px));
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Roboto, Arial, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, var(--font);
}

:root[data-dark] {
  --star-text: #ffc337;
  --track: rgba(255, 255, 255, 0.2);
  --positive: #30d158;
  --shimmer: rgba(255, 255, 255, 0.08);
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.29 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
img { display: block; }
[hidden] { display: none !important; }

.star { width: 18px; height: 18px; flex: none; }

/* --- the top: the balance, as on iOS's stars screens --- */

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 16px;
  background: var(--bg);
}
.topbar-title { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 600; letter-spacing: -0.41px; }
.topbar-icon { width: 28px; height: 28px; border-radius: 7px; }
.balance { text-align: right; line-height: 1.15; }
.balance-caption { font-size: 11px; color: var(--hint); }
.balance-value { display: flex; align-items: center; justify-content: flex-end; gap: 2px; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.balance-value .star { width: 16px; height: 16px; }
.balance.bump .balance-value { animation: bump 0.45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bump { 40% { transform: scale(1.14); } }

.hero { text-align: center; padding: 4px 32px 18px; }
.hero h1 { margin: 0 0 6px; font-size: 20px; font-weight: 600; letter-spacing: 0.38px; }
.hero p { margin: 0; font-size: 15px; color: var(--hint); letter-spacing: -0.24px; }

/* --- the wheel: gift cells as GiftItemComponent draws them --- */

.reel {
  position: relative; height: 152px; overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
  touch-action: pan-y;
}
.reel-track { position: absolute; left: 0; top: 8px; height: 136px; display: flex; gap: 10px; will-change: transform; }
/* The middle of the wheel: a line with a notch at each end. */
.reel-marker {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px;
  background: var(--button); border-radius: 1px; pointer-events: none; z-index: 2;
}
.reel-pointer { position: absolute; left: 50%; width: 14px; height: 8px; margin-left: -7px; background: var(--button); }
.reel-pointer.top { top: 0; clip-path: polygon(0 0, 100% 0, 50% 100%); }
.reel-pointer.bottom { bottom: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.reel.stopped .reel-marker { opacity: 0; transition: opacity 0.2s; }

.gift {
  position: relative; flex: none; width: 108px; height: 136px;
  border-radius: 16px; background: var(--block); overflow: hidden;
  display: flex; flex-direction: column; align-items: center;
}
.gift.backdrop { background: radial-gradient(circle at 50% 42%, var(--center) 0%, var(--edge) 92%); }
.gift-sticker { width: 80px; height: 80px; margin-top: 12px; position: relative; }
.gift-sticker > img, .gift-sticker > div { position: absolute; inset: 0; width: 100%; height: 100%; }
.gift .price { position: absolute; bottom: 10px; }
/* The gift won: selected as iOS selects a gift (a ring around it). */
.gift.landed { animation: landed 0.5s cubic-bezier(.3, 1.5, .5, 1); outline: 2.5px solid var(--button); outline-offset: 3px; overflow: visible; }
@keyframes landed { 40% { transform: scale(1.06); } }

/* The ribbon in a corner (Premium/GiftRibbon, tinted by a gradient). */
.ribbon {
  position: absolute; top: 0; right: 0; width: 58px; height: 58px;
  -webkit-mask: url(icons/ribbon.svg) center / 58px 58px no-repeat;
  mask: url(icons/ribbon.svg) center / 58px 58px no-repeat;
  background: linear-gradient(225deg, var(--r1), var(--r2) 50%, var(--r1));
}
.ribbon-text {
  position: absolute; top: 22px; right: 22px; transform: translate(50%, -50%) rotate(45deg);
  font-size: 10px; font-weight: 600; color: #fff; white-space: nowrap; letter-spacing: 0.1px;
}

/* The price capsule (StarsButtonContentComponent). */
.price {
  display: inline-flex; align-items: center; height: 26px; padding: 0 9px 0 7px; border-radius: 13px;
  background: var(--star-fill); color: var(--star-text);
  font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.price img { width: 15px; height: 15px; margin-right: 2px; }
.price.tinted { background: var(--tint); color: #fff; }
.price.large { height: 30px; padding: 0 12px 0 9px; border-radius: 15px; font-size: 13px; }
.price.large img { width: 17px; height: 17px; }

/* --- lists: ListSectionComponent of the glass style --- */

.section-header {
  padding: 22px 32px 7px; font-size: 13px; line-height: 18px; color: var(--section-header);
  text-transform: uppercase; letter-spacing: -0.08px;
}
.section-footer { padding: 7px 32px 0; font-size: 13px; line-height: 18px; color: var(--hint); letter-spacing: -0.08px; }
.section-footer:empty { display: none; }
.block { margin: 0 16px; background: var(--block); border-radius: 26px; overflow: hidden; }

.row { position: relative; display: flex; align-items: center; min-height: 60px; padding: 8px 16px; gap: 12px; width: 100%; text-align: left; }
.row + .row::before {
  content: ""; position: absolute; top: 0; left: 68px; right: 0; height: 0.5px; background: var(--separator);
  transform: scaleY(0.66); transform-origin: top;
}
.row-icon { width: 40px; height: 40px; flex: none; position: relative; }
.row-icon > img, .row-icon > div { position: absolute; inset: 0; width: 100%; height: 100%; }
.row-icon.backdrop { border-radius: 10px; background: radial-gradient(circle at 50% 45%, var(--center), var(--edge)); }
.row-text { flex: 1; min-width: 0; }
.row-title { font-size: 17px; letter-spacing: -0.41px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-subtitle { display: flex; align-items: center; gap: 2px; font-size: 14px; line-height: 18px; color: var(--hint); margin-top: 1px; }
.row-subtitle .star { width: 14px; height: 14px; }
.row-value { font-size: 17px; color: var(--hint); font-variant-numeric: tabular-nums; letter-spacing: -0.41px; white-space: nowrap; }
.row-value.positive { color: var(--positive); display: flex; align-items: center; gap: 2px; }
.row-value .star { width: 16px; height: 16px; }
.row.action { min-height: 44px; justify-content: flex-start; color: var(--accent); }
.row.action::before { left: 16px !important; }

/* --- the stake: the slider of iOS's "send stars" screen --- */

.stake { padding: 70px 24px 16px; }
.slider { position: relative; height: 30px; touch-action: none; }
.slider-track { position: absolute; left: -8px; right: -8px; top: 7px; height: 16px; border-radius: 8px; background: var(--track); overflow: hidden; }
.slider-fill { position: absolute; left: 0; top: 0; bottom: 0; min-width: 16px; border-radius: 8px; background: var(--slider); }
.slider-knob {
  position: absolute; top: 2px; width: 26px; height: 26px; margin-left: -13px; border-radius: 13px; background: #fff;
  box-shadow: 0 0.5px 4px rgba(0, 0, 0, 0.12), 0 6px 13px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}
.slider-badge { position: absolute; bottom: 38px; height: 48px; transform: translateX(-50%); pointer-events: none; }
.slider-badge-shape { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.slider-badge-shape path { fill: var(--slider); }
.slider-badge-content {
  position: relative; display: flex; align-items: center; width: max-content; height: 40px; padding: 0 16px 0 10px; gap: 3px;
  color: #fff; font: 600 24px/1 var(--font-rounded); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.slider-badge-content img { width: 30px; height: 30px; filter: brightness(0) invert(1); }
.stake-hint { display: flex; justify-content: space-between; margin-top: 14px; font-size: 13px; color: var(--hint); font-variant-numeric: tabular-nums; }

/* --- the button: ButtonComponent of the glass style --- */

.bottom-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 10px 16px calc(10px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.button {
  display: flex; align-items: center; justify-content: center; gap: 4px; width: 100%; height: 52px; border-radius: 26px;
  background: var(--button); color: var(--button-text); font-size: 17px; font-weight: 600; letter-spacing: -0.41px;
  transition: opacity 0.2s, transform 0.15s;
}
.button:active { transform: scale(0.97); opacity: 0.9; }
.button:disabled { opacity: 0.5; transform: none; }
.button img { width: 18px; height: 18px; filter: brightness(0) invert(1); }
.button .spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bottom-space { height: calc(96px + var(--safe-bottom)); }

/* --- empty and loading states --- */

.empty { min-height: 80vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 32px; text-align: center; }
.empty-sticker { width: 140px; height: 140px; margin-bottom: 14px; }
.empty h2 { margin: 0 0 8px; font-size: 20px; font-weight: 600; }
.empty p { margin: 0 0 24px; font-size: 15px; color: var(--hint); }

.loading { padding: 12px 16px; }
.shimmer { background: var(--shimmer); border-radius: 16px; position: relative; overflow: hidden; }
.shimmer::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent); animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.hero-shimmer { height: 56px; margin: 8px 40px 22px; }
.shimmer-row { display: flex; gap: 10px; justify-content: center; margin-bottom: 30px; }
.cell-shimmer { width: 108px; height: 136px; }
.block-shimmer { height: 150px; border-radius: 26px; margin-bottom: 30px; }
.block-shimmer.tall { height: 260px; }

/* --- the sheet with the gift won (GiftViewScreen) --- */

.sheet-dim { position: fixed; inset: 0; z-index: 10; background: var(--dim); animation: fade 0.25s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; max-height: 92vh; overflow-y: auto;
  padding: 0 16px calc(16px + var(--safe-bottom)); background: var(--plain);
  border-radius: 40px 40px 0 0; text-align: center;
  animation: rise 0.42s cubic-bezier(.2, .9, .25, 1);
}
.sheet.closing { animation: sink 0.25s ease-in forwards; }
:root[data-dark] .sheet, :root[data-dark] .sheet-header { background-color: var(--block); }
.sheet-dim.closing { animation: fade 0.25s reverse forwards; }
@keyframes rise { from { transform: translateY(100%); } }
@keyframes sink { to { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
.sheet-close {
  position: absolute; top: 16px; right: 16px; z-index: 2; width: 40px; height: 40px; border-radius: 20px;
  display: flex; align-items: center; justify-content: center; background: var(--close); color: var(--hint);
}
.sheet-header { position: relative; height: 230px; margin: 0 -16px; display: flex; align-items: center; justify-content: center; border-radius: 40px 40px 0 0; overflow: hidden; }
.sheet-header.backdrop { background: radial-gradient(circle at 50% 50%, var(--center), var(--edge) 80%); }
.sheet-header.backdrop .sheet-close { color: #fff; }
.sheet-sticker { width: 160px; height: 160px; position: relative; }
.sheet-title { margin: 6px 0 4px; font-size: 20px; font-weight: 600; }
.sheet-subtitle { margin: 0 0 16px; font-size: 15px; color: var(--hint); }
.sheet-note { margin: 14px 8px 18px; font-size: 13px; line-height: 18px; color: var(--hint); }

/* TableComponent: rows of a title and a value. */
.table { border: 0.5px solid var(--separator); border-radius: 14px; overflow: hidden; text-align: left; }
.table-row { display: flex; min-height: 44px; }
.table-row + .table-row { border-top: 0.5px solid var(--separator); }
.table-title { width: 40%; padding: 12px; font-size: 15px; font-weight: 500; background: var(--close); }
.table-value { flex: 1; display: flex; align-items: center; gap: 4px; padding: 12px; font-size: 15px; border-left: 0.5px solid var(--separator); }
.table-value .star { width: 16px; height: 16px; }

.confetti { position: fixed; inset: 0; z-index: 12; pointer-events: none; width: 100%; height: 100%; }

.toast {
  position: fixed; left: 16px; right: 16px; top: 12px; z-index: 13; padding: 12px 16px; border-radius: 14px;
  background: rgba(30, 30, 30, 0.88); color: #fff; font-size: 15px; text-align: center;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); animation: fade 0.2s;
}
