:root {
  --bg: #0d0820;
  --card: #1c1240;
  --line: #34226b;
  --text: #f1ecff;
  --muted: #b3a8d6;
  --purple: #8b3dff;
  --purple-2: #b26bff;
  --gold: #ffc533;
  --radius: 18px;
  --display: "Fredoka", system-ui, sans-serif;
  --tabbar-h: 64px;

  /* Telegram sets these in fullscreen: the device inset plus the area under its own top controls */
  --safe-top: calc(var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: calc(var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)) + var(--tg-content-safe-area-inset-bottom, 0px));
  --safe-left: var(--tg-safe-area-inset-left, env(safe-area-inset-left, 0px));
  --safe-right: var(--tg-safe-area-inset-right, env(safe-area-inset-right, 0px));
}

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

html, body { margin: 0; height: 100%; overflow: hidden; }

body {
  background: radial-gradient(600px 400px at 90% -10%, #2b1366 0%, transparent 70%), var(--bg);
  color: var(--text);
  font: 15px/1.5 "Inter", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

h2 { font: 600 22px/1.2 var(--display); margin: 0 0 4px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.gold { color: var(--gold); }
.row { display: flex; justify-content: space-between; }

.app { height: 100%; display: flex; flex-direction: column; }

.top {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
}
.top img { border-radius: 50%; }
.top-title { font: 700 20px var(--display); letter-spacing: .02em; }

.screens {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 8px calc(16px + var(--safe-right)) 24px calc(16px + var(--safe-left));
}
.screen { display: flex; flex-direction: column; gap: 14px; animation: in .2s ease; }
.screen[hidden] { display: none; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.badge {
  display: inline-block; align-self: flex-start; background: rgba(255, 197, 51, .15); color: var(--gold);
  border-radius: 999px; padding: 1px 10px; font-size: 12px; font-weight: 600; margin-bottom: 6px;
}
.note { text-align: center; color: var(--muted); font-size: 13px; }

.btn {
  margin-top: 14px; border: 0; border-radius: 999px; padding: 12px 22px;
  background: linear-gradient(180deg, var(--purple-2), var(--purple)); color: #fff;
  font: 600 16px var(--display); box-shadow: inset 0 -3px 0 rgba(0,0,0,.25);
}
.btn:active { transform: scale(.97); }

/* GAMES */
.game-card {
  position: relative; display: block; width: 100%; padding: 0; text-align: left; color: inherit; font: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 10px 30px -12px var(--purple); cursor: pointer; transition: transform .12s ease;
}
.game-card:active { transform: scale(.98); }
.game-card img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.game-info { padding: 14px 112px 16px 16px; }
.play {
  position: absolute; right: 14px; bottom: 18px; padding: 8px 18px; border-radius: 999px;
  background: var(--gold); color: #2a1a00; font: 700 15px var(--display);
}
.soon-card {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted);
}

/* SEASON */
.hero-panel { background: linear-gradient(135deg, #3a1a8a, var(--card)); }
.bar { height: 10px; border-radius: 99px; background: rgba(255,255,255,.08); margin: 16px 0 6px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--purple-2), var(--gold)); }
.tiers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tiers li { display: flex; justify-content: space-between; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.tiers span { color: var(--muted); }

/* ACCOUNT */
.profile { display: flex; align-items: center; gap: 14px; }
.avatar {
  flex: none; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--purple-2), var(--purple)) center / cover; font: 700 26px var(--display);
  border: 2px solid var(--gold);
}
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: center; display: flex; flex-direction: column; }
.stat b { font: 700 22px var(--display); color: var(--gold); }
.stat span { color: var(--muted); font-size: 12px; }
.details { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.details div { display: flex; justify-content: space-between; gap: 12px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 500; }

/* REWARDS */
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 14px; }
.days span { aspect-ratio: 1; display: grid; place-items: center; border-radius: 10px; background: rgba(255,255,255,.06); font: 600 13px var(--display); }

/* SHOP */
.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.emoji { font-size: 34px; }

/* Bottom navigation */
.tabbar {
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px calc(4px + var(--safe-right)) calc(6px + var(--safe-bottom)) calc(4px + var(--safe-left));
  background: rgba(13, 8, 32, .92); border-top: 1px solid var(--line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.tabbar button {
  display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 52px;
  background: none; border: 0; color: var(--muted); font: 600 10.5px/1 "Inter", system-ui, sans-serif; letter-spacing: .04em;
  padding: 6px 0; cursor: pointer;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button.active { color: var(--gold); }
.tabbar button.active svg { filter: drop-shadow(0 0 6px rgba(255, 197, 51, .6)); }
