:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: rgba(255, 255, 255, 0.05);
  --accent-blue: #0088cc;
  --accent-purple: #7b61ff;
  --gold: #f5c542;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --border: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: linear-gradient(135deg, #0d0d1a 0%, #1a1a2e 50%, #16213e 100%);
  color: var(--text-primary);
  overflow-x: hidden;
  min-height: 100vh;
}

#stars-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.star {
  position: absolute;
  background: #ffffff;
  border-radius: 50%;
  animation: twinkle var(--duration, 3s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  opacity: 0;
}

.star.bright {
  box-shadow: 0 0 4px 1px rgba(255, 255, 255, 0.6);
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0;
    transform: scale(0.8);
  }
  50% {
    opacity: var(--brightness, 0.5);
    transform: scale(1.2);
  }
}

:root {
  --bottom-dock-clearance: calc(188px + env(safe-area-inset-bottom, 0px));
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 14px 10px;
}

.topbar-extended {
  flex-wrap: wrap;
  row-gap: 8px;
}

.free-spins-badge {
  flex-shrink: 0;
  background: rgba(245, 197, 66, 0.15);
  border: 1px solid rgba(245, 197, 66, 0.3);
  border-radius: 20px;
  padding: 4px 10px;
  color: #f5c542;
  font-size: 12px;
  font-weight: 600;
}

.invite-btn {
  margin-left: auto;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  color: #fff;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.invite-btn:active {
  transform: scale(0.97);
}

.invite-btn-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: inline-block;
  line-height: 0;
}

.tab-inv-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.avatar,
.center-avatar {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  object-fit: cover;
}

.center-avatar {
  width: 70px;
  height: 70px;
  border: 1px solid rgba(245, 197, 66, 0.45);
  box-shadow: 0 0 22px rgba(245, 197, 66, 0.18);
}

.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.segmented {
  display: flex;
  gap: 8px;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.seg-btn {
  border: 0;
  outline: 0;
  cursor: pointer;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 650;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  min-height: 42px;
  transition: background 180ms ease, color 180ms ease, transform 120ms ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-icon {
  width: 28px;
  height: 28px;
  display: inline-block;
}

.seg-btn-active {
  background: linear-gradient(135deg, rgba(0, 136, 204, 0.25), rgba(123, 97, 255, 0.25));
  color: var(--accent-blue);
  box-shadow: 0 0 0 1px rgba(0, 136, 204, 0.22) inset;
}

.seg-btn:active {
  transform: scale(0.98);
}

.content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 14px;
  padding-bottom: var(--bottom-dock-clearance);
}

/* Скролл внутри секций, отступ под нижний док */
#inventory-view,
#tasks-view,
#profile-view {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--bottom-dock-clearance);
  box-sizing: border-box;
}

#profile-view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--bottom-dock-clearance, 140px) + 20px);
}

#inventory-view.view-active,
#tasks-view.view-active,
#profile-view.view-active {
  max-height: calc(100dvh - 72px);
}

#roll-view {
  padding-top: 0;
  margin-top: 0;
}

#roll-view.view-active {
  padding-bottom: var(--bottom-dock-clearance);
  box-sizing: border-box;
}

.tasks-root,
.profile-root {
  min-height: 120px;
}

#profile-copy-icon,
#profile-invite-icon,
#profile-inv-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.roll-action-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.roll-action-block.hidden {
  display: none !important;
}

#bottom-section.bottom-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 0;
  pointer-events: none;
}

.roll-controls {
  padding: 10px 16px 8px;
  background: linear-gradient(to top, rgba(13, 13, 26, 0.96) 85%, transparent);
  pointer-events: auto;
}

.roll-controls.hidden {
  display: none !important;
}

.wheel-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.wheel-btn {
  flex: 1;
  min-width: 0;
  padding: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.wheel-btn-active {
  background: rgba(0, 136, 204, 0.2);
  border-color: #0088cc;
  color: #ffffff;
}

.wheel-btn-icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  flex-shrink: 0;
}

.bottom-nav {
  display: flex;
  background: rgba(13, 13, 26, 0.97);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 0 4px;
  pointer-events: auto;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  padding: 6px 0;
  transition: color 0.2s ease;
}

.nav-btn span {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2px;
  line-height: 1.2;
}

.nav-btn.nav-btn-active span {
  color: #0088cc;
  font-weight: 600;
}

.nav-btn-icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: inline-block;
  line-height: 0;
}

.bottom-dock .roll-action-block {
  pointer-events: auto;
}

.bottom-dock-error {
  margin: 0;
  max-width: none;
}

.bottom-dock-roll {
  margin-top: 0;
  width: 100%;
}

.view {
  display: none;
  animation: viewIn 220ms ease both;
}

.view-active {
  display: block;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0px);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.wheel-area {
  padding-top: 0;
}

.wheel-stack {
  position: relative;
  width: min(390px, min(100%, calc(100dvh - var(--bottom-dock-clearance) - 120px)));
  margin: 6px auto 8px;
  aspect-ratio: 1 / 1;
}

#wheel-stack {
  padding-bottom: 0;
  margin-bottom: 0;
}

#empty-result-msg {
  margin-top: 8px;
  margin-bottom: 4px;
  min-height: 0;
  font-size: 13px;
}

#empty-result-msg .empty-emoji {
  font-size: 18px;
  margin-bottom: 2px;
}

#empty-result-msg .empty-title {
  font-size: 13px;
  font-weight: 600;
  color: white;
}

#empty-result-msg .empty-subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}

.wheel-canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 999px;
  filter: drop-shadow(0 18px 50px rgba(0, 0, 0, 0.35));
}

.wheel-tgs-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transform-origin: 50% 50%;
}

.wheel-tgs-layer lottie-player {
  opacity: 0.55;
  filter: saturate(0.95) brightness(0.95);
}

.wheel-arrow {
  position: absolute;
  left: 50%;
  top: -4px;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-top: 22px solid var(--gold);
  filter: drop-shadow(0 10px 18px rgba(245, 197, 66, 0.22));
}

.wheel-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 86px;
  height: 86px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 38px rgba(0, 136, 204, 0.12);
}

.roll-btn {
  width: 100%;
  border: 0;
  cursor: pointer;
  border-radius: 18px;
  min-height: 54px;
  margin-top: 0;
  padding: 0 16px;
  font-size: 17px;
  font-weight: 600;
  color: white;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
  box-shadow: 0 14px 40px rgba(0, 136, 204, 0.18);
  transition: transform 120ms ease, filter 180ms ease, opacity 180ms ease;
}

.roll-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.2);
}

.roll-btn:active:not(:disabled) {
  transform: scale(0.97);
  filter: brightness(0.82);
}

.banner {
  margin: 14px auto 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  max-width: 520px;
}

.banner-error {
  color: rgba(255, 160, 160, 0.95);
}

.banner-loading {
  color: rgba(255, 255, 255, 0.75);
}

.hidden {
  display: none !important;
}

.inventory-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 6px;
}

.inventory-title {
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 0.2px;
}

.inventory-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.gift-card {
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  padding: 10px;
  position: relative;
  overflow: hidden;
}

.gift-card:before {
  content: "";
  position: absolute;
  inset: -40px;
  background: radial-gradient(circle at 30% 20%, rgba(0, 136, 204, 0.18), transparent 55%);
  pointer-events: none;
}

.gift-inner {
  position: relative;
}

.gift-lottie {
  width: 100%;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gift-lottie lottie-player {
  width: 86px;
  height: 86px;
  opacity: 0.95;
}

.gift-name {
  margin-top: 8px;
  font-weight: 800;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  min-height: 36px;
  line-height: 1.15;
}

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

.status-pill {
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-weight: 750;
}

.status-available {
  color: rgba(120, 255, 180, 0.95);
  background: rgba(120, 255, 180, 0.08);
}

.status-requested {
  color: rgba(255, 220, 120, 0.95);
  background: rgba(255, 220, 120, 0.08);
}

.status-received {
  color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.05);
}

.nft-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  border-radius: 999px;
  padding: 7px 10px;
  font-weight: 900;
  font-size: 12px;
  color: #2b1f00;
  background: linear-gradient(135deg, #ffd87a, var(--gold));
  box-shadow: 0 0 18px rgba(245, 197, 66, 0.22);
}

.claim-btn {
  width: 100%;
  margin-top: 10px;
  border: 0;
  cursor: pointer;
  min-height: 48px;
  border-radius: 14px;
  font-weight: 900;
  color: white;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
}

.claim-btn:active {
  transform: scale(0.98);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 200;
}

.modal-card {
  position: relative;
  width: min(460px, 100%);
  border-radius: 22px;
  background: rgba(26, 26, 46, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 16px;
  padding-top: 44px;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.6);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 150ms ease, transform 120ms ease;
}

.modal-close:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.18);
}

.success-gift-anim {
  width: 140px;
  height: 140px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.success-gift-anim lottie-player {
  width: 120px;
  height: 120px;
}

.success-text {
  margin-top: 8px;
  text-align: center;
  font-weight: 900;
  line-height: 1.25;
}

.success-btn {
  width: 100%;
  margin-top: 14px;
  border: 0;
  min-height: 54px;
  border-radius: 18px;
  font-weight: 900;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: white;
}

